/* Bernardo Clicker — subway signage look.
   Sections: tokens · base · header · layout · clicker · golden card · transit · store · phone tabs · breakpoints */

/* ---------- Tokens ---------- */
:root {
  --ink: #111;
  --paper: #F4F1EA;
  --rule: #d6cfbf;
  --muted: #4a4a4a;
  --soft: #b5b5b5;
  --yellow: #FCCC0A;
  --orange: #FF6319;
  --red: #B3261E;
  --good: #00732F;
  --led: #FF9F1A;
  --led-bg: #0b0b0b;
  --car: #c4c8cc;
  --poster-frame: #8d9399;
  --header-h: 72px;
  --face: clamp(200px, calc(100dvh - 470px), 380px);
  --font: 'Archivo', system-ui, sans-serif;
  --display: 'Anton', 'Archivo', sans-serif;
  --dot: 'DotGothic16', ui-monospace, monospace;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  display: flex;
  flex-direction: column;
  background: var(--ink);
  color: var(--ink);
  font-family: var(--font);
  line-height: 1.3;
  overflow: hidden;
  user-select: none; /* rapid clicking shouldn't highlight the page */
  -webkit-touch-callout: none;
}
input, textarea, [contenteditable] { user-select: text; }
button { font: inherit; color: inherit; }
h1, h2 { margin: 0; }
img { display: block; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
:focus-visible { outline: 4px dashed var(--orange); outline-offset: 3px; }

/* ---------- Header ---------- */
.topbar {
  height: var(--header-h);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 28px;
  background: var(--ink);
  color: #fff;
}
.logo {
  width: 40px; height: 40px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--orange);
  color: var(--ink);
  font-size: 24px; font-weight: 800;
}
.title { display: flex; align-items: baseline; gap: 16px; flex-grow: 1; min-width: 0; }
.title h1 { font-size: 34px; font-weight: 800; letter-spacing: -0.5px; line-height: 1; white-space: nowrap; }
.tagline { font-size: 14px; font-weight: 500; color: var(--soft); }
.autosave { font-size: 13px; color: #9a9a9a; }
.btn-outline {
  display: inline-flex; align-items: center;
  height: 36px; padding: 0 12px;
  background: transparent;
  border: 2px solid #555; border-radius: 4px;
  color: #ddd;
  font-size: 13px; font-weight: 700; line-height: 1;
  white-space: nowrap;
  cursor: pointer;
}
.btn-outline:hover { border-color: #aaa; color: #fff; }

/* ---------- Layout ---------- */
.layout {
  flex-grow: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: clamp(380px, 33vw, 470px) minmax(460px, 1fr) clamp(380px, 31vw, 450px);
}
.tabs { display: none; }

/* ---------- Clicker ---------- */
.clicker {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 26px 28px 22px;
}
.clicker-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 72% 50%; }

.counter {
  position: relative;
  align-self: stretch;
  display: flex; flex-direction: column; gap: 6px;
  padding: 16px 22px 14px;
  background: #fff;
  border: 3px solid var(--ink);
}
.count { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 12px; font-size: 62px; font-weight: 900; line-height: 1; letter-spacing: -1.5px; font-variant-numeric: tabular-nums; }
.count-unit { font-size: 30px; letter-spacing: -0.5px; }
.count-label { font-size: 13px; font-weight: 800; letter-spacing: 2.5px; text-transform: uppercase; }
.rates { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 15px; font-weight: 700; color: #333; font-variant-numeric: tabular-nums; }
.frenzy-tag { display: none; background: var(--yellow); color: var(--ink); padding: 0 6px; font-weight: 900; }

.face {
  position: relative;
  flex-shrink: 0;
  width: var(--face);
  aspect-ratio: 1;
  padding: 0;
  border: 10px solid var(--ink);
  border-radius: 50%;
  overflow: hidden;
  background: var(--ink);
  cursor: pointer;
  transition: transform 0.07s ease-out, border-color 0.3s, box-shadow 0.3s;
  -webkit-tap-highlight-color: transparent;
}
.face:hover { transform: scale(1.02); }
.face:active { transform: scale(0.96); }
.face-plain { width: 100%; height: 100%; image-rendering: pixelated; }
/* The sunglasses selfie is taller than it is wide; nudged up so the eyes line up with the close-up */
.face-shades { position: absolute; left: 0; top: -12%; width: 100%; opacity: 0; transition: opacity 0.3s ease; }

.pop {
  position: fixed;
  z-index: 20;
  pointer-events: none;
  font-size: 30px; font-weight: 900;
  color: #fff;
  text-shadow: 0 2px 0 var(--ink), 0 0 6px rgba(0, 0, 0, 0.6);
  animation: rise 1s ease-out forwards;
}
@keyframes rise {
  from { opacity: 1; transform: translate(-50%, 0); }
  to { opacity: 0; transform: translate(-50%, -110px); }
}

.ticker {
  position: relative;
  align-self: stretch;
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) 44px;
  gap: 10px;
  align-items: start;
  padding: 10px 14px;
  background: var(--led-bg);
  border: 3px solid #333;
  border-radius: 6px;
  font-family: var(--dot);
  font-size: 16px;
  color: var(--led);
}
.ticker-bullet {
  width: 22px; height: 22px; margin-top: 1px;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--led); border-radius: 50%;
  font-size: 13px; line-height: 1;
}
.ticker-text { min-height: 48px; line-height: 24px; transition: opacity 0.4s; }
.ticker-text.fading { opacity: 0; }
.ticker-now { text-align: right; line-height: 24px; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.25; } }

/* Frenzy: sunglasses on, yellow ring */
body.frenzy .face { border-color: var(--yellow); box-shadow: 0 0 0 5px var(--ink), 0 0 60px 14px var(--yellow); }
body.frenzy .face-shades { opacity: 1; }
body.frenzy .frenzy-tag { display: inline; }

/* ---------- Golden referral card ---------- */
.golden {
  position: absolute;
  z-index: 5;
  width: 168px; height: 104px;
  padding: 12px 14px 0;
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  overflow: hidden;
  background: var(--yellow);
  border: 2px solid var(--ink);
  border-radius: 10px;
  box-shadow: 0 6px 0 #8a6d00;
  text-align: left;
  cursor: pointer;
  animation: bob 1.1s ease-in-out infinite;
}
.golden[hidden] { display: none; }
.golden::after { content: ''; position: absolute; left: 0; right: 0; bottom: 12px; height: 14px; background: var(--ink); } /* magnetic stripe */
.golden-title { font-family: var(--display); font-size: 30px; line-height: 1; }
.golden-timer { font-size: 11px; font-weight: 700; }
@keyframes bob { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }

/* ---------- Transit (middle placeholder) ---------- */
.transit {
  display: flex; flex-direction: column; gap: 16px;
  padding: 22px 24px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--poster-frame) transparent;
  background-color: var(--car);
  background-image: repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.18) 0 2px, transparent 2px 7px);
  border-left: 4px solid var(--ink);
  border-right: 4px solid var(--ink);
}
.transit > * { flex-shrink: 0; }
.service > div { display: flex; border: 3px solid var(--ink); padding: 12px 16px; }
.service-good { flex-wrap: wrap; align-items: center; gap: 8px 12px; background: #fff; }
.service-good > div:last-child { flex: 1 1 220px; }
.service-good .service-title { font-size: 17px; font-weight: 900; color: var(--good); }
.service-good .service-sub { font-size: 13px; color: #444; }
.service > .service-change { display: none; flex-direction: column; gap: 4px; background: var(--yellow); }
.service-change .service-title { font-size: 20px; font-weight: 900; text-transform: uppercase; }
.service-change .service-sub { font-size: 15px; font-weight: 700; }
body.frenzy .service > .service-good { display: none; }
body.frenzy .service > .service-change { display: flex; }

.bullets { display: flex; flex-wrap: wrap; gap: 4px; }
.bullets:empty { display: none; }
.bullet {
  width: 22px; height: 22px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--line);
  color: var(--line-text);
  font-size: 13px; font-weight: 800; line-height: 1;
}

.line-map { display: flex; flex-direction: column; gap: 12px; padding: 12px 16px 14px; background: #fff; border: 3px solid var(--ink); }
.line-map-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.line-map-title { font-size: 13px; font-weight: 800; letter-spacing: 2px; text-transform: uppercase; white-space: nowrap; }
.line-map-next { font-size: 13px; color: #444; text-align: right; }
.stations { position: relative; display: flex; justify-content: space-between; align-items: center; }
.stations::before { content: ''; position: absolute; left: 10px; right: 10px; top: 50%; height: 6px; margin-top: -3px; background: var(--ink); }
.stations .bullet { position: relative; width: 28px; height: 28px; font-size: 15px; }
.stations .bullet.unowned { --line: #d9d4c7; --line-text: #8a857a; }
.stations .bullet.next { box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--ink); }

.poster {
  flex-shrink: 0;
  min-height: 160px;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  overflow: hidden;
  border: 6px solid var(--poster-frame);
  border-radius: 6px;
}
/* Let the copy set the card height; photos fill the resulting grid row. */
.poster img { width: 100%; height: 0; min-height: 100%; object-fit: cover; object-position: 50% 30%; }
.poster-copy { min-width: 0; padding: 12px 18px; display: flex; flex-direction: column; justify-content: center; gap: 6px; }
.poster-title { font-family: var(--display); font-size: 40px; line-height: 1.1; text-transform: uppercase; }
.poster-line { font-size: 15px; font-weight: 700; }
.poster-small { font-size: 12px; opacity: 0.85; }
.poster-font { grid-template-columns: 190px minmax(0, 1fr); background: var(--yellow); }
.poster-elder { grid-template-columns: minmax(0, 1fr) 150px; background: #0039A6; color: #fff; }
.poster-district { grid-template-columns: 170px minmax(0, 1fr); background: #fff; }
.poster-district img { object-position: 50% 45%; }
.poster-district .poster-title { color: #C8201A; }

/* ---------- Store ---------- */
.store {
  display: flex; flex-direction: column;
  overflow-y: auto;
  background: var(--paper);
  scrollbar-width: thin;
  scrollbar-color: #bdb8ad transparent;
}
.store-head {
  position: sticky; top: 0; z-index: 2;
  height: 52px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 12px 0 18px;
  background: var(--ink);
  color: #fff;
}
.store-head h2 { font-size: 20px; font-weight: 800; }
.store-head-note { font-size: 13px; color: var(--soft); padding-right: 6px; }

.buy-mode { display: flex; border: 2px solid #fff; border-radius: 5px; overflow: hidden; }
.buy-mode button {
  min-width: 50px; height: 34px; padding: 0 8px;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: 0; color: #fff;
  font-size: 14px; font-weight: 800; line-height: 1;
  cursor: pointer;
}
.buy-mode button[aria-pressed="true"] { background: #fff; color: var(--ink); }

/* Shared by producer rows and upgrade cards: a scene image under a fade ("veil") */
.scene { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.veil { position: absolute; inset: 0; transition: opacity 0.12s; }
.item-text { position: relative; display: flex; flex-direction: column; min-width: 0; }
.tile {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  background: var(--line);
  border: 2px solid var(--ink);
  overflow: hidden;
}

.upgrades { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; padding: 14px 16px 18px; }
.upgrade {
  position: relative;
  overflow: hidden;
  display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 8px 10px; align-items: center;
  padding: 9px 10px 0;
  text-align: left;
  background: #fff;
  border: 2px solid var(--ink);
  border-radius: 6px;
  box-shadow: 0 2px 0 var(--ink);
  cursor: pointer;
  transition: transform 0.08s;
}
/* The scene fills only the row above the effect bar (explicit grid lines, since auto lines mean the padding edge
   for absolute children), shown whole on the right and faded in from the left.
   The offsets undo .upgrade's padding (9px top, 10px sides) and the 8px row gap. */
.upgrade .scene {
  grid-row: 1 / 2; grid-column: 1 / -1;
  inset: -9px -10px auto auto;
  width: auto; height: calc(100% + 17px);
  object-fit: contain;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 30%);
  mask-image: linear-gradient(90deg, transparent, #000 30%);
}
.upgrade .veil { background: linear-gradient(90deg, rgba(255, 255, 255, 0.96) 0, rgba(255, 255, 255, 0.9) 55%, rgba(255, 255, 255, 0.5) 100%); }
.upgrade .tile { width: 44px; height: 44px; border-radius: 4px; }
.upgrade .tile img { width: 36px; height: 36px; }
.upgrade .item-text { gap: 3px; text-shadow: 0 0 4px #fff, 0 0 2px #fff, 0 0 1px #fff; }
.upgrade .name { font-size: 14px; font-weight: 800; line-height: 1.25; }
.upgrade .cost { font-size: 12px; font-weight: 700; color: var(--good); }
.upgrade-effect {
  position: relative;
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: 8px;
  margin: 0 -10px; padding: 7px 10px;
  background: var(--paper);
  border-top: 1px solid var(--rule);
  text-shadow: none;
}
.effect-value {
  flex-shrink: 0;
  min-width: 42px; padding: 3px 6px;
  background: var(--ink); color: var(--yellow);
  border-radius: 3px;
  font-size: 14px; font-weight: 800; line-height: 1;
  text-align: center;
}
.effect-label { font-size: 12px; font-weight: 700; line-height: 1.3; }
.upgrade:hover { transform: translateY(-2px); box-shadow: 0 4px 0 var(--ink); }
.upgrade.cant { cursor: not-allowed; }
.upgrade.cant .scene, .upgrade.cant .tile { filter: grayscale(1); }
.upgrade.cant .cost { color: var(--red); }
.upgrade.cant:hover { transform: none; box-shadow: 0 2px 0 var(--ink); }
.empty { margin: 0; padding: 0 16px 18px; font-size: 14px; color: #555; }
.empty[hidden] { display: none; }

.producers { display: flex; flex-direction: column; }
.producer {
  position: relative;
  overflow: hidden;
  display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 16px; align-items: center;
  min-height: 86px;
  padding: 12px 18px 14px;
  text-align: left;
  background: transparent;
  border: 0;
  border-bottom: 2px solid var(--ink);
  cursor: pointer;
}
.producer[hidden] { display: none; }
.producer .veil { background: linear-gradient(90deg, rgba(244, 241, 234, 0.9) 0, rgba(244, 241, 234, 0.74) 42%, rgba(244, 241, 234, 0.5) 66%, rgba(244, 241, 234, 0) 90%); }
.tile-wrap { position: relative; width: 60px; height: 60px; }
.producer .tile { position: absolute; inset: 0; box-shadow: 3px 3px 0 var(--ink); }
.producer .tile img { width: 48px; height: 48px; }
.tile-wrap .bullet { position: absolute; right: -10px; bottom: -10px; width: 28px; height: 28px; border: 2px solid var(--paper); font-size: 15px; }
.producer .item-text { gap: 2px; text-shadow: 0 0 4px var(--paper), 0 0 2px var(--paper), 0 0 1px var(--paper); }
.producer .name { font-size: 17px; font-weight: 800; }
.producer .desc { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.producer .meta { display: flex; gap: 12px; font-size: 13px; font-weight: 700; }
.producer .each { color: #555; font-weight: 500; }
.owned {
  position: relative;
  font-size: 36px; font-weight: 900;
  color: #fff;
  -webkit-text-stroke: 5px var(--ink);
  paint-order: stroke fill;
  font-variant-numeric: tabular-nums;
}
.producer:hover .veil { opacity: 0.6; }
.producer.cant { cursor: not-allowed; }
.producer.cant .scene { filter: grayscale(1); }
.producer.cant:hover .veil { opacity: 1; }
.producer.cant .name { color: #6b675f; }
.producer.cant .cost { color: var(--red); }
.producer.mystery .tile-wrap .bullet { display: none; }

/* ---------- Breakpoints ---------- */
/* Tablet: drop the middle panel */
@media (max-width: 1219px) {
  .layout { grid-template-columns: minmax(0, 1fr) minmax(360px, 450px); }
  .transit { display: none; }
  .tagline { display: none; }
}

/* Phone: one scrolling column, tabs pick the panel under the clicker */
@media (max-width: 759px) {
  :root { --header-h: 56px; --face: min(240px, 62vw); }
  body { overflow: auto; height: auto; }
  html, body { height: auto; }
  .topbar { padding: 0 16px; gap: 12px; position: sticky; top: 0; z-index: 10; }
  .logo { width: 32px; height: 32px; font-size: 19px; }
  .title h1 { font-size: 22px; }
  .autosave { display: none; }
  .btn-outline { height: 32px; font-size: 12px; padding: 0 10px; }

  .layout { display: block; }
  .clicker { padding: 16px; gap: 14px; }
  .counter { padding: 12px 16px; gap: 4px; }
  .count { font-size: 44px; }
  .count-unit { font-size: 24px; }
  .count-label { font-size: 12px; letter-spacing: 2px; }
  .rates { font-size: 13px; }
  .face { border-width: 8px; }
  .ticker { font-size: 14px; padding: 8px 12px; }
  .ticker-text { min-height: 40px; line-height: 20px; }

  .tabs {
    position: sticky; top: var(--header-h); z-index: 5;
    display: grid; grid-template-columns: repeat(3, 1fr);
    background: var(--ink);
    border-bottom: 2px solid var(--ink);
  }
  .tabs button {
    height: 46px;
    display: flex; align-items: center; justify-content: center; gap: 6px;
    background: var(--ink); color: #fff;
    border: 0;
    font-size: 15px; font-weight: 800;
    cursor: pointer;
  }
  .tabs button[aria-pressed="true"] { background: var(--paper); color: var(--ink); }
  .tab-count { min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: var(--orange); color: var(--ink); font-size: 12px; display: inline-flex; align-items: center; justify-content: center; }
  .tab-count:empty { display: none; }

  .store { overflow: visible; }
  .store-head { position: static; }
  [data-panel] { display: none; }
  .layout[data-tab="producers"] [data-panel="producers"],
  .layout[data-tab="upgrades"] [data-panel="upgrades"] { display: block; }
  .layout[data-tab="status"] [data-panel="status"] { display: flex; }
  .transit { border: 0; padding: 16px; overflow: visible; }
  .poster { min-height: 130px; }
  .poster-title { font-size: 30px; }
  .poster-font { grid-template-columns: 130px minmax(0, 1fr); }
  .poster-elder { grid-template-columns: minmax(0, 1fr) 110px; }
  .poster-district { grid-template-columns: 120px minmax(0, 1fr); }
  .poster-line { font-size: 13px; }

  .upgrades { padding: 12px; }
  .producer { grid-template-columns: 54px minmax(0, 1fr) auto; gap: 14px; padding: 10px 16px 12px; min-height: 76px; }
  .tile-wrap { width: 50px; height: 50px; }
  .producer .tile img { width: 40px; height: 40px; }
  .tile-wrap .bullet { width: 24px; height: 24px; right: -8px; bottom: -8px; font-size: 13px; }
  .producer .name { font-size: 16px; }
  .owned { font-size: 30px; -webkit-text-stroke-width: 4px; }
}

@media (prefers-reduced-motion: reduce) {
  .golden, .ticker-now { animation: none; }
  .pop { animation-duration: 0.01s; }
}
