/* Melon Wars. House tokens first (local fallbacks), game tokens declared here (spec D18). */
:root {
  --of-paper: #0c1511;
  --card: #14211a;
  --card-2: #1a2b21;
  --of-ink: #eef3ee;
  --of-ink-soft: #9fb3a6;
  --of-rule: #3b5244;
  --of-good: #3fa35b;
  --of-warn: #e6a93a;
  --of-bad: #ff7a8c;
  --accent: #e0475e;
  --accent-fill: color-mix(in srgb, var(--accent) 75%, #111a2d);
  --rind: #3fa35b;
  --pressed: color-mix(in srgb, var(--accent) 40%, var(--card));
  --hud: #05070b;
  --focus: #ffd166;
  --motion-press: 80ms;
  --motion-fast: 140ms;
  --motion-base: 200ms;
  --motion-sheet: 280ms;
  --ease-out: cubic-bezier(.2, 0, 0, 1);
  --ease-sheet: cubic-bezier(.32, .72, 0, 1);
  color-scheme: dark;
}
html[data-theme="light"] {
  --of-paper: #f6f7fa;
  --card: #ffffff;
  --card-2: #eef1f5;
  --of-ink: #111a2d;
  --of-ink-soft: #536078;
  --of-rule: #c9d0db;
  --of-warn: #9a5b00;
  --of-bad: #b3263b;
  --accent: #c8354c;
  --rind: #16803d;
  --focus: #1d4ed8;
  color-scheme: light;
}
html {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
  background: var(--of-paper);
  color: var(--of-ink);
  font: 400 1rem/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
}
html[data-text-size="large"] { font-size: 118%; }
html[data-text-size="x-large"] { font-size: 135%; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
h1, h2, h3, p, ul { margin: 0; }
ul { padding: 0; list-style: none; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--of-ink-soft); }
.center { text-align: center; }
.sr-only { position: fixed; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.game-shell {
  --T: env(safe-area-inset-top, 0px);
  --R: env(safe-area-inset-right, 0px);
  --B: env(safe-area-inset-bottom, 0px);
  --L: env(safe-area-inset-left, 0px);
  --G: 12px;
  --tabbar: 56px;
  --cs: 1;
  position: fixed;
  inset: 0;
  margin: 0;
  overflow: hidden;
  background: var(--of-paper);
}

/* ------------------------------------------------------------ controls */
button {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  min-width: 44px;
  min-height: 44px;
  padding: .5rem .8rem;
  font: inherit;
  font-weight: 650;
  color: var(--of-ink);
  background: var(--card-2);
  border: 1px solid color-mix(in srgb, var(--of-ink) 16%, transparent);
  border-radius: 10px;
  cursor: pointer;
  transition: background var(--motion-fast) var(--ease-out);
}
button:active:not(:disabled), button.pressing { background: var(--pressed); transition-duration: var(--motion-press); }
button:disabled {
  cursor: default;
  color: var(--of-ink-soft);
  background: transparent;
  border-style: dashed;
}
:focus-visible, button:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.primary { background: var(--accent-fill); border-color: transparent; color: #fff; }
.primary:disabled { background: transparent; color: var(--of-ink-soft); border-color: var(--of-rule); }
.big-btn { min-height: 52px; font-size: 1.05rem; font-weight: 800; }
.text-btn { background: none; border: 0; color: var(--of-ink-soft); text-decoration: underline; text-underline-offset: 3px; }
.link { min-height: 44px; min-width: 0; padding: 0 .25rem; background: none; border: 0; color: var(--of-ink); text-decoration: underline; font-weight: 600; }
.danger { color: var(--of-bad); }
.wide { width: 100%; }
select, input { font: inherit; font-size: max(16px, 1rem); color: var(--of-ink); }
select { min-height: 44px; width: 100%; padding: .4rem .6rem; background: var(--card-2); border: 1px solid var(--of-rule); border-radius: 8px; }
input[type="checkbox"] { width: 24px; height: 24px; accent-color: var(--accent); }
svg.i { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
svg.g { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }
svg.sil { width: 40px; height: 40px; flex: none; fill: color-mix(in srgb, var(--of-ink) 35%, transparent); }
svg.pict { width: 48px; height: 48px; flex: none; fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
svg.melon { width: 32px; height: 32px; flex: none; }

/* ------------------------------------------------------------ lobby */
.lobby {
  position: absolute;
  inset: 0;
  overflow: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  display: grid;
  padding: calc(var(--T) + 24px) calc(var(--R) + 20px) calc(var(--B) + 16px) calc(var(--L) + 20px);
  background:
    radial-gradient(60rem 30rem at 50% -10%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 60%),
    var(--of-paper);
}
.lobby-in { width: 100%; max-width: 30rem; margin: auto; display: grid; gap: .7rem; }
.eyebrow { font-size: .75rem; font-weight: 800; letter-spacing: .14em; color: var(--rind); }
.tagline { font-weight: 700; color: var(--of-ink-soft); margin-top: -.4rem; }
.lobby-icon { width: 96px; height: 96px; border-radius: 22px; justify-self: center; margin: .5rem 0 .25rem; box-shadow: 0 10px 40px color-mix(in srgb, var(--accent) 30%, transparent); }
.lobby h1 { font-size: 1.75rem; font-weight: 800; letter-spacing: -.01em; }
.lede { font-size: 1rem; }
.sub-lede { color: var(--of-ink-soft); }
.segment { display: flex; gap: 4px; padding: 4px; background: var(--card); border: 1px solid var(--of-rule); border-radius: 12px; }
.segment button { flex: 1; border: 0; background: transparent; min-height: 44px; }
.segment [aria-checked="true"], .segment [aria-pressed="true"] { background: var(--card-2); box-shadow: inset 0 0 0 2px var(--accent); color: var(--of-ink); }
.segment button:disabled { border: 0; }
.lobby-row { display: flex; flex-wrap: wrap; gap: 8px; }
.lobby-row button { flex: 1 1 10rem; }
.lobby-row p { flex-basis: 100%; color: var(--of-ink-soft); }
.notice { padding: .6rem .8rem; border-radius: 10px; background: color-mix(in srgb, var(--of-warn) 16%, transparent); border: 1px solid color-mix(in srgb, var(--of-warn) 40%, transparent); }

/* ------------------------------------------------------------ game frame: phone portrait */
.game {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: "hud" "stage" "deck";
}
.hud {
  grid-area: hud;
  display: grid;
  gap: 6px;
  padding: calc(var(--T) + 2px) calc(var(--R) + 8px) 8px calc(var(--L) + 8px);
  background: var(--hud);
  color: #eef3ee;
  -webkit-user-select: none;
  user-select: none;
  border-bottom: 1px solid #1b241f;
}
.hud button { background: #121a16; border-color: #26332b; color: #eef3ee; }
.hud-row { display: flex; align-items: center; gap: 8px; min-height: 44px; }
.avatar { display: flex; align-items: center; gap: 4px; padding: 2px 8px 2px 4px; border-radius: 22px; }
.av-art { display: grid; }
.av-level { font-weight: 800; font-size: .85rem; }
.clout { flex: 1; min-width: 0; display: grid; grid-template-columns: auto minmax(24px, 1fr) auto; align-items: center; gap: 6px; font-size: .8rem; }
.cash { font-weight: 800; font-size: 1rem; color: #bfe8c9; white-space: nowrap; }
.icon-btn { width: 44px; padding: 0; display: grid; place-items: center; }
.m-label { font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: #9fb3a6; }
.m-bar { position: relative; display: block; height: 8px; border-radius: 4px; background: #1c2721; overflow: hidden; }
.m-bar i { position: absolute; inset: 0; border-radius: 4px; background: var(--accent); transform-origin: left center; transform: scaleX(var(--p, 0)); transition: transform var(--motion-base) var(--ease-out); }
.clout-bar i { background: linear-gradient(90deg, #f3c969, #ffd98a); }
.meters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 12px; }
.meter { display: grid; grid-template-columns: auto 1fr auto; align-items: baseline; gap: 2px 6px; min-width: 0; }
.meter .m-val { font-weight: 750; font-size: .8rem; font-variant-numeric: tabular-nums; }
.meter .m-next { font-size: .7rem; color: #9fb3a6; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.meter .m-bar { grid-column: 1 / -1; }
/* x-large: each HUD meter wraps to three rows (label + value, countdown, bar) so nothing collides (spec §7.3). */
html[data-text-size="x-large"] .meter { grid-template-columns: auto 1fr; }
html[data-text-size="x-large"] .meter .m-next { grid-column: 1 / -1; text-align: left; }
.m-nerve .m-bar i { background: var(--of-warn); }
.m-composure .m-bar i { background: #3fa35b; }
.m-sincerity .m-bar i { background: linear-gradient(90deg, #3fa35b 0 8%, #e0475e 8% 100%); }

.stage { grid-area: stage; position: relative; min-height: 0; }
.scroller { overflow: auto; overscroll-behavior: contain; touch-action: pan-y; min-height: 0; }
#screen {
  position: absolute;
  inset: 0;
  padding: 12px calc(var(--R) + var(--G)) 88px calc(var(--L) + var(--G));
  outline: none;
}
#screen > * { max-width: 640px; margin-inline: auto; }
#screen > * + * { margin-top: 10px; }
.tab-h { font-size: 1.15rem; font-weight: 800; }
.tab-h:focus-visible { outline-offset: 4px; border-radius: 4px; }

.deck {
  grid-area: deck;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 2px;
  padding: 0 calc(var(--R) + 4px) calc(var(--B) + 8px) calc(var(--L) + 4px);
  background: var(--hud);
  border-top: 1px solid #1b241f;
  -webkit-user-select: none;
  user-select: none;
}
.deck.one-handed { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.deck button {
  position: relative;
  min-height: var(--tabbar);
  min-width: 0;
  padding: 6px 2px 4px;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 2px;
  background: transparent;
  border: 0;
  border-radius: 10px;
  color: #9fb3a6;
  font-size: .72rem;
  font-weight: 700;
}
.deck [aria-selected="true"] { color: #fff; }
.deck [aria-selected="true"]::before { content: ""; position: absolute; top: 0; left: 25%; right: 25%; height: 3px; border-radius: 0 0 3px 3px; background: var(--accent); }
.deck [aria-selected="true"] .tab-i { color: var(--accent); }
.tab-i { display: grid; }
.badge { position: absolute; top: 4px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; background: var(--accent); color: #fff; font-size: .68rem; line-height: 18px; }

.side { grid-area: side; display: none; }
.job-row { display: flex; align-items: flex-end; gap: 12px; }
.job-info { flex: 1; min-width: 0; display: grid; gap: 6px; }
.job-row .actions { flex: none; flex-direction: column; align-items: stretch; }
html[data-handedness="left"] .job-row { flex-direction: row-reverse; }
.again {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  max-width: min(92%, 30rem);
  min-height: 48px;
  padding: .5rem 1.1rem;
  border-radius: 24px;
  background: var(--accent-fill);
  border-color: transparent;
  color: #fff;
  width: max-content;
  line-height: 1.2;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .45);
  z-index: 2;
}
.again:disabled { background: color-mix(in srgb, var(--of-paper) 85%, transparent); color: var(--of-ink-soft); }

/* ------------------------------------------------------------ content cards */
.card {
  display: grid;
  gap: 8px;
  padding: 12px;
  background: var(--card);
  border: 1px solid color-mix(in srgb, var(--of-rule) 70%, transparent);
  border-radius: 12px;
}
.list { display: grid; gap: 10px; }
.card h3 { font-size: 1rem; font-weight: 750; line-height: 1.3; }
.card.off h3 { color: var(--of-ink-soft); }
.actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
html[data-handedness="left"] .actions { justify-content: flex-start; flex-direction: row-reverse; }
html[data-handedness="left"] .actions .footer { margin-left: auto; }
.actions .footer { margin-right: auto; font-size: .8rem; color: var(--of-ink-soft); }
.act.post-btn, .card .act { min-height: max(48px, calc(48px * var(--cs))); min-width: 72px; }
.post-btn { background: var(--accent-fill); border-color: transparent; color: #fff; min-width: 88px; }
.gains span { white-space: nowrap; }
html[data-input="pointer"] .tab-h:focus { outline: none; }
.meta { font-size: .85rem; display: flex; flex-wrap: wrap; gap: 4px 8px; }
.sin { color: var(--of-bad); font-weight: 650; }
.rank { font-weight: 800; font-size: .75rem; letter-spacing: .05em; color: var(--of-ink-soft); }
.rank.trending { color: var(--of-warn); }
.rank.viral { color: var(--rind); }
.ok { color: var(--rind); }
.warn { color: var(--of-warn); }
.reason { font-size: .85rem; color: var(--of-warn); }
.sys-h { font-size: .72rem; font-weight: 800; letter-spacing: .1em; color: var(--rind); }
.lead { font-weight: 650; }
.sub { font-size: .8rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--of-ink-soft); margin-top: 6px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.row-btns { display: flex; gap: 8px; }
.row-btns button { flex: 1; }
.muted-on { font-weight: 500; opacity: .9; }

.strip { position: sticky; top: -12px; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 48px; padding: 2px 4px 2px 12px; border-radius: 12px; background: color-mix(in srgb, var(--rind) 22%, var(--card)); border: 1px solid color-mix(in srgb, var(--rind) 45%, transparent); }
.event { border-color: color-mix(in srgb, var(--accent) 55%, transparent); background: color-mix(in srgb, var(--accent) 10%, var(--card)); }
.event .sys-h { color: var(--accent); }
.event-q { font-size: 1.02rem; font-weight: 650; }
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choices button { flex: 1 1 8rem; min-height: 48px; }

.feed { display: grid; gap: 10px; }
.post { animation: rise var(--motion-fast) var(--ease-out); }
.post-h { display: flex; align-items: center; gap: 8px; font-size: .9rem; }
.post-head { font-weight: 700; }
.post-line { font-size: .94rem; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; min-height: 24px; padding: 0 9px; border-radius: 12px; font-size: .8rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.chip.gain { background: color-mix(in srgb, var(--rind) 22%, transparent); color: color-mix(in srgb, var(--rind) 55%, var(--of-ink)); }
.chip.cost { background: color-mix(in srgb, var(--of-warn) 18%, transparent); color: var(--of-warn); }
.chip.sin { background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--of-bad); }
.social { display: flex; align-items: center; gap: 6px; font-size: .85rem; }
.reply { font-size: .88rem; color: var(--of-ink-soft); font-style: italic; }
details.reply summary { min-height: 32px; cursor: pointer; font-style: normal; }
.system { background: color-mix(in srgb, var(--rind) 10%, var(--card)); border-color: color-mix(in srgb, var(--rind) 40%, transparent); }
.system button { justify-self: start; }
.empty { justify-items: start; }
.empty-art svg.melon { width: 56px; height: 56px; }

.switcher { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; gap: 8px; }
.stage-name { text-align: center; font-weight: 800; letter-spacing: .04em; }
.lock { font-size: .75rem; padding: 2px 6px; border-radius: 6px; background: var(--card-2); color: var(--of-warn); }
.mastery { display: flex; align-items: center; gap: 8px; font-size: .85rem; }
.dots { display: inline-flex; gap: 4px; }
.dot { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--of-rule); }
.dot.trending { border-color: var(--of-warn); background: color-mix(in srgb, var(--of-warn) 40%, transparent); }
.dot.viral { border-color: var(--rind); background: var(--rind); }

.rival-h { display: flex; gap: 10px; align-items: center; }
.rival-h small { font-weight: 500; font-size: .75rem; }
.boss { border-color: color-mix(in srgb, var(--of-warn) 55%, transparent); }
.boss .sys-h { color: var(--of-warn); }
.odds b { letter-spacing: .03em; }
.odds-likely b { color: var(--rind); }
.odds-even b { color: var(--of-warn); }
.odds-long b { color: var(--of-bad); }

.grid3 > p { grid-column: 1 / -1; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.member { display: grid; justify-items: center; text-align: center; gap: 4px; padding: 10px 6px; border-radius: 12px; background: var(--card); border: 1px solid color-mix(in srgb, var(--of-rule) 70%, transparent); font-size: .8rem; }
.owned, .rows { display: grid; gap: 2px; }
.owned li, .rows li { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 40px; padding: 4px 0; border-bottom: 1px solid color-mix(in srgb, var(--of-rule) 45%, transparent); }
.shop { grid-template-columns: 1fr auto; align-items: center; }
.inbox { grid-template-columns: 1fr auto; align-items: center; }
.plus { width: 48px; min-height: 48px; font-size: 1.3rem; padding: 0; }
.side-card { display: grid; gap: 8px; padding: 12px; border-radius: 12px; background: var(--card); border: 1px solid color-mix(in srgb, var(--of-rule) 70%, transparent); }
.side-h { font-size: .75rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--of-ink-soft); }
.big { font-size: 1.4rem; font-weight: 800; }
.big small { font-size: .85rem; font-weight: 600; color: var(--of-ink-soft); }
.side .meters { grid-template-columns: 1fr; gap: 10px; }
.side .m-label, .side .m-next { color: var(--of-ink-soft); }
.side .m-bar { background: var(--card-2); }

/* ------------------------------------------------------------ overlays (PWA §9 translucent card) */
.card-layer {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: calc(var(--T) + var(--G)) calc(var(--R) + var(--G)) calc(var(--B) + var(--G)) calc(var(--L) + var(--G));
  background: rgba(0, 0, 0, .35);
  animation: fade var(--motion-fast) var(--ease-out);
}
.card-layer > .card {
  width: 100%;
  max-width: 28rem;
  max-height: calc(100dvh - var(--T) - var(--B) - 24px);
  overflow: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  gap: 12px;
  padding: 16px;
  background: color-mix(in srgb, var(--of-paper) 72%, transparent);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  backdrop-filter: blur(16px) saturate(140%);
  border: 1px solid color-mix(in srgb, var(--of-ink) 14%, transparent);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
  color: var(--of-ink);
  animation: pop var(--motion-fast) var(--ease-out);
}
@supports not (backdrop-filter: blur(1px)) {
  .card-layer > .card { background: color-mix(in srgb, var(--of-paper) 94%, transparent); }
}
.card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-top h2 { font-size: 1.25rem; font-weight: 800; }
.close { width: 44px; height: 44px; padding: 0; font-size: 1.4rem; line-height: 1; flex: none; }
.how { display: grid; gap: 10px; }
.how-row { display: grid; grid-template-columns: 48px 1fr; gap: 12px; align-items: center; }
.keys { font-size: .85rem; }
.field-note { padding: 10px 12px; border-left: 3px solid var(--rind); background: color-mix(in srgb, var(--rind) 10%, transparent); border-radius: 0 8px 8px 0; }
.menu-list { display: grid; gap: 8px; }
.menu-list button { min-height: 48px; }
.sheet-layer { place-items: end center; padding: calc(var(--T) + var(--G)) 0 0; }
.sheet-layer > .card.sheet {
  max-width: 36rem;
  max-height: min(88dvh, calc(100dvh - var(--T) - 24px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  padding: 8px 0 0;
  border-radius: 16px 16px 0 0;
  border-bottom: 0;
  animation: sheet-in var(--motion-sheet) var(--ease-sheet);
}
.sheet-top { padding: 0 8px 0 16px; }
.grab { width: 40px; height: 4px; border-radius: 2px; background: var(--of-rule); margin-left: calc(50% - 36px); }
.sheet-content { display: grid; gap: 10px; align-content: start; padding: 0 calc(var(--R) + 16px) calc(var(--B) + 16px) calc(var(--L) + 16px); }
.profile-h { display: flex; gap: 12px; align-items: center; }
.profile-h svg.melon { width: 48px; height: 48px; }
.field { display: grid; gap: 4px; font-weight: 600; }
.field.check { grid-template-columns: auto 1fr; align-items: center; gap: 12px; min-height: 44px; }
.question { display: grid; gap: 8px; padding: 12px; border-radius: 10px; background: color-mix(in srgb, var(--of-ink) 6%, transparent); }
.question button { justify-self: start; }
.answer { font-weight: 700; color: var(--rind); }
.over h2 { font-size: 1.6rem; font-weight: 800; }
.over .receipts li:nth-child(2) b { color: var(--of-bad); }
.ending b { color: var(--accent); letter-spacing: .05em; }
.coda { padding-top: 8px; border-top: 1px solid var(--of-rule); font-weight: 600; }
.confirm-card { max-width: 22rem; }

.toast, .orient-chip, .banner {
  position: fixed;
  z-index: 30;
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: min(28rem, calc(100vw - 24px));
  margin: 0;
  padding: 10px 14px;
  text-align: center;
  border-radius: 12px;
  background: color-mix(in srgb, var(--of-paper) 72%, transparent);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  backdrop-filter: blur(16px) saturate(140%);
  border: 1px solid color-mix(in srgb, var(--of-ink) 14%, transparent);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
  color: var(--of-ink);
  font-weight: 650;
  pointer-events: none;
  animation: fade var(--motion-fast) var(--ease-out);
}
.toast { bottom: calc(var(--B) + var(--tabbar) + 8px + 72px); }
.orient-chip { top: calc(var(--T) + 56px); }
.banner { top: calc(var(--T) + var(--G)); pointer-events: auto; }
@supports not (backdrop-filter: blur(1px)) {
  .toast, .orient-chip, .banner { background: color-mix(in srgb, var(--of-paper) 94%, transparent); }
}
.touch-dot { position: fixed; z-index: 40; width: 28px; height: 28px; margin: -14px 0 0 -14px; border-radius: 50%; border: 2px solid var(--focus); pointer-events: none; }

@keyframes rise { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: scale(.98); } to { opacity: 1; transform: none; } }
@keyframes sheet-in { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ------------------------------------------------------------ phone landscape: one-row HUD, left rail */
@media (orientation: landscape) and (max-height: 500px) {
  .game {
    grid-template-columns: calc(72px + var(--L)) minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas: "deck hud" "deck stage";
  }
  html[data-handedness="left"] .game {
    grid-template-columns: minmax(0, 1fr) calc(72px + var(--R));
    grid-template-areas: "hud deck" "stage deck";
  }
  .hud { display: flex; align-items: center; gap: 10px; min-height: calc(44px + var(--T)); padding: var(--T) calc(var(--R) + 8px) 0 8px; }
  html[data-handedness="left"] .hud { padding: var(--T) 8px 0 calc(var(--L) + 8px); }
  .hud-row { flex: 1 1 auto; min-width: 0; }
  /* Each meter stacks its label over its value, so the four take ~250px instead of ~400px and the Clout bar and cash
     keep their room once the 47px side insets are paid (852x393 iPhone landscape). */
  .hud-meters { display: flex; flex: 0 1 auto; gap: 12px; }
  .hud .hud-meters .meter { display: grid; grid-template-columns: auto; gap: 1px; align-items: baseline; line-height: 1.1; }
  .hud-meters .m-next, .hud-meters .m-bar { display: none; }
  .hud-meters .m-label { font-size: .62rem; }
  .deck {
    grid-template-columns: 1fr;
    grid-auto-rows: minmax(52px, auto);
    align-content: center;
    gap: 4px;
    padding: calc(var(--T) + 4px) 4px calc(var(--B) + 4px) calc(var(--L) + 4px);
    border-top: 0;
    border-right: 1px solid #1b241f;
  }
  html[data-handedness="left"] .deck { padding: calc(var(--T) + 4px) calc(var(--R) + 4px) calc(var(--B) + 4px) 4px; border-right: 0; border-left: 1px solid #1b241f; }
  .deck.one-handed { grid-template-columns: 1fr; }
  .deck button { min-height: 52px; font-size: .68rem; }
  .deck [aria-selected="true"]::before { top: 20%; bottom: 20%; left: 0; right: auto; width: 3px; height: auto; border-radius: 0 3px 3px 0; }
  #screen { padding: 10px calc(var(--R) + var(--G)) calc(var(--B) + 72px) var(--G); }
  html[data-handedness="left"] #screen { padding: 10px var(--G) calc(var(--B) + 72px) calc(var(--L) + var(--G)); }
  .toast { bottom: calc(var(--B) + 16px); }
  /* The orientation chip is a toast at the foot of the content column, centred on it (rail excluded), inside the
     #screen bottom padding so no title or control sits under it at rest; app.js hides it early if one ever does. */
  .orient-chip {
    top: auto;
    bottom: calc(var(--B) + 12px);
    left: calc(50% + (72px + var(--L) - var(--R)) / 2);
    max-width: calc(100vw - 72px - var(--L) - var(--R) - 2 * var(--G));
  }
  html[data-handedness="left"] .orient-chip { left: calc(50% - (72px + var(--R) - var(--L)) / 2); }
  .menu-list { grid-template-columns: 1fr 1fr; }
  .menu-list button { min-height: 44px; }
  .explainer-card .how { grid-template-columns: 1fr 1fr; }
  .lobby { padding: calc(var(--T) + 12px) calc(var(--R) + 24px) calc(var(--B) + 12px) calc(var(--L) + 24px); }
  .lobby-in {
    max-width: 48rem;
    grid-template-columns: 96px minmax(0, 1fr) minmax(0, 18rem);
    grid-template-areas:
      "icon eyebrow ctl"
      "icon tagline ctl"
      "icon title ctl"
      "lede lede ctl"
      "sub sub ctl";
    column-gap: 20px;
    align-content: center;
    align-items: start;
  }
  .lobby-icon { grid-area: icon; margin: 0; width: 88px; height: 88px; }
  .eyebrow { grid-area: eyebrow; }
  .tagline { grid-area: tagline; margin: 0; }
  .lobby h1 { grid-area: title; }
  .lede { grid-area: lede; }
  .sub-lede { grid-area: sub; }
  .lobby-in > .segment, .lobby-in > #mode-help, .lobby-in > #start, .lobby-in > #start-over, .lobby-in > #best, .lobby-in > .notice, .lobby-in > .lobby-row { grid-column: 3; }
  .lobby-in > .segment { grid-row: 1 / span 2; align-self: end; }
}

/* ------------------------------------------------------------ desktop: rail, centre, side column */
@media (min-width: 900px) {
  .game {
    grid-template-columns: minmax(0, 1fr) 200px minmax(0, 640px) 300px minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas: "hud hud hud hud hud" ". deck stage side .";
    column-gap: 16px;
  }
  .hud { padding: calc(var(--T) + 6px) max(16px, calc((100% - 1172px) / 2)) 6px; }
  .hud-meters { display: none; }
  .hud-row { gap: 12px; }
  .clout { max-width: 26rem; }
  .deck {
    grid-template-columns: 1fr;
    grid-auto-rows: 52px;
    align-content: start;
    gap: 4px;
    padding: 16px 0;
    background: transparent;
    border: 0;
  }
  .deck.one-handed { grid-template-columns: 1fr; }
  .deck button { grid-template-columns: 28px 1fr auto; justify-items: start; align-items: center; min-height: 52px; padding: 0 12px; font-size: .95rem; color: var(--of-ink-soft); }
  .deck button:hover { background: var(--card); }
  .deck [aria-selected="true"] { background: var(--card); color: var(--of-ink); box-shadow: inset 0 0 0 1px var(--of-rule); }
  .deck [aria-selected="true"]::before { top: 12px; bottom: 12px; left: 0; right: auto; width: 3px; height: auto; border-radius: 0 3px 3px 0; }
  .badge { position: static; }
  #screen { padding: 16px 4px 96px; }
  .side { display: grid; align-content: start; gap: 12px; padding: 16px 0; overflow: auto; overscroll-behavior: contain; touch-action: pan-y; }
  .sheet-layer { place-items: center; padding: 24px; }
  .sheet-layer > .card.sheet { border-radius: 12px; border-bottom: 1px solid color-mix(in srgb, var(--of-ink) 14%, transparent); }
}

/* ------------------------------------------------------------ reduced motion: opacity only, 120 ms */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-name: fade !important; animation-duration: 120ms !important; transition-property: opacity !important; transition-duration: 120ms !important; }
}
html[data-reduced-motion="on"] *, html[data-reduced-motion="on"] *::before, html[data-reduced-motion="on"] *::after {
  animation-name: fade !important;
  animation-duration: 120ms !important;
  transition-property: opacity !important;
  transition-duration: 120ms !important;
}
