/* style.css — Trample design system + game shell layout
 *
 * The palette, type scale and "chunky stone" button treatment mirror the
 * Trample landing page and launch checklist, so the game, the site and the
 * marketing material all read as one product.
 *
 * Colours are declared twice: a hex fallback first, then the oklch value the
 * brand is authored in. Browsers that can't parse oklch drop that declaration
 * and keep the hex.
 */

:root {
  --meadow:        #57B85A;
  --meadow:        oklch(72% 0.18 145);
  --meadow-light:  #7FD07A;
  --meadow-light:  oklch(80% 0.16 145);
  --meadow-dark:   #2F7A38;
  --meadow-dark:   oklch(50% 0.13 148);
  --forest:        #244B28;
  --forest:        oklch(32% 0.08 150);
  --forest-deep:   #16301A;
  --forest-deep:   oklch(22% 0.05 152);

  --parchment:     #F2EDE0;
  --parchment:     oklch(94% 0.025 88);
  --parchment-dim: #E6DECD;
  --parchment-dim: oklch(89% 0.03 86);
  --edge:          #D2C6AC;
  --edge:          oklch(82% 0.04 78);

  --mud:           #7A5731;
  --mud:           oklch(42% 0.07 55);
  --mud-deep:      #55371C;
  --mud-deep:      oklch(30% 0.05 50);
  /* The bridge's own wood, light enough to read on the dark HUD rows: the
     score floats and the row's bridge entries, gained or spent (issue #168). */
  --driftwood:     #C9A98A;
  --driftwood:     oklch(75.5% 0.057 66);

  --bounty:        #E8B84A;
  --bounty:        oklch(80% 0.16 85);
  /* The pale gold every sack's value is stamped in, on the board and on the
     chip (#3E2723 outline). The row's bounty entry and its float wear it too,
     so the +10 in the row is the colour of the 10 on the sack. */
  --bounty-figure: #FFE082;
  --bounty-deep:   #B07B22;
  --bounty-deep:   oklch(60% 0.16 65);

  --danger:        #C4462F;
  --danger:        oklch(55% 0.17 30);

  --ink:           #1E2A20;
  --ink:           oklch(22% 0.02 150);
  --ink-soft:      #4A554C;
  --ink-soft:      oklch(38% 0.02 150);

  --display: 'Bricolage Grotesque', system-ui, sans-serif;
  --body:    'Fredoka', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono:    'JetBrains Mono', ui-monospace, monospace;

  /* The screen's own insets: the status bar a home-screen iOS app draws
     under (black-translucent, index.html) and the home indicator below. Both
     are 0 in a browser tab, on Android, on desktop and in an itch.io frame,
     so every rule that reads them is a no-op there and one layout serves the
     lot — nothing branches on device or context. Read through these rather
     than env() directly, so the fallback is written once. */
  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  /* A HUD pixel (see #ui-panel). 1px anywhere outside the panel. */
  --hud-px: 1px;
  /* The one column everything stands in on a wide window: the game shell,
     the world map's viewport and bar, and the map scene itself, which is
     authored 448 wide — a phone's width, so a desktop or a tablet plays the
     phone's view, letterboxed on the body's ground. It is the board's cap
     too: inside it no board's cell can outgrow a phone's, and the shell's own
     margins centre it once it is hit. */
  --column: 448px;
  /* How far the column's edge stands in from the viewport's on a window
     wider than it — 0 on a phone. The corner furniture (the version stamp,
     the speaker and its menu) measures from here, so on a desktop it sits in
     the game's own corners rather than out at the browser window's edges.
     A fixed element's percentages are the viewport's, so 100% is its width. */
  --column-gutter: max(0px, calc((100% - var(--column)) / 2));
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--forest-deep);
  font-family: var(--body);
  color: var(--ink);
  user-select: none;
  -webkit-user-select: none;
  -webkit-font-smoothing: antialiased;
}
/* The status bar. Only a home-screen iOS app has one to clear (--safe-top is
   0 everywhere else), and it is cleared here, on the body, so the game shell
   below (height: 100%) fills what is left: the board starts under the clock
   rather than beneath it, and main.js's canvas maths, which reads the shell's
   clientHeight, needs no inset of its own. The fixed overlays ignore body
   padding and go on painting under the bar — the look black-translucent is
   for — and keep their cards clear of it themselves (.t-overlay). */
body { padding-top: var(--safe-top); }

/* ═══════════════════════════════════ GAME SHELL */

#game-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  height: 100%;
  max-width: var(--column);
  margin: 0 auto;
  background: var(--forest);
  /* The containing block for the floating Undo / Confirm. `margin: 0 auto`
     centres the shell in anything wider than the column, and main.js measures the
     head tile against THIS box — so with nothing positioned here the absolute
     box resolved against the viewport instead and landed a whole left margin
     out over the desktop letterboxing. On a phone the margin is 0, which is
     why it only ever showed on a wide window.
     Relative with no z-index starts no stacking context, so #drag-confirm's
     60 still competes at the root against the overlays' 100+. */
  position: relative;
}

#game-canvas {
  display: block;
  width: 100%;
  flex: 1;
  min-height: 0;
  touch-action: none;
}

/* UI Panel below the canvas. Hidden until there is a game to play — the player
   rows and the control strip are meaningless in the menus, and a panel that
   starts visible flashes the game shell before the main menu is built
   (issue #84). ui.showGameUI() sets the inline display either way. */
#ui-panel {
  width: 100%;
  background:
    radial-gradient(ellipse 80% 120% at 50% 100%, rgba(0,0,0,.28) 0%, transparent 70%),
    var(--forest);
  border-top: 2px solid var(--meadow-dark);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 -8px 22px -14px rgba(0,0,0,.9);
  /* ONE dial sizes the whole panel. --hud-px is a pixel at the panel's floor
     and grows with the viewport, and everything in here that has to stay
     legible — the type, the icons, the rows, the strip, the chip — is written
     as a count of them. So the panel is exactly the design below on the phone
     it was tuned on (a 430x739 Safari viewport, where 13px is 1.76% of the
     height), up to 15% bigger where there is room, and never smaller: the
     board absorbs the variance and the HUD holds steady, because a board 8%
     smaller is barely noticed and an unreadable score is the whole game.
     Width is in the min() so the strip cannot outgrow a narrow phone, and
     svh rather than vh because vh is the viewport with the browser chrome
     collapsed — on iOS a hundred pixels more than a player ever sees, which
     would have grown the panel on the very phone it was tuned for. The
     @supports below is where the growth is switched on: a custom property
     cannot carry its own fallback (an unsupported unit only fails where it is
     used), so a browser without svh keeps the floor. */
  --hud-px: 1px;
  --hud-pad-y: 7px;
  --hud-pad-x: 9px;
  /* The home indicator's inset beyond the panel's own padding, ADDED to the
     height rather than taken from it. It used to come out of the fixed
     height, which on a home-screen iOS app (34px of inset) squeezed the
     2-player rows from 28px to 14px and left the strip standing a band above
     the bottom — the squashed scores every screenshot from the home screen
     showed. Zero wherever there is no inset. */
  --hud-safe: max(0px, var(--safe-bottom) - var(--hud-pad-y));
  padding: var(--hud-pad-y) var(--hud-pad-x) max(var(--hud-pad-y), var(--safe-bottom));
  display: none;         /* showGameUI(true) sets display:flex inline */
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
  /* Pinned per player count. Player count is fixed for a game, so the board
     never resizes under anyone — the unit moves only with the viewport, which
     re-lays the board out anyway.

     The heights buy every count the SAME ~27px row, which is what lets all
     four share one type scale — four players used to be squeezed to a 10px
     font in an 18.75px row and read as a different, smaller panel.

     They cost almost nothing. The board takes min(width/cols, height/rows)
     and is width-bound on nearly every phone this ships to, so the height
     comes out of slack rather than out of cells. Measured at 165 against the
     old 131, per board:
       Large 12x16   free everywhere (holds its cell to a 176px panel even on
                     a 360x640, and past 300 on the bigger phones)
       Medium 10x14  free except 1px of cell on a 375x667 SE and a 360x640
       Small 8x12    the same two, 1px each — Small has the tallest aspect
                     ratio, so it is the one that binds first
     A 1px cell on the two smallest phones is the whole price. Anything past
     165 starts costing the mid-size phones too. */
  --hud-h: 165;
  height: calc(var(--hud-h) * var(--hud-px) + var(--hud-safe));
}
#ui-panel.players-2 { --hud-h: 110; }   /* 2 rows at 28.5px */
#ui-panel.players-3 { --hud-h: 138; }   /* 3 rows at 27.25px */
                                        /* 4 rows at 27.25px is the 165 above */
@supports (height: 1svh) {
  #ui-panel { --hud-px: calc(clamp(13px, min(1.76svh, 3.5vw), 15px) / 13); }
}

/* ── PLAYER ROWS
   The score chip and the turn log are one element: who, what they last
   scored, and what that leaves them on. Side-by-side chips could not hold
   four players on a phone without wrapping to a 2x2 grid, and that grid cost
   two rows of history; stacked rows hold four and have width to spare.

   The rows are sunk into the panel's own ground and the bounty chip below
   them takes the raised, pressable treatment, so weight sits on the elements
   that are actually controls. Gold means "bounty" here, not "your turn" —
   whose turn it is is a lit green row. */
#player-rows {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  min-height: 0;
}
#player-rows.players-4 { gap: 2px; }

.player-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
  flex: 1;
  min-height: 0;
  border-radius: 9px;
  background: rgba(0,0,0,.26);
  color: var(--parchment);
  font-size: calc(13 * var(--hud-px));
  font-weight: 600;
  white-space: nowrap;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.09);
}
/* Active: lit, not recoloured. */
.player-row.active {
  background: var(--meadow-dark);
  box-shadow: inset 0 0 0 1px var(--meadow), 0 0 0 1px rgba(0,0,0,.25);
}
.player-row .player-dot { width: calc(11 * var(--hud-px)); height: calc(11 * var(--hud-px)); flex-shrink: 0; }

.player-row__name {
  font-family: var(--mono);
  font-size: calc(12 * var(--hud-px));
  letter-spacing: .5px;
  color: var(--parchment-dim);
  opacity: .85;
  flex-shrink: 0;
}
.player-row.active .player-row__name { color: var(--parchment); opacity: 1; }

/* The turn's deltas take the row's slack, which keeps the bridges and the
   boss mark in a left-hand group that lines up down the panel, after the
   name, and puts the last turn against the total it adds to. Its line is
   right-aligned (.t-delta-line), so the newest entries — the bounty last —
   sit beside the total and a short turn leaves no gap. */
.player-row__deltas {
  position: relative;
  align-self: stretch;      /* a definite box for the lines to scroll inside */
  flex: 1;
  min-width: 0;
  overflow: hidden;
  font-family: var(--mono);
  /* 14, up from 12 (issue #168): the turn's score is the line a player is
     reading for, and at 12 it was the smallest type on the panel. */
  font-size: calc(14 * var(--hud-px));
}
/* One turn's entry. Absolutely placed so the outgoing and incoming lines pass
   each other inside the clipped box rather than sitting side by side — two
   turns that earned the same thing are identical to read, and a straight text
   swap between them looks like nothing happened. */
.t-delta-line {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  /* 10 between entries (issue #168): grass, bridge and bounty read as three
     things rather than one run. The worst line a turn can make, "+8 −10 +25"
     with a boss's mark reserved beside it, still fits a 360-wide phone. */
  gap: calc(10 * var(--hud-px));
  /* The arriving line waits for the leaving one to get clear. Without the
     delay both sit within a few px of centre at the midpoint and the frame
     reads as one smudged line rather than two passing. */
  justify-content: flex-end;
  animation: deltaLineIn 240ms cubic-bezier(.2,.85,.3,1) 90ms both;
}
.t-delta-line.is-leaving {
  animation: deltaLineOut 200ms cubic-bezier(.45,0,.75,.3) both;
}
/* The bridge mark is fixed-colour artwork drawn for parchment, so it cannot
   follow the row's text colour and goes muddy on a dark green row. Lifted
   rather than redrawn, so it stays the same bridge everywhere it appears. */
/* Sized with the row rather than under it. At 10px against a 14px total it
   read as a footnote, when it is one of the three numbers a player is here to
   check. The mark grows with it, being sized in em. */
.player-row__bridges {
  flex-shrink: 0;
  font-size: calc(13 * var(--hud-px));
  color: var(--parchment-dim);
  opacity: .85;
}
.player-row__bridges .t-bridge-icon { filter: brightness(1.45) saturate(.85); }
.player-row.active .player-row__bridges { opacity: 1; }
/* One tile a bridge (issue #168), so a spent one is an empty tile rather
   than a digit going down. Bare, two bridges on the row read as a pair of
   eyebrows to someone new; in a tile they read as items held. The tile is
   the boss chip's own shape — 20 HUD px tall, 5px corners, a 1px outline over
   a see-through fill — in parchment rather than the boss's red, so the two
   sit side by side as one family (a solid cream tile was tried first and
   shouted over the chip beside it). It is also the look a button would have,
   should the stock become one. A spent tile loses its fill and keeps a faint
   outline with a ghost of the bridge in it, so the row still reads "one of
   two left"; the opening's tiles start that way and fill as each +5 lands
   (.is-pending). A tile whose bridge is flying to the board is blank for the
   flight (.is-lifting). The bridge is 14 HUD px, the boss chip's mark size. */
.player-row__bridges { display: inline-flex; align-items: center; gap: calc(4 * var(--hud-px)); }
.t-bridge-slot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  height: calc(20 * var(--hud-px));
  padding: 0 calc(3 * var(--hud-px));
  border-radius: 5px;
  background: rgba(242, 237, 224, .16);
  box-shadow: inset 0 0 0 1px rgba(242, 237, 224, .50);
  transition: background 360ms ease-out, box-shadow 360ms ease-out;
}
.player-row__bridges .t-bridge-slot .t-bridge-icon {
  margin: 0;
  font-size: calc(14 * var(--hud-px));
  transition: opacity 360ms ease-out, filter 360ms ease-out;
}
.t-bridge-slot.is-spent,
.t-bridge-slot.is-pending { background: transparent; box-shadow: inset 0 0 0 1px rgba(242, 237, 224, .22); }
.t-bridge-slot.is-spent .t-bridge-icon,
.t-bridge-slot.is-pending .t-bridge-icon { opacity: .3; filter: grayscale(1) brightness(1.8); }
.t-bridge-slot.is-lifting .t-bridge-icon { opacity: 0; transition: none; }
.t-bridge-slot.is-landed { animation: deltaLand 320ms cubic-bezier(.2,.85,.3,1); }
/* The stock is a button (issue #170) — pressing it opens the bridge card.
   Reset here rather than on .player-row__bridges so the size and colour
   above still apply; the hit area takes the row's height, as the boss
   chip's does, and a press lifts every tile's fill at once. */
button.player-row__bridges {
  position: relative;
  padding: 0;
  border: none;
  background: none;
  font-family: inherit;
  line-height: inherit;
  cursor: pointer;
}
button.player-row__bridges::before { content: ''; position: absolute; inset: -5px -4px; }
button.player-row__bridges:active .t-bridge-slot { background: rgba(242, 237, 224, .34); }
/* Free Crossing has no stock, but holds one's width, invisibly, so a boss's
   marks stand in one column down the panel. */
.player-row__bridges.is-held { visibility: hidden; }

/* The opening total ticks up one component at a time (issue #90) and each
   arrival pops. The class rode through the HUD rewrite on the element; the
   rule that gave it an animation did not, because it was keyed on the old
   .score-value — so the pop was silently dead until this was put back. */
.player-row__total.is-bumped { animation: scorePop 360ms ease-out; }
.player-row__total {
  flex-shrink: 0;
  /* 17, up from 15 (issue #168), and its column widened with it. */
  min-width: calc(29 * var(--hud-px));
  text-align: right;
  font-weight: 700;
  font-size: calc(17 * var(--hud-px));
  font-variant-numeric: tabular-nums;
}

/* ONE type scale for every count. The panel used to hold 131px whatever the
   player count and step the type down to fit — four players landed on a 10px
   font in an 18.75px row, which read as a different, smaller panel rather than
   as the same one with more in it. Since the height is free (see #ui-panel),
   the rows get the height instead and the type stays put.
   Three and four still lose a little horizontal padding, because a shorter row
   wants less of it, and four tightens its gap to buy the 25px. */
#player-rows.players-3 .player-row { padding: 0 7px; }
#player-rows.players-4 .player-row { padding: 0 7px; border-radius: 8px; }

/* A turn's gain or loss, in the same icon vocabulary as the score floats. */
.t-delta { display: inline-flex; align-items: center; gap: 2px; }
.t-delta--gain { color: var(--meadow-light); }
.t-delta--bridge { color: var(--driftwood); }
.player-row.active .t-delta--gain { color: #C8F0BE; }
/* A bounty lands gold, the colour its float flew in (issue #168), so the
   turn's biggest number keeps its colour once it is in the row — the pale
   gold its sack is stamped in, not the brand gold it used to be. */
.t-delta--bounty { color: var(--bounty-figure); }
/* The marks as big as the row allows (issue #168). The grass and the sack sit
   in 24-unit boxes with a third of their height empty and their drawings low
   in it, so each is sized up and lifted, its empty sides taken back with a
   negative margin. The sack stands about 14px against the 10px digits,
   lifted a tenth of its box so its middle meets theirs; the grass a little
   smaller at 13px and lifted a little further, about 1px above that middle,
   so its stem stops near the baseline instead of hanging below it (all
   measured off the rendered pixels). The bridge is cropped to its drawing already, and matches the
   stock's bridges on the right of the row. */
.t-delta .t-svg-icon { width: 1.45em; height: 1.45em; margin: 0 -.16em; transform: translateY(-15%); }
.t-delta .t-sack-mark { width: 1.84em; height: 1.84em; margin: 0 -.32em; transform: translateY(-10%); }
.t-delta .t-bridge-icon { font-size: calc(14 * var(--hud-px)); }
/* A turn's entries are laid out at once but shown one by one, each as its
   score float lands on it (issue #116). Hidden rather than absent so the slots
   hold their places and the floats have somewhere to aim. */
.t-delta.is-pending { visibility: hidden; }
.t-delta.is-landed { animation: deltaLand 320ms cubic-bezier(.2,.85,.3,1); }
/* Sized wherever it lands, not just inside a row's delta. The SVG carries a
   viewBox but no width or height, so unsized it has no box to lay out with —
   as an inline element it fell back to a default one, but as a flex item in a
   score float it collapsed to 0x0 and the sack simply vanished. The bounty
   chip sizes its own (.t-rung svg, more specific), so that one is unaffected. */
.t-sack-mark { width: 1.15em; height: 1.15em; display: block; }

/* A boss's abilities, in the right-hand group just before the bridge count.
   Beside the name it pushed that one row's deltas out of line with everyone
   else's, and the column of what each player just scored is the thing being
   read down the panel. Rows without an ability hold the empty slot, but only
   on levels that have a boss at all.
   One mark per ability (issue #124), 13px each in a 17px chip, so a boss
   with two wears a 30px one — and every slot on the panel is sized by the
   widest chip (--boss-marks, set on #player-rows by initPlayerRows), which
   is what keeps the bridges and totals in one column. The boss's own chip is
   a button that opens the ability card; the empty slots are spans. The
   button reset is here rather than on button.t-boss-chip so the two are the
   same box. */
.t-boss-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 1px;
  width: calc((var(--boss-marks, 1) * 15 + 5) * var(--hud-px));
  height: calc(20 * var(--hud-px));
  padding: 0;
  border: none;
  border-radius: 5px;
  flex-shrink: 0;
  font: inherit;
  color: #FF8A73;
  background: rgba(196,70,47,.26);
  box-shadow: inset 0 0 0 1px rgba(255,138,115,.45);
}
.t-boss-chip.is-empty { background: none; box-shadow: none; }
.t-boss-chip .t-svg-icon { width: calc(14 * var(--hud-px)); height: calc(14 * var(--hud-px)); flex-shrink: 0; }
button.t-boss-chip { cursor: pointer; }
/* The chip is 20px in a 27px row: the hit area takes the row's height
   without the mark growing to fill it. */
button.t-boss-chip::before { content: ''; position: absolute; inset: -5px -4px; }
button.t-boss-chip:active { background: rgba(196,70,47,.48); }

/* The bridge mark (ICONS.bridge) — the old How to Play illustration, cropped.
   Sized in em so the one drawing serves the score row and the 20-24px score
   floats; the ratio matches its cropped viewBox, so it never squashes. */
.t-bridge-icon { width: 1.687em; height: 1em; vertical-align: -.16em; }
.player-row__bridges .t-bridge-icon { margin-right: .05em; }
/* The row's gap spaces it now; this only tops it up to the bridge's old feel. */
.score-float .t-bridge-icon { margin-left: .08em; }

/* ── CONTROL STRIP
   Back, bounty, Skip. The two labelled controls sit at either end with the
   chip between them: they were a stacked pair of identical cream buttons in
   an earlier draft, and one forfeits a turn while the other leaves the level. */
#hud-controls {
  display: flex;
  align-items: stretch;
  gap: 7px;
  flex-shrink: 0;
  height: calc(32 * var(--hud-px));
}
.t-hud-mid {
  flex: 1;
  display: flex;
  align-items: stretch;
  justify-content: center;
  min-width: 0;
}

.t-hud-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 100%;
  padding: 0 12px;
  border: none;
  border-radius: 9px;
  cursor: pointer;
  font-family: var(--display);
  font-weight: 700;
  font-size: calc(13 * var(--hud-px));
  letter-spacing: .2px;
  color: var(--mud-deep);
  background: var(--parchment-dim);
  box-shadow: 0 3px 0 var(--edge);
  transition: opacity .15s;
}
.t-hud-btn .t-svg-icon { width: calc(13 * var(--hud-px)); height: calc(13 * var(--hud-px)); }
.t-hud-btn:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 var(--edge); }
/* Skip has two states and no third: active, or dimmed where it cannot act —
   mid-drag there is a path to finish, and on the rival's turn there is no
   turn of yours to skip. It stays in place and dims rather than leaving, so
   the strip is composed identically whichever it is and nothing flickers in
   and out beside a thumb that is already moving. */
.t-hud-btn:disabled { opacity: .34; cursor: default; }
/* The way back to the score card once it has been put away. It stands in the
   bounty chip's slot, which is empty by then — the game is over, so there is
   no next drop and no endgame to count. Gold, because it is the only thing on
   the strip anyone still wants.
   Its emboss has to be named, not inherited: .t-hud-btn's is --edge, the
   cream buttons' own shade, which under gold reads as a lighter yellow and
   makes this the one gold button in the game without a brown lip. */
.t-hud-btn--restore {
  background: var(--bounty, #f5b027);
  color: var(--mud-deep);
  box-shadow: 0 3px 0 var(--bounty-deep);
}
.t-hud-btn--restore:active:not(:disabled) { box-shadow: 0 1px 0 var(--bounty-deep); }

/* ── BOUNTY CHIP — the ladder, not a count
   A playtester played the best part of an hour without noticing the three
   sacks are worth different amounts, so the chip carries the whole ladder in
   the order it drops. Each sack shows the board's own coin pile for its value
   (js/art.js), which makes the chip a legend for the board art.
   It is a real button: pressing it re-opens the round-start popup. */
.t-bounty {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 100%;
  padding: 0 6px;
  min-width: calc(158 * var(--hud-px));
  border: none;
  border-radius: 9px;
  cursor: pointer;
  background: var(--parchment);
  box-shadow: 0 3px 0 var(--edge);
}
.t-bounty:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--edge); }
/* A class rule outranks the browser's own [hidden], so the display above would
   otherwise keep the chip's 158px in the strip at game over and shunt the
   results ▲ over Menu and Skip. */
.t-bounty[hidden] { display: none; }

/* Each rung is the board's own sack, its value stamped on it the way the board
   stamps it (issue #173), so the chip and the grass read alike. The value used
   to sit beside the sack; inside it, the sack takes that room and fills the
   strip's height, its box cropped to the drawing (sackSVG). */
.t-rung { display: flex; align-items: center; gap: 0; flex-shrink: 0; position: relative; isolation: isolate; }
.t-rung svg { width: calc(28 * var(--hud-px)); height: calc(28 * var(--hud-px)); display: block; }
/* The sacks still to fall wait tied shut, and a sack opens and lights up when
   its light goes out to the board (riseLightFromChip), staying open and lit
   while its light or its zone is there — so the chip says which sacks the
   board is marking. Greyed out was tried first and read as "not available";
   a tied sack is still a full one, number and all, just not opened yet. */
.t-sack-closed { display: none; }
.t-rung:not(.is-spent):not(.is-lit) .t-sack-closed { display: inline; }
.t-rung:not(.is-spent):not(.is-lit) .t-sack-open { display: none; }
.t-rung:not(.is-spent) svg { transition: transform .3s; }
/* Opening: the coins spring up out of the mouth as the glow gathers. */
.t-rung.is-glowing .t-sack-open {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  animation: t-sack-opens var(--gather, 450ms) cubic-bezier(.3, 1.5, .6, 1) both;
}
@keyframes t-sack-opens {
  from { transform: scale(.6, .2); }
  to   { transform: scale(1); }
}
/* Lit: a steady glow behind the sack, breathing like the board's light. Gold
   where the board's light is cream: cream on the cream chip does not show, so
   the light is warmer on the chip and cools to cream as it leaves
   (.t-light-flight::before). */
.t-rung.is-lit::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 135%;
  aspect-ratio: 1;
  z-index: -1;
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(circle closest-side,
    rgba(232, 184, 74, .6) 0%, rgba(232, 184, 74, .3) 55%, rgba(232, 184, 74, 0) 100%);
  transform: translate(-50%, -50%);
  animation: t-rung-breathe 1.6s ease-in-out infinite;
}
@keyframes t-rung-breathe {
  0%, 100% { transform: translate(-50%, -50%) scale(.95); }
  50%      { transform: translate(-50%, -50%) scale(1.05); }
}
/* Gathering: the light the sack is about to send out, swelling up over
   --gather to a bright glow with the gold ring inside its edge, the sack
   popping a little as it lights. When it is full the class goes and the
   flight takes off from this glow at this size (LIGHT_HALO, 190% of the
   sack), leaving the steady lit glow behind it. */
.t-rung.is-glowing svg { transform: scale(1.15); }
.t-rung.is-glowing::before {
  width: 190%;
  background:
    radial-gradient(circle closest-side, transparent 74%, rgba(232, 184, 74, .9) 77%, rgba(232, 184, 74, .9) 81%, transparent 84%),
    radial-gradient(circle closest-side,
      rgba(255, 214, 110, .85) 0%, rgba(232, 184, 74, .5) 55%, rgba(232, 184, 74, 0) 100%);
  animation: t-rung-glow var(--gather, 450ms) ease-out both;
}
@keyframes t-rung-glow {
  from { opacity: 0; transform: translate(-50%, -50%) scale(.4); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* Dropped: the rung is the hollow its sack left (issue #186, sackSlotSVG). It
   used to keep the sack, faded, which read as a sack already used up while it
   was still out on the board to be taken. The sack lifts out of the hollow on
   its way to the board (issue #116), its flight drawn over the slot it left. */
/* The sack in flight: a copy of the rung's own drawing, sized to the rung at
   take-off and transformed to the tile's size and place by the flight. */
.t-sack-flight {
  position: fixed;
  z-index: 310;   /* over the phase banner (300): it crosses the words mid-flight, and a
                     moving thing that vanishes behind text reads as lost */
  pointer-events: none;
  transform-origin: center;
  filter: drop-shadow(0 3px 3px rgba(0,0,0,.35));
}
.t-sack-flight svg { width: 100%; height: 100%; display: block; }

/* A drop's light rising out of the chip to its tile (riseLightFromChip): the
   board's own light (SHADOW_ART in js/renderer.js) — a cream glow brightest at
   its middle and gone at its edge, with the gold ring inside the edge — drawn
   in CSS so it can leave the HUD, which the canvas cannot reach. Under the
   coach (140+), so a lesson card's scrim dims it like the rest of the board,
   and under the phase banner: a light is quieter than a sack. */
.t-light-flight {
  position: fixed;
  z-index: 130;
  pointer-events: none;
  transform-origin: center;
  border-radius: 50%;
  background: radial-gradient(circle closest-side,
    rgba(255, 246, 214, .5) 0%, rgba(255, 246, 214, .26) 55%, rgba(255, 246, 214, 0) 100%);
}
.t-light-flight::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle closest-side,
    rgba(255, 214, 110, .85) 0%, rgba(232, 184, 74, .5) 55%, rgba(232, 184, 74, 0) 100%);
  opacity: 0;
}
/* Off a sack's glow: leaves gold, as it glowed on the chip, and cools to the
   board's cream over the first part of the trip. */
.t-light-flight.is-from-glow::before { animation: t-light-cool var(--cool, 400ms) ease-in both; }
@keyframes t-light-cool { from { opacity: 1; } to { opacity: 0; } }
.t-light-flight::after {
  content: '';
  position: absolute;
  inset: 10%;
  border-radius: 50%;
  border: var(--ring, 1.5px) solid rgba(232, 184, 74, .55);
  box-sizing: border-box;
}

/* The countdown sits immediately before the next sack to fall, so it always
   names a value. Once every sack has fallen there is nothing left for it to
   sit in front of, so it comes to rest past the end of the ladder — and that
   position is the endgame: no second chip, no swapped frame, the same row of
   sacks with the clock on the other side of them.
   The count rides the dial's shoulder: level with the values it sits between,
   it read as a fourth number in the ladder. */
.t-clock {
  display: inline-flex;
  align-items: center;
  gap: 0;
  flex-shrink: 0;
  color: var(--mud-deep);
  margin: 0 3px 0 2px;
}
.t-clock .t-svg-icon { width: calc(19 * var(--hud-px)); height: calc(19 * var(--hud-px)); }
.t-clock span {
  align-self: flex-start;
  margin: 0 0 0 1px;
  font-family: var(--mono);
  font-weight: 700;
  font-size: calc(12 * var(--hud-px));
  line-height: 1;
}
/* What the countdown is counting towards once the sacks are gone. It stands
   in the slot a sack would occupy, so the chip still reads left to right as
   "in N turns, this" — position alone was too quiet a signal that the clock
   had changed what it was counting. */
.t-endmark { display: inline-flex; align-items: center; color: var(--mud-deep); flex-shrink: 0; }
.t-endmark .t-svg-icon { width: calc(22 * var(--hud-px)); height: calc(22 * var(--hud-px)); }

/* ── FLOATING UNDO / CONFIRM
   Anchored to a corner of the last tile dragged and opening away from it, so
   it never covers the head — pressing the head is how a short path is
   continued. It carries its own dark ground rather than sitting bare on the
   grass: the board runs six shades of green and a cream button on the light
   ones has almost no edge. */
.t-dragbox {
  --dragbox-rim: rgba(16,29,19,.62);
  position: absolute;
  z-index: 60;
  display: flex;
  border-radius: 13px;
  box-shadow:
    0 0 0 2px var(--dragbox-rim),
    0 4px 0 rgba(16,29,19,.42),
    0 9px 18px -7px rgba(0,0,0,.7);
}
/* A class rule outranks the browser's own [hidden], so the display above would
   otherwise park the box over the main menu. */
.t-dragbox[hidden] { display: none; }

/* The tail names the tile the box is asking about — one capsule can be
   anchored to any of four corners, and without it the box is just a control
   that appeared somewhere. It grows from whichever edge faces the head, in
   the colour of the half it grows out of.
   Only its two OUTER edges carry the rim: a square rotated 45deg points its
   bottom-right corner straight down, so border-right and border-bottom are
   exactly the two that show. The other half of the diamond is inside the
   capsule, over a button of its own colour, where it cannot be seen.
   Its length is DRAG_GAP (js/ui.js) — it bridges the gap to the tile exactly,
   touching it without covering it, which is what the head must never be. */
.t-dragbox[data-arm]::after {
  content: '';
  position: absolute;
  width: 10px;
  height: 10px;
  transform: rotate(45deg);
}
.t-dragbox[data-arm^="up"]::after {
  bottom: -5px;
  border-right: 2px solid var(--dragbox-rim);
  border-bottom: 2px solid var(--dragbox-rim);
}
.t-dragbox[data-arm^="down"]::after {
  top: -5px;
  border-left: 2px solid var(--dragbox-rim);
  border-top: 2px solid var(--dragbox-rim);
}
/* Opened to the right of the head, so the head is off the box's left end —
   under Undo, which is the cream half. */
.t-dragbox[data-arm$="right"]::after { left: 14px; background: var(--parchment-dim); }
.t-dragbox[data-arm$="left"]::after { right: 14px; background: var(--bounty); }
/* The width is still a constraint, just a looser one: an edge-aligned box runs
   from one edge of the head tile to the board's, which from the CENTRE column
   caps it at (board / 2) + (cell / 2) — 200px on a 360px board at a 40px cell.
   Over that and both horizontal arms miss at the one position a player is most
   likely to be drawing in, and the clamp takes over. The capsule lands at
   142px, so there is room now for an icon (~19px) that the old corner-offset
   placement, capped at ~151px, had none for. */
.t-dragbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 40px;
  padding: 0 12px;
  border: none;
  cursor: pointer;
  font-family: var(--display);
  font-weight: 700;
  font-size: 12.5px;
  letter-spacing: .2px;
  color: var(--mud-deep);
}
/* The ends are rounded on the buttons themselves rather than clipped by the
   capsule: overflow:hidden would take the tail off with the corners. */
.t-dragbtn--undo {
  background: var(--parchment-dim);
  border-radius: 13px 0 0 13px;
  box-shadow: inset -1px 0 0 rgba(16,29,19,.28);
}
.t-dragbtn--confirm {
  background: var(--bounty);
  border-radius: 0 13px 13px 0;
}
/* Bigger than the 1em default: at the label's 12.5px a tick loses its corner. */
.t-dragbtn .t-svg-icon { width: 15px; height: 15px; }
/* One capsule, so a pressed half darkens where a separate button would sink —
   dropping one end of a joined pair pulls the shape apart. */
.t-dragbtn--undo:active { background: var(--edge); }
.t-dragbtn--confirm:active { background: var(--bounty-deep); }

/* Small raised button. Down to one user — the world map's back control — now
   that the campaign exit and the results restore have moved into the HUD's
   own control strip and wear .t-hud-btn. */
.t-stone-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  padding: 9px 11px;
  border: none;
  border-radius: 12px;
  background: var(--parchment);
  color: var(--mud-deep);
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--edge), 0 8px 16px -8px rgba(0,0,0,.6);
  transition: transform .1s, box-shadow .1s;
}
.t-stone-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--edge); }
.t-stone-btn .t-svg-icon { width: 18px; height: 18px; }

/* A stone button that names where it goes. The world map's back arrow used to
   be bare, which left the one control on that screen saying nothing — and an
   arrow alone is the same mark the in-game Undo wears. It matches the HUD's
   own back button, which is labelled for exactly that reason. */
.t-stone-btn--labelled {
  gap: 6px;
  padding: 9px 13px 9px 11px;
  font-family: var(--display);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: .2px;
}


/* ═══════════════════════════════════ OVERLAYS & CARDS */

.t-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  /* The insets: a card is centred in the safe area rather than the screen,
     and a scrolling overlay's content starts under the status bar's edge
     rather than beneath the clock. Both are 20px wherever there is none. */
  padding: max(20px, var(--safe-top)) 20px max(20px, var(--safe-bottom));
  font-family: var(--body);
}

/* The menu backdrop, worn by every screen that is not a board or the world
   map: the board's grass as big soft checks, four to the column's width and
   barely two shades apart, so it reads as texture rather than as a board.
   Centred, so the checks fall symmetrically about the title or the card.
   Gradients paint instantly and weigh nothing, which matters because the
   boot screen wears this too and is the game's very first frame. It replaced
   a meadow at dusk (issue #95), itself the replacement for a 2.2 MB painting. */
.t-overlay--map {
  --check: calc(min(100vw, var(--column)) / 4);
  background:
    repeating-conic-gradient(#58B95B 0 25%, #4DB050 0 50%)
    50% 50% / calc(var(--check) * 2) calc(var(--check) * 2);
  background-color: #53B456;
}
/* A shade behind whatever stands in the middle, and a darker edge. */
.t-overlay--map::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 50%, rgba(18,48,22,.26) 0, rgba(18,48,22,0) 42vh),
    radial-gradient(circle at 50% 50%, rgba(12,36,16,0) 30vh, rgba(12,36,16,.35) 75vh);
}

/* The first frame, before js/main.js has run: the menu's backdrop with nothing
   on it yet. It covers the game shell, and sits below every overlay (lowest
   100) so that if it were ever left behind it would hide rather than block.
   pointer-events:none for the same reason — it can never swallow a tap. */
#boot-screen {
  z-index: 50;
  pointer-events: none;
}

.t-overlay--dim   { background: rgba(12,26,14,.72); }
.t-overlay--dimmer{ background: rgba(12,26,14,.85); }

/* Scrollable overlay that still centres its card. Auto margins beat
   align-items in the cross axis: centred when there's room, scrolling from
   the top edge when there isn't (align-items:center would clip the top). */
.t-overlay--scroll {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  align-items: flex-start;
}
.t-overlay--scroll > * {
  margin-top: auto;
  margin-bottom: auto;
}

/* Parchment card — the default surface for every menu and modal */
.t-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 380px;
  max-height: 88vh;
  max-height: 88svh;   /* the viewport a player sees, chrome and all — see #ui-panel */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--parchment);
  border-radius: 22px;
  padding: 24px 22px;
  text-align: center;
  color: var(--ink);
  box-shadow:
    0 4px 0 rgba(0,0,0,.10),
    0 30px 60px -20px rgba(0,0,0,.55),
    inset 0 0 0 1px var(--edge);
}

.t-card--wide { max-width: 420px; }

/* Two gold studs at the top corners — the landing page signup-card motif.
   They sit inside the padding box so a scrolling card never clips them. */
.t-card--studs { padding-top: 30px; }
.t-card--studs::before,
.t-card--studs::after {
  content: '';
  position: absolute;
  width: 14px; height: 14px;
  background: var(--bounty);
  border-radius: 50%;
  top: 13px;
  box-shadow: inset 0 -3px 0 var(--bounty-deep);
}
.t-card--studs::before { left: 16px; }
.t-card--studs::after  { right: 16px; }

/* The boss briefing has no card variant of its own: it is an ordinary
   parchment card, and the red warning sign in its heading carries the whole
   signal. It used to be a scorched dark card ringed in orange, which read as
   aggression rather than as a heads-up. */

/* Campaign complete — gilded variant */
.t-card--gold {
  background: linear-gradient(160deg, #2a5a2a 0%, #14330f 100%);
  color: var(--parchment);
  box-shadow:
    0 4px 0 rgba(0,0,0,.3),
    0 0 40px rgba(232,184,74,.28),
    0 30px 60px -20px rgba(0,0,0,.6),
    inset 0 0 0 2px var(--bounty);
}
.t-card--gold .t-title { color: var(--bounty); }
.t-card--gold .t-body,
.t-card--gold .t-note { color: var(--parchment-dim); }

/* Main menu — hero lockup on the map, no card (mirrors the landing hero) */
.t-menu-hero {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 340px;
  text-align: center;
}
.t-menu-actions { margin-top: 30px; }

/* ═══════════════════════════════════ TYPE */

.t-title {
  font-family: var(--display);
  font-weight: 800;
  font-size: 26px;
  line-height: 1.05;
  letter-spacing: -.02em;
  color: var(--forest);
  margin: 0 0 10px;
}

/* Heading with the warning sign in front of it — the boss briefing. The sign
   is the one red thing on the card; the words stay the ordinary title colour.
   Flex rather than an inline glyph because .t-svg-icon is a block. */
.t-title--warn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.t-warn-sign { display: inline-flex; color: var(--danger); }
.t-warn-sign .t-svg-icon { width: .92em; height: .92em; }

.t-title--hero {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(48px, 15vw, 78px);
  line-height: .9;
  letter-spacing: -.04em;
  color: #fff;
  margin: 0;
  text-shadow: 0 3px 0 var(--meadow-dark), 0 12px 26px rgba(0,0,0,.45);
}

.t-label {
  display: block;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 7px;
}

.t-body {
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--ink-soft);
  margin: 0 0 14px;
}
.t-body strong { color: var(--ink); font-weight: 600; }
/* A second, quieter line under a card's opening paragraph. */
.t-body--aside { font-size: 13px; }

.t-note {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .4px;
  line-height: 1.5;
  color: var(--ink-soft);
  margin: 0;
}

/* ═══════════════════════════════════ BUTTONS */

.t-btn {
  display: block;
  width: 100%;
  margin: 9px 0 0;
  padding: 14px 22px;
  border: none;
  border-radius: 14px;
  font-family: var(--display);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: .2px;
  color: var(--mud-deep);
  background: var(--parchment-dim);
  cursor: pointer;
  box-shadow: 0 4px 0 var(--edge), 0 10px 20px -12px rgba(0,0,0,.5);
  transition: transform .1s, box-shadow .1s;
}
.t-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--edge);
}

/* A link dressed as a button (e.g. the sign-up on the castle menu) */
a.t-btn {
  box-sizing: border-box;
  text-decoration: none;
  text-align: center;
}

/* A link dressed as a button with a mark beside its label — the sign-up and
   the feedback link (issue #155), which sit one above the other at the foot
   of the cards that end a game. The shape is shared so the pair reads as one
   block under the buttons you came to press, and the mark beside each label
   is what tells them apart. */
.t-btn--iconlink {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 15px;
  padding: 11px 18px;
}
.t-btn--iconlink:active { transform: translateY(2px); }
.t-btn--iconlink .t-svg-icon { width: 16px; height: 16px; }

/* Sign-up CTA: an offer, so it shouldn't compete with the button you came to
   press — but it still has to be readable. The bounty-coloured ring gives it
   presence on both the parchment and the dark cards, while the text colour
   comes from whichever ghost variant the caller picked for that background.
   It reaches the button only where the caller picked a class that doesn't
   set one of its own — the castle card's gold — which is the one card where
   the sign-up is the thing you came to press. */
.t-btn--signup {
  box-shadow: inset 0 0 0 2px var(--bounty-deep);
}
.t-btn--signup:active {
  box-shadow: inset 0 0 0 2px var(--bounty-deep);
}

/* The in-game ✉ is a link, not a button, so it needs the same reset a.t-btn
   gets. */
a.t-stone-btn { text-decoration: none; }

/* ═══════════════════════════════════ BUILD STAMP */

/* Top-left on every screen. Above the overlays (max z-index 400) but
   pointer-events:none, so it can never intercept a tap. The shadow keeps it
   legible on the parchment cards as well as the dark backdrops. */
.t-version {
  position: fixed;
  top: max(5px, var(--safe-top));
  left: max(7px, env(safe-area-inset-left), calc(var(--column-gutter) + 7px));
  z-index: 500;
  pointer-events: none;
  user-select: none;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .5px;
  color: rgba(255, 255, 255, .8);
  text-shadow: 0 1px 2px rgba(0, 0, 0, .6);
}

/* The mute toggle (issue #133) — the version stamp's opposite corner, and the
   same idea: pinned, outliving every screen. It is live everywhere the stamp
   is not, so it carries a real hit area (the icon is 18px; the padding takes
   the target past 40px) while staying quiet enough to ignore. Dimmed when
   muted, so the state reads at a glance from the weight rather than from
   reading the mark. It sits above the scenes it lives on (the menus and the
   map are 200) and under every card that can open over one (300 and up), so
   a boss warning or the scoreboard covers it as it covers the rest of the
   scene — unlike the stamp, which can float over them because it takes no
   taps. The one card it stands over is a confirm: see .is-raised below. */
.t-audio {
  position: fixed;
  top: max(5px, var(--safe-top));
  right: max(7px, env(safe-area-inset-right), calc(var(--column-gutter) + 7px));
  z-index: 250;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 11px;
  border: 0;
  background: none;
  cursor: pointer;
  color: rgba(255, 255, 255, .8);
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .6));
  -webkit-tap-highlight-color: transparent;
}

/* It is hidden for the whole of a game (see showAudioToggle), and a class rule
   outranks the browser's own [hidden] { display: none } — without this the
   button would sit over the top-right cell of every board. */
.t-audio[hidden] { display: none; }

/* Over a confirm card (see showAudioToggle) it is raised above the card's
   scrim (400) so it takes taps: the quit-game confirm is the one way to reach
   it during a game, and it stays in its usual corner so it is found where it
   always is. */
.t-audio.is-raised { z-index: 450; }

.t-audio .t-svg-icon { width: 18px; height: 18px; stroke-width: 2; }

.t-audio.is-muted { color: rgba(255, 255, 255, .45); }
.t-audio.is-partial { color: rgba(255, 255, 255, .5); }

.t-audio:active { transform: scale(.92); }

/* The sound menu under the speaker: a volume slider each for the music and
   the effects (issue #181). Placed from the same corner as the button, in the
   same band, and raised with it over a confirm. */
.t-audio-menu {
  position: fixed;
  top: calc(max(5px, var(--safe-top)) + 42px);
  right: max(7px, env(safe-area-inset-right), calc(var(--column-gutter) + 7px));
  z-index: 250;
  width: 208px;
  padding: 8px 14px;
  border-radius: 14px;
  background: var(--parchment);
  color: var(--ink);
  box-shadow:
    0 4px 0 rgba(0,0,0,.10),
    0 18px 40px -14px rgba(0,0,0,.55),
    inset 0 0 0 1px var(--edge);
}
.t-audio-menu[hidden] { display: none; }
.t-audio-menu.is-raised { z-index: 450; }

.t-audio-menu__row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 0;
}

.t-audio-menu__label {
  font-family: var(--display);
  font-weight: 700;
  font-size: 14px;
  line-height: 1.2;
}

/* The slider: a mud-filled track and a parchment thumb, the size of a
   fingertip. The height is the touch target; the track is drawn thin inside
   it. WebKit has no pseudo-element for the filled part, so it is a gradient
   stopped at --fill, set from the value (showAudioToggle) — it moves less
   than half a thumb from the thumb's centre, so the edge is always under it. */
.t-audio-menu__slider {
  --fill: 100%;
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  height: 30px;
  margin: 0;
  background: none;
  cursor: pointer;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}
.t-audio-menu__slider:focus { outline: none; }
.t-audio-menu__slider:focus-visible { outline: 2px solid var(--bounty); outline-offset: 2px; border-radius: 6px; }

.t-audio-menu__slider::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(to right, var(--mud) var(--fill), #fff var(--fill));
  box-shadow: inset 0 0 0 1px var(--edge);
}
.t-audio-menu__slider::-moz-range-track {
  height: 8px;
  border-radius: 999px;
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--edge);
}
.t-audio-menu__slider::-moz-range-progress {
  height: 8px;
  border-radius: 999px;
  background: var(--mud);
}
.t-audio-menu__slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  margin-top: -7px;
  border: 0;
  border-radius: 50%;
  background: var(--parchment);
  box-shadow: inset 0 0 0 2px var(--mud-deep), 0 2px 3px rgba(0, 0, 0, .3);
}
.t-audio-menu__slider::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: var(--parchment);
  box-shadow: inset 0 0 0 2px var(--mud-deep), 0 2px 3px rgba(0, 0, 0, .3);
}
.t-audio-menu__slider:active::-webkit-slider-thumb { transform: scale(1.1); }
.t-audio-menu__slider:active::-moz-range-thumb { transform: scale(1.1); }

/* ?audio=debug only — never in an ordinary session. */
.t-audio-debug {
  position: fixed;
  left: max(6px, env(safe-area-inset-left));
  bottom: max(6px, env(safe-area-inset-bottom));
  z-index: 600;
  pointer-events: none;
  font-family: var(--mono);
  font-size: 9px;
  line-height: 1.4;
  color: #fff;
  background: rgba(0, 0, 0, .55);
  padding: 3px 6px;
  border-radius: 4px;
}

.t-btn--gold {
  background: var(--bounty);
  color: var(--mud-deep);
  box-shadow: 0 4px 0 var(--bounty-deep), 0 10px 20px -12px rgba(0,0,0,.5);
}
.t-btn--gold:active { box-shadow: 0 1px 0 var(--bounty-deep); }

.t-btn--green {
  background: var(--meadow);
  color: #fff;
  text-shadow: 0 1px 0 rgba(0,0,0,.18);
  box-shadow: 0 4px 0 var(--meadow-dark), 0 10px 20px -12px rgba(0,0,0,.5);
}
.t-btn--green:active { box-shadow: 0 1px 0 var(--meadow-dark); }

.t-btn--mud {
  background: var(--mud);
  color: #fff;
  box-shadow: 0 4px 0 var(--mud-deep), 0 10px 20px -12px rgba(0,0,0,.5);
}
.t-btn--mud:active { box-shadow: 0 1px 0 var(--mud-deep); }

.t-btn--ember {
  background: #FF6B35;
  color: #2a1200;
  box-shadow: 0 4px 0 #A83E14, 0 10px 20px -12px rgba(0,0,0,.6);
}
.t-btn--ember:active { box-shadow: 0 1px 0 #A83E14; }

/* Quiet, secondary action on a parchment card */
.t-btn--ghost {
  background: transparent;
  color: var(--ink-soft);
  box-shadow: inset 0 0 0 2px var(--edge);
  font-size: 15px;
  padding: 11px 20px;
}
.t-btn--ghost:active { transform: translateY(2px); box-shadow: inset 0 0 0 2px var(--edge); }

/* Quiet, secondary action on a dark card */
.t-btn--ghost-dark {
  background: transparent;
  color: var(--parchment-dim);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.28);
  font-size: 15px;
  padding: 11px 20px;
}
.t-btn--ghost-dark:active { transform: translateY(2px); box-shadow: inset 0 0 0 2px rgba(255,255,255,.28); }

.t-btn--danger {
  background: transparent;
  color: var(--danger);
  box-shadow: inset 0 0 0 2px var(--danger);
  font-size: 15px;
  padding: 11px 20px;
}
.t-btn--danger:active { transform: translateY(2px); box-shadow: inset 0 0 0 2px var(--danger); }

/* Inline SVG icons — glyphs like ↩ get emoji presentation on iOS, so every
   piece of UI chrome that isn't deliberately an emoji uses a drawn icon. */
.t-svg-icon {
  width: 1em;
  height: 1em;
  display: block;
}
.t-minimise-btn .t-svg-icon { width: 16px; height: 16px; }
.t-minimise-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ═══════════════════════════════════ SEGMENTED OPTIONS ("paving stones") */

.t-field { margin-bottom: 16px; }

.t-seg {
  display: flex;
  gap: 7px;
  justify-content: center;
}

.t-opt {
  flex: 1;
  min-width: 0;
  padding: 12px 8px;
  border: none;
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font-family: var(--display);
  font-weight: 700;
  font-size: 13px;
  line-height: 1.2;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--edge), inset 0 0 0 1px var(--edge);
  transition: transform .1s, box-shadow .1s, background .12s, color .12s;
}
.t-opt:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--edge), inset 0 0 0 1px var(--edge); }

.t-opt.is-selected {
  background: var(--mud);
  color: #fff;
  box-shadow: 0 3px 0 var(--mud-deep), inset 0 0 0 1px var(--mud-deep);
}

.t-opt__sub {
  display: block;
  font-family: var(--mono);
  font-weight: 400;
  font-size: 9px;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-top: 3px;
}
.t-opt.is-selected .t-opt__sub { color: var(--parchment-dim); }

.t-select {
  font-family: var(--body);
  font-size: 14px;
  font-weight: 500;
  padding: 10px 14px;
  min-width: 170px;
  text-align: center;
  color: var(--ink);
  background: #fff;
  border: none;
  border-radius: 12px;
  box-shadow: 0 3px 0 var(--edge), inset 0 0 0 1px var(--edge);
  outline: none;
}

/* ═══════════════════════════════════ SLIDERS */

.t-label--row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.t-slider__val {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .6px;
  text-transform: none;
  color: var(--mud);
  font-weight: 600;
}

.t-slider {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  height: 12px;
  margin: 0;
  padding: 0;
  background: #fff;
  border: none;
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px var(--edge), inset 0 2px 0 rgba(0,0,0,.07);
  outline: none;
  cursor: pointer;
}

/* Thumb repeated per engine — a combined selector list is dropped whole by
   browsers that don't recognise every prefix in it. */
.t-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 50%;
  background: var(--mud);
  box-shadow: 0 3px 0 var(--mud-deep), inset 0 0 0 1px var(--mud-deep);
  cursor: pointer;
}
.t-slider::-moz-range-thumb {
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 50%;
  background: var(--mud);
  box-shadow: 0 3px 0 var(--mud-deep), inset 0 0 0 1px var(--mud-deep);
  cursor: pointer;
}
.t-slider::-moz-range-track { background: transparent; }

.t-slider:focus-visible { box-shadow: inset 0 0 0 2px var(--bounty); }

/* Per-player path style row */
.t-player-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 7px;
}
.t-player-row .player-dot { box-shadow: inset 0 -2px 0 rgba(0,0,0,.22), 0 0 0 1.5px rgba(0,0,0,.12); }
.t-player-row .t-player-tag {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--ink-soft);
  min-width: 22px;
}
.t-player-row .t-select { min-width: 0; flex: 0 1 150px; font-size: 13px; padding: 8px 10px; }

/* ═══════════════════════════════════ RESULTS */

.t-stars {
  display: flex;
  justify-content: center;
  gap: 6px;
  font-size: 30px;
  line-height: 1;
  margin: 0 0 14px;
}
.t-star--on  { color: var(--bounty); text-shadow: 0 2px 0 var(--bounty-deep); }
.t-star--off { color: var(--edge); }
.t-card--gold .t-star--off { color: rgba(255,255,255,.22); }
/* The star key under the stars themselves (issue #120): each star names what
   earns it, so a hollow one says what was missed. Columns, so the three
   captions sit under their stars whatever their width, and the row costs
   the card one line of small type rather than a key of its own. */
.t-stars--keyed { gap: 6px; align-items: flex-start; }
/* A star that was never on offer (issue #172): the ladder is cumulative, so
   once a star is missed every star after it is out of reach, and a hollow
   star there read as merely missed. A solid padlock in the hollow star's
   colour, in the star's own 30px box, so the row keeps its rhythm. */
.t-star--locked { display: block; width: 30px; height: 30px; color: var(--edge); }
.t-star-lock { display: block; width: 100%; height: 100%; }
.t-card--gold .t-star--locked { color: rgba(255,255,255,.22); }
/* The arrow between the stars (issue #172, a plus before it): each star
   needs the one before it, so the row reads "then", not "and". In the mud
   the card's buttons are lettered in, near full strength — the plus at half
   strength was too quiet to say the order was the rule. */
.t-star-step {
  display: flex;
  align-items: center;
  height: 30px;
  margin: 0 1px;
  color: var(--mud);
  opacity: .85;
}
/* 16px: the row is 280px wide at that, inside the 288px a 360 phone's card
   gives it. */
.t-star-step svg { display: block; width: 16px; height: 16px; }
.t-card--gold .t-star-step { color: #fff; opacity: .6; }
.t-star-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  min-width: 72px;
}
.t-star-cap {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--mud);
  white-space: nowrap;
}
.t-star-col.is-off .t-star-cap { color: var(--ink-soft); opacity: .55; }
.t-star-col.is-locked .t-star-cap { opacity: .4; }

.t-result {
  margin-bottom: 8px;
  border-radius: 12px;
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--edge);
  overflow: hidden;
}
.t-result--winner {
  background: var(--bounty);
  box-shadow: inset 0 0 0 1px var(--bounty-deep);
}
.t-result__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  font-weight: 600;
  font-size: 15px;
}
.t-result__who { display: flex; align-items: center; gap: 8px; }
.t-result__score { font-weight: 700; font-size: 18px; font-variant-numeric: tabular-nums; }
.t-result__detail {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .4px;
  color: var(--ink-soft);
  padding: 0 12px 8px;
  text-align: right;
}
.t-result--winner .t-result__detail { color: var(--mud-deep); }

.t-best {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--mud);
  opacity: .75;
  margin: -6px 0 10px;
}
.t-best__stars { font-size: 13px; letter-spacing: 2px; color: var(--bounty); text-shadow: 0 1px 0 var(--bounty-deep); }
.t-card--gold .t-best { color: rgba(255,255,255,.7); }

.t-flag {
  display: inline-block;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--bounty-deep);
  border: 1px solid var(--bounty-deep);
  border-radius: 5px;
  padding: 3px 8px;
  margin-bottom: 10px;
}

/* Boss briefing */
.t-boss-crest {
  font-size: 34px;
  line-height: 1;
  margin-bottom: 8px;
}
/* Same white-on-parchment panel the results rows use, so an ability reads as
   one more piece of briefing rather than as an alarm. */
.t-ability {
  text-align: center;
  margin-bottom: 14px;
  padding: 12px;
  border-radius: 12px;
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--edge);
}
/* Stroked line art, not an emoji — so it takes a colour, and takes the
   heading's. See BOSS_ABILITIES in js/boss-abilities.js for why. */
/* Flex, not text-align: .t-svg-icon is a block, so the card centring the text
   around it leaves the mark itself sitting against the left edge. Same reason
   .t-title--warn is a flex row. */
.t-ability__icon {
  display: flex;
  justify-content: center;
  font-size: 30px;
  line-height: 1;
  color: var(--forest);
  margin-bottom: 3px;
}
.t-ability__name {
  font-family: var(--display);
  font-weight: 700;
  font-size: 16px;
  color: var(--forest);
  margin: 5px 0 3px;
}
.t-ability__text { font-size: 13.5px; line-height: 1.45; color: var(--ink-soft); }

.t-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.t-table th {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  font-weight: 400;
  color: var(--ink-soft);
  padding: 6px 8px;
  border-bottom: 2px solid var(--edge);
}
.t-table td { padding: 9px 8px; border-bottom: 1px solid var(--edge); }
.t-table tfoot td {
  border-top: 2px solid var(--edge);
  border-bottom: none;
  font-weight: 700;
  padding-top: 11px;
}
/* A TALL CARD ON A SHORT PHONE (issue #155). The campaign scoreboard is the
   tallest card in the game — five ranks, a total, a note and three buttons —
   and on a 360x640 it wanted 595px inside a card that caps at 88svh = 563.
   The overflow does not run off the screen, which is why it is easy to miss:
   `.t-card` scrolls, so the last call to action sat below the card's OWN
   fold, with nothing on screen to say it was there. Measure a card with
   `scrollHeight > clientHeight`, never against the viewport.

   What gives is the rhythm, never the type: a table row loses padding and
   the card loses some of its own, so nothing gets smaller to read. 45px,
   which clears the 640 with room and takes the 375x667 SE with it. */
@media (max-height: 700px) {
  .t-card { padding: 18px 22px; }
  .t-table td { padding: 6px 8px; }
  .t-table tfoot td { padding-top: 8px; }
  /* Three full-width buttons stacked: 9px between them is generous on a
     screen this size, and the gaps are the last thing a player reads. */
  .t-btn { margin-top: 6px; }
  .t-body { margin-bottom: 10px; }
  .t-boss-crest { font-size: 28px; margin-bottom: 6px; }
}

.t-table .col-rank  { text-align: left; font-weight: 600; }
.t-table .col-stars { text-align: center; color: var(--bounty); text-shadow: 0 1px 0 var(--bounty-deep); font-weight: 600; }
.t-table .col-score { text-align: right; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.t-table tr.is-locked { opacity: .4; }
.t-rank-dot {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 50%;
  margin-right: 7px;
  vertical-align: middle;
  box-shadow: 0 0 0 1px rgba(0,0,0,.25);
}
/* Dark-card variants of the table */
.t-card--gold .t-table th,
.t-card--gold .t-table td { border-color: rgba(255,255,255,.14); }
.t-card--gold .t-table th,
.t-card--gold .t-table .col-score { color: var(--parchment-dim); }
.t-card--gold .t-table .col-stars { color: var(--bounty); }

/* Minimise (▼) control pinned to the top-right of a results card */
.t-minimise-bar {
  position: sticky;
  top: 0;
  height: 0;
  display: flex;
  justify-content: flex-end;
  z-index: 2;
}
.t-minimise-btn {
  width: 32px; height: 32px;
  border: none;
  border-radius: 10px;
  background: var(--parchment-dim);
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  box-shadow: inset 0 0 0 1px var(--edge);
}
.t-card--gold .t-minimise-btn {
  background: rgba(255,255,255,.14);
  color: #fff;
  box-shadow: none;
}

/* ═══════════════════════════════════ WORLD MAP */

#campaign-map-overlay {
  position: fixed;
  inset: 0;
  /* The letterbox, the body's own ground, either side of the column below. */
  background: var(--forest-deep);
  overflow: hidden;
}
/* The column the map stands in: the one the game shell is capped at
   (--column), so the map's bar ends where the HUD's does (issue #153). It
   used to be the overlay itself, edge to edge: on a desktop window the scene
   stood 448px wide in the middle of it with Menu and the stars pill a screen
   apart at the far edges, while the game beside it kept to a column. The
   scene is authored at the column's width, so the bar is exactly as wide as
   the map. */
.t-map-shell {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  max-width: var(--column);
  margin: 0 auto;
  background: var(--forest);
}

.t-map-viewport {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  position: relative;
  /* The status bar: the scene scrolls under it, as a map should, and this is
     what lets its top — the castle's sky — still be brought fully into view.
     showWorldMap's scroll maths reads the scene's offset below it. */
  padding-top: var(--safe-top);
}
.t-map-container { position: relative; max-width: var(--column); margin: 0 auto; }
.t-map-scene-wrap { position: relative; }
/* The scene carries its 448x2319 size as attributes, so it has an intrinsic
   aspect ratio to scale by — the level nodes are positioned in percentages of
   exactly that box. */
.t-map-scene { width: 100%; height: auto; display: block; }
.t-map-layer { position: absolute; inset: 0; }
/* The trail is trodden only as far as the player has come (issue #100). The
   scene draws the whole road, a cell at a time, and the map puts every cell
   past the highest unlocked level back to grass — the ground is painted under
   the road, so hiding a cell is all it takes. The stretch just earned stomps
   in instead, one cell after another on its own delay: each comes down a
   little over size and settles, the way a foot does. */
.t-map-scene .is-grass { display: none; }
.t-map-scene .is-stomp {
  transform-box: fill-box;
  transform-origin: center;
  animation: mapStomp .28s cubic-bezier(.3, 1.4, .5, 1) both;
}

.t-rank-label {
  position: fixed;
  top: calc(14px + var(--safe-top)); left: 50%;
  transform: translateX(-50%);
  z-index: 210;
  pointer-events: none;
  padding: 8px 18px;
  border-radius: 999px;
  background: rgba(12,26,14,.8);
  border: 2px solid rgba(255,255,255,.18);
  color: #fff;
  font-family: var(--display);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: .5px;
  white-space: nowrap;
  transition: opacity .3s, border-color .3s;
}

.t-level-node {
  position: absolute;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 0;
  font-family: var(--display);
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,.9);
  cursor: pointer;
  transition: transform .1s;
}
.t-level-node.is-locked { cursor: default; }
/* A boss mark on a level node rides in the label's text flow: the base
   .t-svg-icon is a block, which would stack the icon above the number instead
   of beside it. Sized in em so it follows the node's own font-size, and given
   its shadow as a filter — text-shadow does not reach an SVG's strokes, and
   without one the mark washes out over the map's pale cells. */
.t-level-node .t-svg-icon {
  display: inline-block;
  width: 1em;
  height: 1em;
  vertical-align: -.14em;
  stroke-width: 3;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.9));
}
.t-level-node__stars {
  font-size: 10px;
  line-height: 1;
  letter-spacing: 1px;
  color: var(--bounty);
  text-shadow: 0 1px 2px rgba(0,0,0,.8);
}

.t-map-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  padding-bottom: max(12px, var(--safe-bottom));
  flex-shrink: 0;
  background: var(--forest-deep);
  border-top: 2px solid var(--meadow-dark);
  box-shadow: 0 -8px 20px rgba(0,0,0,.6);
  min-height: 54px;
}
.t-map-footer__title {
  font-family: var(--display);
  font-weight: 800;
  font-size: 17px;
  letter-spacing: -.01em;
  color: #fff;
}
.t-stars-pill {
  border: none;
  border-radius: 999px;
  background: var(--bounty);
  color: var(--mud-deep);
  font-family: var(--display);
  font-weight: 700;
  font-size: 14px;
  padding: 8px 15px;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--bounty-deep);
  transition: transform .1s, box-shadow .1s;
}
.t-stars-pill:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--bounty-deep); }

/* ═══════════════════════════════════ TRANSIENT LAYERS */

/* One card, whether it times out or waits to be dismissed — the two say the
   same sentence and must look the same saying it. The chevron is absolutely
   positioned, so it takes no width off a short line, and the min-width stops
   one shrink-wrapping to a sliver beside it. */
#turn-popup {
  position: fixed;
  top: 20%; left: 50%;
  transform: translateX(-50%);
  background: var(--parchment);
  color: var(--ink);
  padding: 22px 26px 15px;
  /* `left: 50%` leaves only half the viewport as available width, and a
     shrink-to-fit box takes that as its ceiling — which wrapped "The 6 point
     bounty" mid-line however much room was really there. max-content sizes to
     the longest line the copy asks for and max-width brings it back in. */
  width: max-content;
  min-width: 210px;
  max-width: min(78vw, 340px);
  border-radius: 16px;
  font-family: var(--display);
  font-weight: 700;
  font-size: 17px;
  line-height: 1.35;
  text-align: center;
  /* The board underneath stays live, so the card must not intercept it: a
     stroke that begins under the card has to reach the canvas, and beginning
     it is what puts the card away. Only the chevron takes taps. */
  pointer-events: none;
  box-shadow: 0 4px 0 var(--edge), 0 20px 40px -18px rgba(0,0,0,.7);
  opacity: 1;
  transition: opacity .3s ease;
}
/* The one part of the card that takes a tap — the card itself is
   pointer-events: none so the live board underneath still gets its strokes. */
.t-popup-x {
  pointer-events: auto;
  position: absolute;
  top: 5px;
  right: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 22px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: none;
  color: var(--ink-soft);
  cursor: pointer;
}
.t-popup-x .t-svg-icon { width: 16px; height: 16px; }

#phase-banner {
  position: fixed;
  top: 42%; left: 50%;
  transform: translate(-50%, -50%);
  color: #fff;
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(40px, 12vw, 84px);
  letter-spacing: -.03em;
  text-align: center;
  white-space: nowrap;
  pointer-events: none;
  text-shadow: 0 3px 0 var(--meadow-dark), 0 8px 30px rgba(0,0,0,.85);
}
/* The level's name over the kick-off headline (issue #120): "LEVEL 1 · FIRST
   STEPS", mono caps, the way the map's rank label and the chip's numbers
   speak — a label, so the headline stays the event. */
#phase-banner .t-banner-eyebrow {
  display: block;
  margin-bottom: 10px;
  font-family: var(--mono);
  font-weight: 600;
  font-size: clamp(11px, 3.3vw, 13px);
  letter-spacing: 2.2px;
  text-transform: uppercase;
  white-space: nowrap;
  color: rgba(255, 255, 255, .92);
  text-shadow: 0 2px 0 var(--meadow-dark), 0 4px 14px rgba(0, 0, 0, .8);
}
/* The banner's one line of news, under the headline: what this moment did and
   what is coming, in the chip's own words (ui.bountyPopupText). It took over
   from the round-start card, which said the same thing in a second object on
   the same beat. Body type, so the headline stays the event and this stays
   the footnote to it. */
#phase-banner .t-banner-sub {
  display: block;
  margin-top: 8px;
  font-family: var(--body);
  font-weight: 600;
  font-size: clamp(15px, 4.4vw, 19px);
  letter-spacing: 0;
  line-height: 1.25;
  white-space: normal;
  max-width: 88vw;
  margin-left: auto;
  margin-right: auto;
  text-shadow: 0 2px 0 var(--meadow-dark), 0 4px 16px rgba(0,0,0,.8);
}

/* ═══════════════════════════════════ THE COACH (issue #120)
   Level 1's lesson cards (js/coach.js). A card of the round-start card's
   kind — the same parchment, the same face — with a tail to the thing it is
   about, and that thing lit by a spotlight: a hole in a dim scrim that
   slides from subject to subject as a tour steps on. The board under it all
   stays live: the scrim and the card take no taps, only the card's buttons
   do, and the first stroke puts the card away (main.js). */
.t-coach-scrim {
  position: fixed;
  inset: 0;
  z-index: 140;
  pointer-events: none;
  overflow: hidden;
  transition: opacity .3s;
}
.t-coach-scrim.is-off { opacity: 0; }
/* The hole IS the element: its shadow is the scrim, thrown past every edge,
   so moving the element moves the hole and the transition slides it from
   one subject to the next. */
.t-coach-spot {
  position: absolute;
  border-radius: 14px;
  box-shadow: 0 0 0 200vmax rgba(10, 22, 12, .46), inset 0 0 0 2px rgba(255, 255, 255, .5);
  transition: left .38s cubic-bezier(.2,.85,.3,1), top .38s cubic-bezier(.2,.85,.3,1),
              width .38s cubic-bezier(.2,.85,.3,1), height .38s cubic-bezier(.2,.85,.3,1);
}
/* A breathing gold rim, so the lit thing reads as chosen rather than merely
   left undimmed. */
.t-coach-spot::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 17px;
  box-shadow: 0 0 0 2px rgba(232, 184, 74, .8), 0 0 22px 5px rgba(232, 184, 74, .38);
  animation: coachSpotBreathe 1.8s ease-in-out infinite;
}

.t-coach {
  position: fixed;
  z-index: 150;
  width: max-content;
  min-width: 220px;
  max-width: min(84vw, 320px);
  padding: 13px 18px 13px;
  border-radius: 16px;
  background: var(--parchment);
  color: var(--ink);
  text-align: left;
  pointer-events: none;
  box-shadow: 0 4px 0 var(--edge), 0 20px 40px -18px rgba(0,0,0,.7);
  transition: left .32s cubic-bezier(.2,.85,.3,1), top .32s cubic-bezier(.2,.85,.3,1);
}
.t-coach.is-in { animation: coachIn 260ms cubic-bezier(.2,.85,.3,1) both; }
.t-coach button { pointer-events: auto; }
/* The tail: a diamond on whichever edge faces the subject, at --tail-x —
   the subject's centre, not the card's, so a card clamped to the viewport
   edge still points at the right thing. Rotated 45deg, a shadow offset down
   its own axes lands under the tip, which is where the card's emboss is. */
.t-coach::after {
  content: '';
  position: absolute;
  left: var(--tail-x, 50%);
  width: 14px;
  height: 14px;
  margin-left: -7px;
  background: var(--parchment);
  transform: rotate(45deg);
}
.t-coach[data-arm="up"]::after { bottom: -6px; box-shadow: 3px 3px 0 -1px var(--edge); }
.t-coach[data-arm="down"]::after { top: -6px; }
.t-coach:not([data-arm])::after { display: none; }

.t-coach__title {
  font-family: var(--display);
  font-weight: 800;
  font-size: 18px;
  line-height: 1.1;
  letter-spacing: -.01em;
  color: var(--forest);
  margin: 0 0 5px;
}
.t-coach__body {
  font-size: 14px;
  line-height: 1.4;
  color: var(--ink-soft);
  margin: 0;
}
.t-coach__body strong { color: var(--ink); font-weight: 600; }
.t-coach__actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 11px;
}
.t-coach__btn {
  border: none;
  border-radius: 10px;
  padding: 8px 16px;
  background: var(--bounty);
  color: var(--mud-deep);
  font-family: var(--display);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--bounty-deep);
}
.t-coach__btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--bounty-deep); }
/* Skip tutorial: a quiet mono link at the other end of the row from Got it,
   on the first card only. */
.t-coach__skip {
  margin-right: auto;
  padding: 6px 0;
  border: none;
  background: none;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--ink-soft);
  cursor: pointer;
}

/* More than one subject lit (issue #177): the spot's own shadow can cut one
   hole only, so the dim moves to a masked svg with a hole per subject, and
   every hole keeps the rim. */
.t-coach-mask { position: absolute; inset: 0; }
.t-coach-mask > rect { fill: rgba(10, 22, 12, .46); }
.t-coach-scrim.is-multi .t-coach-spot { box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .5); }
.t-coach-spot.is-extra { transition: none; }
/* Where the subject was a moment ago — the light's old place, dashed, and a
   dotted arrow from its centre to where it went. Over the scrim, under the
   card. The dots are zero-length dashes with round caps. */
.t-coach-trace {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 146;
  pointer-events: none;
  overflow: visible;
}
.t-coach-trace__was { fill: rgba(255, 248, 225, .1); stroke: #F5D17A; stroke-width: 2.5; stroke-dasharray: 6 6; }
.t-coach-trace__shade { fill: none; stroke: rgba(0, 0, 0, .35); stroke-width: 6.5; stroke-linecap: round; stroke-dasharray: 0 9; }
.t-coach-trace__arc { fill: none; stroke: #F5D17A; stroke-width: 4; stroke-linecap: round; stroke-dasharray: 0 9; }
/* The arrowhead wears the dots' outline: a dark stroke painted under its
   fill (the marker's units are the line's, so 1.6 here is the dots' ring). */
.t-coach-trace marker path { fill: #F5D17A; stroke: rgba(0, 0, 0, .35); stroke-width: 1.6; stroke-linejoin: round; paint-order: stroke; }

/* A nudge (issue #177): the lesson card's little sibling — a parchment tag on
   a HUD control with a gold pulse round it, no scrim and no button. It takes
   no taps, so the control under the pulse stays pressable and the board
   stays live; it stays until the player moves or presses a button. */
.t-nudge {
  position: fixed;
  z-index: 150;
  width: max-content;
  max-width: min(64vw, 236px);
  padding: 7px 11px 8px;
  border-radius: 11px;
  background: var(--parchment);
  color: var(--ink-soft);
  font-family: var(--body);
  font-size: 13px;
  line-height: 1.3;
  pointer-events: none;
  box-shadow: 0 3px 0 var(--edge), 0 12px 26px -12px rgba(0,0,0,.7);
  animation: coachIn 260ms cubic-bezier(.2,.85,.3,1) both;
}
.t-nudge__body { margin: 0; }
.t-nudge__body strong { color: var(--forest); font-family: var(--display); font-weight: 800; }
.t-nudge__more {
  display: block;
  margin-top: 3px;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: .8px;
  text-transform: uppercase;
  opacity: .7;
}
.t-nudge::after {
  content: '';
  position: absolute;
  left: var(--tail-x, 50%);
  width: 12px;
  height: 12px;
  margin-left: -6px;
  background: var(--parchment);
  transform: rotate(45deg);
}
.t-nudge[data-arm="up"]::after { bottom: -6px; box-shadow: 3px 3px 0 -1px var(--edge); }
.t-nudge[data-arm="down"]::after { top: -6px; }
.t-nudge-pulse {
  position: fixed;
  z-index: 149;
  border-radius: 9px;
  pointer-events: none;
  box-shadow: 0 0 0 2px rgba(232, 184, 74, .95), 0 0 16px 5px rgba(232, 184, 74, .5);
  animation: coachSpotBreathe 1.8s ease-in-out infinite;
}

/* The ghost finger: a fingertip's soft disc, sized to the tile, pressed
   (small, dense) while it draws and lifted (larger, fainter) between
   strokes. The wrapper carries the position and the disc the press, so
   the two transitions never fight over one transform. */
.t-ghost {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 145;
  pointer-events: none;
  transition: transform .3s cubic-bezier(.4, 0, .5, 1);
}
.t-ghost::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 38%, rgba(255,255,255,.96), rgba(255,255,255,.62) 52%, rgba(255,255,255,0) 72%);
  box-shadow: 0 0 0 2px rgba(255,255,255,.7), 0 6px 14px rgba(0,0,0,.4);
  transform: scale(.78);
  opacity: .96;
  transition: transform .3s ease, opacity .3s ease;
}
.t-ghost.is-up::before { transform: scale(1.3); opacity: .3; }
/* The pulse on the path's dot while the finger is lifted: "press here". */
.t-ghost-ring {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 144;
  pointer-events: none;
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(255,255,255,.9), 0 0 0 7px rgba(232,184,74,.55);
  animation: ghostRing 1s ease-out infinite;
}

/* A flex row, so the mark sits BESIDE the number whatever it is. The base
   .t-svg-icon is display:block — fine inside .t-delta, which is a flex row of
   its own, but in a plain block it dropped the grass blades onto a line under
   the +3. The bridge and the sack happened not to hit it (neither carries
   that class here), which is exactly why the row is the fix and not another
   per-icon display override. */
.score-float {
  position: fixed;
  display: flex;
  align-items: center;
  gap: .12em;
  font-family: var(--display);
  font-weight: 800;
  font-size: 20px;
  white-space: nowrap;
  text-shadow: 0 1px 3px rgba(0,0,0,.85), 0 0 8px rgba(0,0,0,.45);
  pointer-events: none;
  transform: translate(-50%, 0);
  animation: scoreFloatRise 1200ms ease-out both;
}
.score-float--gain { color: var(--meadow-light); }
.score-float--loss { color: #FF6B5C; }
/* What a float scores sets its size and colour (issue #168): grass green at
   the base, a bridge driftwood a step up — the same colour whether the
   bridge is earned at the start or spent on a crossing, the sign saying
   which — and a bounty gold a step up again — the
   order a turn's floats stack in, so the stack grows towards its biggest
   number. Each shrinks to the row's type size as it dives (ui._diveFloat),
   so the HUD's entries are the same size whichever float landed on them. */
.score-float--bridges { font-size: 22px; color: var(--driftwood); }
.score-float--bounty { font-size: 24px; color: var(--bounty-figure); }
/* A float with a row to land in is driven by the Web Animations API instead
   (ui._launchFloat): the rise is the same, but its end is a measured point in
   the panel rather than 52px up. */
.score-float--fly { animation: none; }

/* ═══════════════════════════════════ KEYFRAMES */

/* The log advancing: the finished turn drops out of the bottom while the new
   one comes down from above, both clipped by the row. Downwards because that
   is the way the score floats arrive (issue #116) — the panel sits under the
   board, so a float dives down into its row and the last turn has to give way
   in the same direction, or the two pass each other head-on. Past 105% so
   neither shows a sliver at the edge on a fractional row height. */
@keyframes deltaLineIn {
  from { transform: translateY(-105%); opacity: 0; }
  to   { transform: none;              opacity: 1; }
}
@keyframes deltaLineOut {
  from { transform: none;             opacity: 1; }
  to   { transform: translateY(105%); opacity: 0; }
}

@keyframes scoreFloatRise {
  0%   { opacity: 0; transform: translate(-50%, 6px) scale(0.7); }
  12%  { opacity: 1; transform: translate(-50%, -6px) scale(1.12); }
  24%  { transform: translate(-50%, -12px) scale(1); }
  70%  { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -52px) scale(1); }
}

/* An entry arriving under its float: a little too big, then settling. */
@keyframes deltaLand {
  0%   { transform: scale(1.4); }
  100% { transform: none; }
}

@keyframes scorePop {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.5); }
  100% { transform: scale(1); }
}

@keyframes phaseBannerFlash {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.6); }
  14%  { opacity: 1; transform: translate(-50%, -50%) scale(1.08); }
  24%  { transform: translate(-50%, -50%) scale(1); }
  78%  { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.12); }
}

@keyframes bossGlow {
  0%, 100% { box-shadow: 0 0 8px 3px rgba(220, 40, 40, 0.6); }
  50%      { box-shadow: 0 0 16px 6px rgba(220, 40, 40, 0.9); }
}

@keyframes currentLevel {
  0%, 100% { box-shadow: 0 0 10px 4px rgba(232, 184, 74, 0.55); }
  50%      { box-shadow: 0 0 20px 8px rgba(232, 184, 74, 0.9); }
}

.t-level-node--boss    { animation: bossGlow 2s ease-in-out infinite; }
.t-level-node--current { animation: currentLevel 1.5s ease-in-out infinite; }

@keyframes coachIn {
  from { opacity: 0; transform: translateY(6px) scale(.94); }
  to   { opacity: 1; transform: none; }
}
@keyframes coachSpotBreathe {
  0%, 100% { opacity: .55; }
  50%      { opacity: 1; }
}
@keyframes ghostRing {
  0%   { transform: scale(.55); opacity: 1; }
  100% { transform: scale(1.5); opacity: 0; }
}

@keyframes mapStomp {
  0%   { opacity: 0; transform: scale(.3); }
  55%  { opacity: 1; transform: scale(1.14); }
  100% { opacity: 1; transform: scale(1); }
}

/* ═══════════════════════════════════ RESPONSIVE */

@media (max-width: 400px) {
  /* The padding is set through its variables so the safe-area inset and the
     height's sum (see #ui-panel) follow it — a shorthand here once reset the
     inset padding to 6px on every phone under 400px wide. */
  #ui-panel { --hud-pad-y: 6px; --hud-pad-x: 7px; }
  .t-card { padding: 20px 16px; }
  .t-btn { font-size: 16px; padding: 13px 18px; }
}

/* Narrow phones. The bounty chip is what gives first: it is the only element
   in the strip with slack, and the two labelled controls either side of it
   have to stay pressable. Plain px: at 360px wide the HUD unit is at its 1px
   floor (its width term, 3.5vw, is under the 13px the clamp starts from), so
   these are exact. */
@media (max-width: 360px) {
  #hud-controls { gap: 5px; }
  .t-hud-btn { padding: 0 9px; font-size: 12px; }
  .t-bounty { min-width: 0; gap: 2px; padding: 0 4px; }
  .t-rung svg { width: 26px; height: 26px; }
  /* The turn line's worst case, "+8 −10 +25", beside a two-mark boss slot
     and both bridge tiles, fills the row exactly at 10px gaps (issue #168). */
  .t-delta-line { gap: 7px; }
}

@media (max-height: 700px) {
  .t-title--hero { font-size: clamp(40px, 12vw, 60px); }
  .t-btn { margin-top: 7px; padding: 12px 20px; }
}

/* Landscape warning */
@media (orientation: landscape) and (max-height: 500px) {
  #game-container::before {
    content: 'Please rotate to portrait mode';
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--forest-deep);
    color: var(--parchment-dim);
    font-family: var(--display);
    font-weight: 700;
    font-size: 18px;
    z-index: 1000;
  }
}
