/* Dragon Fist: the page and its screens, in the language of the painted courtyards and the bronze-and-lacquer plates.
   The parts (panel, plaque, pills, portrait frame, nameplate, scroll page, toast, ink wash) come from ./ui/kit.css with the tokens of
   ./ui/tokens.css; this sheet lays them out for the title, the select screen, pause, options, the result, the sheets and touch. */
:root {
  --night: var(--ui-night);
  --panel: var(--ui-lacquer);
  --panel-2: var(--ui-lacquer-2);
  --ink: var(--ui-cream);
  --muted: var(--ui-text-muted);
  --gold: var(--ui-gold);
  --red: var(--ui-crimson);
  --line: var(--ui-bronze-dark);
  --focus: var(--ui-focus);
}
:root[data-contrast='high'] { --line: #ffffff; --muted: #ffffff; }
* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
  margin: 0;
  background: radial-gradient(120% 80% at 50% 0%, #3a1a47 0%, var(--night) 60%) fixed;
  color: var(--ink);
  font: 16px/1.5 var(--ui-font-body);
  min-height: 100vh;
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: 8px; top: -60px; background: var(--gold); color: #111; padding: 8px 12px; border-radius: 6px; z-index: 20; }
.skip-link:focus { top: 8px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- page header ---------- */
.df-header {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px;
  padding: 8px max(16px, env(safe-area-inset-left)); border-bottom: 2px solid var(--line);
  background: linear-gradient(180deg, rgba(42, 18, 54, 0.95), rgba(20, 9, 28, 0.92));
}
.back-link { color: var(--ink); text-decoration: none; font-weight: 700; min-height: 44px; display: inline-flex; align-items: center; gap: 4px; font-family: var(--ui-font-display); }
.back-link:hover span { text-decoration: underline; }
.df-brand { display: grid; line-height: 1.1; text-align: center; }
.df-brand strong { font: 700 18px/1 var(--ui-font-display); letter-spacing: 0.16em; color: var(--gold); text-shadow: 0 1px 0 var(--ui-ink); }
.df-brand small { color: var(--muted); letter-spacing: 0.1em; text-transform: uppercase; font-size: 10px; }
.header-actions { display: flex; gap: 8px; }
button { font: inherit; }
button:disabled { opacity: 0.5; cursor: default; }
button.primary { font-family: var(--ui-font-display); }

/* ---------- the stage ---------- */
.df-main { width: min(1100px, 100%); margin: 0 auto; padding: 14px max(16px, env(safe-area-inset-left)) 40px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.df-main > * { min-width: 0; }
.stage {
  position: relative; width: 100%; aspect-ratio: 16 / 9; background: #000; border: 3px solid var(--ui-bronze-dark); border-radius: 6px; overflow: hidden;
  box-shadow: 0 0 0 1px rgba(255, 201, 60, 0.35) inset, 0 14px 44px rgba(0, 0, 0, 0.6);
}
.stage canvas { display: block; width: 100%; height: 100%; image-rendering: pixelated; image-rendering: crisp-edges; image-rendering: pixelated; touch-action: none; }

/* a card is a screen over the stage; a wash keeps the picture but calms it (the result and the sheets go opaque) */
.card { position: absolute; inset: 0; display: grid; place-items: safe center; background: rgba(20, 9, 28, 0.55); padding: clamp(8px, 2vw, 20px); overflow: auto; }
.card[hidden] { display: none; }
.panel { width: min(520px, 100%); display: grid; gap: clamp(6px, 1.4vw, 12px); text-align: center; }
.panel.ui-panel { padding: clamp(14px, 2.4vw, 22px) clamp(12px, 2.4vw, 24px); }
.kicker { margin: 0; color: var(--gold); font-weight: 800; letter-spacing: 0.16em; font-size: clamp(10px, 1.6vw, 13px); }
h2 { margin: 0; font-size: 22px; }
.lede { margin: 0; color: var(--muted); font-size: clamp(13px, 2vw, 16px); }
.small { margin: 0; color: var(--muted); font-size: 13px; }
.art-error { color: #ffb4a8; font-weight: 700; }
.stage[data-art='error'] .title-scroll, .stage[data-art='error'] #best-line, .stage[data-art='error'] #start-button, .stage[data-art='error'] #continue-button, .stage[data-art='error'] #continue-note { display: none; }
:root[data-contrast='high'] .art-error { color: #ffffff; }
.button-row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.button-row--column { flex-direction: column; align-items: stretch; width: min(300px, 100%); margin: 0 auto; }
.panel:has(.sbg-demo-actions) .button-row a.button { display: none; }

/* ---------- the title splash: key painting, logo, press any key ---------- */
.card[data-card='title'] { background: none; padding: 0; overflow: hidden; place-items: stretch; }
.title-splash { position: absolute; inset: 0; z-index: 6; display: grid; grid-template-rows: 0.7fr auto auto 1fr auto auto; justify-items: center; align-items: center; overflow: hidden; cursor: pointer; background: var(--ui-night); }
.title-splash__art { position: absolute; inset: -3%; background: url('./art/brand/title-painting.webp') center / cover no-repeat; animation: df-kenburns 36s var(--ui-ease) infinite alternate; }
.title-splash__shade { position: absolute; inset: 0; background: radial-gradient(90% 70% at 50% 45%, rgba(20, 9, 28, 0) 40%, rgba(20, 9, 28, 0.55) 100%), linear-gradient(180deg, rgba(20, 9, 28, 0.35), rgba(20, 9, 28, 0) 30%, rgba(20, 9, 28, 0) 70%, rgba(20, 9, 28, 0.75)); }
.title-splash > * { position: relative; }
.title-splash__art, .title-splash__shade, .title-splash .ui-ambience { position: absolute; }
.title-splash__logo { grid-row: 2; justify-self: start; margin-inline-start: 6%; width: min(42%, 430px); height: auto; filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.7)) drop-shadow(0 0 24px rgba(240, 106, 42, 0.45)); animation: df-float 6s var(--ui-ease) infinite alternate; }
.title-splash__kicker { grid-row: 3; align-self: start; justify-self: start; margin-inline-start: calc(6% + 12px); margin-top: 2px; color: var(--ui-cream); text-shadow: 0 1px 0 var(--ui-ink), 0 0 12px rgba(240, 106, 42, 0.5); }
.title-splash__press { grid-row: 5; align-self: end; margin-bottom: 4%; padding: 8px 22px; border: 2px solid rgba(255, 201, 60, 0.6); border-radius: 999px; background: rgba(20, 9, 28, 0.55); }
.title-splash__notice { grid-row: 6; margin: 0 0 8px; color: var(--ui-cream); opacity: 0.8; font-size: 11px; }
.title-splash .ui-ambience { position: absolute; inset: 0; z-index: 1; }
@keyframes df-kenburns { from { transform: scale(1) translate(0, 0); } to { transform: scale(1.06) translate(-1.2%, 0.8%); } }
@keyframes df-float { from { transform: translateY(0); } to { transform: translateY(-6px); } }
:root[data-motion='reduced'] .title-splash__art, :root[data-motion='reduced'] .title-splash__logo { animation: none; }

/* ---------- the select screen ---------- */
.title-panel { position: absolute; inset: 0; width: auto; display: flex; flex-direction: column; gap: 6px; padding: 8px 10px; text-align: start; overflow: hidden; background: linear-gradient(180deg, rgba(20, 9, 28, 0.35), rgba(20, 9, 28, 0) 22%, rgba(20, 9, 28, 0) 60%, rgba(20, 9, 28, 0.6) 100%); }
.title-panel > * { flex: 0 0 auto; }
.title-panel > .title-scroll { flex: 1 1 auto; }
/* the choices: a column that scrolls on a phone and a grid on a desktop; no group is ever squeezed */
.title-scroll { display: flex; flex-direction: column; gap: 8px; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 2px; scrollbar-gutter: stable; }
.title-scroll > * { flex: 0 0 auto; }
.title-glass { background: linear-gradient(180deg, rgba(42, 18, 54, 0.88), rgba(20, 9, 28, 0.86)); border: 2px solid var(--ui-bronze-dark); border-radius: var(--ui-radius-l); box-shadow: inset 0 0 0 1px rgba(255, 201, 60, 0.28), 0 8px 24px rgba(0, 0, 0, 0.45); }
:root[data-contrast='high'] .title-glass { background: var(--ui-lacquer); }
.title-modes { padding: 4px 8px 4px; gap: 4px; overflow-y: auto; overscroll-behavior: contain; min-height: 0; max-height: 100%; }
.title-modes legend { float: left; width: 100%; margin-bottom: 2px; }
.title-modes label { padding-top: 0; }
.title-modes .ui-plaque { font-size: 11px; letter-spacing: 0; line-height: 1.15; min-height: 32px; padding-block: 0; padding-inline-start: 15px; padding-inline-end: 6px; gap: 5px; margin-top: 8px; }
.title-modes .ui-plaque--hang::before { top: -16px; width: 32px; height: 16px; }
.title-modes .ui-list input + .ui-plaque::after { width: 5px; height: 5px; inset-inline-start: 5px; }
.title-modes .ui-plaque__icon { width: 18px; height: 18px; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.6)); }
/* the list scrolls inside its box when a saved run or a long language leaves it short: a fade and an arrow at the foot say there is more (watchScrollCue sets data-more) */
.title-modes[data-more='true']::after { content: ''; position: sticky; bottom: -4px; flex: 0 0 26px; margin-top: -26px; margin-inline: -8px; pointer-events: none; border-radius: 0 0 var(--ui-radius-l) var(--ui-radius-l); background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 10'%3E%3Cpath d='M2 2l6 6 6-6' fill='none' stroke='%23ffc93c' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center 10px / 16px 10px no-repeat, linear-gradient(180deg, rgba(20, 9, 28, 0), rgba(20, 9, 28, 0.94) 70%); }
.title-window { min-height: 0; }
@media (min-width: 900px) and (min-height: 521px) { .title-window { min-height: 72px; } }
.title-picks { display: grid; gap: 3px; padding: 4px 10px 6px; }
.title-blurb { color: var(--ui-cream); }
.title-picks .ui-pills { gap: 3px 4px; }
/* legends keep a column width but grow for a long language instead of breaking a word (xx-long: COURTYARD, PLAYERS, OPPONENTS) */
.title-picks .ui-pills legend { float: left; width: auto; min-width: 90px; padding-inline-end: 8px; line-height: 28px; }
.title-picks .ui-pill > span { min-height: 28px; padding: 1px 9px; font-size: 11px; }
.title-blurb { font-size: 12px; }
#best-line { font-size: 11px; }
#courtyard-picker .ui-pill > span, #ruleset-picker .ui-pill > span { flex-direction: column; min-height: 28px; line-height: 1.1; }
#courtyard-picker small, #ruleset-picker small { font-size: 10px; }

/* the roster wall: small lacquer frames with the seat badge; the name sits on a strip at the foot of the tile */
.fighter-picker { border: 0; margin: 0; padding: 4px 8px 6px; display: grid; grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); gap: 4px; width: 100%; }
/* the legend floats so the browser lays it out as an ordinary first child (a rendered legend sits half above the box and is clipped) */
.fighter-picker legend { float: left; grid-column: 1 / -1; width: 100%; padding: 2px 0 4px; font: 700 var(--ui-fs-xs)/1.2 var(--ui-font-display); letter-spacing: 0.14em; text-transform: uppercase; color: var(--ui-ember); }
.fighter-picker label { position: relative; display: block; }
.fighter-picker input { position: absolute; opacity: 0; inset: 0; margin: 0; }
.fighter-card { position: relative; display: block; aspect-ratio: 4 / 5; overflow: hidden; cursor: pointer; background: radial-gradient(80% 60% at 50% 30%, var(--ui-violet), var(--ui-deep) 60%, var(--ui-ink)); border: 2px solid var(--ui-bronze-dark); border-radius: 3px; box-shadow: inset 0 0 0 1px rgba(255, 201, 60, 0.4), inset 0 0 0 2px var(--ui-ink); transition: transform var(--ui-t-fast) var(--ui-ease), border-color var(--ui-t-fast); }
.fighter-card img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: top; image-rendering: auto; }
.fighter-card strong { position: absolute; left: 0; right: 0; bottom: 0; padding: 1px 2px; font: 700 10px/1.2 var(--ui-font-display); letter-spacing: 0.02em; text-align: center; color: var(--ui-cream); background: linear-gradient(180deg, rgba(20, 9, 28, 0), rgba(20, 9, 28, 0.85) 40%); text-shadow: 0 1px 0 var(--ui-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* a long name shrinks to the tile instead of ending in an ellipsis ('Obsidi...' in English at 56 px): main.mjs sets --len (the letters of the name), the tile is the container; 7 px is the floor, an ellipsis is the last resort */
.fighter-card { container-type: inline-size; }
.fighter-card strong { font-size: clamp(7px, calc(100cqw / calc(var(--len, 6) * 0.86)), 10px); }
.fighter-card .discipline, .fighter-card .bio { display: none; }
.fighter-picker label:hover .fighter-card { border-color: var(--gold); transform: translateY(-2px); }
.fighter-picker input:checked + .fighter-card { border-color: var(--gold); box-shadow: inset 0 0 0 1px var(--ui-gold-hi), inset 0 0 0 2px var(--ui-ink), 0 0 0 2px var(--gold), 0 0 16px rgba(255, 201, 60, 0.45); }
.fighter-picker input:focus-visible + .fighter-card, :root[data-nav='pad'] .fighter-picker input:focus + .fighter-card { outline: 3px solid var(--focus); outline-offset: 2px; }

/* the spotlight: the picked fighter large */
/* a long language's bio may push the stat marks down: the column scrolls rather than cutting them off */
.spotlight { display: grid; gap: 5px; padding: 8px 10px; align-content: start; justify-items: center; text-align: center; overflow: hidden auto; overscroll-behavior: contain; }
.spotlight__portrait { width: 100%; max-width: 200px; aspect-ratio: auto; height: clamp(120px, 24vh, 170px); }
.spotlight__name { max-width: calc(100% - 20px); font-size: var(--ui-fs-m); min-height: 30px; padding: 2px 16px; }
.spotlight__line { font-size: 10px; }
.spotlight__bio { font-size: 11.5px; line-height: 1.3; color: var(--ui-cream); }
.spotlight__sig { color: var(--gold); font-size: 11px; line-height: 1.3; }
.spotlight__stats { display: grid; gap: 3px; width: 100%; }
.spotlight__stats .ui-stat { grid-template-columns: 52px 1fr; font-size: 11px; }

/* the foot: Players and Opponents, Start, the small plaques, the status line and the notice */
.title-actions { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: 'setup go' 'buttons go' 'status status'; align-items: center; gap: 4px 12px; padding: 6px 10px; }
.title-setup { grid-area: setup; display: flex; flex-wrap: wrap; gap: 4px 14px; }
.title-setup .ui-pills { gap: 3px 4px; }
.title-setup .ui-pills legend { float: left; width: auto; min-width: 72px; margin: 0 4px 0 0; padding: 0; font-size: 10px; line-height: 32px; }
.title-setup .ui-pill > span { min-height: 32px; min-width: 34px; padding: 2px 9px; font-size: 12px; }
.title-go { grid-area: go; display: grid; gap: 4px; justify-items: center; }
.title-go .ui-plaque { min-width: min(100%, 220px); }
/* the note under Continue and Start had the browser's paragraph margins (26 px of dead space in the foot) */
.title-go #continue-note { margin: 0; text-align: center; }
.title-actions .button-row { grid-area: buttons; justify-content: flex-start; gap: 6px; }
.title-actions > #art-status, .title-actions > #art-error, .title-actions > #art-retry, .title-actions > .notice { grid-area: status; justify-self: center; }
.title-actions > #continue-note { grid-area: status; }
.title-actions .notice { font-size: 10px; opacity: 0.8; }
#art-status { font-size: 11px; }

@media (min-width: 900px) and (min-height: 521px) {
  /* the wall and the picks take their own height; the window takes what is left (the camera frames the fighter in a short window) */
  .title-grid { display: grid; grid-template-columns: 196px minmax(0, 1fr) 228px; grid-template-rows: auto minmax(0, 1fr) auto; grid-template-areas: 'modes wall spot' 'modes window spot' 'modes picks spot'; gap: 8px; overflow: hidden; }
  .title-modes { grid-area: modes; align-self: start; }
  /* Continue and Start side by side with the note under both: the foot stays about 110 px (stacked: 183 px) so all eight modes stay in view */
  .title-go--saved { grid-template-columns: auto auto; column-gap: 8px; }
  .title-go--saved #continue-note { grid-column: 1 / -1; }
  .title-window { grid-area: window; }
  .fighter-picker { grid-area: wall; }
  .title-picks { grid-area: picks; }
  .spotlight { grid-area: spot; }
}

/* ---------- pause, ceremony, result ---------- */
.pause-panel { width: min(360px, 100%); }
.ceremony-panel { width: min(460px, 100%); }
.result-panel { width: min(540px, 100%); gap: 6px; }
.result-panel .button-row { margin-top: 8px; align-items: flex-end; }
.result-panel .ui-heading { font-size: 22px; }
.card[data-card='result'], .card[data-card='ceremony'] { background: rgba(20, 9, 28, 0.82); backdrop-filter: blur(5px); }
/* the heading is written on the painted banner cloth and the wax seal hangs off its edge */
.result-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; position: relative; margin-top: -70px; padding: 0 4px 0 14px; min-height: 56px; }
.result-top .ui-heading { color: var(--ui-gold-hi); text-shadow: 0 2px 0 var(--ui-ink), 0 0 10px rgba(36, 18, 43, 0.9); }
.grade { width: 64px; height: 64px; font-size: 30px; margin-top: 18px; }
.grade:empty { display: none; }
.result-banner { height: 64px; margin: calc(-1 * var(--ui-frame-size) - 4px) calc(-1 * var(--ui-frame-size) - 4px) 2px; background: url('./art/ui/result-banner.webp') center 40% / cover no-repeat; border-bottom: 2px solid var(--ui-bronze-dark); box-shadow: inset 0 -20px 24px -16px var(--ui-night); }
.standings { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; text-align: start; }
.standings li { display: grid; grid-template-columns: 32px 1fr auto; gap: 8px; align-items: center; background: linear-gradient(180deg, var(--ui-lacquer-hi), var(--ui-lacquer)); border: 2px solid var(--ui-bronze-dark); border-radius: 4px; padding: 3px 10px; box-shadow: inset 0 0 0 1px rgba(255, 201, 60, 0.25); font-family: var(--ui-font-display); }
.standings li[data-rank='1'] { border-color: var(--gold); }
.standings .rank { font-weight: 700; color: var(--gold); }
.standings .pts { font-variant-numeric: tabular-nums; color: var(--muted); font-family: var(--ui-font-body); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 0; }
.stats div { background: rgba(20, 9, 28, 0.6); border: 1px solid var(--ui-bronze-dark); border-radius: 4px; padding: 3px 6px; }
.stats dt { font-size: 11px; color: var(--muted); }
.stats dd { margin: 0; font: 700 17px/1.2 var(--ui-font-display); color: var(--ui-cream); }
.best { margin: 0; min-height: 1.4em; color: var(--gold); font-weight: 700; font-family: var(--ui-font-display); }
.sash-icon { width: 96px; height: 64px; image-rendering: pixelated; justify-self: center; }

/* ---------- touch ---------- */
.touch { display: none; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 12px 16px; user-select: none; -webkit-user-select: none; touch-action: none; }
.touch button { touch-action: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; font-size: 22px; color: var(--ink); background: linear-gradient(180deg, var(--ui-lacquer-hi), var(--ui-lacquer)); border: 2px solid var(--ui-bronze-dark); border-radius: 8px; min-height: 44px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; box-shadow: inset 0 0 0 1px rgba(255, 201, 60, 0.3); font-family: var(--ui-font-display); font-weight: 700; }
.dpad { display: grid; grid-template-columns: repeat(3, 64px); grid-template-rows: repeat(3, 56px); gap: 6px; grid-template-areas: '. up .' 'left . right' '. down .'; }
.dpad .up { grid-area: up; } .dpad .left { grid-area: left; } .dpad .right { grid-area: right; } .dpad .down { grid-area: down; }
.strikes { display: flex; gap: 12px; align-items: end; }
.strikes button { width: 92px; height: 92px; border-radius: 50%; font-size: 16px; }
.strikes .kick { margin-bottom: 36px; }
.touch button.is-down { background: linear-gradient(180deg, var(--ui-gold-hi), var(--ui-gold)); color: var(--ui-ink); border-color: #7a4d1c; }
@media (pointer: coarse), (max-width: 820px) { .touch { display: flex; } }

/* ---------- the page under the stage ---------- */
.info { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; align-items: start; }
.info > * { background: linear-gradient(180deg, rgba(42, 18, 54, 0.75), rgba(20, 9, 28, 0.7)); border: 2px solid var(--line); border-radius: 6px; padding: 14px 16px; margin: 0; box-shadow: inset 0 0 0 1px rgba(255, 201, 60, 0.2); }
.info h2 { font: 700 17px/1.2 var(--ui-font-display); letter-spacing: 0.08em; margin-bottom: 8px; color: var(--gold); }
.keys { border-collapse: collapse; width: 100%; font-size: 14px; }
.keys th { text-align: start; padding: 4px 8px 4px 0; vertical-align: top; white-space: nowrap; color: var(--ink); }
.keys td { padding: 4px 0; color: var(--muted); }
.plain { margin: 0; padding-inline-start: 1.1em; color: var(--muted); font-size: 14px; display: grid; gap: 6px; }

/* ---------- options ---------- */
.options { display: grid; gap: 10px; }
.options legend { font: 700 var(--ui-fs-s)/1.2 var(--ui-font-display); letter-spacing: 0.1em; color: var(--gold); padding: 0 6px; }
.options label { display: flex; align-items: center; gap: 10px; min-height: 36px; }
.options select { font: inherit; color: var(--ink); background: var(--panel-2); border: 2px solid var(--line); border-radius: 4px; padding: 6px 8px; margin-inline-start: auto; }
.options input[type='checkbox'] { width: 20px; height: 20px; accent-color: var(--gold); }
.card[data-card='options'] { position: fixed; inset: 0; z-index: 40; background: rgba(20, 9, 28, 0.94); place-items: start center; }
.panel-wide { width: min(860px, 100%); text-align: start; }
.panel-wide > h2, .panel-wide > #options-done { justify-self: center; }
.options-body { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; }
.options-body .options { margin: 0; border: 2px solid var(--line); border-radius: 6px; padding: 10px 12px; align-content: start; background: rgba(20, 9, 28, 0.45); }
.options-body .options:last-child { grid-column: 1 / -1; }
.options-body .ui-pills { justify-content: flex-start; }
.options .slider { display: grid; grid-template-columns: 1fr minmax(120px, 50%); }
.options input[type='range'] { accent-color: var(--gold); min-height: 32px; }
.options-status { min-height: 1.5em; }
.bindings { width: 100%; border-collapse: collapse; font-size: 14px; }
.bindings th, .bindings td { padding: 3px 4px; text-align: start; }
.bindings thead th { color: var(--muted); font-weight: 600; font-size: 12px; }
.bindings button.bind { min-height: 36px; min-width: 64px; padding: 4px 8px; font-size: 13px; }
.bindings button.bind:focus-visible { outline-offset: 0; }

/* ---------- replay bar, input display, captions, first hint ---------- */
.card[data-card='replay'] { background: none; place-items: end center; pointer-events: none; padding: 8px; }
.replay-bar { pointer-events: auto; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 4px 6px 4px 12px; }
.replay-bar .small { color: var(--ink); }
.input-display { position: absolute; left: 6px; top: 22%; display: flex; gap: 6px; pointer-events: none; z-index: 2; }
.input-display ol { list-style: none; margin: 0; padding: 4px 6px; background: rgba(20, 9, 28, 0.72); border: 1px solid var(--line); border-radius: 4px; min-width: 52px; font: 700 13px/1.25 var(--ui-font-mono); color: var(--ink); direction: ltr; }
.input-display li { display: flex; justify-content: space-between; gap: 6px; }
.input-display li:first-child { color: var(--gold); }
.input-display small { color: var(--muted); font-weight: 400; }
.captions { position: absolute; left: 50%; top: 27%; transform: translateX(-50%); z-index: 2; margin: 0; max-width: 90%; padding: 4px 14px; border-radius: 4px; background: rgba(20, 9, 28, 0.85); border: 1px solid var(--ui-bronze); font: 700 clamp(13px, 2.2vw, 20px)/1.25 var(--ui-font-display); color: var(--ink); text-align: center; pointer-events: none; }
.first-hint { position: absolute; left: 50%; bottom: 3%; transform: translateX(-50%); z-index: 2; margin: 0; max-width: 92%; padding: 4px 14px; border-radius: 4px; background: rgba(20, 9, 28, 0.88); border: 1px solid var(--ui-bronze); font: 700 clamp(12px, 1.9vw, 18px)/1.25 var(--ui-font-display); color: var(--ink); text-align: center; pointer-events: none; white-space: nowrap; }
@media (max-width: 560px) { .captions { font-size: 12px; padding: 2px 8px; } .first-hint { font-size: 11px; padding: 2px 8px; } }

/* ---------- gamepad focus, reduced motion ---------- */
:root[data-nav='pad'] :focus { outline: 3px solid var(--focus); outline-offset: 2px; }
:root[data-nav='pad'] .ui-pill input:focus + span { outline: 3px solid var(--focus); outline-offset: 2px; }
:root[data-motion='reduced'] * { transition: none !important; animation: none !important; }
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }

/* ---------- sheets: the move list, the sash ladder and the bonus-round list fill the screen ---------- */
.card-sheet { position: fixed; inset: 0; z-index: 40; background: rgba(20, 9, 28, 0.97); backdrop-filter: blur(8px); place-items: stretch center; padding: clamp(8px, 2vw, 20px) clamp(8px, 2vw, 20px) clamp(20px, 3vw, 28px); overflow: hidden; }
.sheet { width: min(960px, 100%); height: 100%; max-height: 100%; grid-template-rows: auto minmax(0, 1fr); grid-auto-rows: auto; text-align: start; overflow: hidden; }
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.sheet-head .small { margin-top: 2px; }
.sheet-head button { flex-shrink: 0; }
.sheet h2 { font-size: 20px; }
.legend { color: var(--muted); font-size: 13px; }
.legend summary { cursor: pointer; min-height: 28px; display: flex; align-items: center; }
.legend p { margin: 4px 0 0; }

/* ---------- the Training Dojo bar ---------- */
.dojo-bar { position: absolute; left: 0; right: 0; bottom: 0; z-index: 3; display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 6px; padding: 4px 8px 6px; pointer-events: none; }
.dojo-bar button { pointer-events: auto; white-space: nowrap; }
.dojo-bar[data-place='below'] { position: static; padding: 0; }
.dojo-bar[data-place='below'] button { flex: 1 1 auto; min-height: 44px; }

/* ---------- move list ---------- */
.movelist { overflow: auto; min-height: 0; border: 2px solid var(--line); border-radius: 6px; background: rgba(20, 9, 28, 0.6); }
.movelist:focus-visible { outline-offset: -3px; }
.move { display: grid; grid-template-columns: minmax(126px, 1.2fr) minmax(150px, 1.4fr) 54px 54px repeat(6, 52px); gap: 2px 8px; align-items: baseline; padding: 7px 12px; border-bottom: 1px solid var(--line); font-size: 14px; }
.move.head { position: sticky; top: 0; z-index: 1; background: var(--panel-2); color: var(--muted); font-size: 12px; font-weight: 700; }
.move strong { font-size: 15px; font-family: var(--ui-font-display); }
.m-num, .m-pts, .move.head .m-num, .move.head .m-pts { text-align: end; font-variant-numeric: tabular-nums; }
.m-input { color: var(--muted); }
.m-note { grid-column: 1 / -1; color: var(--muted); font-size: 12px; line-height: 1.35; }
.move[data-kind='signature'] { background: rgba(255, 210, 90, 0.12); }
.move[data-kind='guard'] { grid-template-columns: minmax(126px, 1.2fr) minmax(150px, 1.4fr) 1fr; }
.move[data-kind='guard'] .m-note { grid-column: 3 / -1; }
.badge { margin-inline-start: 8px; padding: 0 6px; border: 1px solid var(--gold); border-radius: 4px; color: var(--gold); font-size: 11px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; }
@media (max-width: 760px) {
  .move.head { display: none; }
  .move { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 3px 6px; padding: 8px 10px; }
  .m-name { grid-column: 1 / 5; grid-row: 1; }
  .m-height { grid-column: 5 / 6; grid-row: 1; text-align: end; font-weight: 700; }
  .m-pts { grid-column: 6 / 7; grid-row: 1; text-align: end; font-weight: 700; color: var(--gold); }
  .m-pts::after { content: ' ' attr(data-suffix); }
  .m-input { grid-column: 1 / -1; grid-row: 2; }
  .m-num { text-align: start; font-weight: 700; }
  .m-num::before { content: attr(data-label); display: block; color: var(--muted); font-size: 10px; font-weight: 400; }
  .move[data-kind='guard'] { grid-template-columns: 1fr; }
  .move[data-kind='guard'] .m-note { grid-column: 1; }
}

/* ---------- sash ladder ---------- */
.ladder { list-style: none; margin: 0; padding: 2px 4px 2px 2px; overflow: auto; min-height: 0; display: grid; gap: 6px; align-content: start; }
/* the sixteen rungs scroll: a fade and an arrow at the foot say so (watchScrollCue) instead of a rung cut off mid-way looking like a fault */
.ladder[data-more='true']::after { content: ''; position: sticky; bottom: 0; height: 30px; margin-top: -36px; pointer-events: none; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 10'%3E%3Cpath d='M2 2l6 6 6-6' fill='none' stroke='%23ffc93c' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center 14px / 16px 10px no-repeat, linear-gradient(180deg, rgba(20, 9, 28, 0), rgba(20, 9, 28, 0.96) 70%); }
.rung { display: grid; grid-template-columns: 56px minmax(150px, 1fr) minmax(0, 1.6fr) 104px; align-items: center; gap: 2px 12px; padding: 8px 10px; border: 2px solid var(--line); border-radius: 4px; background: linear-gradient(180deg, var(--ui-lacquer-hi), var(--ui-lacquer)); box-shadow: inset 0 0 0 1px rgba(255, 201, 60, 0.2); scroll-margin: 8px; }
.rung:focus-visible { outline-offset: -2px; }
.rung[data-status='won'], .rung[data-status='reached'] { border-color: #74b87d; }
.rung[data-status='now'], .rung[data-status='next'] { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold) inset; }
.rung[data-status='ended'] { border-color: var(--red); box-shadow: 0 0 0 2px var(--red) inset; }
.rung[data-status='ahead'] { opacity: 0.85; }
.rung-main, .rung-details { display: grid; gap: 1px; min-width: 0; }
.rung-main strong { font-size: 15px; font-family: var(--ui-font-display); }
.rung-main span, .rung-details span { color: var(--muted); font-size: 13px; }
.rung-details .rung-bonus { color: var(--gold); }
.rung-status { justify-self: end; text-align: end; font-weight: 800; color: var(--gold); font-size: 13px; font-family: var(--ui-font-display); }
.rung[data-status='won'] .rung-status, .rung[data-status='reached'] .rung-status { color: var(--ui-win); }
.rung[data-status='ended'] .rung-status { color: var(--ui-lose); }
.sash-chip { position: relative; width: 56px; height: 36px; border-radius: 4px; background: var(--sash, #888); border: 2px solid rgba(255, 255, 255, 0.55); display: grid; place-items: center; overflow: hidden; }
.sash-chip img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; }
.sash-chip img ~ small { display: none; }
.sash-chip:has(img) { background: transparent; border-color: transparent; }
.sash-chip small { padding: 0 3px; border-radius: 3px; background: rgba(20, 9, 28, 0.78); color: #fff; font-size: 9px; line-height: 1.3; text-align: center; text-transform: capitalize; }
@media (max-width: 640px) {
  .rung { grid-template-columns: 56px minmax(0, 1fr) auto; gap: 4px 10px; }
  .sash-chip, .rung-main, .rung-status { grid-row: 1; }
  .rung-status { grid-column: 3; }
  .rung-details { grid-column: 1 / -1; grid-row: 2; }
}

/* ---------- bonus rounds in the dojo ---------- */
.bonus-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; overflow: auto; min-height: 0; align-content: start; }
.bonus-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; padding: 8px 10px; border: 2px solid var(--line); border-radius: 4px; background: linear-gradient(180deg, var(--ui-lacquer-hi), var(--ui-lacquer)); }
.bonus-row[data-locked='true'] { opacity: 0.65; }
.bonus-text { display: grid; flex: 1 1 220px; gap: 1px; }
.bonus-text strong { font-family: var(--ui-font-display); }
.bonus-text span { color: var(--muted); font-size: 13px; }
.bonus-levels { display: flex; gap: 6px; }

/* ---------- touch: guard, side, size ---------- */
.strikes .guard { width: 64px; height: 64px; font-size: 13px; align-self: start; }
.touch[data-guard='toggle'] .guard::after { content: ' \2195'; }
.touch[data-side='left'] { flex-direction: row-reverse; }
.touch[data-side='left'] .strikes { flex-direction: row-reverse; }
.touch[data-size='large'] .dpad { grid-template-columns: repeat(3, 76px); grid-template-rows: repeat(3, 66px); }
.touch[data-size='large'] .strikes button { width: 108px; height: 108px; }
.touch[data-size='large'] .strikes .guard { width: 76px; height: 76px; }

/* ================================================================================================================
   Small screens
   ================================================================================================================ */
@media (max-width: 640px) {
  .df-brand { display: none; }
  .df-header { padding-block: 6px; }
  .back-link { white-space: nowrap; }
  .header-actions { flex-shrink: 0; }
  .header-actions button { padding: 6px 10px; font-size: 13px; }
}
@media (max-width: 560px) {
  .panel { gap: 6px; }
  .panel.ui-panel { padding: 12px 10px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .card[data-card='result'], .card[data-card='paused'], .card[data-card='title'], .card[data-card='ceremony'] { position: fixed; inset: 0; z-index: 30; background: rgba(20, 9, 28, 0.92); }
  .dpad { grid-template-columns: repeat(3, clamp(44px, 15vw, 56px)); grid-template-rows: repeat(3, 48px); }
  .strikes button { width: clamp(64px, 21vw, 80px); height: clamp(64px, 21vw, 80px); }
  .strikes .kick { margin-bottom: 28px; }
  .strikes .guard { width: clamp(48px, 15vw, 60px); height: clamp(48px, 15vw, 60px); }
  .touch[data-size='large'] .dpad { grid-template-columns: repeat(3, clamp(52px, 17vw, 64px)); grid-template-rows: repeat(3, 56px); }
  .touch[data-size='large'] .strikes button { width: clamp(72px, 24vw, 92px); height: clamp(72px, 24vw, 92px); }
  .options-body { grid-template-columns: minmax(0, 1fr); }
  /* the Controls table fits the screen in every language (5 Nov: at 390 px with a long language it ran 75 px past the edge: a fieldset is as wide as its content unless told otherwise) */
  .options-body .options { min-width: 0; }
  /* the fieldset is a grid: its one track took the width of its widest item (the table, a select) and ran past the sheet; it takes the sheet's width now and a select shrinks with it */
  .options { grid-template-columns: minmax(0, 1fr); }
  .options > * { min-width: 0; }
  .options select { min-width: 0; max-width: 100%; flex: 1 1 140px; }
  .bindings { table-layout: fixed; }
  .bindings thead th:nth-child(1) { width: 27%; }
  .bindings thead th:nth-child(2), .bindings thead th:nth-child(3) { width: 17%; }
  .bindings thead th:nth-child(4) { width: 39%; }
  .bindings th, .bindings td { padding: 3px 2px; overflow-wrap: anywhere; }
  .bindings button.bind { min-width: 0; width: 100%; padding: 4px 2px; font-size: 11px; line-height: 1.15; white-space: normal; overflow-wrap: anywhere; }
  /* a portrait phone: the select screen is one scrolling column over the painted hall; modes as a wrapped row of plaques */
  .card[data-card='title'] { background: url('./art/brand/title-painting.webp') center / cover no-repeat var(--ui-night); }
  .title-panel { background: linear-gradient(180deg, rgba(20, 9, 28, 0.7), rgba(20, 9, 28, 0.82)); padding: 6px 8px; }
  .title-grid { overflow-y: auto; gap: 6px; }
  .title-modes { flex-direction: row; flex-wrap: wrap; gap: 6px; padding: 6px; }
  .title-modes label { flex: 1 1 45%; padding-top: 0; }
  .title-modes .ui-plaque { min-height: 36px; font-size: 12px; padding-inline-start: 18px; }
  .title-window { display: none; }
  .fighter-picker { grid-template-columns: repeat(auto-fill, minmax(54px, 1fr)); }
  .spotlight { grid-template-columns: 96px minmax(0, 1fr); grid-template-areas: 'portrait name' 'portrait line' 'portrait bio' 'sig sig' 'stats stats'; justify-items: start; text-align: start; gap: 4px 10px; }
  .spotlight__portrait { grid-area: portrait; width: 96px; height: 120px; }
  .spotlight__name { grid-area: name; } .spotlight__line { grid-area: line; } .spotlight__bio { grid-area: bio; } .spotlight__sig { grid-area: sig; } .spotlight__stats { grid-area: stats; }
  .title-actions { grid-template-columns: 1fr; grid-template-areas: 'setup' 'go' 'buttons' 'status'; gap: 6px; }
  .title-actions .button-row { justify-content: center; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }

/* Landscape phones: the whole stage fits above the fold, the controls float over it, the select screen is one scrolling column. */
@media (max-height: 520px) and (orientation: landscape) {
  .df-header { padding-block: 4px; }
  .df-header button, .back-link { min-height: 36px; }
  .df-main { padding: 8px 12px 24px; gap: 10px; }
  .stage { width: min(100%, calc((100vh - 76px) * 16 / 9)); margin: 0 auto; }
  .touch { position: fixed; left: 0; right: 0; bottom: 6px; padding: 0 14px; pointer-events: none; z-index: 5; }
  .touch button { pointer-events: auto; opacity: 0.78; }
  .dpad { grid-template-columns: repeat(3, 50px); grid-template-rows: repeat(3, 40px); gap: 4px; }
  .strikes button { width: 64px; height: 64px; font-size: 13px; }
  .strikes .kick { margin-bottom: 24px; }
  .strikes .guard { width: 48px; height: 48px; font-size: 11px; align-self: end; }
  .stage:not([data-screen='bout']):not([data-screen='bonus']) ~ .touch { visibility: hidden; }
  .touch[data-size='large'] .dpad { grid-template-columns: repeat(3, 58px); grid-template-rows: repeat(3, 46px); }
  .touch[data-size='large'] .strikes button { width: 76px; height: 76px; }
  .input-display { top: 30%; }
  .input-display ol { font-size: 11px; min-width: 44px; }
  .panel { gap: 5px; }
  .panel.ui-panel { padding: 10px 14px; }
  .pause-panel { width: min(360px, 100%); }
  .card[data-card='result'], .card[data-card='paused'], .card[data-card='title'], .card[data-card='ceremony'] { position: fixed; inset: 0; z-index: 30; background: rgba(20, 9, 28, 0.92); }
  .card[data-card='title'] { background: url('./art/brand/title-painting.webp') center / cover no-repeat var(--ui-night); padding: 0; }
  .title-panel { background: linear-gradient(180deg, rgba(20, 9, 28, 0.72), rgba(20, 9, 28, 0.85)); padding: 4px 8px; gap: 4px; }
  .title-grid { overflow-y: auto; gap: 5px; }
  .title-modes { flex-direction: row; flex-wrap: wrap; gap: 5px; padding: 5px; }
  .title-modes legend { position: absolute; width: 1px; height: 1px; margin: 0; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .title-modes label { flex: 0 1 auto; padding-top: 0; }
  .title-modes .ui-plaque { min-height: 34px; font-size: 12px; padding: 2px 10px 2px 18px; }
  .title-window { display: none; }
  .fighter-picker { grid-template-columns: repeat(auto-fill, minmax(50px, 1fr)); padding: 4px 6px 6px; }
  .fighter-picker legend { position: absolute; width: 1px; height: 1px; margin: 0; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .spotlight { grid-template-columns: 72px minmax(0, 1fr); grid-template-areas: 'portrait name' 'portrait line' 'portrait bio'; justify-items: start; text-align: start; gap: 2px 10px; padding: 6px 8px; }
  .spotlight__portrait { grid-area: portrait; width: 72px; height: 90px; }
  .spotlight__name { grid-area: name; min-height: 26px; font-size: 13px; } .spotlight__line { grid-area: line; } .spotlight__bio { grid-area: bio; font-size: 11px; }
  .spotlight__sig, .spotlight__stats { display: none; }
  .title-actions { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: 'setup go' 'buttons buttons' 'status status'; gap: 3px 10px; padding: 4px 8px; }
  .title-actions .button-row { justify-content: center; }
  .title-actions .button-row .ui-plaque, .title-go .ui-plaque { min-height: 34px; }
  .title-actions .ui-pill > span { min-height: 30px; font-size: 11px; padding: 2px 7px; }
  .title-splash__press { margin-bottom: 2%; padding: 4px 16px; font-size: 12px; }
  .title-splash__logo { width: min(34%, 260px); }
  .standings { gap: 3px; }
  .standings li { padding: 2px 8px; }
  .stats div { padding: 3px; }
  .stats dd { font-size: 15px; }
  .stats dt { font-size: 10px; }
  .grade { width: 56px; height: 56px; font-size: 26px; margin-top: 10px; }
  .result-banner { height: 44px; }
  /* the result card fits a 390 px tall screen: the heading on a shorter cloth, tighter rows, a smaller hint */
  .result-top { margin-top: -50px; min-height: 40px; }
  .result-panel { gap: 3px; }
  .result-panel .ui-text { font-size: 11px; line-height: 1.3; }
  .result-panel .button-row { margin-top: 2px; gap: 4px 6px; }
  h2 { font-size: 18px; }
  .best { min-height: 0; font-size: 13px; }
  .button-row button, .button-row .button { min-height: 36px; padding: 4px 12px; }
  .panel .sbg-demo-actions { margin: 4px 0 0; gap: 8px; }
  .panel .sbg-demo-actions a, .panel .sbg-demo-actions button { min-height: 36px; padding: 6px 12px; }
  .sheet { padding: 8px 12px; gap: 6px; }
  .sheet h2 { font-size: 16px; }
  .sheet-head button { min-height: 36px; }
  /* the Dojo bar sits between the touch clusters (the d-pad on one side, the strikes on the other, either side by option): the gap is the
     part of the clusters that reaches into the centred stage, and the bar keeps clear of the wider cluster on both sides (Guard sat over
     the end of the speed button at 844x390) */
  .dojo-bar { --dojo-gap: calc((100vw - min(100vw - 24px, (100vh - 76px) * 16 / 9)) / 2); padding: 2px max(4px, calc(216px - var(--dojo-gap))) 4px; gap: 3px 4px; }
  .df-main:has(.touch[data-size='large']) .dojo-bar { padding-inline: max(4px, calc(244px - var(--dojo-gap))); }
  .dojo-bar button { min-height: 32px; padding: 2px 7px; font-size: 11px; }
  .move { padding: 4px 10px; }
  .rung { padding: 4px 8px; }
}
