/* Shared chrome for all minigame pages: HUD, toast, overlay,
   legend chips, leaderboard. Game-specific canvas/color rules stay in each
   game's own stylesheet (e.g. degen-pong.css, gains-stacker.css). */

.game-body { background: var(--bg); }

.game-page {
  max-width: 640px;
  margin: 0 auto;
  padding: 50px 6vw 90px;
  text-align: center;
}

.game-title {
  font-size: clamp(2.2rem, 8vw, 3.4rem);
  margin-bottom: 14px;
}
.game-title .hl {
  background: linear-gradient(90deg, var(--amber), var(--red));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.game-switcher {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 auto 24px;
}
.game-switch-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 800;
  font-size: 13px;
  padding: 8px 18px;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  color: var(--muted);
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
/* Each game's own shape, a size under the words so the row still reads
   as names first. */
.tab-mark { width: 1.15em; height: 1.15em; flex: none; opacity: 0.85; }
.game-switch-tab:hover { color: var(--text); border-color: var(--amber); }
.game-switch-tab:hover .tab-mark { opacity: 1; }
.game-switch-tab.is-active .tab-mark { opacity: 1; }
.game-switch-tab.is-active {
  background: var(--amber);
  color: #1a1200;
  border-color: #000;
  box-shadow: 3px 3px 0 #000;
}

.game-sub {
  color: var(--muted);
  font-size: 15px;
  max-width: 440px;
  margin: 0 auto 30px;
  line-height: 1.6;
}


.game-hud {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.hud-stat {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 10px 22px;
  min-width: 100px;
}
.hud-label {
  display: block;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}
.hud-value {
  display: block;
  font-family: 'Anton', 'Anton Fallback', sans-serif;
  font-size: 26px;
  color: var(--amber);
  font-variant-numeric: tabular-nums;
}

.game-stage {
  position: relative;
  max-width: 500px;
  margin: 0 auto;
  border-radius: 20px;
  overflow: hidden;
  border: 3px solid #000;
  box-shadow: var(--shadow-hard);
  touch-action: none;
}

.game-toast {
  position: absolute;
  top: 14%;
  left: 50%;
  transform: translate(-50%, -10px);
  font-family: 'Anton', 'Anton Fallback', sans-serif;
  /* Eased down from 2.2rem: the lines got longer when they started
     carrying what a drop earned as well as what it scored, and at the old
     size a long one filled the whole board. */
  font-size: clamp(1.3rem, 5.4vw, 1.9rem);
  color: #fff;
  text-shadow: 0 3px 0 #000, 0 0 20px rgba(0,0,0,0.6);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.3s ease;
  /* A long line wraps inside the stage instead of running off both sides
     of it. Short ones still sit on one line, so nothing that used to fit
     looks any different. */
  max-width: 92%;
  text-align: center;
  text-wrap: balance;
  line-height: 1.05;
}
.game-toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.game-overlay {
  position: absolute;
  inset: 0;
  background: rgba(5, 6, 8, 0.86);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.game-overlay[hidden] { display: none; }
.overlay-card {
  background: var(--panel);
  border: 3px solid #000;
  border-radius: 18px;
  box-shadow: var(--shadow-hard);
  padding: 32px 28px;
  text-align: center;
  max-width: 320px;
}
.overlay-card h2 {
  font-family: 'Anton', 'Anton Fallback', sans-serif;
  font-size: 1.8rem;
  color: var(--amber);
  margin: 0 0 12px;
}
.overlay-card p {
  color: var(--text);
  font-size: 15px;
  margin: 6px 0;
}
#overlay-best { color: var(--muted); font-size: 13px; margin-bottom: 20px; }
#btn-replay { margin-top: 8px; }

.game-hint {
  color: var(--muted);
  font-size: 12.5px;
  max-width: 420px;
  margin: 22px auto 0;
  line-height: 1.6;
}

.game-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin: 20px auto 0;
  max-width: 480px;
}
.legend-chip {
  font-size: 11px;
  font-weight: 800;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  color: var(--muted);
  letter-spacing: 0.3px;
}
.legend-moon { color: #6fb98f; border-color: #6fb98f; }
.legend-10x { color: #f0a94e; border-color: #f0a94e; }
.legend-diamond { color: #5ec4c9; border-color: #5ec4c9; }
.legend-paper { color: #d9c3a3; border-color: #d9c3a3; }
.legend-rekt { color: #d9634f; border-color: #d9634f; }
.legend-rug { color: #b3735f; border-color: #b3735f; }

.leaderboard {
  margin: 30px auto 0;
  max-width: 420px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 18px 20px;
  text-align: left;
}
.leaderboard-title {
  font-family: 'Anton', 'Anton Fallback', sans-serif;
  font-size: 16px;
  letter-spacing: 0.5px;
  color: var(--amber);
  margin: 0 0 10px;
  text-align: center;
}
.leaderboard-sub {
  font-family: inherit;
  font-weight: 600;
  font-size: 11px;
  color: var(--muted);
  text-transform: none;
  letter-spacing: 0;
}
.leaderboard-list {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: rank;
}
.leaderboard-list li {
  counter-increment: rank;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--panel-border);
  font-size: 13.5px;
}
.leaderboard-list li:last-child { border-bottom: none; }
/* Your own row, so you can find yourself on a board of twenty-five. */
.leaderboard-list li.is-you {
  background: rgba(255, 183, 3, 0.08);
  border-radius: 8px;
  padding-left: 6px;
  padding-right: 6px;
  margin: 0 -6px;
}
.leaderboard-list li.is-you .lb-addr { color: var(--amber); }
.leaderboard-list li.is-you::before { color: var(--amber); }
.leaderboard-list li::before {
  content: counter(rank);
  font-family: 'Anton', 'Anton Fallback', sans-serif;
  font-size: 13px;
  color: var(--muted);
  width: 18px;
  flex-shrink: 0;
  text-align: center;
}
.leaderboard-list .lb-addr {
  flex: 1;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
/* The wallet beside a name, quiet enough that the name still leads. */
.leaderboard-list .lb-wallet {
  margin-left: 7px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--muted);
}
.leaderboard-list .lb-score {
  font-family: 'Anton', 'Anton Fallback', sans-serif;
  color: var(--amber);
  font-variant-numeric: tabular-nums;
}
.leaderboard-list .lb-meta {
  font-size: 11px;
  color: var(--muted);
}
.leaderboard-empty {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  margin: 4px 0 0;
}

.game-footnote {
  color: var(--muted);
  font-size: 12px;
  max-width: 440px;
  margin: 26px auto 0;
  line-height: 1.6;
}

/* ---- Rails ----
   Wrappers that exist purely so the desktop grid below has something to put
   in its side columns. `display: contents` makes them invisible to layout
   everywhere else, so a phone lays the page out exactly as if they were
   never in the markup. */
.game-rail { display: contents; }

/* ---- Desktop ---------------------------------------------------------
   One narrow centred column is right for a phone and wrong for a monitor:
   the board lands below the fold with a thousand pixels of dead black on
   either side of it, so you scroll to play and lose sight of your score.
   Wide viewports get the arcade-cabinet treatment instead -- the board
   sized off the viewport's HEIGHT so the whole thing is visible at once,
   flanked by a score panel on the left and the rules and leaderboard on
   the right. */
@media (min-width: 1040px) {
  .game-page:not(.tycoon-page) {
    max-width: 1280px;
    padding: 30px 36px 46px;
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr) 280px;
    /* Rows 1-3 hug their content and row 4 soaks up whatever height the
       board has left over, so the score panel sits directly under the
       blurb instead of being pushed halfway down the board's shadow. */
    grid-template-rows: auto auto auto 1fr;
    column-gap: 36px;
    justify-content: center;
    align-items: start;
  }

  /* Only the title and the game tabs run across the top; the blurb drops
     into the left rail, because every line of centred prose above the
     board is a line the board itself does not get. */
  .game-page:not(.tycoon-page) .game-head { display: contents; }
  :not(.tycoon-page) > .game-head > .game-title { grid-column: 1 / -1; grid-row: 1; }
  .game-page:not(.tycoon-page) .game-switcher { grid-column: 1 / -1; grid-row: 2; margin-bottom: 22px; }
  .game-page:not(.tycoon-page) .game-sub {
    grid-column: 1;
    grid-row: 3;
    max-width: none;
    margin: 0 0 18px;
    text-align: left;
    font-size: 14px;
  }

  .game-rail {
    display: flex;
    flex-direction: column;
    gap: 20px;
    text-align: left;
  }
  .game-rail-left { grid-column: 1; grid-row: 4; }
  .game-stage { grid-column: 2; grid-row: 3 / 5; }
  .game-rail-right { grid-column: 3; grid-row: 3 / 5; }

  /* A row of chips becomes a scoreboard: one line per stat, label left,
     number right, tabular figures already keeping the digits from
     jittering as they count up. */
  .game-rail-left .game-hud {
    flex-direction: column;
    gap: 8px;
    margin-bottom: 0;
  }
  .game-rail-left .hud-stat {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 14px;
    width: 100%;
    padding: 11px 18px;
  }
  .game-rail-left .hud-label { font-size: 11.5px; }
  .game-rail-left .hud-value { font-size: 27px; line-height: 1; }

  .game-rail-right .game-hint,
  .game-rail-right .game-footnote {
    max-width: none;
    margin: 0;
    text-align: left;
  }
  .game-rail-right .game-legend {
    max-width: none;
    margin: 0;
    justify-content: flex-start;
  }
  /* Last in the rail: it grows when the board comes in, and anything
     under it would be pushed down the screen as it did. */
  .game-rail-right .leaderboard { max-width: none; margin: 0; order: 1; }
  /* "this browser, for now" trails the title on a wide page; in a 280px
     rail it wraps into the middle of it, so give it its own line. */
  .game-rail-right .leaderboard-sub { display: block; margin-top: 3px; }

  /* The canvases are a fixed 5:7 portrait, so the board is sized by picking
     a width and letting the aspect ratio derive the height. The three terms
     are the three things that can limit it: the column it sits in, its own
     native 500px, and the viewport height (converted through the 5:7), which
     is the one that actually keeps the whole board above the fold. The
     max() floor stops a very short window shrinking it to nothing -- there,
     a little page scroll is the better trade. */
  .game-stage {
    justify-self: center;
    max-width: none;
    width: min(100%, 500px, max(300px, calc((100vh - 268px) * 5 / 7)));
    aspect-ratio: 5 / 7;
    height: auto;
    margin: 0;
  }
  .game-stage canvas {
    width: 100%;
    height: 100%;
  }
}

/* ---- Juice: the layers game-juice.js puts over the board ----
   A flash, floating numbers, confetti, a HUD number that jumps when it
   changes, the card that pops in when a game ends, and the toast that
   lands rather than fades in. None of it takes a click. */
.juice-flash {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  z-index: 3;
}
.juice-floats {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 4;
}
.juice-float {
  position: absolute;
  transform: translate(-50%, -50%);
  font-family: 'Anton', 'Anton Fallback', sans-serif;
  font-size: clamp(1rem, 4.2vw, 1.4rem);
  color: #fff;
  text-shadow: 0 2px 0 #000, 0 0 12px rgba(0, 0, 0, 0.6);
  white-space: nowrap;
  animation: juice-rise 1.1s cubic-bezier(0.2, 0.8, 0.3, 1) forwards;
}
.juice-float.is-gold { color: #ffd28a; }
.juice-float.is-green { color: #6fb98f; }
.juice-float.is-blue { color: #8ecbff; }
.juice-float.is-red { color: #ff7a6b; }
.juice-float.is-big { font-size: clamp(1.4rem, 6vw, 2rem); }
@keyframes juice-rise {
  0%   { opacity: 0; transform: translate(-50%, -30%) scale(0.6); }
  12%  { opacity: 1; transform: translate(-50%, -55%) scale(1.15); }
  30%  { transform: translate(-50%, -70%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -170%) scale(0.95); }
}
.juice-confetti {
  position: absolute;
  top: -12px;
  width: 8px;
  height: 12px;
  border-radius: 2px;
  opacity: 0.95;
  animation: juice-confetti 1.6s cubic-bezier(0.3, 0.1, 0.6, 1) forwards;
}
@keyframes juice-confetti {
  0%   { transform: translate(0, 0) rotate(0deg); opacity: 1; }
  100% { transform: translate(var(--drift, 0px), 110vh) rotate(var(--spin, 360deg)); opacity: 0.6; }
}
.hud-value.juice-pop { animation: juice-pop 0.3s cubic-bezier(0.2, 1.6, 0.4, 1); }
@keyframes juice-pop {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.28); color: #fff; }
  100% { transform: scale(1); }
}
/* The switch sits in the HUD as one more tile, because that is where the
   eye already goes for the state of the game. */
.hud-sound {
  cursor: pointer;
  font: inherit;
  color: inherit;
  text-align: center;
  min-width: 84px;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.hud-sound:hover { border-color: var(--amber); }
.hud-sound:active { transform: scale(0.96); }
.hud-sound.is-off .hud-value { color: var(--muted); }
.hud-sound:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.game-overlay:not([hidden]) .overlay-card {
  animation: juice-card-in 0.45s cubic-bezier(0.2, 1.4, 0.4, 1);
}
@keyframes juice-card-in {
  0%   { transform: translateY(24px) scale(0.86); opacity: 0; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}
.game-toast.show { animation: juice-toast-in 0.26s cubic-bezier(0.2, 1.5, 0.4, 1); }
@keyframes juice-toast-in {
  0%   { transform: translate(-50%, 6px) scale(0.7); }
  100% { transform: translate(-50%, 0) scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .juice-float, .juice-confetti, .hud-value.juice-pop,
  .game-overlay:not([hidden]) .overlay-card, .game-toast.show { animation: none; }
  .juice-float { opacity: 1; }
}

/* ---- Depth, redone ----
   The same pass the rest of the site had: the stage and the cards are lit
   instead of outlined in 3px of black with a solid block thrown behind
   them. The tokens are defined on :root in style.css, which every game
   page loads before this one. */
.game-stage {
  border: 1px solid rgba(0, 0, 0, 0.7);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 2px 6px rgba(0, 0, 0, 0.55),
    0 30px 60px -30px rgba(0, 0, 0, 1);
}
.overlay-card {
  background: var(--face, var(--panel));
  border: 1px solid var(--edge, rgba(255, 255, 255, 0.09));
  border-radius: 22px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 4px 10px rgba(0, 0, 0, 0.6),
    0 40px 70px -40px rgba(0, 0, 0, 1);
}

/* On the way to another game: the tab lights up and is still lit when
   the page goes, rather than the press never being seen at all. */
.game-switch-tab { position: relative; }
.game-switch-tab:active { transform: scale(0.97); }
.game-switch-tab.is-going {
  color: #1a1200;
  border-color: rgba(120, 72, 0, 0.5);
  background: linear-gradient(180deg, #ffd44e 0%, var(--amber) 55%, #f39200 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55),
    0 10px 20px -12px rgba(255, 150, 3, 0.7);
}
@media (prefers-reduced-motion: reduce) {
  .game-switch-tab.is-going { transition: none; }
}
