/* Lightkeepers UI — Nocturne (v0.7).
   Ink navy glass, glazed ivory, aged-gold hairlines; refined serif display over
   a legible system sans. Team Jade (seat 0, circle) vs Amber (seat 1, diamond).
   Board colours live in public/js/theme.js. Colour values: public/js/tokens.js,
   mirrored as --tk-* in css/tokens-v020.css (v0.20). No web fonts: system stacks only. */
:root {
  --ink-0: var(--tk-ink-0);
  --ink-1: var(--tk-ink-1);
  --ink-2: var(--tk-ink-2);
  --ink-3: var(--tk-ink-3);
  --glass: var(--tk-glass);
  --glass-hi: var(--tk-glass-hi);
  --line: var(--tk-line);
  --line-soft: var(--tk-line-soft);
  --line-strong: var(--tk-line-strong);
  --ivory: var(--tk-ivory);
  --ivory-2: var(--tk-ivory-2);
  --cream: var(--tk-cream);
  --text: var(--tk-text);
  --muted: var(--tk-muted);
  --gold: var(--tk-gold);
  --gold-hot: var(--tk-gold-hot);
  --gold-deep: var(--tk-gold-deep);
  --danger: var(--tk-danger);
  --seat0: var(--tk-seat0);
  --seat0-dark: var(--tk-seat0-dark);
  --seat0-light: var(--tk-seat0-light);
  --seat1: var(--tk-seat1);
  --seat1-dark: var(--tk-seat1-dark);
  --seat1-light: var(--tk-seat1-light);
  --team: var(--seat0);
  --team-dark: var(--seat0-dark);
  --team-light: var(--seat0-light);
  --opp: var(--seat1);
  --display: "Cormorant Garamond", "Hoefler Text", "Baskerville", "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", "Noto Serif Display", "Noto Serif", Georgia, serif;
  --serif: var(--display);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --ease: cubic-bezier(.2, .7, .2, 1);
  color-scheme: dark;
}
body[data-seat="1"] {
  --team: var(--seat1);
  --team-dark: var(--seat1-dark);
  --team-light: var(--seat1-light);
  --opp: var(--seat0);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body {
  margin: 0;
  height: 100%;
  background: radial-gradient(140% 90% at 50% 10%, var(--tk-panel-glow) 0%, #0a0f2a 52%, var(--ink-0) 100%);
  color: var(--cream);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}
body { overflow: hidden; }
.sprite-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
button, input { font: inherit; color: inherit; }
svg { flex: none; }
kbd {
  display: inline-block; min-width: 1.5em; padding: 0 .35em; border-radius: 5px;
  border: 1px solid var(--line); background: rgba(255,255,255,.05); font-size: .85em; text-align: center; font-family: var(--font);
}
:focus-visible { outline: 3px solid var(--gold-hot); outline-offset: 2px; }

#app { position: fixed; inset: 0; }
.screen { position: absolute; inset: 0; display: none; }
#app[data-screen="home"] #screen-home,
#app[data-screen="lobby"] #screen-lobby { display: flex; }
#app[data-screen="game"] #screen-game { display: flex; }

/* ---------- home: key art ---------- */
/* The old attract board and the character pile are retired on home; the canvas
   ids stay in the tree for main.js but never paint. */
#screen-home > .backdrop { display: none; }
.keyart {
  position: absolute; inset: 0; overflow: hidden; pointer-events: none;
  background:
    radial-gradient(60% 40% at 64% 12%, rgba(236, 226, 196, .16), transparent 60%),
    radial-gradient(90% 60% at 60% 30%, #1b2552 0%, #0c1233 55%, var(--ink-0) 100%);
}
.keyart-img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; object-position: 60% 0%;
  filter: saturate(.92) contrast(1.03);
}
.keyart-veil {
  position: absolute; inset: 0;
  background:
    linear-gradient(180deg, rgba(4, 7, 22, .62) 0%, rgba(4, 7, 22, 0) 16%),
    linear-gradient(180deg, rgba(4, 7, 22, 0) 30%, rgba(4, 7, 22, .55) 46%, rgba(4, 7, 22, .9) 64%, rgba(4, 7, 22, .97) 100%);
  transition: background-color .3s;
}
#app[data-tab="cards"] .keyart-veil,
#app[data-tab="journey"] .keyart-veil { background-color: rgba(4, 7, 22, .74); }

/* ---------- home / lobby shell ---------- */
.backdrop { position: absolute; inset: 0; width: 100%; height: 100%; opacity: .5; filter: brightness(.62) saturate(.9); }
.home-inner {
  position: relative; z-index: 1; margin: auto; width: min(420px, 100%);
  padding: calc(18px + var(--safe-top)) 16px calc(18px + var(--safe-bottom));
  display: flex; flex-direction: column; gap: 14px; max-height: 100%; overflow-y: auto;
}
/* The page never scrolls; only the active panel does, when it must. */
.shell {
  position: relative; z-index: 1; width: min(460px, 100%); height: 100%; margin: 0 auto;
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto;
}
.shell-head {
  display: flex; align-items: center; min-height: 62px; min-width: 0;
  /* right: room for the fixed help / sound / motion buttons */
  padding: calc(9px + var(--safe-top)) 158px 5px 12px;
}
.hdr-trophy-icon { width: 20px; height: 20px; }
.hdr-trophy-text { display: flex; flex-direction: column; min-width: 0; text-align: left; line-height: 1.05; }
.hdr-trophy-text b { font-family: var(--display); font-weight: 500; font-size: 20px; color: var(--gold-hot); font-variant-numeric: lining-nums tabular-nums; }
.hdr-trophy-text span {
  font-size: 10px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: var(--gold);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.shell-main { position: relative; min-height: 0; }
.tab-panel {
  position: absolute; inset: 0; overflow-y: auto; overscroll-behavior: contain;
  padding: 4px 16px 14px; display: flex; flex-direction: column; gap: 10px;
  scrollbar-width: thin; scrollbar-color: rgba(var(--tk-line-rgb), .3) transparent;
}
.tab-panel:focus { outline: none; }
/* Battle sits low, over the dark lake of the key art; the art owns the top. */
.battle { gap: 14px; }
.battle > :first-child { margin-top: auto; }
.panel-title { margin: 6px 0 0; font-family: var(--display); font-weight: 500; font-size: 26px; color: var(--ivory); letter-spacing: .01em; }

.tabbar {
  position: relative; z-index: 2; padding: 4px 10px calc(4px + var(--safe-bottom));
  background: linear-gradient(0deg, rgba(4, 7, 22, .97), rgba(7, 11, 30, .9));
  border-top: 1px solid var(--line-soft);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.tabbar [role="tablist"] { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.tab {
  position: relative; min-height: 54px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  border-radius: 12px; border: 0; background: transparent; color: var(--muted); cursor: pointer;
  font-weight: 600; font-size: 10.5px; letter-spacing: .16em; text-transform: uppercase;
  transition: color .2s;
}
.tab svg { width: 22px; height: 22px; opacity: .8; }
.tab::before {
  content: ""; position: absolute; top: 0; left: 50%; width: 22px; height: 1.5px; margin-left: -11px; border-radius: 2px;
  background: var(--gold-hot); box-shadow: 0 0 10px rgba(var(--tk-gold-hot-rgb), .7); opacity: 0; transform: scaleX(.3); transition: opacity .2s, transform .25s var(--ease);
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--gold-hot); }
.tab[aria-selected="true"] svg { opacity: 1; filter: drop-shadow(0 0 6px rgba(var(--tk-gold-hot-rgb), .45)); }
.tab[aria-selected="true"]::before { opacity: 1; transform: none; }

/* ---------- brand ---------- */
.brand { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.brand-crest { width: 132px; height: 13px; color: var(--gold); opacity: .85; margin-bottom: 4px; }
h1 {
  margin: 0; font-family: var(--display); font-weight: 500; text-transform: uppercase;
  /* sized so the whole word always fits the narrowest (320 px) column */
  font-size: clamp(26px, 8.2vw, 40px); letter-spacing: .15em; padding-left: .15em; line-height: 1.02;
  white-space: nowrap; max-width: 100%;
  color: var(--ivory);
  text-shadow: 0 0 28px rgba(250, 232, 190, .28), 0 2px 12px rgba(2, 4, 16, .9);
}

/* ---------- panels & controls ---------- */
.panel {
  position: relative;
  background: linear-gradient(180deg, rgba(14, 19, 46, .78), rgba(7, 10, 28, .88));
  border: 1px solid var(--line); border-radius: 20px;
  padding: 18px; box-shadow: 0 22px 50px rgba(0,0,0,.5), inset 0 1px 0 rgba(255, 240, 210, .07);
  backdrop-filter: blur(14px) saturate(1.1); -webkit-backdrop-filter: blur(14px) saturate(1.1);
  display: flex; flex-direction: column; gap: 12px;
}
.panel::before {
  content: ""; position: absolute; inset: 4px; border-radius: 16px; pointer-events: none;
  border: 1px solid rgba(var(--tk-line-rgb), .09);
}

.btn {
  position: relative; min-height: 46px; padding: 10px 18px; border-radius: 12px; cursor: pointer;
  border: 1px solid var(--line); color: var(--ivory);
  background: linear-gradient(180deg, rgba(40, 50, 100, .42), rgba(14, 19, 46, .6));
  font-weight: 600; font-size: 15px; letter-spacing: .02em;
  box-shadow: inset 0 1px 0 rgba(255, 244, 220, .08), 0 2px 8px rgba(0, 0, 0, .28);
  transition: transform .12s var(--ease), border-color .2s, background-color .2s, filter .2s, box-shadow .2s;
}
.btn:hover { border-color: var(--line-strong); filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: default; transform: none; filter: none; }
.btn.primary {
  overflow: hidden; color: var(--tk-gilt-ink); border-color: rgba(250, 236, 196, .9);
  background: linear-gradient(180deg, var(--tk-gilt-top) 0%, var(--tk-gilt-mid) 46%, var(--tk-gilt-base) 100%);
  font-family: var(--display); font-weight: 500; font-size: 19px; letter-spacing: .05em;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .7), inset 0 -1px 0 rgba(110, 72, 18, .35),
    0 10px 28px rgba(214, 170, 92, .22), 0 2px 6px rgba(0, 0, 0, .4);
}
.btn.primary::after {
  content: ""; position: absolute; top: 0; bottom: 0; left: -40%; width: 30%; pointer-events: none;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .55), transparent);
  transform: skewX(-18deg); opacity: 0; animation: sheen 7s ease-in-out 1.2s infinite;
}
.btn.primary:hover { filter: brightness(1.05); box-shadow: inset 0 1px 0 rgba(255,255,255,.7), inset 0 -1px 0 rgba(110,72,18,.35), 0 12px 34px rgba(230, 186, 104, .34), 0 2px 6px rgba(0,0,0,.4); }
.btn.primary:disabled { filter: saturate(.4); }
.btn.big { min-height: 54px; font-size: 21px; }
.btn.ghost { background: rgba(255, 255, 255, .02); border-color: rgba(255, 255, 255, .14); box-shadow: none; color: var(--text); }
.btn.ghost:hover { border-color: var(--line); color: var(--ivory); }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 10.5px; letter-spacing: .18em; text-transform: uppercase; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, transparent, var(--line), transparent); }
.join-row { display: flex; gap: 10px; }
.field-label { font-weight: 600; font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--gold); }
.join-row input, .share input {
  flex: 1; min-width: 0; min-height: 48px; border-radius: 12px; border: 1px solid var(--line);
  background: rgba(3, 6, 20, .8); padding: 0 14px; font-size: 22px; letter-spacing: .3em; text-transform: uppercase; font-weight: 600;
  font-family: var(--display); color: var(--ivory);
  box-shadow: inset 0 2px 6px rgba(0,0,0,.45);
}
.join-row input:focus, .share input:focus, .code-field:focus { border-color: var(--line-strong); outline: none; box-shadow: inset 0 2px 6px rgba(0,0,0,.45), 0 0 0 3px rgba(var(--tk-line-rgb), .18); }
.share input { font-size: 13px; letter-spacing: 0; text-transform: none; font-weight: 500; color: var(--muted); font-family: var(--font); }
.hint { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.hint b { color: var(--ivory); font-weight: 600; }
.error { margin: 0; min-height: 1em; color: var(--danger); font-weight: 600; font-size: 13.5px; }
.status { margin: 0; text-align: center; font-weight: 600; color: var(--gold-hot); font-size: 14px; }
.howto ol { padding-left: 20px; margin: 0 0 12px; line-height: 1.5; font-size: 14px; color: var(--text); }
.howto li { margin-bottom: 7px; }
.howto li::marker { color: var(--gold); font-family: var(--display); font-weight: 500; }
.howto b { color: var(--ivory); font-weight: 600; }
.inline-ic { width: 1em; height: 1em; vertical-align: -0.14em; color: var(--gold-hot); }
.gallery-link {
  display: block; text-align: center; color: var(--gold-hot); font-weight: 600; font-size: 13.5px;
  padding: 12px; border-radius: 12px; background: rgba(4, 7, 22, .6); border: 1px solid var(--line-soft);
  text-decoration: none;
}
.gallery-link:hover { border-color: var(--line); }
.sheet-body .gallery-link { margin-top: 12px; }

/* Practice row (v0.11: in the menu sheet): the Practice button above the
   skill pills it configures. */
.practice-row {
  display: flex; flex-direction: column; gap: 6px; padding: 6px; border-radius: 14px;
  background: rgba(3, 6, 20, .34); border: 1px solid var(--line-soft);
}
.practice-row > #btn-training { order: 0; }
.practice-row > .difficulty { order: 2; }
.difficulty {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; padding: 2px; border-radius: 12px;
  background: rgba(3, 6, 20, .5); border: 1px solid var(--line-soft);
}
.difficulty button {
  min-height: 44px; border-radius: 10px; border: 1px solid transparent; background: transparent; color: var(--muted);
  font-weight: 600; font-size: 13px; letter-spacing: .02em; cursor: pointer; transition: color .2s, background-color .2s, border-color .2s;
}
.difficulty button:hover { color: var(--text); }
.difficulty button[aria-checked="true"] {
  color: var(--gold-hot); background: linear-gradient(180deg, rgba(46, 56, 112, .95), rgba(24, 31, 70, .95));
  border-color: rgba(var(--tk-line-strong-rgb), .6); box-shadow: inset 0 1px 0 rgba(255, 240, 210, .1), 0 2px 8px rgba(0, 0, 0, .35);
}

/* Journey: optional research consent (section#research.journey-block.research). */
.research .hint { font-size: 12px; }
.research-choice {
  display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 6px 12px; border-radius: 12px; cursor: pointer;
  border: 1px solid var(--line-soft); background: rgba(3, 6, 20, .45); color: var(--ivory); font-size: 13.5px; font-weight: 500;
}
.research-choice:hover { border-color: var(--line); }
.research-choice input[type="checkbox"] { width: 20px; height: 20px; margin: 0; flex: none; accent-color: var(--gold); cursor: pointer; }
.research-choice:has(input:checked) { border-color: var(--line-strong); background: rgba(var(--tk-line-rgb), .08); }
#research-status:empty { display: none; }

/* AI identity badge (rival intro, result score). Always visible for bots. */
.ai-badge {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  padding: 2px 6px 1px; border-radius: 5px; border: 1px solid var(--line-strong); background: rgba(var(--tk-line-rgb), .12);
  color: var(--gold-hot); font: 700 10px/1.2 var(--font); letter-spacing: .14em; text-transform: uppercase;
}

/* Before-play rival intro: a board overlay during the countdown (div#rival-intro,
   data-opp="human"|"ai"). Never takes pointer input. */
.rival-intro {
  position: absolute; left: 50%; top: 12px; transform: translateX(-50%); z-index: 4; pointer-events: none;
  /* clear of the 44 px HUD tool column on the right edge of the board */
  width: min(290px, calc(100% - 112px)); display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 12px 18px 11px; border-radius: 18px; text-align: center;
  background: radial-gradient(120% 80% at 50% 0%, rgba(var(--tk-line-rgb), .14), transparent 65%), linear-gradient(180deg, rgba(14, 19, 46, .95), rgba(6, 9, 26, .95));
  border: 1px solid var(--line); box-shadow: 0 16px 36px rgba(0,0,0,.55), inset 0 1px 0 rgba(255, 240, 210, .07);
  animation: rise .35s var(--ease);
}
.rival-intro p { margin: 0; }
.ri-kicker { font-size: 10px; font-weight: 600; letter-spacing: .22em; text-transform: uppercase; color: var(--gold); }
.ri-name-row { display: flex; align-items: center; justify-content: center; gap: 8px; max-width: 100%; min-width: 0; }
.ri-name { font-family: var(--display); font-weight: 500; font-size: 28px; line-height: 1.1; color: var(--ivory); overflow-wrap: anywhere; min-width: 0; }
.ri-detail { font-size: 12.5px; color: var(--text); line-height: 1.35; }
.ri-detail:empty, .ri-kicker:empty { display: none; }
.rival-intro[data-opp="human"] { border-color: rgba(var(--tk-gold-hot-rgb), .7); }
.rival-intro[data-opp="human"] .ri-kicker { color: var(--gold-hot); }

/* First-match tip (div#coach.coach, role=note): above the canvas, never
   blocking lanes; only the 44 px close button takes pointer input. */
.coach {
  position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); z-index: 4; pointer-events: none;
  width: max-content; max-width: calc(100% - 20px); display: flex; align-items: center; gap: 6px;
  padding: 4px 4px 4px 14px; border-radius: 16px;
  background: rgba(6, 10, 30, .94); border: 1px solid var(--line); box-shadow: 0 12px 28px rgba(0,0,0,.5);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  font-size: 13px; line-height: 1.4; color: var(--ivory); animation: rise .3s var(--ease);
}
.coach-text { min-width: 0; }
.coach-close {
  pointer-events: auto; flex: none; width: 44px; height: 44px; border-radius: 50%; border: 0; cursor: pointer;
  background: transparent; color: var(--muted); font-size: 15px; line-height: 1;
}
.coach-close:hover { color: var(--gold-hot); background: rgba(255, 255, 255, .05); }
.board-wrap:has(.coach:not([hidden])) .queue-chip { bottom: 66px; }

/* ---------- icon buttons (help / sound / motion / leave / close) ---------- */
#app[data-screen="lobby"] #btn-help { display: none; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); cursor: pointer; padding: 0;
  background: rgba(6, 10, 30, .58); color: var(--ivory-2);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  display: grid; place-items: center; box-shadow: inset 0 1px 0 rgba(255, 240, 210, .06);
  transition: color .2s, border-color .2s, background-color .2s;
}
.icon-btn svg { width: 20px; height: 20px; grid-area: 1 / 1; }
.icon-btn:hover { color: var(--gold-hot); border-color: var(--line-strong); }
.icon-btn .i-on, .icon-btn .i-off { display: none; }
/* Sound: speaker, or speaker with a cross when off. */
#btn-sound .i-on, #btn-sound-home .i-on { display: block; }
#btn-sound[aria-pressed="false"] .i-on, #btn-sound-home[aria-pressed="false"] .i-on { display: none; }
#btn-sound[aria-pressed="false"] .i-off, #btn-sound-home[aria-pressed="false"] .i-off { display: block; }
#btn-sound[aria-pressed="false"], #btn-sound-home[aria-pressed="false"] { color: var(--muted); }
/* Motion: waves; still lines and a gold ring while reduced motion is on. */
#btn-motion .i-off, #btn-motion-home .i-off { display: block; }
#btn-motion[aria-pressed="true"] .i-off, #btn-motion-home[aria-pressed="true"] .i-off { display: none; }
#btn-motion[aria-pressed="true"] .i-on, #btn-motion-home[aria-pressed="true"] .i-on { display: block; }
#btn-motion[aria-pressed="true"], #btn-motion-home[aria-pressed="true"] { color: var(--gold-hot); border-color: var(--line-strong); background-color: rgba(var(--tk-line-rgb), .14); }

/* ---------- dialogs (Join, Help, Restore) ---------- */
.sheet {
  padding: 0; border: 0; background: transparent; color: var(--cream);
  width: min(440px, calc(100% - 24px)); max-height: calc(100% - 24px);
}
.sheet::backdrop { background: rgba(3, 5, 16, .72); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); }
.sheet-card {
  position: relative; display: flex; flex-direction: column; gap: 10px; max-height: calc(100dvh - 24px); overflow: hidden;
  background: linear-gradient(180deg, var(--tk-panel-top), #0a0f2a); border: 1px solid var(--line); border-radius: 20px;
  padding: 14px 16px 16px; box-shadow: 0 30px 60px rgba(0,0,0,.6), inset 0 1px 0 rgba(255, 240, 210, .06); animation: rise .28s var(--ease);
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-bottom: 8px; border-bottom: 1px solid var(--line-soft); }
.sheet-head h2 { margin: 0; font-family: var(--display); font-weight: 500; font-size: 25px; color: var(--ivory); letter-spacing: .01em; }
.sheet-close { flex: none; background: transparent; backdrop-filter: none; -webkit-backdrop-filter: none; }
.sheet-body { overflow-y: auto; min-height: 0; overscroll-behavior: contain; padding-top: 4px; }

/* ---------- Cards tab ---------- */
.ci-cost {
  font-family: var(--font); font-size: 10.5px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--gold-hot);
  border: 1px solid var(--line); background: rgba(var(--tk-line-rgb), .08); border-radius: 999px; padding: 2px 9px;
}
.rule-list {
  margin: 0; display: grid; gap: 0; font-size: 13px; padding: 4px 14px; border-radius: 16px;
  background: linear-gradient(180deg, rgba(var(--tk-glass-hi-rgb), .82), rgba(8, 11, 30, .86)); border: 1px solid var(--line-soft);
}
.rule-list div { display: grid; grid-template-columns: 7.8em 1fr; gap: 10px; padding: 8px 0; border-top: 1px solid rgba(var(--tk-line-rgb), .1); }
.rule-list div:first-child { border-top: 0; }
.rule-list dt { color: var(--gold); font-weight: 600; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; padding-top: 2px; }
.rule-list dd { margin: 0; color: var(--text); }

/* ---------- Journey: trophies, Trophy Road, record ---------- */
.journey {
  position: relative; border-radius: 18px; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px;
  background: radial-gradient(120% 90% at 0% 0%, rgba(var(--tk-line-rgb), .12), transparent 55%), linear-gradient(180deg, rgba(var(--tk-glass-hi-rgb), .86), rgba(8, 11, 30, .9));
  border: 1px solid var(--line); box-shadow: 0 14px 34px rgba(0,0,0,.42), inset 0 1px 0 rgba(255, 240, 210, .06);
}
.journey-head { display: flex; align-items: center; gap: 12px; }
.journey-medal {
  width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; flex: none; color: var(--gold-hot);
  background: radial-gradient(circle at 38% 30%, rgba(var(--tk-gold-hot-rgb), .3), rgba(16, 20, 48, .95) 70%);
  box-shadow: inset 0 0 0 1px rgba(var(--tk-line-strong-rgb), .65), inset 0 0 0 4px rgba(4, 7, 22, .5), inset 0 0 0 5px rgba(var(--tk-line-rgb), .2), 0 0 22px rgba(232, 196, 120, .2);
}
.trophy-icon { width: 28px; height: 28px; }
.journey-total { display: flex; flex-direction: column; min-width: 0; }
.journey-total b { font-family: var(--display); font-weight: 500; font-size: 36px; line-height: .95; color: var(--gold-hot); font-variant-numeric: lining-nums tabular-nums; }
.journey-total span { font-size: 10.5px; font-weight: 600; letter-spacing: .18em; text-transform: uppercase; color: var(--gold); margin-top: 3px; }
.record { margin: 0 0 0 auto; display: grid; gap: 3px; text-align: right; font-size: 12.5px; }
.record div { display: flex; gap: 8px; justify-content: flex-end; }
.record dt { color: var(--muted); font-weight: 500; }
.record dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ivory); }
.road-bar { position: relative; height: 6px; border-radius: 999px; background: rgba(255, 255, 255, .06); box-shadow: inset 0 0 0 1px rgba(var(--tk-line-rgb), .22); overflow: hidden; }
.road-bar i {
  position: absolute; inset: 0; transform-origin: left; transform: scaleX(var(--p, 0)); border-radius: inherit;
  background: linear-gradient(90deg, var(--tk-gold-deep), #e2c07a 70%, var(--tk-gilt-hi)); box-shadow: 0 0 10px rgba(245, 214, 150, .6);
  transition: transform .8s var(--ease);
}
.road-next { margin: 0; font-size: 12.5px; font-weight: 600; color: var(--gold-hot); letter-spacing: .02em; }
.road-next:empty { display: none; }
.journey [data-testid="journey-status"] { font-size: 12px; }
.journey[data-state="unavailable"] .journey-medal, .journey[data-state="unavailable"] .road-bar { opacity: .4; }
.journey-block {
  display: flex; flex-direction: column; gap: 6px; padding: 12px 16px; border-radius: 18px;
  background: linear-gradient(180deg, rgba(16, 22, 52, .8), rgba(7, 10, 28, .86)); border: 1px solid var(--line-soft);
}
.journey-block h3 { margin: 0; font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .2em; color: var(--gold); }
.road-list, .recent-list { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 0; font-size: 13.5px; }
.road-list li {
  position: relative; display: flex; justify-content: space-between; align-items: center; padding: 8px 4px 8px 20px;
  border-top: 1px solid rgba(var(--tk-line-rgb), .09); color: var(--muted);
}
.road-list li:first-child { border-top: 0; }
.road-list li::before {
  content: ""; position: absolute; left: 4px; top: 50%; width: 6px; height: 6px; margin-top: -3px; transform: rotate(45deg);
  border: 1px solid rgba(var(--tk-line-rgb), .45);
}
.road-list li.reached { color: var(--ivory); }
.road-list li.reached::before { background: var(--gold); border-color: var(--gold); }
.road-list li.current { color: var(--gold-hot); font-weight: 600; }
.road-list li.current::before { background: var(--gold-hot); border-color: var(--gold-hot); box-shadow: 0 0 8px rgba(var(--tk-gold-hot-rgb), .8); }
.road-list .rl-name { font-family: var(--display); font-size: 16.5px; font-weight: 500; }
.road-list .rl-at { font-variant-numeric: tabular-nums; font-size: 12.5px; }
.recent-list li {
  display: grid; grid-template-columns: 3.2em 1fr auto auto; gap: 2px 10px; align-items: baseline;
  padding: 8px 4px 8px 12px; border-top: 1px solid rgba(var(--tk-line-rgb), .09); position: relative;
}
.recent-list li:first-child { border-top: 0; }
.recent-list li::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 2px; border-radius: 2px; background: var(--muted); opacity: .6; }
.recent-list li.win::before { background: var(--gold-hot); opacity: 1; }
.recent-list li.loss::before { background: #8a90b3; }
.recent-list .rc-out { font-weight: 600; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
.recent-list li.win .rc-out { color: var(--gold-hot); }
.recent-list .rc-who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.recent-list .rc-score, .recent-list .rc-delta { font-variant-numeric: tabular-nums; font-weight: 600; }
.recent-list .rc-delta { color: var(--gold); }
.recent-list .rc-when { grid-column: 2 / -1; font-size: 11px; color: var(--muted); }

/* Journey: keep your progress (private code copy / restore) */
.keep { display: block; }
.keep-body { display: flex; flex-direction: column; gap: 8px; }
.keep summary {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 44px; margin: -6px -8px;
  padding: 0 8px; border-radius: 12px; cursor: pointer; list-style: none;
  font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .2em; color: var(--gold);
}
.keep summary::-webkit-details-marker { display: none; }
.keep summary::after {
  content: ""; width: 7px; height: 7px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg) translateY(-2px); transition: transform .2s;
}
.keep[open] summary { margin-bottom: 6px; }
.keep[open] summary::after { transform: rotate(-135deg) translateY(-2px); }
.keep-warn b { color: var(--gold-hot); }
.keep-status:empty { display: none; }
.keep-status[data-kind="ok"] { color: var(--tk-jade-text); font-weight: 600; }
.keep-status[data-kind="bad"] { color: var(--danger); font-weight: 600; }
.keep-reveal { display: flex; flex-direction: column; gap: 6px; }
.code-field {
  width: 100%; min-width: 0; min-height: 44px; border-radius: 12px; border: 1px solid var(--line); background: rgba(3, 6, 20, .8);
  padding: 0 10px; font: 600 12px/1 ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: 0; color: var(--ivory); /* 36 chars fit at 360 px */
  box-shadow: inset 0 2px 6px rgba(0,0,0,.45); user-select: all; -webkit-user-select: all;
}
.restore-form { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; padding-top: 10px; border-top: 1px solid var(--line-soft); }
.restore-row { display: flex; flex-wrap: wrap; gap: 8px; }
.restore-row .code-field { flex: 1 1 12em; width: auto; }
.restore-row .btn { flex: 1 0 auto; min-height: 44px; font-size: 16px; }
.restore-compare { margin: 0; display: grid; gap: 6px; font-size: 14px; }
.restore-compare div { display: flex; justify-content: space-between; gap: 10px; padding: 9px 12px; border-radius: 12px; background: rgba(255,255,255,.03); border: 1px solid var(--line-soft); }
.restore-compare dt { color: var(--muted); font-weight: 500; }
.restore-compare dd { margin: 0; font-weight: 600; color: var(--ivory); text-align: right; font-variant-numeric: tabular-nums; }
.restore-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.restore-actions .btn.primary { font-size: 17px; }
#restore-dialog .sheet-card { overflow-y: auto; overscroll-behavior: contain; }
#restore-dialog .error:empty { display: none; }

/* ---------- practice search / matchmaking dialog ---------- */
.search {
  position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 16px;
  background: rgba(3, 5, 16, .74); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.search-card {
  position: relative; width: min(360px, 100%); text-align: center; display: flex; flex-direction: column; gap: 10px; align-items: center;
  background: radial-gradient(120% 70% at 50% 0%, rgba(var(--tk-line-rgb), .12), transparent 60%), linear-gradient(180deg, var(--tk-panel-top), #0a0f2a);
  border: 1px solid var(--line); border-radius: 22px; padding: 26px 20px 18px;
  box-shadow: 0 30px 60px rgba(0,0,0,.6), inset 0 1px 0 rgba(255, 240, 210, .06); animation: rise .3s var(--ease);
}
.search-card h2 { margin: 0; font-family: var(--display); font-weight: 500; font-size: 26px; color: var(--ivory); }
.search-kicker, .result-kicker {
  margin: 0; text-transform: uppercase; letter-spacing: .24em; font-size: 10.5px; color: var(--gold); font-weight: 600;
}
.search-card .btn { width: 100%; margin-top: 6px; }
.search-orbit {
  position: relative; width: 76px; height: 76px; border-radius: 50%; margin-bottom: 4px; display: grid; place-items: center; color: var(--gold-hot);
  box-shadow: inset 0 0 0 1px var(--line), inset 0 0 0 7px rgba(4, 7, 22, .5), inset 0 0 0 8px rgba(var(--tk-line-rgb), .14);
  background: radial-gradient(circle, rgba(245, 214, 150, .2), rgba(245, 214, 150, 0) 62%);
}
.search-orbit svg { width: 30px; height: 30px; filter: drop-shadow(0 0 8px rgba(245, 214, 150, .6)); }
.search-orbit span {
  position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px; border-radius: 50%;
  background: var(--gold-hot); box-shadow: 0 0 8px rgba(255, 220, 150, .9);
  animation: orbit 2.4s linear infinite;
}
.search-orbit span:nth-child(2) { animation-delay: -.8s; opacity: .7; }
.search-orbit span:nth-child(3) { animation-delay: -1.6s; opacity: .45; }
.search-note { margin: -2px 0 0; font-size: 13px; color: var(--muted); }
.search-note:empty { display: none; }

/* ---------- lobby ---------- */
#screen-lobby::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 1;
  background: radial-gradient(80% 60% at 50% 40%, rgba(4, 7, 22, .35), rgba(4, 7, 22, .85));
}
#screen-lobby .home-inner { z-index: 2; }
.lobby h2 { margin: 0; text-align: center; font-size: 10.5px; text-transform: uppercase; letter-spacing: .24em; color: var(--gold); font-weight: 600; }
.code-tiles { display: flex; gap: 8px; justify-content: center; }
.code-tiles span {
  width: 50px; height: 62px; display: grid; place-items: center; border-radius: 10px;
  background: linear-gradient(180deg, #fbf7ee, #e6dccb); color: #151a36; font-size: 32px; font-weight: 500; font-family: var(--display); font-variant-numeric: lining-nums;
  border: 1px solid #e9d39b; box-shadow: 0 0 0 3px rgba(4, 7, 22, .6), 0 0 0 4px rgba(var(--tk-line-rgb), .3), 0 10px 20px rgba(0,0,0,.4);
}
.share { display: flex; flex-direction: column; gap: 8px; }
.seats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seat {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 12px; min-width: 0;
  background: rgba(255,255,255,.03); border: 1px solid var(--line-soft); font-weight: 600; font-size: 14px;
}
.seat .seat-state { margin-left: auto; font-size: 11.5px; color: var(--muted); font-weight: 500; }
.seat.you { border-color: var(--line-strong); }
.seat.on .seat-state { color: var(--tk-jade-text); }

.emblem { display: inline-block; width: 12px; height: 12px; border: 1px solid rgba(var(--tk-ivory-rgb), .9); flex: none; box-shadow: 0 0 0 2px rgba(4, 7, 22, .5); }
.emblem.circle { border-radius: 50%; background: var(--seat0); }
.emblem.diamond { background: var(--seat1); transform: rotate(45deg) scale(.85); }

/* ---------- game ---------- */
#screen-game {
  flex-direction: column; width: min(100%, 640px); left: 50%; transform: translateX(-50%);
  background: var(--ink-0); box-shadow: 0 0 0 1px rgba(var(--tk-line-rgb), .08), 0 0 120px rgba(0,0,0,.7);
}
.hud {
  position: relative; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: calc(7px + var(--safe-top)) 12px 7px; gap: 8px; z-index: 2;
  background: linear-gradient(180deg, rgba(4, 7, 22, .98), rgba(8, 12, 32, .9));
  border-bottom: 1px solid var(--line-soft);
  box-shadow: 0 8px 20px rgba(0, 0, 0, .35);
}
.score { display: flex; align-items: center; gap: 8px; min-width: 0; }
.score b { font-size: 32px; font-weight: 500; line-height: 1; font-family: var(--display); font-variant-numeric: lining-nums tabular-nums; text-shadow: 0 2px 10px rgba(0,0,0,.6); }
.score .who {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); font-weight: 600;
  white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.score.me { justify-content: flex-end; }
.score.me b { color: var(--team-light); }
.score.opp b { color: var(--opp); }
body[data-seat="0"] .score.me .emblem, body[data-seat="1"] .score.opp .emblem { border-radius: 50%; background: var(--seat0); transform: none; }
body[data-seat="1"] .score.me .emblem, body[data-seat="0"] .score.opp .emblem { background: var(--seat1); transform: rotate(45deg) scale(.85); border-radius: 0; }
.clock {
  min-width: 78px; text-align: center;
  font-family: var(--display); font-size: 24px; font-weight: 500; font-variant-numeric: lining-nums tabular-nums; line-height: 1;
  padding: 6px 12px 5px; border-radius: 999px;
  background: linear-gradient(180deg, #fbf7ee, #e3d8c4); color: #141a36; border: 1px solid #ecd49c;
  box-shadow: 0 0 0 3px rgba(4, 7, 22, .7), 0 0 0 4px rgba(var(--tk-line-rgb), .32), 0 8px 18px rgba(0,0,0,.45);
}
.clock.low { color: #fff; background: linear-gradient(180deg, #c03e56, #7d1d35); border-color: #ffb3bf; animation: pulse 1s infinite; }
.clock.surge:not(.low) { box-shadow: 0 0 0 3px rgba(4, 7, 22, .7), 0 0 0 4px var(--gold-hot), 0 0 22px rgba(255, 214, 130, .55); }
.hud-tools { position: absolute; right: 6px; top: calc(100% + 6px); display: flex; flex-direction: column; gap: 6px; }
.hud-tools .icon-btn { background: rgba(4, 7, 22, .55); border-color: var(--line-soft); color: var(--ivory-2); }
.hud-tools .icon-btn svg { width: 18px; height: 18px; }

.board-wrap { position: relative; flex: 1; min-height: 0; touch-action: none; }
#board { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: pointer; }

.banner {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 3;
  padding: 9px 16px; border-radius: 12px; background: rgba(46, 12, 28, .94); border: 1px solid rgba(var(--tk-danger-rgb), .7);
  font-weight: 600; font-size: 13.5px; white-space: nowrap; box-shadow: 0 10px 24px rgba(0,0,0,.45);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.banner.info { background: rgba(6, 10, 30, .92); border-color: var(--line-strong); }
.countdown {
  position: absolute; inset: 0; display: grid; place-items: center; z-index: 3; pointer-events: none;
  font-size: 128px; font-weight: 500; font-family: var(--display); color: var(--ivory); font-variant-numeric: lining-nums;
  text-shadow: 0 0 50px rgba(255, 224, 160, .75), 0 0 12px rgba(255, 236, 196, .5), 0 4px 24px rgba(2, 4, 16, .9);
  background: radial-gradient(40% 30% at 50% 50%, rgba(4, 7, 22, .45), rgba(4, 7, 22, .2));
}
.countdown.pop { animation: pop .5s var(--ease); }
.toast {
  position: absolute; left: 50%; top: 58px; transform: translate(-50%, -10px); z-index: 3; opacity: 0;
  padding: 10px 16px; border-radius: 12px; background: rgba(6, 10, 30, .95); border: 1px solid var(--line);
  font-weight: 600; font-size: 13.5px; line-height: 1.4; max-width: 88%; text-align: center; pointer-events: none;
  transition: opacity .18s, transform .22s var(--ease); box-shadow: 0 12px 28px rgba(0,0,0,.5);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { border-color: rgba(var(--tk-danger-rgb), .8); }
.toast.warn { border-color: var(--gold-hot); color: var(--gold-hot); }
.lane-hint {
  position: absolute; left: 50%; top: 44%; transform: translateX(-50%); z-index: 2; pointer-events: none;
  padding: 6px 14px; border-radius: 999px; background: rgba(4, 7, 22, .78); font-weight: 600; font-size: 11px;
  letter-spacing: .18em; text-transform: uppercase; color: var(--team-light); border: 1px solid var(--line-soft);
}

.hand {
  position: relative; z-index: 2; padding: 8px 10px calc(10px + var(--safe-bottom));
  background: linear-gradient(0deg, var(--ink-0), rgba(8, 12, 32, .95));
  border-top: 1px solid var(--line-soft);
  box-shadow: 0 -10px 24px rgba(0, 0, 0, .35);
}
.focus-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.focus-label { display: flex; align-items: baseline; gap: 5px; min-width: 72px; }
.focus-label b { font-size: 26px; font-weight: 500; font-family: var(--display); color: var(--gold-hot); line-height: 1; font-variant-numeric: lining-nums tabular-nums; }
.focus-label span { font-size: 10px; text-transform: uppercase; letter-spacing: .18em; color: var(--muted); font-weight: 600; }
.focus-label .surge-badge {
  align-self: center; margin-left: 2px; padding: 2px 6px; border-radius: 999px; letter-spacing: 0;
  font-size: 11px; color: var(--tk-gilt-ink); background: linear-gradient(180deg, var(--tk-gilt-hi), var(--tk-gilt-lo)); border: 1px solid var(--tk-gilt-hi);
  box-shadow: 0 0 12px rgba(255, 210, 120, .55);
}
.hand.surge .focus-bar i::after { background: linear-gradient(180deg, #fffbe9, #f0cf82); box-shadow: 0 0 8px rgba(255, 220, 150, .8); }
.phase-cue {
  position: absolute; left: 50%; top: 12px; translate: -50% 0; z-index: 3; pointer-events: none; /* translate, not transform: the pop keyframes own transform */
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 9px 18px; border-radius: 14px;
  background: rgba(6, 10, 30, .94); border: 1px solid var(--gold-hot); box-shadow: 0 0 30px rgba(255, 210, 120, .35), 0 12px 28px rgba(0,0,0,.45);
  text-align: center; white-space: nowrap; animation: pop .45s var(--ease);
}
.phase-cue b { font-family: var(--display); font-size: 22px; font-weight: 500; color: var(--gold-hot); letter-spacing: .02em; }
.phase-cue span { font-size: 11.5px; font-weight: 500; color: var(--text); }
#ot-cue { white-space: normal; width: max-content; max-width: min(300px, calc(100% - 24px)); }
.queue-chip {
  position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); z-index: 3; max-width: calc(100% - 20px);
  display: flex; align-items: center; gap: 10px; padding: 5px 5px 5px 14px; border-radius: 999px;
  background: rgba(6, 10, 30, .95); border: 1px dashed var(--gold-hot); font-weight: 600; font-size: 12.5px;
  box-shadow: 0 10px 24px rgba(0,0,0,.5);
  pointer-events: none; /* taps on the text still reach the lanes; only Cancel is a target */
}
.queue-chip span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.queue-chip button {
  pointer-events: auto; flex: none; min-height: 44px; padding: 0 16px; border-radius: 999px; cursor: pointer; font-weight: 600; font-size: 12.5px;
  border: 1px solid var(--line); background: rgba(255, 255, 255, .05); color: var(--ivory);
}
.focus-bar { flex: 1; display: grid; grid-template-columns: repeat(10, 1fr); gap: 3px; height: 10px; }
.focus-bar i { position: relative; border-radius: 2px; background: rgba(255, 255, 255, .04); box-shadow: inset 0 0 0 1px rgba(var(--tk-line-rgb), .24); overflow: hidden; }
.focus-bar i::after {
  content: ""; position: absolute; inset: 0; transform-origin: left; transform: scaleX(var(--fill, 0));
  background: linear-gradient(180deg, #fff3d2, var(--tk-gold));
}
.carriers {
  min-width: 52px; text-align: center; font-weight: 600; font-size: 12.5px; padding: 4px 9px; border-radius: 999px;
  background: rgba(255, 255, 255, .03); border: 1px solid var(--line-soft); color: var(--muted); font-variant-numeric: tabular-nums;
}
.carriers.full { color: var(--gold-hot); border-color: var(--line-strong); }
.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.card {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  min-height: 94px; padding: 6px 4px 8px; border-radius: 14px; cursor: pointer; touch-action: none; user-select: none;
  -webkit-user-select: none; -webkit-touch-callout: none; color: var(--ivory);
  background:
    radial-gradient(120% 70% at 50% 0%, rgba(var(--tk-seat0-rgb), .2), transparent 70%),
    linear-gradient(180deg, #1a2250, var(--tk-panel-deep));
  background:
    radial-gradient(120% 70% at 50% 0%, color-mix(in srgb, var(--team) 24%, transparent), transparent 70%),
    linear-gradient(180deg, #1a2250, var(--tk-panel-deep));
  border: 1px solid rgba(var(--tk-line-rgb), .34);
  box-shadow: inset 0 1px 0 rgba(255, 240, 210, .09), inset 0 0 0 3px rgba(4, 7, 22, .35), 0 8px 18px rgba(0,0,0,.4);
  transition: transform .14s var(--ease), box-shadow .18s, border-color .18s, filter .18s, opacity .18s;
}
.card[data-card="hook"] { background: radial-gradient(120% 70% at 50% 0%, rgba(200, 70, 96, .22), transparent 70%), linear-gradient(180deg, #2a1a3e, #0d0b24); }
.card[data-card="cover"] { background: radial-gradient(120% 70% at 50% 0%, rgba(150, 200, 255, .2), transparent 70%), linear-gradient(180deg, #172a4e, #0a0f28); }
.card svg { width: 44px; height: 44px; margin-top: 10px; color: var(--gold-hot); filter: drop-shadow(0 0 6px rgba(245, 214, 150, .25)); }
.card .portrait { display: none; width: 60px; height: 60px; margin-top: 2px; filter: drop-shadow(0 6px 6px rgba(0,0,0,.45)); }
.card.has-art .portrait { display: block; }
.card.has-art > svg { display: none; }
.card .name { font-weight: 600; font-size: 10.5px; margin-top: 3px; text-transform: uppercase; letter-spacing: .16em; }
.card .cost {
  position: absolute; top: -7px; left: -5px; width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 500; font-size: 16px; color: var(--tk-gilt-ink); font-family: var(--display); font-variant-numeric: lining-nums;
  background: radial-gradient(circle at 35% 28%, #fff8e2, #e6c77f 58%, #a88035); border: 1px solid #f8e8bd;
  box-shadow: 0 0 0 2px rgba(4, 7, 22, .7), 0 3px 8px rgba(0,0,0,.5);
}
.card .key { position: absolute; top: 5px; right: 8px; font-size: 10px; color: var(--muted); font-weight: 600; opacity: .7; }
.card:hover { border-color: rgba(var(--tk-line-strong-rgb), .55); }
.card[aria-pressed="true"] {
  transform: translateY(-7px); border-color: var(--gold-hot);
  box-shadow: inset 0 1px 0 rgba(255, 240, 210, .12), 0 0 0 1px var(--gold-hot), 0 0 0 4px color-mix(in srgb, var(--team) 55%, transparent),
    0 14px 26px rgba(0,0,0,.55), 0 0 34px rgba(255, 224, 160, .3);
}
.card.poor { filter: saturate(.3) brightness(.6); }
.card.pending { opacity: .72; }
.card.pending::after {
  content: ""; position: absolute; inset: 4px; border-radius: 10px; border: 1.5px dashed var(--gold-hot);
  animation: spin 1.2s linear infinite;
}
.card.shake { animation: shake .35s; }
.card.queued { border-color: var(--gold-hot); border-style: dashed; }
.card .queued-tag {
  display: none; position: absolute; left: 50%; bottom: -9px; transform: translateX(-50%); padding: 1px 8px; border-radius: 999px;
  font-size: 9.5px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--tk-gilt-ink); background: var(--gold-hot);
}
.card.queued .queued-tag { display: block; }
/* Too late to get home before the bell: a small engraved clock, not an emoji. */
.card.late::before {
  content: ""; position: absolute; top: 4px; left: 25px; width: 13px; height: 13px; opacity: .95;
  background: center / contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23f5e2ae' stroke-width='1.5' stroke-linecap='round'%3E%3Ccircle cx='8' cy='9' r='5.6'/%3E%3Cpath d='M8 6v3.2l2 1.3M6.3 1.8h3.4'/%3E%3C/svg%3E");
}
.card.late .name { color: var(--muted); }
.card.alert { box-shadow: 0 0 0 1px var(--danger), 0 0 0 4px rgba(var(--tk-cv-danger-rgb), .35), 0 0 26px rgba(var(--tk-cv-danger-rgb), .5); }
.card.dragging { opacity: .55; }
.drag-ghost {
  position: fixed; z-index: 50; width: 64px; height: 64px; margin: -32px 0 0 -32px; pointer-events: none;
  filter: drop-shadow(0 8px 12px rgba(0,0,0,.6)); opacity: .95; color: var(--gold-hot);
}

/* ---------- result ---------- */
.result {
  position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 14px;
  background: radial-gradient(70% 50% at 50% 40%, rgba(4, 7, 22, .55), rgba(3, 5, 16, .86));
  backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px);
}
.result-card {
  position: relative; width: min(400px, 100%); max-height: 100%; overflow-y: auto; text-align: center;
  background:
    radial-gradient(110% 55% at 50% 0%, rgba(232, 196, 120, .16), transparent 62%),
    linear-gradient(180deg, #141b40, #090d26);
  border: 1px solid var(--line); border-radius: 22px;
  padding: 18px 18px calc(16px + var(--safe-bottom)); box-shadow: 0 40px 80px rgba(0,0,0,.65), inset 0 1px 0 rgba(255, 240, 210, .08);
  display: flex; flex-direction: column; gap: 10px; animation: rise .4s var(--ease);
}
.result-card > * { flex-shrink: 0; } /* scroll the card, never squash a block */
.result-card::before {
  content: ""; position: absolute; inset: 5px; border-radius: 17px; pointer-events: none; border: 1px solid rgba(var(--tk-line-rgb), .1);
}
.result-crest { width: 150px; height: 14px; margin: 0 auto -2px; color: var(--gold); opacity: .8; }
.result-card h2 {
  margin: 0; font-size: 50px; font-weight: 500; font-family: var(--display); line-height: 1; letter-spacing: .01em;
  color: var(--gold-hot);
  background: linear-gradient(180deg, #fff8e4 10%, #f1d593 55%, #c99c4c 95%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 22px rgba(250, 214, 140, .35));
}
.result-card.lose h2 { background: none; -webkit-text-fill-color: var(--tk-down-text); color: var(--tk-down-text); filter: none; }
.result-card.draw h2 { background: none; -webkit-text-fill-color: var(--ivory); color: var(--ivory); filter: none; }
.result-card.lose { background: linear-gradient(180deg, #121833, #080b20); }
.result-score { --rs-num: 46px; display: flex; justify-content: center; align-items: flex-start; gap: 22px; margin-top: 2px; }
.rs { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 10.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .16em; min-width: 0; max-width: 40%; }
.rs > span:last-child { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rs b { font-size: var(--rs-num); line-height: 1; font-family: var(--display); font-weight: 500; color: var(--ivory); font-variant-numeric: lining-nums tabular-nums; }
.rs.me b { color: var(--team-light); }
.rs.opp b { color: var(--opp); }
body[data-seat="0"] .rs.me .emblem, body[data-seat="1"] .rs.opp .emblem { border-radius: 50%; background: var(--seat0); }
body[data-seat="1"] .rs.me .emblem, body[data-seat="0"] .rs.opp .emblem { background: var(--seat1); transform: rotate(45deg) scale(.85); }
/* the dash sits on the numerals' centre line (emblem 12 px + gap 4 px above them) */
.rs-dash { width: 18px; height: 1px; margin-top: calc(16px + var(--rs-num) / 2); background: var(--line-strong); font-size: 0; color: transparent; overflow: hidden; }

/* result: trophy change */
.result-progress {
  position: relative; overflow: hidden; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 14px 11px; border-radius: 16px;
  background: linear-gradient(180deg, rgba(var(--tk-line-rgb), .12), rgba(var(--tk-line-rgb), .04)); border: 1px solid var(--line);
}
.rp-line { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; }
.rp-medal {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; color: var(--gold-hot); flex: none;
  background: radial-gradient(circle at 38% 30%, rgba(var(--tk-gold-hot-rgb), .35), rgba(18, 22, 52, .95) 70%);
  box-shadow: inset 0 0 0 1px rgba(var(--tk-line-strong-rgb), .7), inset 0 0 0 4px rgba(4, 7, 22, .45), 0 0 18px rgba(232, 196, 120, .3);
}
.rp-icon { width: 24px; height: 24px; }
.rp-line b { font-family: var(--display); font-size: 38px; font-weight: 500; line-height: 1; color: var(--gold-hot); font-variant-numeric: lining-nums tabular-nums; }
.result-progress[data-dir="down"] b { color: var(--tk-down-text); }
.result-progress[data-dir="down"] .rp-medal, .result-progress[data-dir="flat"] .rp-medal { color: var(--ivory-2); box-shadow: inset 0 0 0 1px rgba(200, 205, 230, .45), inset 0 0 0 4px rgba(4, 7, 22, .45); }
.rp-line span { font-weight: 600; font-size: 14px; color: var(--ivory); font-variant-numeric: tabular-nums; }
.rp-note { margin: 0; font-size: 12.5px; color: var(--text); line-height: 1.4; letter-spacing: .01em; }
.result-progress[data-status]:not([data-status="saved"]) .rp-medal { opacity: .4; }
.result-progress.celebrate { animation: glow 1.6s var(--ease); }
.result-progress.celebrate .rp-medal { animation: trophy-pop .8s cubic-bezier(.2, 1.5, .4, 1); }
.result-progress.celebrate b { animation: pop .6s var(--ease) .15s both; }
.result-progress.celebrate::after {
  content: ""; position: absolute; top: 0; bottom: 0; left: -50%; width: 40%; pointer-events: none;
  background: linear-gradient(100deg, transparent, rgba(var(--tk-cv-gold-hot-rgb), .45), transparent);
  transform: skewX(-18deg); animation: sweep 1.3s ease-out .2s both;
}
.stats { width: 100%; border-collapse: collapse; font-size: 13px; }
.stats th { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); padding: 2px 4px 5px; }
.stats td { padding: 5px 6px; border-top: 1px solid rgba(var(--tk-line-rgb), .1); }
.stats td:first-child { text-align: left; color: var(--text); }
.stats td:not(:first-child) { font-weight: 600; font-variant-numeric: tabular-nums; width: 64px; color: var(--ivory); }
.result-actions { display: grid; grid-template-columns: 1.7fr 1fr; gap: 8px; }
/* Quick Play adds "Find new match": the main action takes the full row. */
.result-actions:has(#btn-next-match:not([hidden])) { grid-template-columns: 1fr 1fr; }
.result-actions:has(#btn-next-match:not([hidden])) > #btn-rematch { grid-column: 1 / -1; }
.result-opp { margin: -4px 0 0; font-size: 12.5px; color: var(--text); letter-spacing: .01em; }
.result-opp:empty { display: none; }
.rs .ai-badge { margin-top: 1px; }
.feedback-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; }
.feedback-label { width: 100%; font-size: 10px; font-weight: 600; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); }
.feedback-btn {
  min-height: 44px; padding: 0 16px; border-radius: 999px; cursor: pointer; font-weight: 600; font-size: 13px;
  border: 1px solid var(--line-soft); background: rgba(255, 255, 255, .03); color: var(--text);
}
.feedback-btn:hover { border-color: var(--line); color: var(--ivory); }
.feedback-btn[aria-pressed="true"], .feedback-btn.sent { color: var(--gold-hot); border-color: var(--line-strong); background: rgba(var(--tk-line-rgb), .12); }
.result-actions .btn.big { font-size: 20px; }

@keyframes pulse { 50% { filter: brightness(1.3); } }
@keyframes pop { from { transform: scale(1.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes rise { from { transform: translateY(18px); opacity: 0; } }
@keyframes shake { 20%, 60% { transform: translateX(-5px); } 40%, 80% { transform: translateX(5px); } }
@keyframes glow { 0% { box-shadow: 0 0 0 0 rgba(255, 224, 160, .0); border-color: var(--gold-hot); } 30% { box-shadow: 0 0 36px 2px rgba(255, 224, 160, .35); } 100% { box-shadow: 0 0 0 0 rgba(255, 224, 160, 0); } }
@keyframes trophy-pop { 0% { transform: scale(.4) rotate(-14deg); opacity: 0; } 100% { transform: scale(1) rotate(0); opacity: 1; } }
@keyframes sweep { from { left: -50%; } to { left: 120%; } }
@keyframes sheen { 0%, 82% { left: -40%; opacity: 0; } 86% { opacity: 1; } 100% { left: 130%; opacity: 0; } }
@keyframes orbit { from { transform: rotate(0deg) translateX(34px); } to { transform: rotate(360deg) translateX(34px); } }

/* v0.23 interaction polish (js/polish.js). Outcome cues sit on properties the
   existing states do not use: outline (not border: the selected card owns it)
   and the standalone scale property (not transform: raised card, shake, spin).
   Reduced motion: the global rules below remove the settle and transitions; the
   outline and the meter are static, so they remain. */
.card.rejected { outline: 2px solid rgba(var(--tk-danger-rgb), .85); outline-offset: 2px; }
.card.accepted { animation: settle .14s var(--ease); }
@keyframes settle { from { scale: .96; } to { scale: 1; } }
.card .queue-meter {
  display: none; position: absolute; left: 8px; right: 8px; bottom: 5px; height: 3px; border-radius: 2px;
  background: var(--gold-hot); transform-origin: left center; transform: scaleX(var(--q, 0)); transition: transform .18s linear;
  pointer-events: none;
}
.card.queued .queue-meter { display: block; }
.card.queued.poor { filter: none; } /* armed, not unavailable: the meter carries the wait */
.card:not(.dragging):not(:disabled):active { scale: .97; transition: scale 80ms; }
.btn:not(:disabled):active { scale: .97; }
.btn:disabled { scale: none; }

/* Reduced motion: OS preference or in-game toggle */
body.reduced *, body.reduced *::before, body.reduced *::after { animation: none !important; transition: none !important; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .btn.primary::after { display: none; }
}

/* ---------- Keeper Trials (v0.8) ----------
   The town itself (#town-root) is styled by town.css; these are the panel
   around it, the Battle entry, the in-match goals and the result lanterns. */
.trials-panel { gap: 10px; }
.trials-intro, .trials-fine { margin: 0; }
.trials-intro { font-family: var(--display); font-size: 17px; color: var(--ivory); text-align: center; }
.trials-fine { font-size: 11.5px; opacity: .85; text-align: center; }
.trials-status { margin: 0; }
.trials-status:empty { display: none; }
.tf-count { margin: 0; font-family: var(--display); font-size: 19px; color: var(--ivory); }
.trials-status[data-kind="bad"] { color: var(--danger); }
.trials-status[data-kind="session"], .trials-status[data-kind="degraded"] { color: var(--gold); }
.town-root { min-height: 120px; }
/* Stand-in list when the town view is unavailable. */
.town-fallback { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.town-fallback > li { padding: 10px 12px; border-radius: 14px; border: 1px solid var(--line-soft); background: rgba(3, 6, 20, .45); display: flex; flex-direction: column; gap: 6px; }
.town-fallback > li.locked { opacity: .6; }
.tf-head { margin: 0; font-size: 13px; color: var(--text); }
.tf-head b { font-family: var(--display); font-size: 19px; font-weight: 500; color: var(--ivory); }
.tf-goals { margin: 0; padding-left: 18px; font-size: 12.5px; color: var(--text); }
.tf-goals .lit { color: var(--gold-hot); }

/* In-match goals (div#trial-hud): top-left of the board, never takes input. */
.trial-hud {
  position: absolute; left: 8px; top: 8px; z-index: 3; pointer-events: none;
  max-width: min(236px, calc(100% - 64px)); display: flex; flex-direction: column; gap: 2px;
  padding: 6px 9px; border-radius: 12px; background: rgba(5, 8, 26, .78); border: 1px solid var(--line-soft);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.th-goal { margin: 0; display: flex; align-items: center; gap: 6px; font-size: 11px; line-height: 1.35; color: var(--text); min-width: 0; }
.th-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.th-val { flex: none; font-weight: 600; color: var(--ivory); font-variant-numeric: tabular-nums; }
.th-lamp { flex: none; width: 8px; height: 8px; border-radius: 50%; border: 1px solid var(--line-strong); background: transparent; }
.th-goal.met .th-lamp { background: var(--gold-hot); border-color: var(--gold-hot); box-shadow: 0 0 8px rgba(var(--tk-gold-hot-rgb), .8); }
.th-goal.met .th-val { color: var(--gold-hot); }
.th-goal.pending .th-val { color: var(--muted); font-weight: 500; }
.board-wrap:has(.rival-intro:not([hidden])) .trial-hud { display: none; }

/* Result: the trial's three lanterns (div#result-trial). */
.result-trial {
  display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; border-radius: 16px; text-align: left;
  background: linear-gradient(180deg, rgba(var(--tk-line-rgb), .1), rgba(var(--tk-line-rgb), .03)); border: 1px solid var(--line);
}
.rt-name { margin: 0; font-size: 10.5px; font-weight: 600; letter-spacing: .18em; text-transform: uppercase; color: var(--gold); text-align: center; }
.rt-lanterns { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.rt-lanterns li { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text); min-height: 22px; }
.rt-lamp {
  flex: none; width: 16px; height: 20px; border-radius: 7px 7px 4px 4px; border: 1px solid var(--line-strong);
  background: rgba(3, 6, 20, .6);
}
.rt-lanterns li.lit .rt-lamp { background: radial-gradient(circle at 50% 55%, #fff4d2, var(--gold) 60%, var(--gold-deep)); border-color: var(--gold-hot); box-shadow: 0 0 10px rgba(var(--tk-gold-hot-rgb), .55); }
.rt-lanterns li.new .rt-lamp { animation: lamp-in 1s var(--ease) both; }
.rt-goal { flex: 1; min-width: 0; }
.rt-lanterns li.lit .rt-goal { color: var(--ivory); }
.rt-val { flex: none; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--muted); }
.rt-lanterns li.met .rt-val { color: var(--gold-hot); }
.rt-note { margin: 0; font-size: 12.5px; line-height: 1.4; color: var(--text); text-align: center; }
.rt-note:empty { display: none; }
.result-trial[data-status="unsaved"] .rt-note { color: var(--danger); }
@keyframes lamp-in { 0% { transform: scale(.5); opacity: .2; box-shadow: 0 0 0 rgba(var(--tk-gold-hot-rgb), 0); } 60% { transform: scale(1.15); box-shadow: 0 0 22px rgba(var(--tk-gold-hot-rgb), .9); } 100% { transform: none; opacity: 1; } }

/* Result: recap. One fact stays visible; the rest is a disclosure. */
.recap-insight {
  margin: 0; padding: 8px 12px; border-radius: 12px; font-size: 13px; line-height: 1.4; color: var(--ivory); text-align: left;
  background: rgba(3, 6, 20, .45); border-left: 2px solid var(--gold);
}
.recap { border: 1px solid var(--line-soft); border-radius: 14px; background: rgba(3, 6, 20, .35); text-align: left; }
.recap > summary {
  min-height: 44px; display: flex; align-items: center; justify-content: space-between; padding: 0 14px; cursor: pointer; list-style: none;
  font-size: 11px; font-weight: 600; letter-spacing: .18em; text-transform: uppercase; color: var(--gold);
}
.recap > summary::-webkit-details-marker { display: none; }
/* v0.18: the Details disclosure uses an inline chevron (css/result-v018.css); no "+" glyph above OK. */
.recap-body { display: flex; flex-direction: column; gap: 10px; padding: 0 12px 12px; }
.recap-chart { margin: 0; display: flex; flex-direction: column; gap: 4px; }
.recap-svg { width: 100%; height: auto; display: block; }
.recap-svg .rc-surge { fill: rgba(var(--tk-line-rgb), .08); }
.recap-svg .rc-axis { stroke: var(--line); stroke-width: 1; }
.recap-svg .rc-mid { stroke: var(--line); stroke-width: 1; stroke-dasharray: 3 3; }
.recap-svg polyline { fill: none; stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.recap-svg .rc-me { stroke: var(--team); }
.recap-svg .rc-opp { stroke: var(--opp); opacity: .85; stroke-dasharray: 5 3; }
.recap-cap { font-size: 11.5px; color: var(--muted); line-height: 1.35; }
.recap-phases { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.rp-phase { padding: 6px 8px; border-radius: 10px; background: rgba(255, 255, 255, .03); border: 1px solid rgba(var(--tk-line-rgb), .1); }
.rp-phase dt { font-size: 10px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.rp-phase dd { margin: 2px 0 0; font-size: 13px; font-weight: 600; color: var(--ivory); font-variant-numeric: tabular-nums; }
.recap-moments { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; line-height: 1.4; color: var(--text); }
.recap-tip { margin: 0; font-size: 12.5px; line-height: 1.4; color: var(--gold-hot); }
/* Rematch / Try again stay reachable while the card scrolls (360x640). */
.result-actions {
  position: sticky; bottom: 0; z-index: 1;
  margin: 0 -18px calc(-16px - var(--safe-bottom)); padding: 8px 18px calc(16px + var(--safe-bottom));
  background: linear-gradient(0deg, #090d26 70%, rgba(9, 13, 38, 0));
}
.result-card.lose .result-actions { background: linear-gradient(0deg, #080b20 70%, rgba(8, 11, 32, 0)); }

/* ---------- Decks (v0.9) ----------
   Cards tab deck builder (#deck-slots, .deck-presets, .ci-toggle), the Battle
   deck summary, the hand's new cards, the countdown loadout telegraph, the
   Beacon timer chip and the connection states. Built by main.js. */
/* Cards tab intro: short, on a dark backing so it reads over the bright key art. */
.deck-ic { width: 18px; height: 18px; color: var(--gold-hot); flex: none; }
.deck-summary {
  display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 6px 12px; border-radius: 12px; cursor: pointer;
  border: 1px solid var(--line-soft); background: rgba(3, 6, 20, .45); color: var(--ivory); font: inherit; text-align: left;
}
.deck-summary:hover { border-color: var(--line); }
.deck-summary .ds-label { font-size: 10px; font-weight: 600; letter-spacing: .2em; text-transform: uppercase; color: rgba(var(--tk-gold-rgb), .78); }
.deck-summary .ds-name { font-family: var(--display); font-weight: 500; font-size: 17px; color: var(--ivory); }
.deck-summary .ds-icons { display: flex; gap: 4px; margin-left: auto; }
.deck-presets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.preset {
  display: flex; flex-direction: column; gap: 2px; min-height: 44px; padding: 8px 10px; border-radius: 12px; cursor: pointer; text-align: left;
  border: 1px solid var(--line-soft); background: rgba(3, 6, 20, .45); color: var(--muted); font: inherit;
}
.preset b { font-family: var(--display); font-weight: 500; font-size: 17px; color: var(--ivory); }
.preset span { font-size: 11.5px; line-height: 1.3; }
.preset:hover { border-color: var(--line); }
.preset[aria-pressed="true"] { border-color: rgba(var(--tk-line-strong-rgb), .6); background: linear-gradient(180deg, rgba(46, 56, 112, .95), rgba(24, 31, 70, .95)); color: var(--text); }
.deck-slots { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.deck-slots .slot {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; min-height: 84px; padding: 8px 4px; border-radius: 14px;
  border: 1px solid var(--line-soft); background: linear-gradient(180deg, rgba(var(--tk-glass-hi-rgb), .82), rgba(8, 11, 30, .86));
}
.deck-slots .slot.empty { border-style: dashed; background: rgba(3, 6, 20, .35); justify-content: center; }
.deck-slots .slot .deck-ic { width: 30px; height: 30px; margin-top: 8px; }
.deck-slots .slot-key { position: absolute; top: 5px; left: 8px; font-size: 10px; font-weight: 600; color: var(--muted); }
.deck-slots .slot-name { font-size: 10.5px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--ivory); }
.deck-slots .slot.empty .slot-name { color: var(--muted); }
.slot-remove {
  position: absolute; top: 0; right: 0; min-width: 44px; min-height: 44px; border: 0; background: transparent; cursor: pointer;
  color: var(--muted); font-size: 13px; border-radius: 0 14px 0 14px;
}
.slot-remove:hover { color: var(--ivory); }
.deck-status { margin: 0; font-size: 12.5px; line-height: 1.45; color: var(--text); }
.deck-status:empty { display: none; }
.deck-status[data-kind="saved"] { color: var(--gold-hot); }
.deck-status[data-kind="session"], .deck-status[data-kind="offline"], .deck-status[data-kind="incomplete"] { color: var(--gold); }
.deck-status[data-kind="unsaved"] { color: var(--danger); }
.collection-title { margin: 6px 0 0; font-family: var(--display); font-weight: 500; font-size: 20px; color: var(--ivory); }
.ci-kind { font-family: var(--font); font-size: 10px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.card[data-card="gleaner"] { background: radial-gradient(120% 70% at 50% 0%, rgba(214, 180, 96, .22), transparent 70%), linear-gradient(180deg, #2a2440, #0d0b24); }
.card[data-card="beacon"] { background: radial-gradient(120% 70% at 50% 0%, rgba(255, 214, 140, .26), transparent 70%), linear-gradient(180deg, #2c2a48, #0c0d26); }
.hand.offline .card { filter: saturate(.2) brightness(.55); cursor: not-allowed; }
.hand.offline .card[aria-pressed="true"] { transform: none; }
.ri-decks { display: flex; flex-direction: column; gap: 3px; margin-top: 4px; }
.ri-deck { display: flex; align-items: center; justify-content: center; gap: 5px; }
.ri-deck .rd-who { min-width: 3.4em; font-size: 10px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); text-align: right; }
.boost-chip {
  position: absolute; left: 10px; top: 10px; z-index: 3; pointer-events: none; max-width: calc(100% - 76px);
  padding: 5px 12px; border-radius: 999px; font-size: 11.5px; font-weight: 600; letter-spacing: .04em; font-variant-numeric: tabular-nums;
  color: var(--gold-hot); background: rgba(6, 10, 30, .92); border: 1px solid var(--line); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.net-status {
  margin: 0; padding: 8px 12px; border-radius: 12px; font-size: 12.5px; line-height: 1.4; text-align: center;
  color: var(--gold-hot); background: rgba(3, 6, 20, .6); border: 1px solid var(--line);
}

/* ---------- responsive ---------- */
/* Short phones: tighten the home column and the hand so the board keeps room. */
@media (max-height: 760px) {
  .deck-summary { min-height: 40px; padding: 4px 12px; }
  .battle { gap: 10px; }
  .brand-crest { margin-bottom: 2px; }
}
@media (max-height: 680px) {
  .deck-summary { min-height: 36px; padding: 2px 10px; }
  .deck-summary .ds-label { display: none; }
  .card { min-height: 72px; }
  .card svg { width: 34px; height: 34px; margin-top: 6px; }
  .card .portrait { width: 44px; height: 44px; }
  .shell-head { min-height: 56px; padding-top: calc(6px + var(--safe-top)); }
  .tab { min-height: 50px; }
  .focus-row { margin-bottom: 7px; }
  .score b { font-size: 26px; }
  .clock { font-size: 21px; min-width: 70px; }
  .btn.big { min-height: 50px; }
  .result-card { gap: 7px; padding: 12px 14px calc(12px + var(--safe-bottom)); }
  .result-card h2 { font-size: 36px; }
  .result-progress { padding: 8px 12px 7px; gap: 2px; }
  .rp-medal { width: 36px; height: 36px; }
  .rp-icon { width: 20px; height: 20px; }
  .rp-line b { font-size: 30px; }
  .stats { font-size: 12px; }
  .stats th { padding-bottom: 3px; }
  .stats td { padding: 3px 6px; }
  #rematch-status { font-size: 12.5px; }
  .result-actions .btn.big { min-height: 48px; font-size: 19px; }
  .result-actions .btn:not(.primary) { min-height: 44px; font-size: 14px; padding: 8px 10px; }
  .result-actions { margin: 0 -14px calc(-12px - var(--safe-bottom)); padding: 6px 14px calc(12px + var(--safe-bottom)); }
  .result-trial { padding: 8px 10px; gap: 4px; }
  .rt-lanterns li { min-height: 20px; font-size: 12px; }
  .result-score { --rs-num: 38px; }
  .result-crest { display: none; }
}
/* Very short viewports (landscape phones, 200% zoom): drop the ornament, keep every control; the panel scrolls. */
@media (max-height: 480px) {
  .brand-crest { display: none; }
  h1 { font-size: 22px; }
  .shell-head { min-height: 52px; padding-top: calc(4px + var(--safe-top)); padding-bottom: 2px; }
  .tab { min-height: 46px; flex-direction: row; gap: 6px; }
  .tab::before { display: none; }
  .tab svg { width: 20px; height: 20px; }
}
@media (min-width: 700px) {
  .hud-tools { right: -56px; top: 8px; }
}
/* Desktop: the key art fills the window, the controls take a composed left
   column over the dark figure side, and the tabs become a floating dock. */
@media (min-width: 900px) and (min-height: 560px) {
  .keyart-img { object-position: 60% 12%; }
  .keyart-veil {
    background:
      linear-gradient(90deg, rgba(4, 7, 22, .92) 0%, rgba(4, 7, 22, .78) 30%, rgba(4, 7, 22, .2) 58%, rgba(4, 7, 22, 0) 75%),
      linear-gradient(180deg, rgba(4, 7, 22, .5) 0%, rgba(4, 7, 22, 0) 18%, rgba(4, 7, 22, 0) 70%, rgba(4, 7, 22, .7) 100%);
  }
  .shell { width: 440px; margin: 0 0 0 max(40px, 7vw); padding-bottom: 18px; }
  .shell-head { padding-left: 16px; padding-right: 16px; min-height: 76px; }
  .battle { justify-content: center; }
  .battle > :first-child { margin-top: auto; }
  .battle > :last-child { margin-bottom: auto; }
  .brand { align-items: flex-start; text-align: left; }
  .brand-crest { margin-left: -2px; }
  h1 { font-size: 40px; padding-left: 0; }
  .tabbar { margin: 0 16px; border: 1px solid var(--line-soft); border-radius: 18px; padding: 4px 8px; background: rgba(5, 8, 24, .72); }
}

/* ---------- v0.10: first session ----------
   Computer training (#tutor, #tutor-done, #tutor-pointer, .tut-want), its
   routes (Battle, Cards, Journey, Help) and first-Quick-Play offer, result
   landing and the road to the next title, deck and Journey polish, and
   landscape safe areas. Same Nocturne porcelain palette; no new fonts. */
:root {
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}
.shell-head { padding-left: calc(12px + var(--safe-left)); }
.tab-panel { padding-left: calc(16px + var(--safe-left)); padding-right: calc(16px + var(--safe-right)); }
.hud { padding-left: calc(12px + var(--safe-left)); padding-right: calc(12px + var(--safe-right)); }
.hand { padding-left: calc(10px + var(--safe-left)); padding-right: calc(10px + var(--safe-right)); }

/* Battle: one clear primary action, then two routes side by side. */
.brand-note {
  margin: 6px 0 0; display: inline-flex; align-items: center; gap: 8px; padding: 3px 12px; border-radius: 999px;
  font-size: 10.5px; font-weight: 600; letter-spacing: .18em; text-transform: uppercase; color: var(--gold-hot);
  background: rgba(4, 7, 22, .55); border: 1px solid var(--line-soft);
}
#btn-practice { font-size: 23px; letter-spacing: .06em; }

/* First Quick Play: the training offer (dialog#training-offer). */
.offer-card { gap: 12px; }
.offer-art { display: flex; justify-content: center; gap: 10px; padding: 8px 0 2px; color: var(--gold-hot); }
.offer-art svg {
  width: 46px; height: 46px; padding: 6px; border-radius: 50%;
  background: radial-gradient(circle at 50% 32%, rgba(64, 76, 140, .55), rgba(6, 9, 26, .95) 72%);
  box-shadow: inset 0 0 0 1px rgba(var(--tk-line-strong-rgb), .5), 0 6px 14px rgba(0, 0, 0, .35);
}
.offer-text { margin: 0; font-size: 14.5px; line-height: 1.5; color: var(--text); }
.offer-text b { color: var(--ivory); }
.offer-actions { display: grid; gap: 8px; }
.offer-fine { font-size: 12px; text-align: center; }

.help-training {
  display: flex; flex-direction: column; gap: 8px; margin: 0 0 12px; padding: 10px 12px; border-radius: 14px;
  background: linear-gradient(180deg, rgba(var(--tk-seat0-rgb), .14), rgba(3, 6, 20, .4)); border: 1px solid var(--line-soft);
}
.help-training p { margin: 0; font-size: 13.5px; line-height: 1.45; color: var(--text); }
.help-training b { color: var(--ivory); }

/* Journey: the training line. */
.training-status { margin: 0; font-size: 13px; line-height: 1.45; color: var(--text); }
.training-status[data-state="done"] { color: #bff3e3; }
.training-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.training-actions .btn { min-height: 44px; font-size: 14px; padding: 8px 10px; }

/* In the match: the lesson card has its own row between HUD and board. */
.tutor {
  position: relative; z-index: 2; flex: none; display: grid; grid-template-columns: auto 1fr auto; gap: 4px 10px; align-items: start;
  padding: 8px calc(10px + var(--safe-right)) 9px calc(12px + var(--safe-left));
  background:
    radial-gradient(90% 140% at 0% 0%, color-mix(in srgb, var(--team) 20%, transparent), transparent 60%),
    linear-gradient(180deg, rgba(14, 19, 46, .98), rgba(7, 10, 28, .98));
  border-bottom: 1px solid var(--line); box-shadow: 0 8px 18px rgba(0, 0, 0, .4);
  animation: tutor-in .35s var(--ease);
}
.tutor-steps { display: flex; flex-direction: column; gap: 5px; padding-top: 4px; }
.tutor-steps i {
  display: block; width: 8px; height: 8px; border-radius: 50%; border: 1px solid var(--line-strong); background: rgba(3, 6, 20, .6);
}
.tutor-steps i.done { background: var(--gold); border-color: var(--gold-hot); }
.tutor-steps i.now { background: var(--gold-hot); border-color: #fff4d2; box-shadow: 0 0 10px rgba(var(--tk-gold-hot-rgb), .9); }
.tutor-body { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.tutor-kicker {
  margin: 0; display: flex; align-items: center; gap: 8px; min-width: 0; white-space: nowrap;
  font-size: 10.5px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--gold);
}
.tutor-count { font-variant-numeric: tabular-nums; letter-spacing: .08em; color: var(--ivory-2); }
.tutor-state { flex: none; color: var(--team-light); white-space: nowrap; }
.tutor[data-phase="try"] .tutor-state::before {
  /* a small pause glyph: two bars */
  content: ""; display: inline-block; width: 3px; height: 8px; margin-right: 6px;
  border-left: 2px solid currentColor; border-right: 2px solid currentColor;
}
.tutor-title { margin: 0; font-family: var(--display); font-weight: 500; font-size: 19px; line-height: 1.15; color: var(--ivory); }
.tutor-text { margin: 0; font-size: 13px; line-height: 1.4; color: var(--text); }
.tutor-hint {
  margin: 0; font-size: 13px; line-height: 1.4; font-weight: 600; color: var(--gold-hot);
  padding-left: 8px; border-left: 2px solid var(--gold-hot); animation: hint-in .25s var(--ease);
}
.tutor.has-hint .tutor-text { display: none; }
.tutor-skip {
  flex: none; min-width: 64px; min-height: 44px; padding: 0 14px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: rgba(255, 255, 255, .04); color: var(--ivory-2);
  font-weight: 600; font-size: 13px; letter-spacing: .04em;
}
.tutor-skip:hover { border-color: var(--line-strong); color: var(--gold-hot); }
.tutor .ai-badge { color: var(--tk-jade-text); border-color: rgba(var(--tk-jade-text-rgb), .55); background: rgba(var(--tk-seat0-rgb), .14); }
.clock.paused { box-shadow: 0 0 0 3px rgba(4, 7, 22, .7), 0 0 0 4px rgba(var(--tk-jade-text-rgb), .7), 0 0 18px rgba(120, 230, 200, .35); }
/* The old first-match tip never shows in training (main.js also keeps it off). */
body.tutoring #coach { display: none !important; }

/* Hand spotlight: the lesson's card glows; the others stay usable but quiet. */
.hand.tut-try .card:not(.tut-want) { opacity: .5; filter: saturate(.45) brightness(.8); }
.card.tut-want {
  border-color: var(--gold-hot);
  box-shadow: inset 0 1px 0 rgba(255, 240, 210, .12), 0 0 0 1px var(--gold-hot), 0 0 0 4px color-mix(in srgb, var(--team) 60%, transparent), 0 0 30px rgba(255, 224, 160, .45);
  animation: want 1.5s var(--ease) infinite;
}
.card.tut-want::after {
  content: "Try"; position: absolute; left: 50%; top: -11px; transform: translateX(-50%); padding: 1px 8px; border-radius: 999px;
  font-size: 9.5px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: var(--tk-gilt-ink); background: var(--gold-hot);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .45);
}
.card.tut-want[aria-pressed="true"]::after { content: "Now a lane"; }
.card.tut-want[aria-pressed="true"] { animation: none; }

/* "Tap here" at the lesson's lane: decoration only, never a target. */
.tutor-pointer {
  position: absolute; z-index: 3; pointer-events: none; transform: translate(-50%, -100%);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.tutor-pointer span {
  padding: 3px 10px; border-radius: 999px; font-size: 10.5px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  color: var(--tk-gilt-ink); background: linear-gradient(180deg, var(--tk-gilt-hi), var(--tk-gilt-lo)); box-shadow: 0 4px 12px rgba(0, 0, 0, .5), 0 0 16px rgba(255, 214, 140, .5);
  white-space: nowrap;
}
.tutor-pointer::after {
  content: ""; width: 0; height: 0; border: 7px solid transparent; border-top-color: var(--tk-gilt-lo); margin-top: -1px;
}
.tutor-pointer { animation: bob 1.2s ease-in-out infinite; }

/* Scene complete: a small result card over the (finished, frozen) board. */
.tutor-done {
  position: absolute; inset: 0; z-index: 6; display: grid; place-items: center; padding: 14px;
  background: radial-gradient(70% 50% at 50% 45%, rgba(4, 7, 22, .45), rgba(3, 5, 16, .8));
}
.tutor-done-card {
  width: min(380px, 100%); max-height: 100%; overflow-y: auto; display: flex; flex-direction: column; gap: 9px; text-align: center;
  padding: 18px 18px 16px; border-radius: 22px; border: 1px solid var(--line);
  background: radial-gradient(110% 55% at 50% 0%, rgba(120, 230, 200, .14), transparent 62%), linear-gradient(180deg, #141b40, #090d26);
  box-shadow: 0 30px 60px rgba(0, 0, 0, .6), inset 0 1px 0 rgba(255, 240, 210, .08);
  animation: rise .4s var(--ease);
}
.tutor-done-card h2 {
  margin: 0; font-family: var(--display); font-weight: 500; font-size: 34px; line-height: 1.05;
  background: linear-gradient(180deg, #fff8e4 10%, #f1d593 55%, #c99c4c 95%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.tutor-done-lamps { list-style: none; margin: 2px 0; padding: 0; display: flex; justify-content: center; gap: 12px; }
.tutor-done-lamps li {
  width: 18px; height: 24px; border-radius: 8px 8px 4px 4px; border: 1px solid var(--gold-hot);
  background: radial-gradient(circle at 50% 55%, #fff4d2, var(--gold) 60%, var(--gold-deep)); box-shadow: 0 0 12px rgba(var(--tk-gold-hot-rgb), .6);
  animation: lamp-in .8s var(--ease) both; animation-delay: calc(var(--i, 0) * 140ms);
}
.tutor-done-text { margin: 0; font-size: 14px; line-height: 1.5; color: var(--text); }
.tutor-done-save:empty { display: none; }
.tutor-done-actions { display: grid; gap: 8px; margin-top: 4px; }

/* Result: the score lands, a win lights up, the road fills. */
.result-card.landed .rs b { animation: score-land .7s cubic-bezier(.2, 1.4, .4, 1) both; }
.result-card.landed .rs.opp b { animation-delay: .12s; }
.result-card.landed h2 { animation: title-land .6s var(--ease) both; }
.result-card.win.landed::after {
  content: ""; position: absolute; left: 50%; top: 40px; width: 240px; height: 240px; margin-left: -120px; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, rgba(255, 228, 160, .38), rgba(255, 228, 160, 0) 65%);
  animation: burst 1.4s var(--ease) both;
}
.rp-road { position: relative; width: min(240px, 90%); height: 6px; border-radius: 999px; background: rgba(255, 255, 255, .06); box-shadow: inset 0 0 0 1px rgba(var(--tk-line-rgb), .25); overflow: hidden; }
.rp-road i {
  position: absolute; inset: 0; transform-origin: left; transform: scaleX(var(--p, 0)); border-radius: inherit;
  background: linear-gradient(90deg, var(--tk-gold-deep), #e2c07a 70%, var(--tk-gilt-hi)); box-shadow: 0 0 10px rgba(245, 214, 150, .6);
  transition: transform 1.1s var(--ease) .35s;
}

/* Journey: the road reads as a goal. */
.journey .road-bar { height: 8px; }
.road-next { font-family: var(--display); font-size: 16px; font-weight: 500; letter-spacing: .01em; }
.road-list li.current { background: linear-gradient(90deg, rgba(var(--tk-line-rgb), .12), transparent); border-radius: 8px; }

/* Cards: slots carry their cost; the collection marks what is in the deck. */
.deck-slots .slot-cost {
  position: absolute; top: -7px; left: 50%; transform: translateX(-50%); width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center; font: 500 14px/1 var(--display); color: var(--tk-gilt-ink); font-variant-numeric: lining-nums;
  background: radial-gradient(circle at 35% 28%, #fff8e2, #e6c77f 58%, #a88035); border: 1px solid #f8e8bd;
  box-shadow: 0 0 0 2px rgba(4, 7, 22, .7);
}
.deck-slots .slot.filled { border-color: var(--line); box-shadow: inset 0 1px 0 rgba(255, 240, 210, .06), 0 6px 14px rgba(0, 0, 0, .3); }

@keyframes tutor-in { from { transform: translateY(-8px); opacity: 0; } }
@keyframes hint-in { from { transform: translateX(-6px); opacity: 0; } }
@keyframes want { 50% { box-shadow: inset 0 1px 0 rgba(255, 240, 210, .12), 0 0 0 1px var(--gold-hot), 0 0 0 5px color-mix(in srgb, var(--team) 70%, transparent), 0 0 40px rgba(255, 224, 160, .6); } }
@keyframes bob { 50% { transform: translate(-50%, calc(-100% - 6px)); } }
@keyframes score-land { 0% { transform: scale(1.8); opacity: 0; filter: blur(3px); } 100% { transform: none; opacity: 1; filter: none; } }
@keyframes title-land { 0% { transform: translateY(10px) scale(.94); opacity: 0; letter-spacing: .12em; } 100% { transform: none; opacity: 1; } }
@keyframes burst { 0% { transform: scale(.3); opacity: 0; } 35% { opacity: 1; } 100% { transform: scale(1.35); opacity: 0; } }

@media (max-height: 820px) {
  .brand-note { display: none; }
}
@media (max-height: 700px) {
  .tutor { padding-top: 6px; padding-bottom: 7px; }
  .tutor-title { font-size: 16px; }
  .tutor-text, .tutor-hint { font-size: 12.5px; line-height: 1.35; }
}
@media (max-height: 680px) {
  #btn-practice { font-size: 21px; }
}

@media (max-width: 699px) {
  body.tutoring .hud-tools { top: calc(100% + 6px + var(--tutor-h, 0px)); }
}
.card.tut-want.pending::after { display: none; }

/* ---------- v0.10: startup ----------
   #app is inert until main.js has bound its controls; a small status shows
   meanwhile, and after 6 s boot.js adds a Reload (body[data-boot="slow"]). */
body[data-boot="loading"] { cursor: progress; }
.boot-status {
  position: fixed; left: 50%; bottom: calc(18px + var(--safe-bottom)); transform: translateX(-50%); z-index: 60;
  display: flex; flex-direction: column; align-items: center; gap: 8px; max-width: calc(100% - 32px);
  padding: 10px 16px; border-radius: 14px; text-align: center; font-size: 13.5px; line-height: 1.4; color: var(--ivory);
  background: rgba(6, 10, 30, .92); border: 1px solid var(--line); box-shadow: 0 12px 28px rgba(0, 0, 0, .5);
}
body[data-boot="ready"] .boot-status:not(.noscript) { display: none; }
.boot-slow { display: none; }
body[data-boot="slow"] .boot-slow { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; }
body[data-boot="slow"] .boot-text { display: none; }
.boot-slow .btn { min-height: 44px; }
/* No JavaScript: only the noscript message, never an endless "Loading". */
@media (scripting: none) { .boot-status:not(.noscript) { display: none; } }

/* ---------- UX2/bal: side-stable team colours (flag OFF; opt in with body.cb-team) ----------
   Self is always azure, the opponent always amber, whatever the seat. Colour is
   never the only cue: self = solid circle with a light ring, opponent = diamond
   with diagonal hatching. HUD/result/lobby only: canvas units stay seat-coloured
   until render.js/sprites.js map THEME.teams by side (see UX2/bal HANDOFF). */
body.cb-team, body.cb-team[data-seat] {
  --self: #3f9bff; --self-dark: #1f5fa8; --self-light: #b5d8ff;
  --foe: var(--tk-seat1); --foe-dark: var(--tk-seat1-dark); --foe-light: var(--tk-seat1-light);
  --team: var(--self); --team-dark: var(--self-dark); --team-light: var(--self-light); --opp: var(--foe);
}
body.cb-team[data-seat] .score.me .emblem, body.cb-team[data-seat] .rs.me .emblem, body.cb-team .seat.you .emblem {
  border-radius: 50%; transform: none; background: var(--self);
  box-shadow: 0 0 0 2px rgba(4, 7, 22, .5), 0 0 0 3.5px var(--self-light);
}
body.cb-team[data-seat] .score.opp .emblem, body.cb-team[data-seat] .rs.opp .emblem, body.cb-team .seat:not(.you) .emblem {
  border-radius: 0; transform: rotate(45deg) scale(.85);
  background: repeating-linear-gradient(0deg, var(--foe) 0 2px, var(--foe-dark) 2px 4px);
}
