:root {
  color-scheme: dark;
  --ink: #fff4df;
  --muted: #aab9b8;
  --base: #101d25;
  --panel: #182a33;
  --line: #3a5056;
  --mint: #8ee4c8;
  --coral: #ff9d86;
  --gold: #f6cb86;
  font: 15px/1.35 system-ui, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: radial-gradient(ellipse at 26% 0%, #223c42, var(--base) 47%); }
button { font: inherit; color: inherit; border: 1px solid var(--line); border-radius: 8px; background: #20343d; cursor: pointer; min-height: 36px; padding: 5px 10px; }
button:hover { background: #2d464e; }
button:focus-visible, canvas:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
button:disabled { opacity: .53; cursor: default; }
button[aria-pressed="true"].selected, .camera button[aria-pressed="true"] { color: #1a302f; background: var(--mint); border-color: var(--mint); }
[hidden] { display: none !important; }
.shell { width: min(100% - 36px, 1440px); margin: 0 auto; }
.masthead { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 17px 0; }
.brand { display: flex; align-items: center; gap: 15px; }
.brand-mark { flex: none; background: var(--gold); color: #233b40; display: flex; flex-direction: column; align-items: center; justify-content: center; width: 30px; height: 47px; border-radius: 6px; transform: rotate(-13deg); box-shadow: 1px 3px #a8754e; font-size: 13px; line-height: 1; }
.brand-mark span + span { border-top: 1px solid currentColor; padding: 2px 2px 0; }
h1, h2 { font-family: Georgia, serif; font-weight: 500; letter-spacing: -.034em; margin: 0; }
h1 { font-size: clamp(25px, 4vw, 43px); line-height: 1.08; }
.brand p { color: var(--gold); margin: 4px 0 0; font-size: .73rem; font-weight: 650; text-transform: uppercase; letter-spacing: .18em; }
.brand p span { margin: 0 4px; }
.brand .teknos-brand { margin-top: 8px; }
.tools, .camera, .zoom, .actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tools button { font-size: .84rem; }
.game { border: 1px solid var(--line); border-radius: 15px; overflow: hidden; box-shadow: 0 16px 50px #08121966; background: var(--panel); }
.scorebar { min-height: 60px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 7px clamp(9px, 3vw, 32px); gap: clamp(8px, 3vw, 32px); background: #162832; }
.team { display: flex; align-items: center; gap: clamp(5px, 1.2vw, 14px); }
.team > div { flex: 1; }
.team-away { text-align: right; }
.team-mark { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--mint); box-shadow: 0 0 0 3px #8ee4c828; }
.team-away .team-mark { background: var(--coral); box-shadow: 0 0 0 3px #ff9d8628; }
.team strong, .team small, .goal span { display: block; }
.team small, .goal span + span { color: var(--muted); font-size: .73rem; }
.team output { font: 500 clamp(22px, 4vw, 34px)/1 Georgia, serif; min-width: 2ch; color: var(--mint); }
.team-away output { color: var(--coral); }
.goal { border-inline: 1px solid var(--line); padding: 0 clamp(7px, 3vw, 28px); text-align: center; white-space: nowrap; font-weight: 650; }
.stage { position: relative; isolation: isolate; height: clamp(360px, calc(100svh - 298px), 740px); background: #335e66; }
.scene, .scene canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.scene canvas { touch-action: none; cursor: grab; }
.scene canvas:active { cursor: grabbing; }
.stage-top, .stage-bottom { position: absolute; inset-inline: 12px; display: flex; justify-content: space-between; align-items: start; gap: 7px; pointer-events: none; }
.stage-top { top: 12px; }
.stage-bottom { bottom: 12px; align-items: end; }
.stage-top button, .stage-bottom button, .result button { pointer-events: auto; }
.camera, .seats, .zoom, .tile-label:not(:empty) { background: #14262beb; border: 1px solid #587075; border-radius: 10px; padding: 5px; }
.camera button, .zoom button { min-height: 33px; }
.zoom button { width: 36px; font-size: 1.2rem; }
.seats { display: flex; gap: 3px; }
.seat { color: var(--muted); padding: 5px 6px; font-size: .79rem; white-space: nowrap; border: 1px solid transparent; border-radius: 6px; }
.seat b { color: var(--mint); }
.seat[data-team="1"] b { color: var(--coral); }
.seat.current { border-color: #6a7d7c; background: #32454a; color: var(--ink); }
.tile-label:not(:empty) { padding: 7px 11px; }
.scene-error { position: absolute; top: 42%; inset-inline: 10%; text-align: center; }
.dock { display: grid; grid-template-columns: minmax(156px, 1fr) auto minmax(156px, 1fr); align-items: center; gap: 12px; padding: 12px 15px 14px; min-height: 102px; border-top: 1px solid var(--line); }
.turn-panel { min-width: 0; }
.turn-panel strong { display: block; color: var(--ink); font-size: 1rem; margin-bottom: 3px; }
.turn-panel span { display: block; color: var(--muted); font-size: .8rem; }
.rack { display: flex; justify-content: center; align-items: center; gap: clamp(4px, 1.5vw, 10px); min-height: 68px; }
.domino { flex: none; position: relative; width: clamp(32px, 7vw, 43px); height: clamp(60px, 12vw, 75px); display: grid; grid-template-rows: 1fr 1fr; padding: 4px; color: #17262e; background: #fff4da; box-shadow: 0 3px #a59270; border: 1px solid #b9a681; border-radius: 7px; }
.domino:hover { background: #fff9e9; }
.domino[aria-pressed="true"].selected { box-shadow: 0 3px #4b9a88; }
.domino.unplayable { background: #d9d1bb; }
.domino.playable::after { content: ''; position: absolute; inset-inline: 9px; bottom: -7px; height: 2px; border-radius: 3px; background: var(--mint); }
.half { display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr); justify-items: center; align-items: center; padding: 2px; }
.half + .half { border-top: 1px solid #b6a887; }
.pip { background: currentColor; width: clamp(3px, 1vw, 5px); aspect-ratio: 1; border-radius: 50%; }
.actions { justify-content: flex-end; }
.primary, .actions .end-action { color: #142e29; background: var(--mint); border-color: var(--mint); font-weight: 700; }
.primary:hover, .actions .end-action:hover { background: #c0f4de; }
.result { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(350px, calc(100% - 32px)); background: #172930f2; border: 1px solid #6b887f; border-radius: 13px; padding: 17px 20px; text-align: center; box-shadow: 0 12px 40px #1020278c; }
.result h2 { font-size: 26px; }
.result p { margin: 6px 0 10px; }
.result small { display: block; margin-bottom: 12px; color: var(--muted); }
footer { display: flex; justify-content: space-between; gap: 8px; padding: 12px 2px; font-size: .73rem; color: var(--muted); }
footer span:first-child { letter-spacing: .14em; text-transform: uppercase; }
dialog { width: min(550px, calc(100% - 26px)); max-height: 86svh; background: var(--panel); color: var(--ink); padding: 23px; border: 1px solid #65827e; border-radius: 13px; }
dialog::backdrop { background: #071317b9; }
dialog h2 { font-size: 30px; padding-right: 30px; }
dialog h3 { margin-bottom: 5px; }
dialog li + li { margin-top: 8px; }
dialog p { margin: 9px 0; }
.close { float: right; font-size: 1.2rem; }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 17px; }
@media (max-width: 720px) {
  .shell { width: calc(100% - 18px); }
  .masthead { flex-wrap: wrap; gap: 9px; padding: 11px 0; }
  .brand { gap: 11px; padding-left: 3px; }
  .brand-mark { width: 23px; height: 34px; font-size: 10px; }
  .tools button { min-height: 33px; padding: 4px 8px; }
  .team strong { font-size: .79rem; }
  .team-mark { width: 6px; height: 6px; }
  .stage { height: clamp(320px, calc(100svh - 347px), 580px); }
  .stage-top { flex-direction: column; align-items: stretch; }
  .stage-top .seats, .stage-top .camera { justify-content: center; align-self: center; }
  .dock { grid-template-columns: minmax(0, 1fr) auto; gap: 10px 6px; padding: 9px 9px 12px; }
  .rack { grid-column: 1 / -1; grid-row: 2; min-height: 63px; }
  .actions { grid-row: 1; grid-column: 2; gap: 4px; }
  .actions button { font-size: .77rem; padding-inline: 6px; }
  .controls-help { display: none; }
}
