/* BEGIN GENERATED BRANDING — run node scripts/sync-branding.mjs */
/* Official UI palette. See docs/art/branding.md. */
/* The display face (ADR 0158). Only the table's host serves the file; a page opened elsewhere falls back to the
   serif named after it in --font-display. */
@font-face {
  font-family: "Marcellus";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/marcellus-latin-400.woff2') format('woff2');
}
:root {
  color-scheme: dark;
  --brand-slate: #0b1519;
  --brand-panel: #132228;
  --brand-raised: #1c2a2d;
  --brand-line: #52636b;
  --brand-ivory: #ece9dc;
  --brand-muted: #adb8bd;
  --brand-gold: #e7c183;
  --brand-gold-bright: #ffe2a6;
  --brand-ember: #d39c85;
  --brand-wash: #352e25;
  --brand-on-accent: #0b1519;
  --brand-soot: #070d10;
  --brand-bone: #d8c7a7;
  --brand-line-soft: #2a3a41;
  --ink: var(--brand-ivory);
  --muted: var(--brand-muted);
  --paper: var(--brand-slate);
  --paper-glass: rgb(11 21 25 / 94%);
  --panel: var(--brand-panel);
  --card: var(--brand-panel);
  --raised: var(--brand-raised);
  --sunken: var(--brand-raised);
  --line: var(--brand-line);
  --gold: var(--brand-gold);
  --accent: var(--brand-gold);
  --accent-ink: var(--brand-on-accent);
  --accent-wash: var(--brand-wash);
  --accent-strong: var(--brand-gold-bright);
  --soot: var(--brand-soot);
  --bone: var(--brand-bone);
  --line-soft: var(--brand-line-soft);
  /* Bone and soot (ADR 0158): carved capitals for titles, sharp corners, one cut corner on what matters. */
  --font-display: "Marcellus", "Trajan Pro", Georgia, serif;
  --font-text: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius-sharp: 2px;
  --radius-soft: 3px;
  --cut: 12px;
  /* Bone grain and soot smudges, drawn by the browser from two small SVG filters: no image to serve. */
  --tex-grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .85 0 0 0 0 .78 0 0 0 0 .65 0 0 0 .17 0'/%3E%3C/filter%3E%3Crect width='220' height='220' filter='url(%23n)'/%3E%3C/svg%3E");
  --tex-soot: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='700' height='700'%3E%3Cfilter id='s' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.008' numOctaves='4' seed='7' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .01 0 0 0 0 .02 0 0 0 0 .03 2.4 0 0 0 -.95'/%3E%3C/filter%3E%3Crect width='700' height='700' filter='url(%23s)'/%3E%3C/svg%3E");
  /* The rule under a title: the rune, then a bone hairline that fades out. */
  --tex-rule: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='104 30 282 440'%3E%3Cg fill='%23d8c7a7'%3E%3Cpath d='M119 170 254 41 209 145 371 241 319 300 280 269 291 258Z'/%3E%3Cpath d='M164 215 304 307 244 338 299 373 267 459 171 341 231 277Z'/%3E%3C/g%3E%3C/svg%3E");
  /* Semantic colours are independent of the brand accents. */
  --ally: #96ccb0;
  --enemy: #e3a29a;
  --refused: #ffb3a7;
  --ok: #96ccb0;
  --ok-wash: #20382d;
  --warn: #e7c183;
  --warn-wash: #352e25;
  --bad: #ffb3a7;
  --bad-wash: #392622;
  --health: #96ccb0;
  --health-low: #ffb3a7;
  --player1: #8bc6ed;
  --player2: #e3a29a;
  --chart-above: #8bc6ed;
  --chip-bg: #29303f;
  --chip-ink: #d4c5ef;
}
/* END GENERATED BRANDING */
/* Slate surfaces, warm paper cards and one eclipse-gold action. Layout never determines game rules. */
:root {
  color-scheme: dark;
  /* Shared motion language: future effects use these tokens instead of hard-coded timings.
     Keep gameplay readable if the user requests reduced motion. */
  --motion-instant: 80ms;
  --motion-fast: 120ms;
  --motion-normal: 220ms;
  --motion-slow: 360ms;
  --motion-enter: cubic-bezier(.2, .8, .2, 1);
  --motion-exit: cubic-bezier(.4, 0, 1, 1);
  --motion-standard: cubic-bezier(.2, 0, 0, 1);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; padding: 0 32px 32px; color: var(--ink); background: radial-gradient(ellipse at 40% 0, var(--raised) 0, transparent 65%), var(--paper); min-height: 100dvh; }
h1, h2, p { margin: 0; }
h1 { font-family: var(--font-display); font-size: 25px; font-weight: 400; }
h2 { font-size: 14px; font-weight: 650; }
button, textarea { font: inherit; }
button { min-height: 44px; border: 1px solid var(--line); border-radius: var(--radius-soft); padding: 11px 14px; background: var(--raised); color: var(--ink); cursor: pointer; text-align: left; }
button:hover:not(:disabled), [role="button"]:hover { border-color: var(--gold); }
button:disabled { opacity: 0.5; cursor: default; }
button:focus-visible, [tabindex]:focus-visible, summary:focus-visible, textarea:focus-visible { outline: 3px solid var(--gold); outline-offset: 4px; }
button, [role="button"] { touch-action: manipulation; }
.muted { color: var(--muted); font-size: 12px; line-height: 1.6; }
.eyebrow { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: 1.8px; font-weight: 650; }
.masthead { max-width: 1500px; margin: auto; min-height: 108px; display: flex; align-items: center; gap: 28px; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 15px; }
.brand-mark, .pass-emblem { color: var(--gold); border: 1px solid var(--brand-ember); width: 43px; height: 49px; display: grid; place-items: center; font: 31px var(--font-display); border-radius: 12px 3px; }
.brand-mark { background: url('/brand-mark.svg') center / contain no-repeat; border: 0; border-radius: 0; flex: 0 0 auto; }
.brand .eyebrow { display: block; margin-bottom: 4px; }
.session-state { margin-left: auto; text-align: right; }
.waiting-room { margin: 10px 0 0; display: grid; gap: 8px; }
.waiting-seat { border: 1px solid var(--line); border-radius: var(--radius-soft); padding: 10px 12px; background: var(--raised); }
.waiting-code { font-size: 20px; letter-spacing: 3px; color: var(--gold); }
.waiting-seat a { color: var(--gold); }
.admin-link { display: inline-block; margin-top: 6px; padding: 4px 10px; border: 1px solid var(--gold); border-radius: var(--radius-soft); color: var(--gold); text-decoration: none; font-size: 12px; letter-spacing: 1px; text-transform: uppercase; }
.seat-label { color: var(--gold); font-size: 12px; }
#phase { margin-top: 5px; font-size: 13px; }
.versus-line { margin-top: 4px; font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
#shape { position: relative; z-index: 30; font-size: 12px; }
summary { cursor: pointer; min-height: 44px; padding: 13px 0; }
.guide-body { position: absolute; right: 0; top: 45px; width: 310px; padding: 20px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-soft); box-shadow: 0 15px 40px #0008; z-index: 5; line-height: 1.8; max-height: min(680px, 75dvh); overflow-y: auto; overscroll-behavior: contain; }
.guide-body ol, .guide-body ul { padding-left: 20px; }
#table { max-width: 1500px; margin: 24px auto 0; display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 28px; align-items: start; }
.play-area, .action-area, #board, .team-section, .hand-section { min-width: 0; }
.tabs { display: flex; gap: 5px; align-items: center; margin-bottom: 26px; border-bottom: 1px solid var(--line); }
.tab { border: 0; border-radius: 0; background: transparent; color: var(--muted); padding: 13px 18px; border-bottom: 2px solid transparent; }
.tab.on { color: var(--gold); border-bottom-color: var(--gold); }
.table-caption { color: var(--muted); font: italic 13px var(--font-display); margin-left: auto; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 13px; }
.section-heading h2 { display: flex; align-items: center; gap: 8px; }
.side-dot { width: 7px; height: 7px; border-radius: 50%; }
.enemy-dot { background: var(--enemy); }.ally-dot { background: var(--ally); }
.team-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr)); gap: 12px; }
.creature { position: relative; padding: 16px; background: linear-gradient(140deg, var(--raised), var(--panel)); border: 1px solid var(--line); border-top: 2px solid var(--ally); border-radius: var(--radius-soft); font-variant-numeric: tabular-nums; }
.creature.enemy { border-color: #614a44; border-top-color: var(--enemy); background: linear-gradient(140deg, #322c27, #221f1d); }
.creature.dead { opacity: 0.55; }
.creature.active { box-shadow: 0 0 0 2px var(--gold); }
.who { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; }
.creature-id { display: grid; place-items: center; min-width: 33px; height: 33px; padding: 4px; background: #ffffff0a; border: 1px solid #ffffff25; border-radius: var(--radius-soft); color: var(--ally); font-weight: 750; }
.enemy .creature-id { color: var(--enemy); }
.creature-name { font-size: 15px; font-weight: 650; overflow-wrap: anywhere; }
.creature-label { font-size: 10px; color: var(--muted); display: block; margin-top: 3px; letter-spacing: 0.4px; }
.health { position: relative; height: 24px; margin: 0 0 12px; border-radius: var(--radius-sharp); overflow: hidden; background: #050a0777; }
.health .bar { display: block; height: 100%; background: #42644f; }
.enemy .health .bar { background: #694b42; }
.health .number { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 650; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { display: flex; flex-direction: column; gap: 3px; }
.stat strong { font-size: 20px; font-weight: 550; }.stat span { font-size: 10px; text-transform: capitalize; color: var(--muted); }
.badges { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.badge, .marker { padding: 3px 7px; border: 1px solid var(--line); border-radius: var(--radius-sharp); font-size: 10px; }
.dock, .markers { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }
.dock:empty, .badges:empty { display: none; }
.dock-group { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; border: 1px dashed var(--line); padding: 4px; border-radius: var(--radius-sharp); }
.dock-rounds { color: var(--muted); font-size: 10px; }.chip { background: #ffffff0a; font-size: 11px; padding: 3px 5px; border-radius: var(--radius-sharp); }.chip-source { display: block; font-size: 10px; color: var(--muted); }
.creature.legal { cursor: pointer; border: 2px dashed var(--gold); padding: 15px; }
.creature.picked { border: 2px solid var(--gold); padding: 15px; background: var(--accent-wash); }
.marker.picked { background: var(--gold); color: var(--accent-ink); border-color: var(--gold); }
.initiative-section { margin: 22px 0; padding: 15px 18px; border: 1px solid var(--line); border-radius: var(--radius-soft); background: #0a120e55; }
.initiative-section .section-heading { margin-bottom: 10px; }.initiative-section h2 { font-size: 12px; color: var(--muted); }
.strip { display: flex; gap: 20px; overflow-x: auto; padding: 2px 2px 5px; scrollbar-width: thin; }
.strip:empty::before { content: 'The order appears after tempo selection.'; font-size: 12px; color: var(--muted); }
.band { flex: none; display: flex; gap: 9px; align-items: center; }.band-name { color: var(--muted); font-size: 11px; }.slots { display: flex; gap: 6px; }
.slot { flex: none; padding: 7px 10px; border-radius: var(--radius-sharp); border: 1px solid var(--line); font-size: 12px; }.slot.ally { color: var(--ally); }.slot.enemy { color: var(--enemy); }.slot.now { color: var(--accent-ink); border-color: var(--gold); background: var(--gold); }.slot .roll { display: block; margin-top: 2px; font-size: 10px; opacity: .75; }
.hand { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin: 13px 0 25px; color: var(--muted); font-size: 11px; line-height: 1.6; }
.hand-section { border-top: 1px solid var(--line); padding-top: 20px; }.hand-section > .section-heading { align-items: baseline; }
.hand-cards { display: grid; gap: 12px; }.hand-row { min-width: 0; }.hand-row summary { padding: 13px 0; border-top: 1px solid var(--line); margin-bottom: 0; }.hand-row[open] summary { margin-bottom: 8px; }.hand-who { color: var(--muted); font-size: 11px; margin-bottom: 9px; }.hand-row.active .hand-who { color: var(--gold); font-weight: 650; }
.held-cards { display: flex; overflow-x: auto; gap: 10px; padding: 4px 3px 12px; scroll-snap-type: x proximity; scrollbar-width: thin; }
.card { display: block; padding: 15px; border-radius: var(--radius-soft); border: 1px solid #c9c4ac; background: #e8e5d7; color: #27332b; text-align: left; font: inherit; }
.card-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }.card-title { font: 400 18px var(--font-display); line-height: 1.25; }.card-meta { display: block; font: 10px ui-sans-serif, system-ui, sans-serif; margin-top: 5px; color: #546151; }
.card-cost { flex: none; width: 30px; height: 30px; display: grid; place-items: center; border: 1px solid #b3b7a4; background: #d3d8c3; border-radius: 50%; font-size: 14px; font-weight: 750; }
.card-body { margin-top: 13px; padding-top: 11px; border-top: 1px solid #c8c9b6; font-size: 11px; color: #414f41; line-height: 1.65; }.card-body div + div { margin-top: 3px; }
.held { flex: 0 0 205px; scroll-snap-align: start; background: var(--raised); border-color: var(--line); color: var(--muted); }.held .card-meta, .held .card-body { color: var(--muted); }.held .card-body { border-color: var(--line); }.held .card-cost { background: var(--raised); border-color: var(--line); }
.held:is(.castable, .reference) { background: #e8e5d7; border-color: #c9c4ac; color: #27332b; }.held:is(.castable, .reference) .card-meta, .held:is(.castable, .reference) .card-body { color: #414f41; }.held:is(.castable, .reference) .card-body { border-color: #c8c9b6; }.held:is(.castable, .reference) .card-cost { background: #d3d8c3; border-color: #b3b7a4; }
.held.offered { cursor: pointer; }.held.short.offered { border-style: dashed; border-color: #8a7a4a; }.held.short.offered .card-availability { color: #d9c27a; }.held.chosen { outline: 3px solid var(--gold); outline-offset: 0; }
.card-availability { display: block; margin-top: 12px; font-size: 10px; font-weight: 650; }

/* UX 03: make the selectable spellbook feel like cards without changing tap behavior.
   Only offered cards are interactive; reference and enemy cards stay still. */
#own-hand .held.offered {
  position: relative;
  transform-origin: center bottom;
  -webkit-tap-highlight-color: transparent;
}
/* The chosen card is marked in place, never moved: the second tap that declares it has to land where the
   first one did (the "spell rows stay put" browser test). */
#own-hand .held.offered.chosen {
  border-color: var(--gold);
  box-shadow: 0 0 0 1px var(--gold), 0 7px 22px #0005, 0 0 20px color-mix(in srgb, var(--gold) 14.9%, transparent);
}
/* Focus must remain obvious for keyboard selection, regardless of motion settings. */
#own-hand .held.offered:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}
@media (prefers-reduced-motion: no-preference) {
  #own-hand .held.offered {
    transition: border-color var(--motion-fast) var(--motion-standard),
                background-color var(--motion-fast) var(--motion-standard),
                box-shadow var(--motion-normal) var(--motion-enter),
                transform var(--motion-fast) var(--motion-enter);
  }
  #own-hand .held.offered:active {
    transform: translateY(1px) scale(.99);
  }
}
@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  #own-hand .held.offered:not(.chosen):hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 14px #0003;
  }
}

.action-area { position: sticky; top: 22px; }.sheet { padding: 22px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-soft); box-shadow: 0 15px 35px #0002; max-height: calc(100dvh - 44px); overflow-y: auto; scrollbar-width: thin; }
.decision-heading { display: flex; justify-content: space-between; gap: 10px; align-items: center; margin-bottom: 18px; }.status-tag { color: var(--gold); border: 1px solid #756443; border-radius: 99px; font-size: 10px; padding: 4px 8px; }
#asking { font: 26px/1.2 var(--font-display); margin-bottom: 20px; text-wrap: balance; }
#choices { display: grid; gap: 10px; }#choices > button:not(.card) { width: 100%; background: var(--gold); border-color: var(--gold); color: var(--accent-ink); font-weight: 650; text-align: center; }
#choices .secondary { background: transparent !important; color: var(--muted) !important; border-color: var(--line) !important; }
.creature-picker { display: flex; gap: 6px; flex-wrap: wrap; }.creature-picker button { flex: 1; text-align: center; font-size: 12px; padding: 8px; }.creature-picker .chosen { color: var(--gold); border-color: var(--gold); }
.choice-cards { display: grid; gap: 10px; }.choice-help { color: var(--muted); line-height: 1.6; font-size: 12px; }
.problem { margin-top: 12px; padding: 10px; background: #562e2a; color: var(--refused); border-radius: var(--radius-sharp); font-size: 12px; }
.revealed { border-left: 3px solid var(--gold); padding: 13px 16px; margin-bottom: 22px; background: color-mix(in srgb, var(--gold) 4.7%, transparent); font-size: 12px; line-height: 1.8; }
.band-row { border: 1px solid var(--line); border-radius: var(--radius-soft); background: var(--panel); padding: 18px; margin-bottom: 14px; }.band-row > .band-name { color: var(--gold); font-size: 14px; margin-bottom: 10px; }.mat-spell { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 0; border-top: 1px solid var(--line); font-size: 13px; }.mat-spell > span:first-child { flex: 1; }.gate { color: var(--muted); font-size: 11px; }.pip { min-width: 25px; padding: 4px; text-align: center; border: 1px solid var(--line); border-radius: var(--radius-sharp); color: var(--muted); font-size: 11px; }.pip.known { background: var(--ally); color: #18271d; border-color: var(--ally); }
#log { border-top: 1px solid var(--line); margin-top: 25px; font-size: 12px; }#log summary .muted { float: right; }#feed { padding-left: 20px; color: var(--muted); line-height: 1.7; }#feed li { padding: 6px 0; }
.notes { padding: 20px 4px 0; }.notes h2 { font-size: 12px; color: var(--muted); margin-bottom: 10px; }.note-buttons { display: flex; gap: 8px; }.notes button { flex: 1; font-size: 11px; background: transparent; color: var(--muted); }.notes label { display: block; margin: 14px 0 8px; font-size: 12px; }.notes textarea { width: 100%; border: 1px solid var(--line); border-radius: var(--radius-soft); padding: 10px; background: var(--panel); color: var(--ink); margin-bottom: 8px; }.notes #noted { margin-top: 10px; }
#pass { position: fixed; inset: 0; z-index: 100; background: var(--paper); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 13px; padding: 25px; text-align: center; }.pass-emblem { width: 65px; height: 76px; font-size: 45px; margin-bottom: 20px; }.pass-line { color: var(--muted); margin-top: 10px; }.pass-seat { font: 50px var(--font-display); }#pass-ready { background: var(--gold); color: var(--accent-ink); border: 0; min-width: 250px; text-align: center; font-weight: 650; margin-top: 20px; }#pass-ready > span:last-child { margin-left: 12px; }
@media (min-width: 1600px) { :root { font-size: 15px; } #table { grid-template-columns: minmax(0, 1fr) 380px; gap: 36px; } }
@media (max-width: 1000px) {
  body { padding: 0 18px 24px; }.masthead { gap: 18px; }#table { grid-template-columns: minmax(0, 1fr) 290px; gap: 18px; }.sheet { padding: 17px; }.team-grid { grid-template-columns: 1fr; }.creature { padding: 13px; }.who { margin-bottom: 10px; }.stats { grid-template-columns: repeat(3, 1fr); }.table-caption { display: none; }
}
@media (max-width: 760px) {
  body { padding: 0 14px max(16px, env(safe-area-inset-bottom)); }.masthead { flex-wrap: wrap; gap: 10px; padding: 18px 0; min-height: 0; }.brand { flex: 1; }.brand h1 { font-size: 22px; }.brand-mark { width: 33px; height: 39px; font-size: 24px; }.session-state { width: 100%; order: 3; text-align: left; display: flex; align-items: baseline; gap: 12px; }#phase { font-size: 12px; }.guide-body { width: min(310px, calc(100vw - 28px)); }
  #table { display: flex; flex-direction: column; gap: 18px; margin-top: 12px; }.play-area { width: 100%; }.tabs { margin-bottom: 18px; }.section-heading .eyebrow { font-size: 8px; letter-spacing: 1px; }.team-grid { grid-template-columns: 1fr; gap: 8px; }
  .creature { display: grid; grid-template-columns: minmax(0, 1fr) 126px; gap: 6px 12px; padding: 12px; }.creature.legal, .creature.picked { padding: 11px; }.who { margin: 0; }.creature-name { font-size: 13px; }.creature-id { min-width: 28px; height: 30px; }.health { grid-column: 1; margin: 0; height: 19px; }.stats { grid-column: 2; grid-row: 1 / 3; align-self: center; gap: 5px; }.stat strong { font-size: 18px; }.stat span { font-size: 9px; }.badges, .dock, .markers { grid-column: 1 / -1; margin-top: 2px; }
  .initiative-section { margin: 16px 0; padding: 12px; }.hand-section > .section-heading { display: block; }.hand-section > .section-heading .muted { display: block; margin-top: 5px; }.held { flex-basis: 185px; }.action-area { position: sticky; bottom: 0; top: auto; width: 100%; z-index: 10; }.sheet { max-height: 44dvh; border-radius: var(--radius-soft) var(--radius-soft) 0 0; padding: 15px; padding-bottom: max(15px, env(safe-area-inset-bottom)); box-shadow: 0 -10px 35px #0006; }.decision-heading { margin-bottom: 8px; }#asking { font-size: 22px; margin-bottom: 13px; }.notes { background: var(--paper); padding: 12px 2px; }.action-area:has(#decision[data-kind="Evolution"]) .notes { display: none; }
  .choice-cards { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
}
/* Existing interaction transitions consume the shared tokens. */
@media (prefers-reduced-motion: no-preference) {
  .creature, .held {
    transition: border-color var(--motion-fast) var(--motion-standard),
                background-color var(--motion-fast) var(--motion-standard);
  }
  /* Buttons react without changing layout, click targets, or triggering a second action.
     Touch gets a press cue; only fine-pointer devices get hover elevation. */
  button:not(:disabled) {
    transition: border-color var(--motion-fast) var(--motion-standard),
                background-color var(--motion-fast) var(--motion-standard),
                box-shadow var(--motion-fast) var(--motion-standard),
                transform var(--motion-instant) var(--motion-standard);
  }
}
@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  button:not(:disabled):hover {
    box-shadow: 0 3px 12px #0003, inset 0 0 0 1px color-mix(in srgb, var(--gold) 13.3%, transparent);
  }
}
/* :active works for mouse and touch without JS or delaying submission. */
@media (prefers-reduced-motion: no-preference) {
  button:not(:disabled):active {
    transform: translateY(1px) scale(.992);
    box-shadow: inset 0 2px 5px #0004;
  }
}
/* Pressed/toggled controls retain a clear visual state after release.
   :where() keeps it at no specificity, so a component's own selected style stays authoritative: a selected
   node of the mutation tree keeps its family's colour. */
:where(button[aria-pressed="true"]:not(:disabled)) {
  border-color: var(--gold);
}

/* Motion tokens become effectively immediate for effects added in later PRs.
   This fallback also covers animations built without tokens. */
@media (prefers-reduced-motion: reduce) {
  :root {
    --motion-instant: 0ms;
    --motion-fast: 0ms;
    --motion-normal: 0ms;
    --motion-slow: 0ms;
  }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Keep the revealed spell prominent while the player chooses its targets. */
#decision[data-kind="Target"] #asking { font-size: 32px; color: var(--gold); overflow-wrap: anywhere; }

/* Public, completed casts remain readable while the next round is being planned. */
.round-recap { margin-bottom: 22px; border: 1px solid #766441; border-radius: var(--radius-soft); background: var(--panel); overflow: hidden; }
.round-recap summary { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 18px 20px; list-style: none; }
.round-recap summary::-webkit-details-marker { display: none; }
.round-recap summary::after { content: '+'; color: var(--gold); font-size: 22px; }
.round-recap[open] summary::after { content: '−'; }
.round-recap summary > span:first-child { flex: 1; }
#recap-title { display: block; color: var(--gold); font: 25px var(--font-display); margin-top: 6px; }
#recap-actions { display: grid; gap: 10px; list-style: none; margin: 0; padding: 0 16px 16px; max-height: 52dvh; overflow-y: auto; scrollbar-width: thin; }
.recap-action { padding: 14px 16px; border: 1px solid var(--line); border-left: 3px solid var(--muted); border-radius: var(--radius-soft); background: var(--panel); min-width: 0; }
.recap-action.ally { border-left-color: var(--ally); }.recap-action.enemy { border-left-color: var(--enemy); }
.recap-action-head { display: flex; gap: 12px; justify-content: space-between; align-items: start; }
.recap-spell { font: 20px var(--font-display); overflow-wrap: anywhere; }
.recap-status { flex: none; font-size: 10px; padding: 4px 7px; border-radius: var(--radius-sharp); background: #ffffff0a; color: var(--muted); }
.recap-status.critical { color: #ffe0a4; background: #65501f; }.recap-status.fizzled { color: #f6b6ac; background: #502f2d; }
.recap-path { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin: 10px 0; font-size: 12px; color: var(--muted); }
.recap-person { overflow-wrap: anywhere; }.recap-person.ally { color: var(--ally); }.recap-person.enemy { color: var(--enemy); }
.recap-effects { display: flex; flex-wrap: wrap; gap: 6px; }
.recap-effect { padding: 6px 9px; border-radius: var(--radius-sharp); font-size: 12px; line-height: 1.5; background: var(--raised); overflow-wrap: anywhere; }
.recap-effect.harm { color: #ffbbb4; background: #472a29; }.recap-effect.recovery { color: #b0edc2; background: #23452e; }
.recap-effect.energy { color: #b4d7ff; background: #253a50; }.recap-effect.condition { color: #dfc4fa; background: #3f3050; }
.recap-skipped { margin-top: 8px; color: var(--enemy); font-size: 12px; line-height: 1.5; }
@media (max-width: 760px) {
  .round-recap summary { padding: 14px; gap: 8px; }.round-recap .eyebrow { font-size: 8px; letter-spacing: 1px; }
  #recap-title { font-size: 23px; }#recap-count { max-width: 85px; text-align: center; }
  #recap-actions { padding: 0 10px 10px; max-height: 45dvh; }.recap-action { padding: 12px; }
}

.hand-row.active, .creature.legal { scroll-margin-top: 18px; }
.held.reference .card-availability { color: #4b604f; }
.target-removals { display: flex; flex-wrap: wrap; gap: 6px; }
.target-removals:empty { display: none; }
.target-removals button { min-height: 44px; padding: 8px 10px; font-size: 11px; background: transparent; color: var(--muted); }

/* Class colour follows the same card from reference to unlock picker to hand. */
.class-accent { border-top: 4px solid var(--class-color); padding-top: 10px; }
.class-accent .card-meta { font-size: 11px; font-weight: 700; }
.reference-link { background: transparent; color: var(--gold); font-size: 12px; padding: 8px 10px; }
.enemy-books { margin-top: 10px; }
.enemy-book { border-color: #614a44; }
.enemy-book > summary { color: var(--enemy); font-size: 12px; }
.turn-label { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: 10px; }
.turn-order { display: inline-grid; place-items: center; width: 27px; height: 27px; border-radius: 50%; border: 1px solid #b3c4b7; color: var(--ink); background: var(--panel); font-size: 14px; font-weight: 750; }
.turn-order.now { background: var(--gold); color: var(--accent-ink); border-color: var(--gold); }
.talent-toolbar { display: grid; gap: 12px; padding: 20px; border: 1px solid var(--line); border-radius: var(--radius-soft); background: var(--panel); margin-bottom: 24px; }
.talent-toolbar h2 { font: 25px var(--font-display); color: var(--gold); }
.talent-toolbar select { width: 100%; min-width: 0; min-height: 44px; border: 1px solid var(--line); border-radius: var(--radius-soft); padding: 10px; font: inherit; color: var(--ink); background: var(--raised); }
.talent-toolbar select:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.talent-lane { min-width: 0; margin-bottom: 26px; border: 1px solid var(--line); border-left: 4px solid var(--class-color); border-radius: var(--radius-soft); padding: 18px; background: var(--panel); }
.talent-class { font: 22px var(--font-display); color: var(--class-color); margin-bottom: 8px; }
.talent-tiers { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(215px, 1fr); overflow-x: auto; gap: 16px; padding-bottom: 8px; scrollbar-width: thin; }
.talent-tier { min-width: 0; }
.talent-tier h3 { font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted); padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.talent-card { margin-bottom: 12px; }
.talent-card.available { box-shadow: 0 0 0 2px var(--gold); }
.talent-card.picked { box-shadow: 0 0 0 2px var(--ally); }
.talent-card.future { background: var(--raised); border-color: var(--line); color: var(--ink); }
.talent-card.future .card-meta, .talent-card.future .card-body { color: #c0cbbf; }
.talent-card.future .card-body { border-color: var(--line); }
.talent-card.future .card-cost { color: #27332b; }
.talent-status { display: block; font-size: 10px; font-weight: 750; margin-bottom: 12px; color: #315640; }
.talent-card.available .talent-status { color: #70500e; }
.talent-card.future .talent-status { color: #c0cbbf; }
#mat { scroll-margin-top: 18px; min-width: 0; }
@media (max-width: 760px) {
  .talent-lane { padding: 14px; }
  .talent-tiers { grid-auto-flow: row; grid-auto-columns: auto; overflow: visible; }
  .talent-toolbar { padding: 16px; }
  .talent-toolbar h2 { font-size: 23px; }
  .turn-order { width: 24px; height: 24px; font-size: 12px; }
}

/* A movable reference, with the battlefield and its decision still behind it. */
.talent-window { margin: 0; padding: 0; color: inherit; position: fixed; z-index: 30; left: 24px; top: 96px; width: min(1280px, calc(100vw - 48px)); height: min(800px, calc(100dvh - 120px)); min-width: 480px; min-height: 320px; max-width: calc(100vw - 16px); max-height: calc(100dvh - 16px); display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-soft); box-shadow: 0 20px 80px #000b; overflow: hidden; resize: both; }
.window-bar { display: flex; align-items: center; gap: 5px; padding: 7px 10px; border-bottom: 1px solid var(--line); background: var(--raised); flex: none; }
.window-bar button { background: transparent; border: 0; padding: 7px 12px; font-size: 20px; }
#talent-grip { flex: 1; text-align: left; cursor: grab; touch-action: none; }
#talent-grip:active { cursor: grabbing; }
#talent-title { font: 23px var(--font-display); color: var(--gold); }
.window-hint { display: block; font-size: 10px; color: var(--muted); margin-top: 3px; }
.talent-window #mat { overflow: auto; padding: 18px; flex: 1; min-height: 0; scrollbar-width: thin; }
.talent-window.maximized { left: 8px !important; top: 8px !important; width: calc(100vw - 16px) !important; height: calc(100dvh - 16px) !important; resize: none; }
.talent-window .talent-toolbar { position: sticky; top: -18px; z-index: 4; grid-template-columns: 1fr 300px; gap: 10px 20px; padding: 16px 0; background: var(--panel); border: 0; border-bottom: 1px solid var(--line); border-radius: 0; margin-bottom: 8px; box-shadow: 0 8px 12px #132228dd; }
.atlas-context { display: block; font: 600 12px ui-sans-serif, system-ui, sans-serif; color: var(--ink); margin-top: 7px; line-height: 1.5; }
.talent-window #mat { scroll-padding-top: 170px; }
.talent-toolbar h2 { font-size: 22px; }
.talent-toolbar .muted { grid-column: 1; grid-row: 2; max-width: 80ch; }
.talent-toolbar .creature-picker { grid-column: 2; grid-row: 1; }
.talent-toolbar select { grid-column: 2; grid-row: 2; }
.tree-map { overflow-x: auto; padding: 12px 4px 18px; scrollbar-width: thin; }
.tree-map ul { display: flex; margin: 0; padding: 24px 0 0; position: relative; list-style: none; }
.tree-map li { flex: 1; position: relative; padding: 24px 5px 0; text-align: center; min-width: 122px; }
.tree-map li::before, .tree-map li::after { content: ''; position: absolute; top: 0; width: 50%; height: 24px; border-top: 1px solid #7b8d80; }
.tree-map li::before { right: 50%; }
.tree-map li::after { left: 50%; border-left: 1px solid #7b8d80; }
.tree-map li:only-child::before, .tree-map li:only-child::after { display: none; }
.tree-map li:first-child::before, .tree-map li:last-child::after { border: 0; }
.tree-map li:last-child::before { border-right: 1px solid #7b8d80; border-radius: 0 7px 0 0; }
.tree-map li:first-child::after { border-radius: 7px 0 0 0; }
.tree-map ul ul::before { content: ''; position: absolute; top: 0; left: 50%; height: 24px; border-left: 1px solid #7b8d80; }
.tree-map .tree-roots { padding-top: 0; }
.tree-roots > li { padding-top: 0; }
.tree-node { width: 100%; max-width: 200px; min-height: 94px; padding: 12px 9px; border: 1px solid var(--class-color); border-top: 3px solid var(--class-color); border-radius: var(--radius-soft); background: var(--raised); text-align: center; }
.tree-node.selected { background: var(--accent-wash); outline: 2px solid var(--class-color); outline-offset: 3px; }
.tree-title { display: block; color: var(--class-color); font: 17px var(--font-display); overflow-wrap: anywhere; }
.tree-progress { display: block; color: #cfdbcf; font-size: 10px; margin-top: 8px; }
.tree-offer { display: block; color: var(--muted); font-size: 10px; margin-top: 5px; }
.tree-node.unlockable .tree-offer { color: var(--gold); }
.tree-node.picked .tree-offer { color: var(--ally); }
.atlas-prompt { text-align: center; padding: 22px; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius-soft); font-size: 12px; }
.talent-inspector { border-top: 1px solid var(--line); padding-top: 16px; }
.talent-inspector .talent-lane { margin: 0; }
.atlas-unlock { width: 100%; margin-top: 14px; text-align: center; background: var(--accent-wash); color: var(--ink); border-color: var(--line); font-size: 12px; }
@media (max-width: 1099px) {
  .talent-window { inset: 8px; width: calc(100vw - 16px); height: calc(100dvh - 16px); min-width: 0; min-height: 0; resize: none; }
  .window-hint, #talent-reset, #talent-max { display: none; }
  #talent-grip { cursor: default; }
  .talent-window #mat { padding: 12px; }
  .talent-window .talent-toolbar { grid-template-columns: 1fr; }
  .talent-window .talent-toolbar { top: -12px; padding: 10px 0; gap: 8px; }
  .talent-window .talent-toolbar .muted { display: none; }
  .talent-window #mat { scroll-padding-top: 200px; }
  .talent-toolbar .muted, .talent-toolbar .creature-picker, .talent-toolbar select { grid-column: auto; grid-row: auto; }
  .tree-map { max-height: 55dvh; }
}
.shortcuts { border-top: 1px solid var(--line); margin-top: 12px; color: var(--muted); font-size: 11px; }
.shortcuts summary { padding: 10px 0; min-height: 36px; }
.shortcuts p { line-height: 1.7; margin-bottom: 6px; }
kbd { font: 10px ui-monospace, monospace; border: 1px solid #70816e; border-radius: var(--radius-sharp); padding: 2px 5px; color: var(--ink); }
.shortcut-number { display: inline-grid; place-items: center; width: 21px; height: 21px; border: 1px solid currentColor; border-radius: var(--radius-sharp); margin-left: auto; font: 11px ui-monospace, monospace; opacity: 0.8; }
@media (pointer: coarse) { .shortcuts { display: none; } }
.round-choice { grid-column: 1 / -1; border-top: 1px solid #65554c; padding-top: 9px; margin-top: 9px; font-size: 11px; }
.choice-round { display: block; font-size: 9px; color: var(--muted); letter-spacing: 0.5px; }
.choice-spell { display: block; margin-top: 5px; color: #f0c7a0; font: 17px var(--font-display); }
.choice-targets, .choice-previous { display: block; margin-top: 5px; line-height: 1.5; color: #c9b8ad; overflow-wrap: anywhere; }
.choice-previous { font-size: 10px; color: var(--muted); }
@media (min-width: 1100px) {
  .creature { display: grid; grid-template-columns: minmax(0, 1fr) 88px; gap: 5px 8px; }
  .who { margin: 0; gap: 7px; }
  .creature-name { font-size: 13px; }
  .creature-id { min-width: 26px; height: 28px; font-size: 12px; }
  .creature-label { font-size: 9px; }
  .health { grid-column: 1; margin: 0; height: 19px; }
  .stats { grid-column: 2; grid-row: 1 / 3; align-self: center; gap: 3px; }
  .stat strong { font-size: 16px; }
  .stat span { font-size: 8px; }
  .badges, .dock, .markers { grid-column: 1 / -1; margin-top: 0; }
  .round-choice { margin-top: 2px; padding-top: 6px; }
  .choice-spell { font-size: 15px; }
}
@media (min-width: 1100px) {
  .creature { grid-template-columns: minmax(0, 1fr) 106px; }
  .stats { gap: 4px; }
}
.held { display: flex; flex-direction: column; }
.held > .card-availability { order: -1; margin: 0 0 9px; }

/* One page scroll. On laptops the board and the planning desk share the viewport. */
body:has(#table) { overflow: auto; }
#table { display: block; height: auto; max-width: 1440px; margin: 22px auto 0; }
.play-area { display: flex; flex-direction: column; height: auto; overflow: visible; gap: 24px; }
.tabs { order: -3; margin-bottom: 0; }
.round-recap { order: -2; margin-bottom: 0; }
#planning { display: contents; }
.action-area { order: 1; position: static; width: 100%; }
#board { order: 2; overflow: visible; min-height: 0; padding: 0; scroll-margin-top: 20px; }
.hand-section { order: 3; max-height: none; overflow: visible; }
#notes { order: 4; }
#log { order: 5; }
#planning:is([data-kind="Speed"], [data-kind="Intent"]) { display: block; order: 1; padding: 24px; border: 1px solid var(--line); border-radius: var(--radius-soft); background: linear-gradient(135deg, var(--raised), var(--panel) 65%); box-shadow: 0 16px 45px #0002; scroll-margin-top: 18px; }
#decision { max-height: none; overflow: visible; padding: 24px; display: grid; grid-template-columns: minmax(260px, 0.9fr) minmax(320px, 1.1fr); gap: 8px 36px; scroll-margin-top: 18px; }
#planning:is([data-kind="Speed"], [data-kind="Intent"]) #decision { padding: 0 0 16px; background: transparent; border: 0; box-shadow: none; }
#decision .decision-heading { grid-column: 1; margin-bottom: 5px; justify-content: flex-start; }
#decision #asking { grid-column: 1; font-size: clamp(28px, 3vw, 40px); text-wrap: initial; margin: 0; align-self: center; }
.decision-context { grid-column: 1; color: #c7d4c4; font-size: 14px; margin: 6px 0 8px; }
.decision-context:empty { display: none; }
#choices { grid-column: 2; grid-row: 1 / span 3; align-content: center; }
#decision .shortcuts, #decision .problem { grid-column: 1 / -1; margin-top: 5px; }
#decision[data-kind="Speed"] #choices { grid-template-columns: 1fr 1fr; gap: 14px; }
#decision[data-kind="Speed"] #choices > button { min-height: 96px; font-size: 24px; border-radius: var(--radius-soft); }
#decision[data-kind="Speed"] #choices > button::before { display: block; font: 11px ui-monospace, monospace; opacity: 0.65; margin-bottom: 8px; }
#decision[data-kind="Speed"] #choices > [data-focus="speed-Quick"]::before { content: '1'; }
#decision[data-kind="Speed"] #choices > [data-focus="speed-Standard"]::before { content: '2'; }
#decision[data-kind="Intent"] #choices > button { min-height: 56px; font-size: 17px; }
#decision[data-kind="Evolution"] { grid-template-columns: 1fr; }
#decision[data-kind="Evolution"] #choices { grid-column: 1; grid-row: auto; grid-template-columns: 1fr 1fr; }
#decision[data-kind="Evolution"] .creature-picker, #decision[data-kind="Evolution"] .choice-help, #decision[data-kind="Evolution"] .choice-cards { grid-column: 1 / -1; }
#decision[data-kind="Evolution"] .choice-cards { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
#planning .hand-section { padding-top: 16px; }
.hand-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.hand-row.active .hand-who { font-size: 13px; margin: 5px 0 12px; }
.hand-row.active { margin-bottom: 14px; }
#own-hand .held-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 215px), 1fr)); overflow: visible; padding: 4px 3px 12px; align-items: stretch; }
#own-hand .held { min-width: 0; padding: 18px; }
#own-hand .card-title { font-size: 21px; }
#own-hand .card-body { font-size: 12px; line-height: 1.7; }
#own-hand .card-availability { font-size: 11px; }
.enemy-books { display: flex; gap: 14px; }
.enemy-book { flex: 1; }
.enemy-book .held-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr)); overflow: visible; }
@media (min-width: 761px) and (max-width: 1099px) {
  .play-area:has(#decision[data-kind="Target"]) .action-area { position: sticky; top: 10px; z-index: 10; }
}
@media (min-width: 1100px) {
  body:has(#table) { padding: 0 20px 24px; }
  .masthead { min-height: 72px; }
  .brand h1 { font-size: 23px; }
  #table { max-width: 1600px; margin-top: 10px; }
  .play-area { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(410px, 1fr); gap: 14px 20px; align-items: start; }
  .tabs, .round-recap, #notes, #log { grid-column: 1 / -1; }
  .tabs { grid-row: 1; }
  #notes { grid-row: 4; }
  #log { grid-row: 5; }
  #planning, #planning:is([data-kind="Speed"], [data-kind="Intent"]) {
    display: block; grid-column: 2; grid-row: 3; min-width: 0; padding: 16px;
    border: 1px solid var(--line); border-radius: var(--radius-soft); background: linear-gradient(145deg, var(--raised), var(--panel) 65%);
  }
  .round-recap { grid-row: 2; }
  #board { grid-column: 1; grid-row: 3; position: sticky; top: 14px; align-self: start; }
  #decision, #planning:is([data-kind="Speed"], [data-kind="Intent"]) #decision {
    display: block; padding: 0 0 8px; background: transparent; border: 0; box-shadow: none;
  }
  #decision #asking { font-size: 27px; margin: 8px 0; }
  #decision[data-kind="Target"] #asking { font-size: 30px; }
  .decision-context { font-size: 12px; margin: 6px 0 12px; }
  #decision[data-kind="Speed"] #choices { gap: 10px; }
  #decision[data-kind="Speed"] #choices > button { min-height: 52px; font-size: 18px; text-align: center; padding: 10px; }
  #decision[data-kind="Speed"] #choices > button::before { display: inline; margin-right: 10px; }
  #decision[data-kind="Intent"] #choices > button { min-height: 44px; font-size: 15px; }
  #decision[data-kind="Evolution"] .choice-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .shortcuts summary { min-height: 28px; padding: 6px 0; }
  #planning .hand-section { padding-top: 12px; }
  .hand-section > .section-heading { align-items: center; gap: 6px; margin-bottom: 8px; }
  .hand-actions .reference-link { min-height: 30px; padding: 5px 8px; font-size: 10px; }
  .hand-row.active .hand-who { font-size: 11px; margin-bottom: 6px; }
  #own-hand .held-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  #own-hand .held { padding: 12px; }
  #own-hand .card-title { font-size: 17px; }
  #own-hand .card-body { font-size: 11px; line-height: 1.5; padding-top: 8px; margin-top: 8px; }
  #own-hand .card-cost { width: 25px; height: 25px; font-size: 12px; }
  #own-hand .card-availability { font-size: 10px; margin-bottom: 6px; }
  .hand-cards { gap: 4px; }
  .hand-row.active { margin-bottom: 4px; }
  .hand-row summary { min-height: 32px; padding: 8px 0; }
  .team-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .creature { padding: 11px; grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .creature.legal, .creature.picked { padding: 10px; }
  .health { grid-column: 1; }
  .stats { grid-column: 1; grid-row: auto; display: flex; gap: 14px; }
  .stat { flex-direction: row; align-items: baseline; gap: 4px; }
  .stat strong { font-size: 15px; }
  .stat span { font-size: 9px; }
  .creature-label { display: none; }
  .section-heading { margin-bottom: 8px; }
  .initiative-section { margin: 12px 0; padding: 9px 11px; }
  .initiative-section .section-heading { margin-bottom: 5px; }
  .strip { flex-wrap: wrap; gap: 8px 16px; overflow: visible; }
  .slot { padding: 4px 7px; }
  .enemy-book > summary { min-height: 30px; padding: 7px 0; font-size: 10px; }
  .enemy-books:has(.enemy-book[open]) { flex-wrap: wrap; }
  .enemy-book[open] { flex-basis: 100%; }
  .hand { margin: 8px 0; }
  .revealed { padding: 0 10px; margin: 8px 0 0; }
  .revealed summary { min-height: 30px; padding: 6px 0; }
  .round-choice { padding-top: 5px; }
  .choice-spell { margin-top: 3px; }
  .choice-targets { margin-top: 3px; }
  .ally .choice-spell { color: #b9dcc1; }
  .round-recap summary { padding: 10px 16px; }
  #recap-title { font-size: 20px; }
}
@media (max-width: 760px) {
  .play-area { gap: 18px; }
  #planning:is([data-kind="Speed"], [data-kind="Intent"]) { padding: 16px; }
  #decision { grid-template-columns: minmax(0, 1fr); padding: 18px; gap: 10px; }
  #decision #asking { font-size: 30px; }
  #choices { grid-column: 1; grid-row: auto; }
  #decision[data-kind="Speed"] #choices > button { min-height: 76px; font-size: 21px; }
  #own-hand .held-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; overflow: visible; align-items: start; }
  #own-hand .held { padding: 12px; }
  .enemy-books { display: block; }
  #decision[data-kind="Evolution"] #choices { grid-template-columns: 1fr; }
  .hand-actions .reference-link { font-size: 11px; padding: 8px; }
}

.creature.legal { scroll-margin-top: var(--target-offset, 18px); }

/* A compact reference dock leaves the battlefield in place as rounds change. */
body:has(#table) { padding-bottom: 110px; }
#phase-dock { position: fixed; z-index: 20; inset: auto 0 0; display: grid; grid-template-columns: auto 1fr; gap: 7px 18px; padding: 12px 285px 12px 20px; border-top: 1px solid var(--line); background: var(--paper-glass); box-shadow: 0 -8px 25px #0004; }
#phase-round { align-self: center; color: var(--gold); font-size: 12px; white-space: nowrap; }
#phase-steps { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 0; margin: 0; list-style: none; }
#phase-steps li { padding: 5px 9px; color: #a2b0a7; border-radius: var(--radius-sharp); font-size: 11px; }
#phase-steps li + li::before { content: '›'; margin-right: 10px; opacity: .6; }
#phase-steps .current { background: var(--gold); color: var(--accent-ink); font-weight: 750; }
#phase-steps .complete { color: #b7dbbd; }
#phase-reminder { grid-column: 1 / -1; font-size: 12px; color: #c1cec4; line-height: 1.5; }
.round-recap { position: fixed; z-index: 24; right: 20px; bottom: 15px; width: 245px; margin: 0; box-shadow: 0 8px 30px #0006; }
.round-recap summary { padding: 10px 12px; gap: 8px; min-height: 45px; }
#recap-title { margin: 0; font: 600 13px ui-sans-serif, system-ui, sans-serif; flex: 1; }
#recap-count { font-size: 10px; white-space: nowrap; }
.round-recap[open] { bottom: 92px; width: min(640px, calc(100vw - 40px)); }
#recap-actions { max-height: 56dvh; }
.stat-energy strong, .stat-energy span { color: #e6be70; }
.stat-defense strong, .stat-defense span { color: #8bc6ed; }
.stat-initiative strong, .stat-initiative span { color: #c4a2ef; }
.badge[data-speed="Quick"] { color: #ffe0a0; background: #5c4525; border-color: #b48b48; }
.badge[data-speed="Standard"] { color: #b8dcff; background: #253f58; border-color: #537fa5; }
.turn-order, .turn-order.now, .slot-order { background: var(--turn-color, #b4dacf); color: #152222; border-color: transparent; font-weight: 750; }
.turn-order.now, .slot.now .slot-order { outline: 2px solid #fff3c9; outline-offset: 2px; box-shadow: 0 0 12px color-mix(in srgb, var(--gold) 39.6%, transparent); }
.slot { display: grid; grid-template-columns: 20px 1fr; gap: 2px 6px; padding: 6px 8px; }
.slot-order { grid-row: 1 / 3; align-self: center; border: 1px solid currentColor; border-radius: 50%; width: 20px; height: 20px; display: grid; place-items: center; font-size: 11px; }
.slot strong { font-size: 11px; font-weight: 650; }
.slot-initiative { font-size: 9px; opacity: .85; }
.strip { gap: 8px; }
.band { flex-wrap: wrap; gap: 6px; }
.band-name { min-width: 55px; }
.slots { flex-wrap: wrap; gap: 5px; }
.pick-budget { padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-soft); background: var(--accent-wash); margin-bottom: 10px; }
.pick-budget > strong { display: block; font-size: 14px; color: #f5dda0; }
.pick-tokens { display: flex; flex-wrap: wrap; gap: 5px; margin: 7px 0 5px; }
.pick-token { border: 1px solid var(--line); border-radius: var(--radius-sharp); padding: 4px 7px; font-size: 10px; }
.pick-token.available { color: #f6e0a8; background: var(--accent-wash); }
.pick-token.spent { color: var(--muted); border-color: var(--line); }
.pick-note { display: block; font-size: 10px; color: #bac7b3; }
#evolution-budget { grid-column: 1 / -1; }
.talent-window .talent-toolbar .muted { display: none; }
.talent-toolbar .pick-budget { grid-column: 1; grid-row: 2; margin: 0; padding: 8px 10px; }
.talent-toolbar select { align-self: start; }
.talent-toolbar h2 { font-size: 21px; }
.talent-window #mat { scroll-padding-top: 190px; }
.talent-lane { padding: 12px; max-width: 920px; margin-inline: auto; }
.talent-inspector .talent-lane { margin-inline: auto; }
.talent-tiers { display: flex; flex-wrap: wrap; gap: 12px; overflow: visible; }
.talent-tier { flex: 1 1 350px; display: grid; grid-template-columns: repeat(var(--tier-columns, 1), minmax(0, 1fr)); align-content: start; gap: 10px; }
.talent-tier h3 { grid-column: 1 / -1; margin: 4px 0 0; padding-bottom: 6px; }
.talent-card { padding: 12px; margin: 0; display: flex; flex-direction: column; }
.talent-card .card-title { font-size: 17px; }
.talent-card .card-body { margin-top: 8px; padding-top: 8px; line-height: 1.5; }
.talent-status { margin-bottom: 7px; }
.atlas-unlock { margin-top: auto; min-height: 36px; padding: 8px; }
.talent-card .card-body + .atlas-unlock { margin-top: 10px; }
.card { border-radius: var(--radius-soft); background: linear-gradient(145deg, #f4f0e5, #dedbc9); box-shadow: 0 3px 9px #0002; }
.card:not(.future):has(.card-head[data-tone="harm"]) { background: linear-gradient(145deg, #f4ece3, #e1d7c5); }
.card:not(.future):has(.card-head[data-tone="recovery"]) { background: linear-gradient(145deg, #edf2e5, #d9e0ce); }
.card-head { padding-top: 3px; }
.card-title { letter-spacing: -.25px; }
.card-cost { box-shadow: inset 0 0 0 2px #ffffff40; }
.card-cues { display: flex; flex-wrap: wrap; gap: 5px; margin: 10px 0 0; }
.card-cues:empty { display: none; }
.card-cue { display: inline-flex; align-items: center; gap: 4px; padding: 4px 7px; border-radius: var(--radius-sharp); font: 650 10px ui-sans-serif, system-ui, sans-serif; color: #46533f; background: #d6ddca; }
.card-cue[data-tone="harm"] { color: #893e2b; background: #efd4c4; }
.card-cue[data-tone="recovery"] { color: #285739; background: #cce4cb; }
.card-cue[data-tone="protection"] { color: #31566d; background: #cadde5; }
.card-cue[data-tone="control"] { color: #644975; background: #ddd0e6; }
.card-cue[data-tone="critical"] { color: #614212; background: #edcc81; border: 1px solid #b99848; padding: 3px 6px; }
.card-critical-note { margin-top: 8px; font-size: 10px; line-height: 1.45; font-style: italic; }
@media (max-width: 1099px) {
  .talent-toolbar .pick-budget { grid-column: 1; grid-row: auto; }
}
@media (max-width: 760px) {
  body:has(#table) { padding-bottom: 200px; }
  #phase-dock { padding: 10px 12px; gap: 6px; grid-template-columns: 1fr; }
  #phase-steps { gap: 2px; }
  #phase-steps li { padding: 4px; font-size: 10px; }
  #phase-steps li + li::before { margin-right: 4px; }
  #phase-reminder { font-size: 11px; }
  .round-recap { right: 12px; bottom: 136px; width: 220px; }
  .round-recap[open] { bottom: 136px; width: calc(100vw - 24px); }
  #recap-actions { max-height: 48dvh; }
  .talent-window #mat { scroll-padding-top: 280px; }
  .talent-toolbar .pick-note { display: none; }
  .talent-toolbar .pick-budget { padding: 6px 8px; }
  .talent-toolbar .pick-tokens { margin-bottom: 0; }
  .talent-tier { flex-basis: 100%; grid-template-columns: 1fr; }
}

/* Phase cues never capture input or displace the battlefield. Details remain available after the cue. */
#phase-notice { position: absolute; left: 20px; bottom: calc(100% + 12px); width: min(570px, calc(100vw - 40px)); padding: 14px 18px; border: 1px solid #a58c56; border-left: 3px solid var(--gold); border-radius: var(--radius-soft); background: var(--paper-glass); box-shadow: 0 8px 24px #0005; pointer-events: none; }
#phase-notice-title { display: block; font-size: 17px; color: #f3d697; }
#phase-notice[data-kind="round"] { border-color: #e6c57d; background: linear-gradient(110deg, var(--accent-wash), var(--paper-glass)); }
#phase-notice[data-kind="round"] #phase-notice-title { font: 400 26px var(--font-display); letter-spacing: .2px; }
#phase-notice-detail { margin: 6px 0 0; font-size: 12px; line-height: 1.55; color: #d4dfd5; }
.notice-changes { display: grid; gap: 5px; margin-top: 9px; }
.notice-changes p { display: flex; justify-content: space-between; gap: 8px; margin: 0; padding: 7px 9px; border-left: 3px solid #9ac9a5; border-radius: var(--radius-sharp); background: #ffffff0a; font-size: 12px; }
.notice-changes p[data-tone="opponent"], .notice-changes p[data-tone="harm"] { border-left-color: var(--enemy); }
.notice-changes p[data-tone="energy"] { border-left-color: #e6be70; }
.notice-changes p[data-tone="active"] { border-left-color: #a997d0; }
.notice-changes strong { flex: 0 0 auto; white-space: nowrap; }
.notice-changes span { min-width: 0; text-align: right; overflow-wrap: anywhere; }
.enemy-packages { grid-column: 1 / -1; display: flex; gap: 5px; flex-wrap: wrap; align-items: center; }
.enemy-packages::before { content: 'Packages'; color: var(--muted); font-size: 10px; margin-right: 3px; }
.enemy-package { padding: 4px 7px; border: 1px solid var(--class-color, var(--line)); border-radius: var(--radius-sharp); background: #ffffff0b; color: var(--class-color, var(--ink)); font-size: 11px; overflow-wrap: anywhere; }
#phase-dock { grid-template-columns: auto 1fr auto; }
#phase-reminder { grid-column: 1 / 3; }
#upkeep { grid-column: 3; grid-row: 1 / 3; align-self: center; }
#upkeep summary { cursor: pointer; color: #e9d49b; border: 1px solid var(--line); border-radius: var(--radius-sharp); padding: 8px 10px; font-size: 11px; white-space: nowrap; }
#upkeep summary:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
#upkeep-panel, #match-panel { position: absolute; left: 20px; bottom: calc(100% + 12px); width: min(520px, calc(100vw - 40px)); max-height: 48dvh; overflow-y: auto; padding: 18px; border: 1px solid var(--line); border-radius: var(--radius-soft); background: var(--panel); box-shadow: 0 8px 30px #0008; }
#match-tools[hidden] { display: none; }
#match-panel { display: grid; gap: 10px; }
#match-panel p, #concede-problem { display: block; font-size: 13px; line-height: 1.5; margin: 0; }
#concede-problem[hidden] { display: none; }
#concede-confirm { display: grid; gap: 8px; }
#concede-yes { background: #7a2b2b; border-color: #a54848; color: #fff; }
#phase-dock:has(#upkeep[open]) #phase-notice { visibility: hidden; }
body:has(#upkeep[open]) .round-recap { visibility: hidden; }
#upkeep-title { font-size: 18px; margin: 0 0 10px; }
#upkeep-energy { color: #e6be70; font-size: 13px; }
.upkeep-order, #upkeep-panel > .muted { font-size: 11px; line-height: 1.5; margin-top: 9px; }
#upkeep-effects { margin: 14px 0; }
/* The upkeep as the chips read it: one row a creature, its number in its side's colour, then symbol chips. */
.upkeep-grid { display: grid; gap: 6px; }
.upkeep-row { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }
.upkeep-row .mini-id { flex: none; display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; font-size: 11px; font-weight: 750; color: var(--accent-ink); background: #9aa89c; }
.upkeep-row .mini-id.enemy { background: var(--enemy); }
.upkeep-row .mini-id.ally { background: var(--ally); }
.tick { padding: 4px 8px; border-radius: var(--radius-sharp); font-size: 12px; font-weight: 650; line-height: 1.3; white-space: nowrap; background: var(--raised); color: var(--ink); }
.tick[data-tone="harm"] { color: #ffbbb4; background: #472a29; }
.tick[data-tone="recovery"] { color: #b0edc2; background: #23452e; }
.tick[data-tone="energy"] { color: #f0d08a; background: #4a3d20; }
.tick[data-tone="active"] { color: #dfc4fa; background: #3f3050; }
.upkeep-legend { margin-top: 10px; font-size: 10px; line-height: 1.5; }
.upkeep-conditions { border-top: 1px solid var(--line); padding-top: 10px; font-size: 11px; color: #c8d4ca; }
.upkeep-conditions > strong { display: block; margin-bottom: 5px; color: #e9d49b; }
.upkeep-conditions p { margin: 5px 0; }
.card .card-cost { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; flex: 0 0 46px; width: 46px; height: 46px; border-radius: var(--radius-soft); font-size: 17px; color: #684b1d; background: #e6d5ab; }
.card-cost small { font: 650 8px ui-sans-serif, system-ui, sans-serif; text-transform: uppercase; letter-spacing: .4px; }
.card-stats { display: grid; gap: 4px; margin-top: 9px; }
.card-stats:empty { display: none; }
.card-stat { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 5px; border: 1px solid #89847140; border-radius: var(--radius-sharp); padding: 6px; background: #ffffff36; }
.card-stat > span { align-self: center; font-size: 10px; font-weight: 650; }
.card-stat > strong { font: 750 15px ui-sans-serif, system-ui, sans-serif; }
.card-stat > small { font-size: 9px; opacity: .85; text-align: right; }
.card-stat[data-stat="initiative"] { color: #614977; }
.card-stat[data-stat="critical"] { color: #715019; }
.card-line-target { font-weight: 650; padding-bottom: 5px; }
.card-line-requires { margin-top: 6px; font-size: 11px; opacity: .85; }
.card.future .card-stat { color: #e3d9bf; background: var(--raised); border-color: #7d897344; }
@media (max-width: 760px) {
  #phase-dock { grid-template-columns: 1fr auto; }
  #phase-round { grid-column: 1; }
  #phase-steps { grid-column: 1 / -1; grid-row: 2; }
  #phase-reminder { grid-column: 1 / -1; grid-row: 3; }
  #upkeep { grid-column: 2; grid-row: 1; }
  #upkeep summary { padding: 5px 8px; }
  #phase-notice, #upkeep-panel, #match-panel { left: 12px; width: calc(100vw - 24px); }
  #phase-notice-title { font-size: 15px; }
  #phase-notice-detail { font-size: 11px; }
}

/* One compact status bar at eye level; reference panels open only when requested. */
body:has(#table) { padding-bottom: 24px; }
#table { --phase-height: 84px; }
#phase-dock { position: sticky; inset: 0 auto auto; top: 0; z-index: 24; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 5px 16px; padding: 12px 16px; margin-bottom: 12px; border: 1px solid var(--line); border-radius: var(--radius-soft); box-shadow: 0 6px 20px #0004; background: var(--paper-glass); }
.phase-primary { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 14px; }
#phase-round { font-size: 18px; font-weight: 750; color: #f1dab0; }
#phase-current { font-size: 17px; color: #f0f4e8; }
#phase-turn { color: #cbd8c5; font-size: 12px; }
#phase-reminder { grid-column: 1; grid-row: 2; font-size: 11px; color: #b7c5b7; }
.phase-tools { grid-column: 2; grid-row: 1 / 3; align-self: center; display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.phase-tools > details { position: static; margin: 0; }
.phase-tools > details > summary { display: flex; align-items: center; min-height: 34px; padding: 7px 9px; border: 1px solid var(--line); border-radius: var(--radius-sharp); font-size: 10px; color: #e1d6b3; white-space: nowrap; list-style: none; }
.phase-tools > details > summary::-webkit-details-marker { display: none; }
.phase-tools > details[open] > summary { background: var(--accent-wash); border-color: #c5ac6c; }
#upkeep { grid-column: auto; grid-row: auto; }
#phase-steps, #announcement-list, #upkeep-panel, #match-panel, #recap-actions { position: absolute; top: calc(100% + 8px); bottom: auto; left: auto; right: 0; width: min(580px, calc(100vw - 40px)); max-height: min(58dvh, 480px); margin: 0; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius-soft); background: var(--panel); box-shadow: 0 12px 30px #0008; overflow-y: auto; }
#phase-steps { width: auto; gap: 6px; }
#announcement-list { list-style: none; display: grid; gap: 7px; }
#announcement-list button { width: 100%; padding: 10px 12px; font-size: 13px; }
.phase-tools .round-recap, .phase-tools .round-recap[open] { position: static; inset: auto; width: auto; overflow: visible; border: 0; background: none; box-shadow: none; visibility: visible; }
#recap-title { font-size: 10px; }
#recap-count { display: none; }
.round-recap summary::after { font-size: 14px; }
#phase-notice { top: calc(100% + 8px); bottom: auto; left: auto; right: 0; width: min(480px, calc(100vw - 40px)); pointer-events: auto; max-height: 55dvh; overflow-y: auto; }
#phase-notice-context { display: block; margin-bottom: 6px; font-size: 9px; }
#phase-notice-title { font-size: 18px; }
.notice-controls { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }
.notice-controls button { min-height: 30px; font-size: 11px; padding: 5px 9px; background: transparent; }
.notice-controls #phase-notice-next { min-height: 44px; margin-right: auto; background: var(--gold); border-color: var(--gold); color: var(--accent-ink); font-size: 13px; font-weight: 750; }
.notice-controls #phase-notice-next[hidden], .notice-controls #phase-notice-skip[hidden], .notice-controls #phase-notice-pin[hidden] { display: none; }
#decision .decision-heading { flex-wrap: wrap; gap: 8px; }
#decision-phase { color: #f1d69b; font-size: 17px; font-weight: 750; }
.decision-turn { background: var(--accent-wash); border: 1px solid var(--line); color: var(--ink); border-radius: var(--radius-sharp); padding: 5px 8px; font-size: 12px; font-weight: 700; }
#decision-state { margin-left: auto; font-size: 10px; }
.target-instruction { font-size: 14px; color: #e6e9dc; line-height: 1.5; }
.selection-help { font-size: 11px; color: var(--muted); }
.selection-help summary { min-height: 28px; padding: 5px 0; }
.selection-help p { margin: 4px 0 8px; line-height: 1.5; }
#board, #planning, #planning:is([data-kind="Speed"], [data-kind="Intent"]), #decision { scroll-margin-top: calc(var(--phase-height) + 12px); }
.tabs { min-height: 34px; }
.tab { padding: 8px 14px; min-height: 34px; }
@media (min-width: 1100px) {
  #board { top: calc(var(--phase-height) + 12px); }
  .play-area { row-gap: 12px; }
}
@media (min-width: 761px) and (max-width: 1099px) {
  .play-area:has(#decision[data-kind="Target"]) .action-area { top: calc(var(--phase-height) + 8px); }
  #phase-dock { grid-template-columns: 1fr; }
  .phase-tools { grid-column: 1; grid-row: 3; justify-content: flex-start; }
}
@media (max-width: 760px) {
  #phase-dock { padding: 10px; grid-template-columns: 1fr; gap: 7px; }
  #phase-round { font-size: 16px; }
  #phase-current { font-size: 15px; }
  #phase-reminder { display: none; }
  #phase-turn { font-size: 11px; }
  .phase-tools { grid-column: 1; grid-row: 2; justify-content: flex-start; gap: 4px; }
  .phase-tools > details > summary { min-height: 32px; padding: 6px; font-size: 9px; }
  #phase-notice, #phase-steps, #announcement-list, #upkeep-panel, #match-panel, #recap-actions { width: min(480px, calc(100vw - 28px)); right: 0; left: auto; top: calc(100% + 6px); bottom: auto; max-height: 58dvh; }
  #phase-notice { padding: 12px; }
  #phase-notice[data-kind="round"] #phase-notice-title { font-size: 23px; }
  #decision-phase { font-size: 16px; }
}

/* A creature's current spell stays next to its stats, from private choice to confirmed targets. */
.private-choice { padding: 6px 0 0; border-top: 1px dashed #879879; background: transparent; }
.private-choice .choice-round { color: #d1dcbf; letter-spacing: .2px; }
.round-choice .choice-spell { font-size: 14px; line-height: 1.35; }
.private-choice .choice-targets { font-size: 11px; color: #d6dfcf; }
@media (min-width: 1100px) {
  .creature { align-content: start; padding: 9px; gap: 4px; }
  .creature.legal, .creature.picked { padding: 8px; }
  .badges { gap: 4px; }
  .badge { padding: 3px 5px; font-size: 9px; }
  .initiative-section .strip { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .initiative-section .band { display: block; min-width: 0; }
  .initiative-section .band-name { margin-bottom: 4px; }
  .initiative-section .slots { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; }
  .initiative-section .slot { min-width: 0; padding: 5px; }
}

/* Resolution review uses the decision column, with the battlefield still beside it. */
#playback { order: 1; max-height: none; overflow: visible; padding: 18px; scroll-margin-top: calc(var(--phase-height) + 12px); }
#playback-title { font: 27px/1.2 var(--font-display); color: var(--gold); margin: 10px 0 6px; }
#playback-action { padding: 0; list-style: none; margin: 14px 0; }
#playback-action .recap-action { margin: 0; }
#playback-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
#playback-controls button { text-align: center; }
#playback-controls button:nth-child(2) { background: var(--gold); color: var(--accent-ink); font-weight: 750; }
#playback-controls button:last-child { grid-column: 1 / -1; min-height: 32px; font-size: 12px; background: transparent; }
#playback-board-note { margin-bottom: 10px; color: #e2d0a8; }
.creature.replay-caster { outline: 2px solid var(--gold); outline-offset: 2px; }
.creature.replay-target { box-shadow: inset 0 0 0 2px #8ad4de; }
.replay-caster .creature-name::after { content: ' · acting'; color: var(--gold); font-size: 10px; }
.replay-target:not(.replay-caster) .creature-name::after { content: ' · target'; color: #8ad4de; font-size: 10px; }
.live.replay-caster .creature-name::after { content: ' · just acted'; }
.live.replay-target:not(.replay-caster) .creature-name::after { content: ' · just targeted'; }
@media (min-width: 1100px) { #playback { grid-column: 2; grid-row: 3; align-self: start; } }

/* Package progression has three independent roots and seven leaves per family. Keep every path in view
   at laptop widths; narrow screens can pan the graph without widening the page. */
.tree-roots > li::before, .tree-roots > li::after { display: none; }
.tree-map li { min-width: 86px; padding-left: 3px; padding-right: 3px; }
.tree-node { min-height: 86px; padding: 9px 5px; }
.tree-title { font-size: 14px; }
.tree-progress, .tree-offer { font-size: 9px; }
.package-summary { margin: 8px 0; color: var(--muted); line-height: 1.5; }
.talent-lane > .atlas-unlock { margin: 10px 0; }
.talent-lane > .talent-status { color: #c3cfbf; }
.talent-lane > .talent-tier { margin-top: 12px; }
.package-card { border-top: 3px solid var(--class-color); }
.package-requires { margin-top: 8px; color: #546151; font-size: 10px; }
.package-tags { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0 0; }
.tree-node .package-tags { justify-content: center; }
.package-tag { padding: 1px 7px; border: 1px solid var(--class-color, var(--line)); border-radius: 999px; background: color-mix(in srgb, var(--class-color, var(--line)) 18%, transparent); font-size: 10px; letter-spacing: .02em; line-height: 1.5; white-space: nowrap; }
#decision[data-kind="TieOrder"] { display: block; }
#decision[data-kind="TieOrder"] .creature-picker { flex-wrap: wrap; }
#decision[data-kind="TieOrder"] .creature-picker > p { flex: 1 0 100%; }

.replay-changes { display: flex; flex-wrap: wrap; gap: .35rem; }
.replay-changes:empty { display: none; }
.recap-status.ready { color: var(--muted); }

/* Decision guidance stays beside the commitment on narrow and wide screens. */
.decision-guide:empty { display: none; }
.decision-guide { padding: .85rem; margin-block: .7rem; border: 1px solid var(--line); border-radius: var(--radius-soft); background: var(--panel); }
.decision-guide p { margin-block: .35rem; line-height: 1.5; }
.decision-guide small { display: block; color: #bbc9c2; line-height: 1.5; margin-top: .65rem; }
.card-advice { padding: .5rem .75rem; margin: 0; color: #c6e4d3; font-size: .78rem; line-height: 1.4; }
.held:is(.castable, .reference) .card-advice { color: #2f5a44; }
.practice-panel { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: .6rem 1rem; max-width: 1100px; margin: 1rem auto; padding: 1rem; border: 1px solid var(--line); border-radius: var(--radius-soft); background: var(--panel); }
.practice-panel[hidden] { display: none; }
.practice-panel > div, .practice-panel > p, .practice-panel > output { grid-column: 1 / -1; }
.invitation-panel { max-width: 640px; }
.notices-row { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .8rem; margin-top: .8rem; }
.notices-row[hidden] { display: none; }
/* Fixed to the bottom of the screen: on a phone anything in the flow sits under the phase dock or off screen,
   and the offer is made once, so it may cover the controls until either of its two buttons is tapped. */
.notices-offer { position: fixed; z-index: 40; left: 12px; right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); max-width: 460px; margin-left: auto; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 14px; padding: 12px 14px; border: 1px solid var(--gold); border-radius: var(--radius-soft); background: var(--raised); box-shadow: 0 10px 30px #000a; }
.notices-offer[hidden] { display: none; }
.notices-offer p { flex: 1 1 220px; margin: 0; line-height: 1.5; min-width: 0; overflow-wrap: anywhere; }
.notices-offer .muted { display: block; font-size: 12px; }
.notices-offer-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.notices-offer-actions button { min-height: 40px; }
.invitation-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1rem; }
.practice-panel h2, .practice-panel p { margin: 0; }
.practice-panel select { min-height: 44px; max-width: 100%; color: inherit; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-soft); padding: .6rem; font: inherit; }
.practice-panel output { font-size: .8rem; color: #bbc9c2; }
@media (max-width: 600px) {
  .practice-panel { grid-template-columns: minmax(0, 1fr); margin: .75rem; }
  .practice-panel > * { grid-column: 1; }
}

/* All speed candidates fit in a compact list; effects stay available on disclosure. */
#own-hand .held-cards.speed-reference { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; overflow: visible; }
.speed-spell { border: 1px solid var(--line); border-radius: var(--radius-soft); background: var(--panel); min-width: 0; }
#own-hand .speed-spell > summary { display: flex; align-items: center; gap: 8px; min-height: 46px; padding: 10px; margin: 0; border: 0; font-size: 12px; list-style: none; }
.speed-spell > summary::-webkit-details-marker { display: none; }
.speed-spell > summary::after { content: '+'; color: var(--muted); }
.speed-spell[open] > summary::after { content: '−'; }
.speed-spell > summary strong { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.speed-cost { color: var(--muted); white-space: nowrap; font-size: 11px; }
.speed-critical { color: #ffe0a4; background: #65501f; border-radius: var(--radius-sharp); padding: 4px 6px; white-space: nowrap; font-weight: 700; font-size: 11px; }
.speed-spell:has(.speed-critical) { border-color: #887344; }
.speed-spell-details { padding: 0 12px 12px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.speed-spell-details p { margin: 6px 0 0; }
.speed-spell > summary:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: var(--radius-soft); }
@media (max-width: 760px) {
  .masthead { min-height: 44px; padding: 0; flex-wrap: nowrap; gap: 12px; }
  .masthead .brand { display: none; }
  .session-state { flex: 1; width: auto; order: 0; margin: 0; flex-wrap: wrap; gap: 4px 10px; }
  #phase[data-repeated="true"] { display: none; }
  #shape { margin-left: auto; flex-shrink: 0; }
  #shape > summary { min-height: 44px; display: flex; align-items: center; }
  #shape > summary::before { content: '▸'; margin-right: 5px; }
  #shape[open] > summary::before { content: '▾'; }
  #shape > summary::-webkit-details-marker { display: none; }
  .guide-body { top: 44px; }
  #table { margin-top: 8px; }
  #decision[data-kind="Speed"] #asking { font-size: 24px; }
  #decision[data-kind="Speed"] #choices > button { min-height: 56px; font-size: 19px; }
  #decision[data-kind="Speed"] #choices > button::before { display: none; }
}

/* The battlefield below the laptop layout. The round bar carries it at a glance, a chip per creature, and a
   Battlefield button that opens the whole of it over the page, under the bar, so the spellbook keeps its
   place; it is no longer a section at the bottom of the page. On a laptop the board is beside the desk and
   neither is drawn. The bar's one column is allowed to be narrower than what it holds, so a long phase name
   or a crowded chip is cut inside the bar rather than widening the page. */
.board-toggle { margin-left: auto; align-self: center; min-height: 36px; padding: 6px 12px; font-size: 13px; font-weight: 700; color: #f1dab0; background: var(--raised); border: 1px solid #c5ac6c; border-radius: var(--radius-soft); }
.board-toggle[aria-pressed="true"] { background: #c5ac6c; color: var(--panel); }
.mini-board, .atlas-back { display: none; }
@media (min-width: 1100px) {
  .board-toggle { display: none; }
}
@media (max-width: 1099px) {
  #phase-dock { grid-template-columns: minmax(0, 1fr); background: var(--panel); }
  #phase-reminder { grid-column: 1 / -1; }
  .phase-primary { min-width: 0; align-items: center; }
  #tab-board { display: none; }
  body.board-open { overflow: hidden; }
  body:not(.board-open) #board { display: none; }
  body.board-open #board { position: fixed; z-index: 23; inset: var(--board-top, 0px) 0 0; margin: 0; overflow-y: auto; overscroll-behavior: contain; padding: 12px 14px max(24px, env(safe-area-inset-bottom)); background: var(--paper); border-top: 1px solid var(--line); }
  body.board-open #board:focus { outline: none; }
  .mini-board { grid-column: 1 / -1; min-width: 0; display: grid; gap: 4px; }
  body.board-open .mini-board { display: none; }
  .mini-row { display: flex; min-width: 0; gap: 4px; }
  .mini-creature { position: relative; flex: 1 1 0; min-width: 0; display: flex; align-items: center; gap: 5px; min-height: 30px; margin: 0; padding: 3px 6px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-sharp); background: var(--panel); color: var(--ink); font-size: 11px; text-align: left; }
  .mini-creature.enemy { border-color: #6b4843; }
  .mini-creature.ally { border-color: #3f6a55; }
  .mini-id { flex: none; display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; font-size: 10px; font-weight: 750; color: var(--accent-ink); }
  .mini-creature.enemy .mini-id { background: var(--enemy); }
  .mini-creature.ally .mini-id { background: var(--ally); }
  .mini-health { position: relative; flex: 1 1 auto; min-width: 0; height: 14px; overflow: hidden; border-radius: var(--radius-sharp); background: var(--paper); }
  .mini-bar { position: absolute; inset: 0 auto 0 0; background: #4f7f61; }
  .mini-creature.enemy .mini-bar { background: #93564d; }
  .mini-hp { position: relative; display: block; font-size: 10px; font-weight: 750; line-height: 14px; text-align: center; color: #f6f2e6; text-shadow: 0 1px 1px #000c; }
  .mini-energy { flex: none; font-size: 10px; font-weight: 650; color: var(--gold); }
  .mini-defense { flex: none; font-size: 10px; font-weight: 650; color: #8bc6ed; }
  .mini-delta { flex: none; padding: 0 3px; border-radius: var(--radius-sharp); font-size: 10px; font-weight: 750; }
  .mini-delta.harm { color: #ffbbb4; background: #472a29; }
  .mini-delta.recovery { color: #b0edc2; background: #23452e; }
  .mini-flag { position: absolute; top: 1px; left: 2px; font-size: 9px; line-height: 1; color: #ffb3a7; text-shadow: 0 0 2px #000; }
  .mini-creature.stunned .mini-id { box-shadow: 0 0 0 2px #ffb3a7; }
  .mini-creature:is(.active, .turn) { border-color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold); }
  .mini-creature.dead { opacity: .45; }
  .mini-creature.dead .mini-id { text-decoration: line-through; }
  .mini-board.targeting .mini-creature:not(.legal) { opacity: .4; }
  .mini-creature.legal { border: 1px dashed var(--gold); background: var(--accent-wash); }
  .mini-creature.picked { border-style: solid; background: #544520; box-shadow: inset 0 0 0 1px var(--gold); }
  .mini-creature.picked .mini-energy::after { content: ' ✓'; }
  .mini-creature.confirm .mini-energy::after { content: ' ⏎'; }
  .mini-creature.replay-caster { border-color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold); }
  .mini-creature.replay-target { box-shadow: inset 0 0 0 2px #8ad4de; }
  .mini-creature:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
}

/* A tablet has room for both sides of the bar on one line, and no board in the page to keep a decision above:
   the decision scrolls with the page again. */
@media (min-width: 761px) and (max-width: 1099px) {
  .mini-board { grid-row: 4; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .play-area:has(#decision[data-kind="Target"]) .action-area { position: static; }
}

/* A phone: less to scroll and nothing to pan sideways.
   - The round bar keeps one line (the turn is in the decision heading and on the acting creature's chip), its
     tools one line (the Round guide at the top of the page already lists the round's steps), and the atlas is
     reached from the spellbook rather than from a tab row of its own.
   - The decision states itself in one line and the spellbook heading is one row.
   - The hand is a list to choose from, not a spread of printed cards: one compact row per spell. The "select"
     label comes back on the chosen card; the critical reminder does not, so a chosen card barely grows.
   - Each package is a two-line row, and the atlas and pass sit side by side.
   - The opened battlefield draws each creature on a few lines, its stats as the symbols the cards already use
     (the word stays for a screen reader), and the turn order wraps.
   - The atlas's prerequisite graph reads top to bottom: one family per block, each upgrade beside the package
     it grows from. */
@media (max-width: 760px) {
  #phase-dock { padding: 8px; gap: 5px; }
  .phase-primary { flex-wrap: nowrap; }
  #phase-round, .board-toggle { flex: none; }
  #phase-current { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #phase-current .phase-major { display: none; }
  #phase-turn { display: none; }
  .board-toggle { min-height: 30px; padding: 4px 10px; font-size: 12px; }
  .tabs, #phase-progress { display: none; }
  .phase-tools { flex-wrap: nowrap; }
  .phase-tools > details > summary { min-height: 26px; padding: 3px 6px; font-size: 9px; }
  #recap-title { font-size: 9px; }
  .mini-board { grid-row: 3; }

  #decision { padding: 12px; gap: 6px; }
  #decision .decision-heading { margin-bottom: 2px; }
  #decision #asking, #decision[data-kind="Speed"] #asking, #decision[data-kind="Target"] #asking { font-size: 22px; margin: 2px 0; }
  .decision-context { margin: 0 0 4px; }
  #decision .shortcuts { display: none; }
  .decision-guide { padding: 8px 10px; margin-block: 6px; font-size: 12px; }
  .decision-guide p { margin-block: 3px; line-height: 1.4; }
  .decision-guide small { margin-top: 4px; font-size: 10px; line-height: 1.4; }
  .target-instruction { font-size: 13px; margin: 0; }
  #decision[data-kind="Speed"] #choices > button { min-height: 48px; font-size: 18px; }
  #decision[data-kind="Intent"] #choices > button, #decision[data-kind="Target"] #choices > button { min-height: 44px; font-size: 15px; }
  #planning:is([data-kind="Speed"], [data-kind="Intent"]) { padding: 12px; }
  #planning .hand-section { padding-top: 10px; }
  .hand-section > .section-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
  #hand-heading { font-size: 14px; margin: 0; }
  .hand-actions .reference-link { min-height: 32px; padding: 4px 0; border: 0; font-size: 11px; }

  :is(#own-hand, .enemy-books) .held-cards { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  :is(#own-hand, .enemy-books) .held { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 6px; padding: 9px 11px; border-radius: var(--radius-soft); }
  :is(#own-hand, .enemy-books) .held > .card-head { display: contents; }
  :is(#own-hand, .enemy-books) .held .card-title { order: 1; min-width: 0; font-size: 16px; }
  :is(#own-hand, .enemy-books) .held .class-accent .card-title { padding-left: 7px; border-left: 3px solid var(--class-color); }
  :is(#own-hand, .enemy-books) .held > .card-cues { order: 2; margin: 0; }
  :is(#own-hand, .enemy-books) .held > .card-stats { order: 3; margin: 0; }
  :is(#own-hand, .enemy-books) .held .card-cost { order: 4; flex: none; flex-direction: row; width: auto; height: 26px; margin-left: auto; padding: 0 8px; border-radius: var(--radius-sharp); font-size: 13px; }
  :is(#own-hand, .enemy-books) .held .card-cost small { display: none; }
  :is(#own-hand, .enemy-books) .held .card-meta { display: none; }
  :is(#own-hand, .enemy-books) .held .card-cue[data-tone="critical"] { display: none; }
  :is(#own-hand, .enemy-books) .held .card-stat { display: flex; gap: 4px; padding: 3px 6px; border-radius: var(--radius-sharp); }
  :is(#own-hand, .enemy-books) .held .card-stat > span { font-size: 0; }
  :is(#own-hand, .enemy-books) .held .card-stat > span::before { content: '✦ Crit'; font-size: 10px; }
  :is(#own-hand, .enemy-books) .held .card-stat > strong { font-size: 12px; }
  :is(#own-hand, .enemy-books) .held .card-stat > small { display: none; }
  :is(#own-hand, .enemy-books) .held > .card-body { order: 5; flex: 1 0 100%; margin: 0; padding-top: 6px; font-size: 12px; line-height: 1.45; }
  :is(#own-hand, .enemy-books) .held .card-line { display: inline; padding: 0; }
  :is(#own-hand, .enemy-books) .held .card-line + .card-line::before { content: ' · '; }
  /* The critical reminder stays off phone rows; the Speed reference and laptop cards still carry it. */
  :is(#own-hand, .enemy-books) .held .card-critical-note { display: none; }
  :is(#own-hand, .enemy-books) .held > .card-advice { order: 6; flex: 1 0 100%; padding: 0; font-size: 11px; }
  /* The selected row keeps its height: the fixed Declare button gives the confirmation cue. */
  #own-hand .held.offered > .card-availability, .enemy-books .held:not(.chosen) > .card-availability { display: none; }
  :is(#own-hand, .enemy-books) .held > .card-availability { flex: 1 0 100%; margin: 0; }

  #decision[data-kind="Evolution"] #choices { grid-template-columns: 1fr 1fr; gap: 8px; }
  #decision[data-kind="Evolution"] #choices > :is(.creature-picker, .choice-help, .choice-cards) { grid-column: 1 / -1; }
  #decision[data-kind="Evolution"] #choices > button { min-height: 40px; padding: 6px; font-size: 12px; }
  #decision[data-kind="Evolution"] .choice-cards { gap: 6px; }
  #decision[data-kind="Evolution"] .choice-help { margin: 0; font-size: 11px; }
  #decision .package-card { min-height: 0; padding: 8px 11px; border-radius: var(--radius-soft); }
  #decision .package-card .card-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 8px; font-size: 16px; }
  #decision .package-card .card-meta { margin: 0; }
  #decision .package-card .card-body { margin: 3px 0 0; padding: 0; border: 0; font-size: 12px; line-height: 1.35; }
  #decision .package-card .package-requires { margin: 1px 0 0; font-size: 10px; }
  #evolution-budget .pick-budget { padding: 7px 10px; margin-bottom: 4px; }
  #evolution-budget .pick-budget > strong { font-size: 13px; }
  #evolution-budget .pick-tokens { margin: 4px 0 2px; }

  #board .creature { grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; padding: 9px 10px; }
  #board .creature.legal, #board .creature.picked { padding: 8px 9px; }
  #board .creature:not(.legal, .picked, .active, .dead) .creature-label { display: none; }
  #board .creature-id { min-width: 24px; height: 24px; }
  #board .health { grid-column: 1 / -1; height: 17px; }
  #board .stats { grid-column: 2; grid-row: 1; align-self: start; display: flex; gap: 8px; }
  #board .stat { flex-direction: row; align-items: baseline; gap: 3px; }
  #board .stat strong { font-size: 15px; }
  #board .stat strong::before { margin-right: 1px; font-size: 12px; }
  #board .stat-energy strong::before { content: 'ϟ'; }
  #board .stat-defense strong::before { content: '◇'; }
  #board .stat-initiative strong::before { content: '↟'; }
  #board .stat span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  #board .round-choice { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; margin-top: 2px; padding-top: 5px; }
  #board .round-choice .choice-spell { margin: 0; font-size: 13px; }
  #board .round-choice .choice-targets, #board .round-choice .choice-previous { margin: 0; font-size: 11px; }
  #board .team-section .section-heading { margin-bottom: 6px; }
  #board .team-grid { gap: 6px; }
  .initiative-section .strip { display: grid; gap: 8px; overflow: visible; }
  .initiative-section .band { display: block; min-width: 0; }
  .initiative-section .band-name { margin-bottom: 4px; }
  .initiative-section .slots { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
  .initiative-section .slot { min-width: 0; padding: 5px; }

  .talent-window .talent-toolbar { position: static; box-shadow: none; }
  .talent-window #mat { scroll-padding-top: 0; }
  .tree-map { max-height: none; overflow: visible; padding: 4px 0 12px; }
  .tree-map ul { display: grid; gap: 6px; padding: 0; }
  .tree-map .tree-roots { gap: 14px; }
  .tree-map li { min-width: 0; padding: 0; text-align: left; }
  .tree-map li::before, .tree-map li::after, .tree-map ul ul::before { display: none; }
  .tree-roots > li > ul { margin: 6px 0 0 10px; padding-left: 10px; border-left: 1px solid #7b8d80; }
  .tree-roots > li > ul > li { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .tree-node { max-width: none; min-height: 0; height: auto; padding: 8px 10px; text-align: left; border-top-width: 1px; border-left-width: 4px; }
  .tree-title { font-size: 15px; overflow-wrap: normal; }
  .tree-progress { margin-top: 3px; }
  .tree-node:not(.unlockable, .known, .picked) .tree-offer { display: none; }
  .atlas-back { display: block; margin: 0 0 10px auto; }
}

/* The narrowest phones: the round's line keeps its button, and a chip showing what an action just did to
   health leaves its energy out rather than squeeze the bar away. */
@media (max-width: 360px) {
  .phase-primary { gap: 4px 8px; }
  #phase-round { font-size: 14px; }
  #phase-current { font-size: 13px; }
  .board-toggle { padding: 4px 8px; font-size: 11px; }
  .mini-creature { gap: 3px; padding: 3px 4px; }
  .mini-creature:has(.mini-delta) .mini-energy { display: none; }
  .mini-energy, .mini-defense { font-size: 9px; }
  .phase-tools { flex-wrap: wrap; }
}

/* Nothing in the decision sheet may widen it: a grid track sized `1fr` grows to its widest unbreakable line, and a
   resolved action or a pick token is one long line on a phone. Every line wraps inside the sheet instead. */
#decision > * { min-width: 0; }
.pick-token, .pick-note, #decision-context { overflow-wrap: anywhere; }
@media (max-width: 760px) {
  #decision[data-kind="Evolution"] #choices { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #decision[data-kind="Evolution"] #choices > button { white-space: normal; }
}

/* The opponent's action, read one at a time above the question it holds back. */
.combat-step { grid-column: 1 / -1; margin: 0 0 10px; padding: 10px 12px; border: 1px solid #a58c56; border-left: 3px solid var(--enemy); border-radius: var(--radius-soft); background: #2a2320; }
.combat-step > .eyebrow { margin: 0 0 6px; color: #f0b8a8; }
#combat-step-action { list-style: none; margin: 0; padding: 0; }
#combat-step-action .recap-spell { font-size: 17px; }
#combat-step-controls { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
#combat-step-controls > button { flex: 1 1 auto; min-height: 40px; padding: 6px 10px; font-size: 13px; }
#combat-step-controls > button:first-child { flex-basis: 100%; background: var(--gold); border-color: var(--gold); color: var(--accent-ink); font-weight: 700; }
#combat-step-controls > button[aria-pressed="true"] { border-color: var(--gold); color: var(--gold); }
#planning.stepping .hand-section { opacity: .55; }
#planning.stepping #own-hand { pointer-events: none; }

/* The active spellbook can be scanned by the types the catalogue supplies, with no classification guessed
   from a spell name or effect sentence. Other creatures keep their ordinary collapsed hand. */
#own-hand .held-cards.grouped-spells { grid-template-columns: minmax(0, 1fr); }
.spell-group { min-width: 0; }
.spell-group h3 { margin: 4px 2px; color: var(--gold); font-size: 11px; font-weight: 700; }
.spell-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr)); gap: 8px; }
#hand-view { display: none; }

@media (max-width: 1099px) {
  .mini-creature { display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; grid-template-rows: 15px 13px; gap: 2px 4px; min-height: 39px; align-content: center; }
  .mini-id { grid-column: 1; grid-row: 1; }
  .mini-health { grid-column: 2; grid-row: 1; width: 100%; }
  /* A health change is read against the bar it changed, never beside the energy on the line below. */
  .mini-delta { grid-column: 3; grid-row: 1; }
  .mini-stats { grid-column: 1 / -1; grid-row: 2; min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 2px; white-space: nowrap; }
  .mini-initiative { flex: none; font-size: 10px; font-weight: 700; color: #d0aff3; }
}

/* During phone targeting the battlefield is a touch control, not just a status strip. Only rows with
   legal targets grow, keeping the other team and ordinary phase changes compact. */
@media (max-width: 760px) {
  .mini-board.targeting { gap: 8px; }
  .mini-board.targeting .mini-row { gap: 8px; }
  .mini-board.targeting .mini-row:has(.legal) .mini-creature {
    min-height: 72px; padding: 8px 6px; grid-template-columns: 24px minmax(0, 1fr) auto;
    grid-template-rows: 24px 18px; gap: 5px 4px; border-radius: var(--radius-soft);
  }
  .mini-board.targeting .mini-row:has(.legal) .mini-id { width: 24px; height: 24px; font-size: 14px; }
  .mini-board.targeting .mini-row:has(.legal) .mini-health { height: 18px; }
  .mini-board.targeting .mini-row:has(.legal) .mini-hp { font-size: 12px; line-height: 18px; }
  .mini-board.targeting .mini-row:has(.legal) :is(.mini-energy, .mini-defense, .mini-initiative) { font-size: 11px; }
  #decision[data-kind="Target"] .decision-context { font-size: 12px; margin-bottom: 0; }
  #decision[data-kind="Target"] .decision-guide { padding: 6px 8px; margin-block: 4px; }
  #decision[data-kind="Target"] .decision-guide p { margin-block: 2px; }
}

@media (max-width: 760px) {
  #own-hand .held-cards.speed-reference:not(.grouped-spells),
  #own-hand .speed-reference .spell-grid,
  #planning[data-kind="Intent"] #own-hand .hand-row.active .held-cards:not(.grouped-spells),
  #planning[data-kind="Intent"] #own-hand .hand-row.active .spell-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px;
  }
  #own-hand .speed-spell > summary { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3px; min-height: 60px; padding: 7px; align-content: start; }
  .speed-spell > summary strong { grid-column: 1 / -1; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 11px; line-height: 1.25; }
  .speed-cost { font-size: 10px; }
  .speed-critical { font-size: 9px; padding: 2px 3px; }
  .speed-spell > summary::after { display: none; }
  .hand-actions { display: flex; gap: 7px; }
  .hand-actions #hand-view:not([hidden]) { display: inline-block; }
  .hand-actions #hand-view { white-space: nowrap; }
  #planning[data-kind="Intent"]:not(.full-spells) #own-hand .hand-row.active .held { min-height: 111px; padding: 8px; align-content: start; gap: 4px; }
  #planning[data-kind="Intent"]:not(.full-spells) #own-hand .hand-row.active .card-title { font-size: 14px; line-height: 1.2; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  #planning[data-kind="Intent"]:not(.full-spells) #own-hand .hand-row.active .card-cues,
  #planning[data-kind="Intent"]:not(.full-spells) #own-hand .hand-row.active .card-advice { display: none; }
  #planning[data-kind="Intent"]:not(.full-spells) #own-hand .hand-row.active .card-body { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; flex-basis: 100%; padding-top: 2px; font-size: 11px; line-height: 1.25; }
  #planning[data-kind="Intent"].full-spells #own-hand .hand-row.active .held-cards:not(.grouped-spells),
  #planning[data-kind="Intent"].full-spells #own-hand .hand-row.active .spell-grid { grid-template-columns: minmax(0, 1fr); }
}

/* The round bar's play-by-play: one or two lines, never wider than the bar. */
/* The clamp is on the text, inside the padding, so a third line is never half drawn in it. */
.combat-line { grid-column: 1 / -1; min-width: 0; margin: 0; padding: 4px 8px; border-left: 3px solid #e4c37a; border-radius: var(--radius-sharp); background: var(--panel); color: #efe2c2; font-size: 12px; line-height: 1.35; }
.combat-line[hidden] { display: none; }
.combat-line > span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.combat-line > span::before { content: 'Last action ▸ '; color: #b9a877; font-size: 10px; letter-spacing: .04em; text-transform: uppercase; }
.combat-line[data-pending="true"] { border-left-color: var(--enemy); background: #2a2320; }
.combat-line[data-pending="true"] > span::before { content: 'Opponent ▸ '; color: #f0b8a8; }

/* The speeds both sides revealed and the order they make, from the round bar. */
#order-panel { position: absolute; top: calc(100% + 8px); right: 0; width: min(480px, calc(100vw - 40px)); max-height: min(58dvh, 480px); overflow-y: auto; margin: 0; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius-soft); background: var(--panel); box-shadow: 0 12px 30px #0008; }
#order-title { margin: 0 0 8px; font-size: 17px; color: #f3d697; }
.order-side { margin: 0 0 4px; font-size: 13px; overflow-wrap: anywhere; }
.order-side.enemy { color: var(--enemy); }
.order-side.ally { color: var(--ally); }
#order-list { list-style: none; display: grid; gap: 5px; margin: 10px 0; padding: 0; }
.order-slot { display: grid; grid-template-columns: auto auto minmax(0, 1fr); align-items: center; gap: 8px; padding: 5px 8px; border-left: 3px solid var(--ally); border-radius: var(--radius-sharp); background: #ffffff07; font-size: 12px; }
.order-slot.enemy { border-left-color: var(--enemy); }
.order-slot.now { box-shadow: inset 0 0 0 1px var(--gold); }
.order-slot > span:last-child { color: #c7d4c4; overflow-wrap: anywhere; }
.order-slot .turn-order { display: grid; place-items: center; min-width: 22px; height: 22px; border-radius: 50%; background: var(--turn-color, #9fd); color: var(--accent-ink); font-weight: 750; }
#order-panel > .muted { margin: 0; font-size: 11px; line-height: 1.5; }
.announcement-mute button { background: transparent; }
@media (max-width: 760px) {
  #order-panel { width: min(480px, calc(100vw - 28px)); top: calc(100% + 6px); max-height: 58dvh; }
  .combat-line { font-size: 11px; padding: 3px 7px; }
  .notice-controls { flex-wrap: wrap; }
  /* Recap, turn order, announcements and upkeep can all be up at once: a second line beats a wider bar. */
  .phase-tools { flex-wrap: wrap; }
}

/* The turn order is read, not worked in: a tap anywhere on it closes it. */
#order-panel { cursor: pointer; }

/* On a phone the question and its controls stay put. Only the offered packages or the spellbook move. */
@media (max-width: 760px) {
  #planning:is([data-kind="Speed"], [data-kind="Intent"]) {
    display: flex; flex-direction: column; min-height: 0;
    height: calc(100dvh - var(--phase-height, 140px) - 18px); overflow-x: hidden; overflow-y: auto;
  }
  #planning:is([data-kind="Speed"], [data-kind="Intent"]) .action-area { flex: none; position: static; }
  #planning:is([data-kind="Speed"], [data-kind="Intent"]) #decision { display: block; overflow: visible; max-height: none; padding: 0 0 8px; }
  #decision[data-kind="Intent"] .declare-spell { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #planning:is([data-kind="Speed"], [data-kind="Intent"]) .hand-section {
    /* A floor, so a long preview on a short phone never squeezes the spellbook to nothing: the desk scrolls. */
    flex: 1 0 auto; height: 0; min-height: 132px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin;
  }
  #decision[data-kind="Evolution"] {
    display: flex; flex-direction: column; gap: 5px;
    max-height: calc(100dvh - var(--phase-height, 140px) - 18px); overflow: hidden;
  }
  #decision[data-kind="Evolution"] #choices {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    flex: 1; min-height: 0; overflow: hidden; align-content: stretch;
  }
  #decision[data-kind="Evolution"] .choice-cards {
    grid-column: 1 / -1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
    grid-auto-rows: max-content; align-content: start; scrollbar-width: thin;
  }
  #decision[data-kind="Evolution"] .package-card { min-height: 66px; }
}


/* UX 04: legal targets are discoverable and picked targets unmistakable.
   All effects are paint-only: no resizing, transforms, pointer overlays or layout shifts. */
#board .creature.legal,
.mini-board.targeting .mini-creature.legal {
  outline: 1px solid color-mix(in srgb, var(--gold) 53.3%, transparent);
  outline-offset: -3px;
}
#board .creature.picked,
.mini-board.targeting .mini-creature.picked {
  outline: 2px solid var(--gold);
  outline-offset: -3px;
  box-shadow: inset 0 0 0 1px var(--gold), 0 0 0 2px color-mix(in srgb, var(--gold) 22.0%, transparent), 0 0 16px color-mix(in srgb, var(--gold) 15.7%, transparent);
}
.mini-board.targeting .mini-creature.legal:not(.picked) {
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--gold) 33.3%, transparent);
}
.mini-board.targeting .mini-creature.legal:focus-visible,
#board .creature.legal:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}
@media (prefers-reduced-motion: no-preference) {
  #board .creature.legal,
  #board .creature.picked,
  .mini-board.targeting .mini-creature.legal {
    transition: background-color var(--motion-fast) var(--motion-standard),
                border-color var(--motion-fast) var(--motion-standard),
                outline-color var(--motion-fast) var(--motion-standard),
                box-shadow var(--motion-normal) var(--motion-enter);
  }
  /* Only eligible, unselected targets breathe; selected ones stay stable. */
  @keyframes target-available-glow {
    0%, 100% { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--gold) 33.3%, transparent); }
    50% { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--gold) 60.0%, transparent), 0 0 11px color-mix(in srgb, var(--gold) 13.3%, transparent); }
  }
  .mini-board.targeting .mini-creature.legal:not(.picked) {
    animation: target-available-glow 2s ease-in-out infinite;
  }
}

/* UX 05 — opening-only panel transitions. Never delay hide, focus, or a player's input.
   Battlefield and draggable windows only fade: their interactive targets must not move.
   The board and Mutation Tree are toggled by hidden/class immediately in table.js. */
@media (prefers-reduced-motion: no-preference) {
  @keyframes panel-enter {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
  }
  @keyframes panel-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
  }
  /* Mutation Tree can be draggable/resizable: don't animate its left/top/size. */
  .talent-window:not([hidden]) {
    animation: panel-fade-in var(--motion-normal) var(--motion-enter) both;
  }
  /* Full battlefield overlay only exists on tablet/phone; desktop stays still. */
  @media (max-width: 1099px) {
    body.board-open #board {
      animation: panel-fade-in var(--motion-normal) var(--motion-enter) both;
    }
  }
  /* The phase announcement is not here: table.js already plays its entrance (and skips it for reduced
     motion), and a second, CSS one would only run under it. */
  /* Browser-native dialogs show immediately; the dialog content gets a subtle entrance. The lobby loads this
     stylesheet too, so its New Table dialog takes this rule and needs none of its own. */
  dialog[open]:not([hidden]):not(.talent-window) {
    animation: panel-enter var(--motion-normal) var(--motion-enter) both;
  }
}


/* UX 08–11: effects are purely visual, never change layout or capture taps. */
.creature, .mini-creature { isolation: isolate; position: relative; }
.combat-float {
  position: absolute; z-index: 3; top: 2px; right: 8px; pointer-events: none;
  font-size: 18px; font-weight: 800; text-shadow: 0 2px 5px #000;
  color: #ffaea4; opacity: 0; white-space: nowrap;
}
.combat-float.heal { color: #a8efd0; }
.combat-float.defense { color: #e4d4ff; }
/* The chip clips what overflows it (overflow: hidden), so its number starts at the bottom and rises inside. */
.mini-creature .combat-float { font-size: 13px; right: 3px; top: auto; bottom: 2px; }
@media (prefers-reduced-motion: no-preference) {
  @keyframes combat-number-rise {
    0% { opacity: 0; transform: translateY(5px) scale(.9); }
    16% { opacity: 1; transform: translateY(-2px) scale(1.08); }
    75% { opacity: 1; }
    100% { opacity: 0; transform: translateY(-21px); }
  }
  @keyframes combat-hit {
    0%, 100% { filter: none; }
    35% { filter: brightness(1.65) sepia(.4); }
  }
  @keyframes combat-heal {
    0%, 100% { filter: none; }
    40% { filter: brightness(1.35); }
  }
  @keyframes combat-shield {
    0%, 100% { box-shadow: none; }
    40% { box-shadow: inset 0 0 0 3px #c4a6f7, 0 0 16px #b49bee77; }
  }
  @keyframes combat-stun {
    0%, 100% { outline-color: transparent; }
    40% { outline: 3px solid #c4a6f7; outline-offset: -2px; }
  }
  @keyframes combat-defeat {
    0% { filter: grayscale(0); opacity: 1; }
    100% { filter: grayscale(.8); opacity: .55; }
  }
  @keyframes combat-number-rise-inside {
    0% { opacity: 0; transform: translateY(3px); }
    16% { opacity: 1; transform: translateY(0); }
    75% { opacity: 1; }
    100% { opacity: 0; transform: translateY(-10px); }
  }
  .combat-float { animation: combat-number-rise 700ms var(--motion-enter) both; }
  .mini-creature .combat-float { animation-name: combat-number-rise-inside; }
  /* One action can hit, stun and break a shield at once: each effect names its own layer and one rule plays
     them all, so none replaces another. Defeat waits for the hit's flash, both being filters. */
  .fx-damage { --fx-flash: combat-hit 340ms ease-out; }
  .fx-heal { --fx-flash: combat-heal 400ms ease-out; }
  .fx-defense { --fx-shield: combat-shield 420ms ease-out; }
  .fx-stun { --fx-stun: combat-stun 540ms ease-out; }
  .fx-defeated { --fx-defeat: combat-defeat 650ms ease-out 340ms forwards; }
  :is(.fx-damage, .fx-heal, .fx-defense, .fx-stun, .fx-defeated, .spell-reveal-caster, .spell-reveal-target) {
    animation: var(--fx-reveal, none), var(--fx-flash, none), var(--fx-shield, none), var(--fx-stun, none), var(--fx-defeat, none);
  }
}
@media (prefers-reduced-motion: reduce) {
  .combat-float { display: none; }
}

/* Persistent condition identity, even when motion is disabled. */
.chip.condition-bleed { border-color: #be655f; color: #f2b7ab; background: #462521; }
.chip.condition-stun { border-color: #9d82bd; color: #e7ccff; background: #362845; }


/* UX 12: show progress through the server-owned initiative timeline. */
.initiative-section .slot.completed {
  opacity: .48;
  border-color: var(--line);
}
.initiative-section .slot.now {
  position: relative;
  box-shadow: inset 0 0 0 1px #fff3c9, 0 0 14px color-mix(in srgb, var(--gold) 33.3%, transparent);
}
.initiative-section .slot.now::before {
  content: '';
  position: absolute;
  inset: -2px auto -2px -2px;
  width: 3px;
  border-radius: var(--radius-sharp);
  background: var(--gold);
  pointer-events: none;
}
@media (prefers-reduced-motion: no-preference) {
  .initiative-section .slot {
    transition: opacity var(--motion-normal) var(--motion-standard),
                border-color var(--motion-fast) var(--motion-standard),
                box-shadow var(--motion-normal) var(--motion-enter);
  }
  @keyframes initiative-arrival {
    0% { box-shadow: inset 0 0 0 1px #fff3c9, 0 0 0 color-mix(in srgb, var(--gold) 0.0%, transparent); }
    55% { box-shadow: inset 0 0 0 2px #fff3c9, 0 0 20px color-mix(in srgb, var(--gold) 66.7%, transparent); }
    100% { box-shadow: inset 0 0 0 1px #fff3c9, 0 0 14px color-mix(in srgb, var(--gold) 33.3%, transparent); }
  }
  .initiative-section .slot.now.arrived {
    animation: initiative-arrival var(--motion-slow) var(--motion-enter) both;
  }
}


/* UX 13: the public cast appears as a brief, nonblocking light cue.
   No positioning, hitbox or DOM order changes; private intents are never animated. */
@media (prefers-reduced-motion: no-preference) {
  @keyframes spell-caster-reveal {
    0%, 100% { outline-color: transparent; }
    45% { outline: 2px solid var(--gold); outline-offset: 2px; box-shadow: 0 0 18px color-mix(in srgb, var(--gold) 46.7%, transparent); }
  }
  @keyframes spell-target-reveal {
    0%, 100% { box-shadow: none; }
    45% { box-shadow: inset 0 0 0 2px #8ad4de, 0 0 14px #8ad4de66; }
  }
  /* A layer of the combat effects' one animation list (UX 08-11): a target the cast hurts also flashes. */
  .spell-reveal-caster { --fx-reveal: spell-caster-reveal 520ms var(--motion-enter); }
  .spell-reveal-target { --fx-reveal: spell-target-reveal 520ms var(--motion-enter); }
}

/* UX 16–17: a single, nonblocking pulse after confirmed mutation/spell unlocks. */
@media (prefers-reduced-motion: no-preference) {
  @keyframes mutation-acquired-glow {
    0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--gold) 0.0%, transparent); }
    45% { box-shadow: 0 0 0 2px var(--gold), 0 0 22px color-mix(in srgb, var(--gold) 53.3%, transparent); }
    100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--gold) 0.0%, transparent); }
  }
  @keyframes learned-spell-glow {
    0% { box-shadow: inset 0 0 0 0 #96ccb000; }
    45% { box-shadow: inset 0 0 0 2px #96ccb0, 0 0 16px #96ccb077; }
    100% { box-shadow: inset 0 0 0 0 #96ccb000; }
  }
  .tree-node.mutation-just-acquired {
    animation: mutation-acquired-glow 850ms var(--motion-enter);
  }
  #own-hand .held.spell-just-unlocked, #own-hand .speed-spell.spell-just-unlocked {
    animation: learned-spell-glow 850ms var(--motion-enter);
  }
}

/* UX 18: endgame is a result inside the existing sheet, never a blocking modal. */
.match-finished .decision-heading { opacity: .7; }
.match-result { --result-accent: var(--gold); margin: 4px 0 20px; padding: 22px; border: 1px solid var(--result-accent); border-radius: var(--radius-soft); background: linear-gradient(135deg, color-mix(in srgb, var(--gold) 7.8%, transparent), var(--panel) 75%); }
.match-result.defeat { --result-accent: #e3a29a; }
.match-result-rematch { display: block; margin-top: 16px; text-align: center; text-decoration: none; }
.match-result:is(.draw, .unknown) { --result-accent: #b0bbb2; }
.match-result-eyebrow { display: block; font-size: 10px; letter-spacing: 2px; font-weight: 700; color: var(--result-accent); }
.match-result-title { display: block; margin: 9px 0 5px; color: var(--result-accent); font: 400 clamp(28px, 5vw, 44px) var(--font-display); letter-spacing: 1px; }
.match-result-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 18px; }
.match-result-stat { display: grid; gap: 5px; min-width: 0; padding: 10px; border: 1px solid var(--line); border-radius: var(--radius-soft); background: #0002; }
.match-result-stat span { color: var(--muted); font-size: 11px; }
.match-result-stat strong { font-size: 13px; }
@media (max-width: 480px) { .match-result { padding: 14px; } .match-result-stats { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: no-preference) {
  @keyframes result-enter { from { opacity: .45; } to { opacity: 1; } }
  .match-result.new-result { animation: result-enter var(--motion-slow) var(--motion-enter) both; }
}

/* PWA connectivity lives in the dock; it never covers or disables controls. */
#connection-state:not([hidden]) { grid-column: 1 / -1; color: #f1c78d; font-size: 11px; line-height: 1.3; }

/* Optional interaction feedback: a note-sized toggle in the masthead beside the Round guide, its two settings
   in a small popover like the guide's. Lit while either is on, so a sound that plays is never a mystery. */
.feedback-preferences { position: relative; z-index: 30; font-size: 12px; }
.feedback-preferences > summary { min-width: 44px; display: flex; align-items: center; justify-content: center; padding: 0; color: var(--muted); font-size: 18px; list-style: none; }
.feedback-preferences > summary::-webkit-details-marker { display: none; }
.feedback-preferences:is([open], .on) > summary { color: var(--gold); }
.feedback-body { position: absolute; right: 0; top: 45px; width: min(260px, calc(100vw - 28px)); padding: 12px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-soft); box-shadow: 0 15px 40px #0008; z-index: 5; }
.feedback-body label { display: flex; align-items: center; gap: 9px; min-height: 36px; color: var(--ink); font-size: 12px; }
.feedback-body input { accent-color: var(--gold); }
@media (max-width: 760px) {
  /* Anchored to the masthead rather than the note, which sits mid-row: it opens under the row's right edge
     and never past the left of a narrow screen. */
  .masthead { position: relative; }
  .feedback-preferences { position: static; margin-left: auto; flex-shrink: 0; }
  .feedback-preferences + #shape { margin-left: 0; }
  .feedback-body { top: 44px; z-index: 30; }
}

/* Tempos are chosen per creature from its tab and sent together: the tabs and Confirm span both tempo buttons,
   and Confirm is a plain action, not a third tempo. */
#decision[data-kind="Speed"] #choices > .tempo-picker, #decision[data-kind="Speed"] #choices > .tempo-confirm { grid-column: 1 / -1; }
#decision[data-kind="Speed"] #choices > .tempo-confirm { min-height: 48px; font-size: 16px; text-align: center; }
#decision[data-kind="Speed"] #choices > .tempo-confirm:not(:disabled) { background: var(--gold); border-color: var(--gold); color: var(--accent-ink); font-weight: 700; }
#decision[data-kind="Speed"] #choices > .tempo-confirm::before { content: none; display: none; }

/* A phone held sideways has the width for two columns and not the height for one page: the battlefield and the
   desk side by side, each in reach without scrolling past the other. The round bar heads the battlefield on the
   left, fixed, and the board under it scrolls on its own (the bar's height is --phase-height, which the page
   keeps current); the desk and its spellbook are the page on the right. The bar keeps its chips, a row a side,
   so every creature is in view at once; the board under them is the detail. The board being always there, the
   Battlefield button is not drawn, nor the phase's reminder line. */
@media (orientation: landscape) and (max-height: 520px) and (max-width: 1099px) {
  :root { --side: clamp(270px, 38vw, 380px); }
  body:has(#table:not([hidden])) { padding: env(safe-area-inset-top) max(12px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) calc(var(--side) + 12px); }
  body:has(#table:not([hidden])) .masthead { min-height: 0; padding: 4px 0; gap: 10px; flex-wrap: nowrap; }
  body:has(#table:not([hidden])) .masthead .brand { display: none; }
  .tabs, .session-state #phase { display: none; }
  body:has(#table:not([hidden])) .session-state { flex: 1; width: auto; order: 0; margin: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; text-align: left; }
  #table { margin-top: 4px; }
  #phase-dock { position: fixed; top: 0; left: 0; width: var(--side); margin: 0; padding: max(8px, env(safe-area-inset-top)) 10px 8px max(10px, env(safe-area-inset-left)); gap: 5px; border-width: 0 1px 1px 0; border-radius: 0 0 10px 0; z-index: 24; }
  /* What opens from the bar opens over both columns from its left edge, rather than off the screen's. */
  #phase-notice, #phase-steps, #announcement-list, #upkeep-panel, #match-panel, #recap-actions, #order-panel {
    left: 0; right: auto; width: min(520px, calc(100vw - 20px)); max-height: min(70dvh, 320px);
  }
  #phase-reminder, .board-toggle, #phase-turn { display: none; }
  .phase-primary { flex-wrap: nowrap; gap: 10px; }
  #phase-round { font-size: 14px; }
  #phase-current { font-size: 14px; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #phase-current .phase-major { display: none; }
  /* The bar stays short enough to leave the board most of the column: the last action on one line (its full
     text is its title), the tools on one row that slides sideways. */
  .combat-line { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .phase-tools { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .phase-tools > details > summary { min-height: 30px; padding: 4px 8px; font-size: 11px; white-space: nowrap; }
  .mini-board, body.board-open .mini-board { display: grid; grid-row: auto; grid-template-columns: minmax(0, 1fr); }
  body.board-open { overflow: auto; }
  #board, body.board-open #board, body:not(.board-open) #board {
    display: block; position: fixed; inset: auto; top: var(--phase-height, 120px); left: 0; bottom: 0; width: var(--side);
    margin: 0; padding: 10px 10px max(16px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); overflow-y: auto; overscroll-behavior: contain;
    background: var(--paper); border-right: 1px solid var(--line); z-index: 22; scroll-margin-top: 12px;
  }
  /* A creature in a few lines, as a phone's opened battlefield draws it (its stats as the cards' symbols, the
     word kept for a screen reader), whatever the width: the column is a phone's either way. */
  #board .who { margin: 0; }
  #board .creature-name { font-size: 13px; }
  #board :is(.badges, .dock, .markers) { grid-column: 1 / -1; margin-top: 2px; }
  #board .creature { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; padding: 9px 10px; }
  #board .creature.legal, #board .creature.picked { padding: 8px 9px; }
  #board .creature:not(.legal, .picked, .active, .dead) .creature-label { display: none; }
  #board .creature-id { min-width: 24px; height: 24px; }
  #board .health { grid-column: 1 / -1; height: 17px; margin-bottom: 2px; }
  #board .stats { grid-column: 2; grid-row: 1; align-self: start; display: flex; gap: 8px; }
  #board .stat { flex-direction: row; align-items: baseline; gap: 3px; }
  #board .stat strong { font-size: 15px; }
  #board .stat strong::before { margin-right: 1px; font-size: 12px; }
  #board .stat-energy strong::before { content: 'ϟ'; }
  #board .stat-defense strong::before { content: '◇'; }
  #board .stat-initiative strong::before { content: '↟'; }
  #board .stat span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  #board .round-choice { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; margin-top: 2px; padding-top: 5px; }
  #board .round-choice .choice-spell { margin: 0; font-size: 13px; }
  #board .round-choice .choice-targets, #board .round-choice .choice-previous { margin: 0; font-size: 11px; }
  #board .team-section .section-heading { margin-bottom: 6px; }
  #board .team-grid { grid-template-columns: 1fr; gap: 6px; }
  .initiative-section .strip { display: grid; gap: 8px; overflow: visible; }
  .initiative-section .band { display: block; min-width: 0; }
  .initiative-section .band-name { margin-bottom: 4px; }
  .initiative-section .slots { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
  .initiative-section .slot { min-width: 0; padding: 5px; }
  /* One continuous right column. A capped sheet with overflow:visible paints choices over the next
     section; the portrait flex/scroll rules also leave no usable list height on a short screen. */
  #planning, #planning:is([data-kind="Speed"], [data-kind="Intent"]) {
    display: block; min-width: 0; height: auto; max-height: none; overflow: visible;
    padding: 14px; border: 1px solid var(--line); border-radius: var(--radius-soft); background: var(--panel); scroll-margin-top: 12px;
  }
  .play-area:has(#decision[data-kind="Target"]) .action-area, .action-area { position: static; }
  .sheet { max-height: none; border-radius: var(--radius-soft); box-shadow: none; }
  #decision, #decision[data-kind="Evolution"], #planning:is([data-kind="Speed"], [data-kind="Intent"]) #decision {
    display: block; max-height: none; overflow: visible; padding: 0 0 12px; border: 0; background: transparent; box-shadow: none; scroll-margin-top: 12px;
  }
  #decision .decision-heading { margin-bottom: 8px; }
  #decision #asking { font-size: 22px; margin: 0 0 6px; }
  .decision-context { margin: 0 0 10px; font-size: 12px; }
  #decision .shortcuts { display: none; }
  #evolution-budget .pick-budget { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; padding: 8px; margin-bottom: 8px; }
  #evolution-budget .pick-budget > strong { font-size: 12px; }
  #evolution-budget .pick-tokens { margin: 0; gap: 4px; }
  #evolution-budget .pick-token { padding: 2px 5px; }
  #evolution-budget .pick-note { flex-basis: 100%; }
  #choices, #decision[data-kind="Evolution"] #choices { grid-column: 1; grid-row: auto; grid-template-rows: none; overflow: visible; gap: 10px; }
  #decision[data-kind="Evolution"] .choice-cards {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr));
    gap: 8px; overflow: visible; min-height: 0;
  }
  #decision .package-card {
    display: flex; flex-direction: column; align-items: stretch; justify-content: flex-start;
    min-width: 0; min-height: 88px; padding: 12px; border-color: var(--line);
    border-top-color: var(--class-color, var(--gold)); border-radius: var(--radius-soft);
    background: var(--raised); color: var(--ink); box-shadow: none;
  }
  #decision .package-card .card-title { display: block; font-size: 19px; overflow-wrap: anywhere; }
  #decision .package-card .card-meta { color: #b7c9bd; margin-top: 4px; font-size: 11px; }
  #decision .package-card .card-body { margin-top: 9px; padding-top: 8px; border-top: 1px solid var(--line); color: var(--ink); font-size: 12px; line-height: 1.5; }
  #decision .package-card .package-requires { color: #b7c9bd; margin-top: 6px; font-size: 11px; }
  #decision[data-kind="Evolution"] #choices > button { min-height: 44px; font-size: 12px; padding: 8px; }
  #decision[data-kind="Speed"] #choices > button { min-height: 48px; font-size: 18px; text-align: center; padding: 8px; }
  #decision[data-kind="Speed"] #choices > button::before { display: inline; margin: 0 8px 0 0; }
  #planning .hand-section, #planning:is([data-kind="Speed"], [data-kind="Intent"]) .hand-section {
    height: auto; min-height: 0; overflow: visible; padding-top: 12px;
  }
  .hand-section > .section-heading { display: flex; align-items: center; gap: 8px; }
  .hand-actions .reference-link { min-height: 44px; padding: 6px 8px; font-size: 11px; }
}
