:root {
  color-scheme: light;
  --paper: #f6eee2;
  --ink: #33263e;
  --muted: #695b6b;
  --line: #d8c9bd;
  --mint: #9de4c7;
  --coral: #ff9b86;
  font: 16px/1.45 "Segoe UI", system-ui, sans-serif;
  background: var(--paper);
  color: var(--ink);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 280px; }
button, select, input { font: inherit; }
button { cursor: pointer; color: inherit; }
button:disabled { cursor: default; }
:focus-visible { outline: 3px solid #a83d55; outline-offset: 3px; }
.shell { width: min(1440px, 100%); padding-inline: clamp(14px, 5vw, 76px); margin-inline: auto; }
.masthead { display: flex; justify-content: space-between; align-items: center; min-height: 76px; border-bottom: 1px solid var(--line); gap: 8px; }
.eyebrow, footer { font-size: .71rem; letter-spacing: .16em; font-weight: 800; }
.header-actions { display: flex; gap: clamp(4px, 2vw, 25px); }
.text-button { min-height: 44px; padding: 6px; border: 0; background: transparent; font-size: .85rem; font-weight: 700; }
.text-button span { color: #933f59; margin-left: 3px; }
.cabinet { display: grid; grid-template-columns: minmax(220px, .66fr) minmax(0, 1.6fr); gap: clamp(24px, 5.2vw, 86px); padding-block: clamp(25px, 5.1vh, 60px) 24px; align-items: start; }
.story { padding-top: clamp(4px, 3vh, 36px); }
.eyebrow { color: #87465b; margin: 0; }
.eyebrow span { display: inline-block; width: 19px; height: 2px; margin: 0 5px 3px 0; background: #a04861; }
h1 { margin: 9px 0 13px; font: 900 clamp(4.35rem, 9vw, 8.55rem)/.88 "Arial Black", "Segoe UI Black", "Segoe UI", sans-serif; letter-spacing: -.115em; white-space: nowrap; }
.title-number { color: #a34261; margin-left: .1em; }
.intro { color: var(--muted); margin: 0; max-width: 29ch; font-size: clamp(.93rem, 1.35vw, 1.1rem); }
.lobby, .match { display: grid; gap: 12px; margin-top: clamp(23px, 5vh, 47px); max-width: 340px; }
.difficulty { border: 0; padding: 0; margin: 0 0 1px; min-width: 0; }
.difficulty legend { color: var(--muted); font-size: .78rem; font-weight: 700; margin-bottom: 6px; padding: 0; }
.segments { display: flex; gap: 4px; border-radius: 11px; padding: 3px; background: #ebe0d5; }
.segments label { cursor: pointer; position: relative; flex: 1; text-align: center; }
.segments span { display: block; padding: 10px 6px; font-size: .8rem; font-weight: 700; border-radius: 8px; }
.segments input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.segments input:checked + span { background: #fffbf5; box-shadow: 0 1px 4px #4330441f; }
.segments input:focus-visible + span { outline: 3px solid #a83d55; }
.action { display: flex; align-items: center; justify-content: space-between; text-align: left; gap: 8px; min-height: 65px; width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 11px 15px; font-weight: 800; }
.action small { display: block; font-size: .73rem; font-weight: 500; margin-top: 1px; opacity: .86; }
.primary { background: #352643; color: #fff8f2; border-color: #352643; }
.primary:hover { background: #51375a; }
.secondary { background: #fff9f0; }
.secondary:hover { background: #eee1d9; }
.compact { min-height: 46px; }
.round-card { display: flex; gap: 12px; align-items: center; padding: 13px; min-height: 72px; background: #fff9f0; border: 1px solid var(--line); border-radius: 12px; }
.round-card[data-result="win"] { border-color: #a45b73; background: #fff3e5; }
.round-card[data-result="draw"] { background: #eee6ef; }
.round-card p { margin: 0; }
.round-title { font-size: 1.1rem; font-weight: 800; }
.round-detail { font-size: .79rem; color: var(--muted); min-height: 1.2em; }
.players { display: flex; gap: 8px; flex-wrap: wrap; margin-block: 2px; }
.player { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 30px; padding: 5px 8px; font-size: .74rem; font-weight: 700; }
.player[data-active="true"] { border-color: #95556c; background: #fffbf5; }
.sample { width: 21px; height: 21px; flex: none; border-radius: 50%; background: var(--mint); color: #265147; display: inline-grid; place-items: center; font-weight: 900; box-shadow: inset 0 0 0 1px #22585255; }
[data-side="2"] > .sample { background: var(--coral); color: #773529; box-shadow: inset 0 0 0 1px #912b3455; }
.round-token { width: 35px; height: 35px; font-size: 1.15rem; }
[data-result="draw"] > .sample { background: #dad0e3; color: #523864; box-shadow: inset 0 0 0 1px #52386455; }
.round-actions { display: grid; gap: 7px; }
.game-panel { min-width: 0; }
.stage { height: clamp(340px, 61vh, 630px); min-width: 0; position: relative; overflow: hidden; isolation: isolate; border: 1px solid #60415e; border-radius: 23px; background: radial-gradient(ellipse at 51% 90%, #b36f78 0, #814c68 28%, transparent 65%), linear-gradient(151deg, #382c53, #583653 70%, #7b4b5c); }
.stage::before { content: ""; position: absolute; inset: 0; pointer-events: none; background: repeating-linear-gradient(115deg, #fdf0ce06 0 1px, transparent 1px 6px); }
.stage::after { content: ""; position: absolute; inset: auto 8% 4% 8%; height: 25%; background: radial-gradient(ellipse, #f9a88642, transparent 70%); pointer-events: none; z-index: -1; }
.stage-label { z-index: 2; position: absolute; top: 14px; left: 15px; color: #fff0e4; background: #31243fa8; border: 1px solid #ffd8d14a; border-radius: 24px; padding: 5px 10px; font-size: .58rem; line-height: 1.2; font-weight: 800; letter-spacing: .12em; display: flex; align-items: center; gap: 6px; pointer-events: none; }
.stage-label span:first-child { width: 6px; height: 6px; border-radius: 50%; background: var(--mint); }
.stage-stars { position: absolute; inset: 13% 8%; color: #ffd4a0; opacity: .72; pointer-events: none; }
.stage-stars span { position: absolute; }
.stage-stars span:nth-child(1) { left: 7%; top: 24%; font-size: 1.45rem; }
.stage-stars span:nth-child(2) { right: 8%; top: 13%; font-size: 1.65rem; }
.stage-stars span:nth-child(3) { right: 1%; top: 53%; font-size: .95rem; }
#fireworks { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.viewport { position: absolute; inset: 0; perspective: 1050px; perspective-origin: 50% 51%; touch-action: none; user-select: none; cursor: grab; }
.viewport.grabbing { cursor: grabbing; }
.frame, .world { position: absolute; left: 50%; top: 51%; width: 0; height: 0; transform-style: preserve-3d; }
.world { left: 0; top: 0; pointer-events: none; }
.surface, .counter, .hit, .choice, .box-face { position: absolute; }
.surface, .box-face, .counter { pointer-events: none; }
.surface { display: block; }
.hit { width: 56px; height: 348px; top: -193px; background: transparent; border: 0; pointer-events: auto; cursor: pointer; backface-visibility: hidden; }
.viewport.grabbing .hit { cursor: grabbing; }
.viewport[data-live="false"] .hit { pointer-events: none; }
.choice { width: 43px; height: 312px; top: -153px; border: 1px solid #ffead3b0; box-shadow: inset 0 0 15px #ffe5bb32; border-radius: 24px 24px 11px 11px; pointer-events: none; opacity: 0; }
.choice.visible { opacity: 1; }
.box-face { border-radius: 2px; background-color: #774a64; }
.base-face { background-color: #ba827a; }
.counter { width: 40px; height: 40px; margin: -20px; transform-style: preserve-3d; }
.counter span, .counter canvas { width: 40px; height: 40px; position: absolute; inset: 0; display: block; border-radius: 50%; }
.counter span { inset: 1px; width: 38px; height: 38px; background: #5ba893; }
.counter[data-side="2"] span { background: #c76056; }
.counter canvas { backface-visibility: hidden; }
.counter .counter-rim { width: 8px; height: 9px; border-radius: 0; inset: 15.5px 16px; }
.counter.preview canvas { opacity: .82; }
.counter.winning canvas { outline: 2px solid #fff3a3; box-shadow: 0 0 14px 4px #ffea92b0; }
.counter.winning span { background: #f5d182; }
.viewport.flat { perspective: none; cursor: default; }
.viewport.flat .rear { display: none; }
.columns { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: clamp(3px, 1vw, 7px); margin-top: 8px; }
.columns button, .view-buttons button, .movement button { border: 1px solid var(--line); border-radius: 8px; background: #fff9f0; padding: 4px; min-height: 44px; font-weight: 750; }
.columns button { display: grid; place-content: center; min-width: 0; line-height: 1.05; }
.columns button[data-selected="true"], .view-buttons button[aria-pressed="true"] { background: #4c3656; color: #fff8f0; border-color: #4c3656; }
.columns button[data-full="true"] small { visibility: visible; }
.columns small { visibility: hidden; font-size: .55rem; margin-top: 4px; }
.columns button[aria-disabled="true"] { color: #62536a; }
.columns button[data-selected="true"][aria-disabled="true"] { color: #fff8f0; }
.view-buttons button:disabled, .movement button:disabled { opacity: .5; }
.board-reader, .camera-more { padding: 6px 0 0; color: var(--muted); font-size: .76rem; }
summary { cursor: pointer; width: fit-content; }
summary:hover { text-decoration: underline; }
.board-reader p, .camera-more p { margin: 5px 0 0; }
.toolbar { margin-top: 9px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px; }
.view-buttons, .movement > div { display: flex; align-items: center; gap: 4px; }
.view-buttons button { min-width: 44px; padding-inline: 9px; font-size: .75rem; }
.movement { display: flex; flex-wrap: wrap; gap: 7px 16px; margin-top: 5px; }
.movement span { width: 33px; font-weight: 750; }
.movement button { min-width: 44px; }
footer { display: flex; justify-content: space-between; gap: 10px; padding: 15px 0 21px; border-top: 1px solid var(--line); color: var(--muted); }
footer span:last-child { font-size: .72rem; font-weight: 600; letter-spacing: .03em; }
dialog { width: min(440px, calc(100% - 24px)); border: 1px solid var(--line); border-radius: 17px; background: #fff9f0; padding: 26px; color: var(--ink); }
dialog::backdrop { background: #22172bb0; }
dialog h2 { margin: 4px 0 16px; font-size: 1.8rem; }
dialog ol { padding-left: 20px; }
dialog li + li { margin-top: 7px; }
.close { position: absolute; right: 10px; top: 10px; border: 0; background: none; font-size: 1.45rem; width: 44px; height: 44px; }
.setting { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; align-items: center; border-top: 1px solid var(--line); }
.setting select { max-width: 54%; padding: 5px; }
.setting input { width: 22px; height: 22px; accent-color: #6a426e; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (max-width: 700px) and (orientation: portrait), (max-width: 510px) {
  .masthead { min-height: 57px; }
  .cabinet { grid-template-columns: minmax(0, 1fr); gap: 14px; padding-block: 14px 25px; }
  .story { padding-top: 0; }
  h1 { font-size: clamp(3.3rem, 15vw, 5.5rem); margin-block: 6px 7px; }
  .intro { max-width: 43ch; font-size: .86rem; }
  .lobby, .match { margin-top: 13px; max-width: none; gap: 7px; }
  .lobby { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .difficulty { grid-column: 1 / -1; }
  .action { min-height: 52px; padding: 7px 9px; font-size: .85rem; }
  .action small { font-size: .67rem; }
  .round-card { min-height: 53px; padding: 6px 9px; }
  .round-title { font-size: .97rem; }
  .round-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .round-actions .compact { min-height: 44px; }
  .stage { height: clamp(244px, 84vw, 403px); border-radius: 16px; }
  body.in-match .title-group .eyebrow, body.in-match .intro { display: none; }
  body.in-match h1 { font-size: 2.25rem; margin-block: 0; }
  body.in-match .match { margin-top: 6px; }
}
@media (orientation: landscape) and (max-height: 520px) and (min-width: 511px) {
  .shell { padding-inline: 13px; }
  .masthead { min-height: 44px; }
  .cabinet { grid-template-columns: minmax(160px, .68fr) minmax(0, 1.6fr); gap: 15px; padding-block: 7px 16px; }
  .story { padding-top: 0; }
  h1 { font-size: clamp(2.9rem, 9vw, 4.1rem); margin-block: 3px 4px; }
  .intro { font-size: .77rem; }
  body.in-match .title-group .eyebrow, body.in-match .intro { display: none; }
  .match, .lobby { margin-top: 7px; gap: 5px; }
  .lobby { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .difficulty { grid-column: 1 / -1; }
  .lobby .action { font-size: .77rem; min-height: 48px; padding-inline: 6px; }
  .lobby .action > span:last-child { display: none; }
  .action { min-height: 44px; padding: 5px 8px; }
  .round-card { min-height: 49px; padding: 5px; }
  .round-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .round-actions .action { font-size: .78rem; }
  .stage { height: clamp(135px, calc(100dvh - 178px), 340px); border-radius: 13px; }
  .stage-label { top: 6px; left: 6px; }
  .columns, .toolbar { margin-top: 4px; }
}
@media (orientation: landscape) and (max-height: 360px) and (min-width: 511px) {
  body:not(.in-match) .cabinet { grid-template-columns: minmax(204px, .9fr) minmax(0, 1.4fr); }
  body:not(.in-match) .title-group .eyebrow { display: none; }
  h1 { font-size: clamp(2.35rem, 7vw, 3.35rem); }
  body:not(.in-match) .intro { line-height: 1.25; }
  .round-card { gap: 7px; }
  .round-title { font-size: .85rem; line-height: 1.2; }
  .round-detail { font-size: .72rem; line-height: 1.2; }
  .players { gap: 4px; }
  .player { font-size: .66rem; padding: 3px 5px; }
  .player .sample { width: 17px; height: 17px; }
}
