:root{color-scheme:dark;font-family:system-ui,sans-serif;background:#151210;color:#fff4df}*{box-sizing:border-box}[hidden]{display:none!important}body{margin:0;background:radial-gradient(ellipse at top,#463024,#151210 70%);min-height:100dvh}main{max-width:560px;margin:auto;padding:max(8px,env(safe-area-inset-top)) 12px max(12px,env(safe-area-inset-bottom))}header,nav{display:flex;align-items:center;justify-content:space-between;gap:8px}h1{font-size:clamp(17px,5vw,25px);margin:7px 0}a{color:#f9d29b;text-decoration:none}button,select{font:inherit;color:inherit;background:#382b24;border:1px solid #87674b;border-radius:10px;padding:8px;min-height:36px}button:disabled{opacity:.5}.primary{background:#a63130;font-weight:bold}#lobby button,#lobby select{width:100%;margin:4px 0}label{display:block;margin:6px 0}.hint,small{font-size:12px;color:#dfc7a9}#scores{display:grid;grid-template-columns:repeat(auto-fit,minmax(65px,1fr));gap:4px;margin:6px 0}.score{background:#28211c;border:1px solid #614b39;border-radius:8px;text-align:center;padding:4px;font-size:12px}.score strong{display:block;font-size:22px}.score small{display:block;font-size:10px}.score.active{border:2px solid #f8c56d}#court{position:relative;background:radial-gradient(ellipse at top,#675143,#291c16);border:1px solid #795d43;border-radius:14px;overflow:hidden;text-align:center}#board{display:block;width:min(100%,45dvh,370px);margin:auto;filter:drop-shadow(0 6px 7px #0009)}#throwpad{touch-action:none;user-select:none;position:relative;height:clamp(64px,12dvh,100px);background:linear-gradient(transparent,#211b18);cursor:grab}#dart{position:absolute;left:50%;top:0;transform:translateX(-50%);font-size:38px;line-height:1;color:#e2c481}#throwpad small{position:absolute;bottom:2px;left:0;right:0}#status{margin:5px 0;min-height:20px;text-align:center;font-weight:600}#throws{display:flex;gap:5px;justify-content:center;min-height:24px}#throws span{background:#3a2b21;padding:3px 8px;border-radius:6px}#callout{position:absolute;inset:30% 0 auto;pointer-events:none;color:#ffd782;text-shadow:0 2px 5px #000;font-weight:900;font-size:clamp(22px,6vw,36px)}details{font-size:12px;margin:4px 0}input[type=range]{width:100%}#checkout{min-height:16px;text-align:center}
.join,.match{display:flex;gap:6px;align-items:center;margin:5px 0}.join input{min-width:0;flex:1;background:#382b24;border:1px solid #87674b;color:inherit;padding:8px;border-radius:8px;font:inherit}.join button,#lobby .join button,#lobby .match button{width:auto}.match button:first-child{flex:1;text-align:left}#chat{border:1px solid #87674b;padding:5px 8px;border-radius:8px}#messages{max-height:120px;overflow:auto;overflow-wrap:anywhere}#room{font-size:12px;margin:4px 0}#room button{min-height:28px;padding:3px 8px}#throwpad[aria-disabled=true]{opacity:.55;cursor:default}
#dart{width:26px;height:60px;top:0}#dart svg{display:block;width:100%;height:100%;filter:drop-shadow(0 3px 4px #0009)}#statPanel{padding:8px;border:1px solid #87674b;border-radius:8px}#stats p{margin:5px 0}#callout{z-index:2}#throwpad{z-index:3}
/* Keep the iPhone viewport stationary during play; chat and accessibility controls remain scrollable. */
html.darts-playing,body.darts-playing{height:100%;width:100%;overflow:hidden;overscroll-behavior:none}body.darts-playing{position:fixed;inset:0;min-height:0}body.darts-playing main{height:100vh;height:100svh;min-height:0;overflow-y:auto;overscroll-behavior:contain;-webkit-overflow-scrolling:touch}#court,#court *,#throwpad,#throwpad *{touch-action:none;user-select:none;-webkit-user-select:none;-webkit-touch-callout:none;-webkit-user-drag:none}#court{overscroll-behavior:none}#board{width:min(100%,45svh,370px)}#throwpad{height:clamp(64px,12svh,100px)}#messages{overscroll-behavior:contain;touch-action:pan-y}#chat input{font-size:16px}#alternate input{touch-action:pan-x} @media(max-height:700px){body.darts-playing #board{width:min(100%,39svh,340px)}body.darts-playing h1{margin:3px 0}body.darts-playing #throwpad{height:64px}body.darts-playing #messages{max-height:88px}}

/* Board-first play layout: score dock below, no hit zoom, fixed game viewport. */
body.darts-playing main{display:flex;flex-direction:column;max-width:680px;padding-left:6px;padding-right:6px;gap:3px}
body.darts-playing main>header{flex:0 0 auto;padding:0 4px}
body.darts-playing h1{font-size:clamp(16px,4.6vw,23px);margin:2px 0}
body.darts-playing header button,body.darts-playing nav button{min-height:28px;padding:4px 8px;font-size:12px}
#game{display:flex;flex:1 0 auto;flex-direction:column;min-height:0;gap:3px}
body.darts-playing #game{flex:1 0 0;min-height:min-content}
#game>nav,#game>#room,#game>#chat,#game>#alternate,#game>#again,#game>#rematch{flex:0 0 auto}
#game>nav{padding:0 4px;font-size:12px}
#room{margin:0 4px}#chat,#alternate{margin:0 4px;padding-top:3px;padding-bottom:3px}
#game #court{display:flex;flex-direction:column;flex:1 1 0;min-height:190px;border-radius:12px;overflow:hidden;background:radial-gradient(ellipse at 50% 28%,#4a372b,#221915 75%)}
body.darts-playing #game #board{display:block;width:100%;height:100%;max-width:none;min-height:0;flex:1 1 0;margin:0;filter:none}
#game #throwpad{flex:0 0 49px;height:49px;min-height:49px;margin:0;background:linear-gradient(transparent,#211b18)}
#game #dart{width:20px;height:39px;top:0}
#game #throwpad small{font-size:10px;bottom:1px}
#game #callout{inset:5px 8px auto auto;max-width:43%;font-size:clamp(17px,5vw,25px);text-align:right;line-height:1.05;white-space:nowrap;pointer-events:none}
#scoreDock{flex:0 0 auto;background:#211a16;border:1px solid #614b39;border-radius:10px;padding:5px 6px 6px;display:grid;gap:4px;margin:0 1px}
#scoreDock #status{margin:0;min-height:0;font-size:13px;line-height:1.2;color:#ffdc89}
#scoreDock #scores{grid-template-columns:repeat(var(--player-count,2),minmax(0,1fr));gap:4px;margin:0}
#scoreDock .score{padding:4px 2px;min-width:0;border:2px solid #614b39;line-height:1.1}
#scoreDock .score.active{border-color:#f8c56d;background:#483523}
#scoreDock .score span{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-size:11px}
#scoreDock .score strong{font-size:clamp(24px,7vw,34px);line-height:1.1;font-variant-numeric:tabular-nums}
#scoreDock .score small{font-size:10px;line-height:1.2;overflow-wrap:anywhere}
#scoreDock #checkout{min-height:0;font-size:11px;line-height:1.2}
#scoreDock #checkout:empty,#scoreDock #throws:empty{display:none}
#scoreDock #throws{min-height:0;font-size:11px;gap:4px}
#scoreDock #throws span{padding:2px 6px}
#board .hit-flash{stroke:#ffe09b;stroke-width:.014;filter:brightness(1.45)}
@media(max-height:700px){#game #throwpad{flex-basis:43px;height:43px;min-height:43px}#game #dart{height:33px}#scoreDock .score strong{font-size:24px}#scoreDock{padding:3px 4px;gap:3px}}

/* Branded board and finger-following dart: no transform/zoom of the board. */
#game #court>#dart{position:absolute;z-index:5;pointer-events:none;left:50%;top:auto;bottom:10px;width:23px;height:43px;transform:translateX(-50%);filter:drop-shadow(0 3px 4px #0009)}#game #court.aiming>#dart{bottom:auto;width:28px;height:60px;filter:drop-shadow(2px 6px 5px #000b)}#game #court.aiming #throwpad{opacity:.68}#game #court #board text{paint-order:stroke;stroke:#171411;stroke-width:.0015;stroke-linejoin:round}#game #court{background:radial-gradient(ellipse at 50% 32%,#49382d,#211b18 80%)}@media(max-height:700px){#game #court>#dart{height:36px;bottom:9px}#game #court.aiming>#dart{height:56px;bottom:auto}}

/* Clear ring callouts without obscuring the board or changing its size. */
#game #callout{font-size:clamp(23px,6.8vw,32px);font-variant-numeric:tabular-nums;letter-spacing:.015em;font-weight:900;color:#fff4d8;text-shadow:0 2px 6px #000b}#scoreDock #throws span{min-width:36px;text-align:center;font-size:13px;font-weight:800;font-variant-numeric:tabular-nums}#game #board .hit-flash{stroke:#ffe09b;stroke-width:.009;filter:brightness(1.42)}

/* Impact feedback is drawn in board coordinates, independent of screen size. */
#game #board .impact-text{font-family:system-ui,sans-serif;font-size:.225px;font-weight:950;fill:#fff34d;stroke:#201c10;stroke-width:.017;paint-order:stroke fill;stroke-linejoin:round;filter:drop-shadow(.009px .016px .014px #000b);pointer-events:none;letter-spacing:0}
#game #board .impact-text.visible{animation:darts-impact-in .15s ease-out both}@keyframes darts-impact-in{from{opacity:0}to{opacity:1}}
#game #court>#dart{width:32px;height:63px;bottom:9px}#game #court.aiming>#dart{width:37px;height:78px;bottom:auto}#game #court.dart-in-flight>#dart{visibility:hidden}#game #throwpad small{z-index:6;pointer-events:none} @media(max-height:700px){#game #court>#dart{height:55px;bottom:8px}#game #court.aiming>#dart{height:70px;bottom:auto}}
@media(prefers-reduced-motion:reduce){#game #board .impact-text.visible{animation:none}}

/* Flying dart may emerge from the throw zone, while the court clips the outer boundary. */
body.darts-playing #game #board{overflow:visible;position:relative;z-index:4;pointer-events:none}#game #court>#dart{z-index:5}#game #throwpad{z-index:3}

/* Use the exact same projected dart while aiming and flying. Keep the board
   viewport stable while the throw history and checkout text change. */
#game #court.aiming>#dart{visibility:hidden}#scoreDock #throws,#scoreDock #throws:empty{display:flex;min-height:20px;align-items:center}#scoreDock #checkout,#scoreDock #checkout:empty{display:block;min-height:14px}#scoreDock #status{min-height:16px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}

/* V333: compact mode-specific electronic scoreboard. */
#scoreDock{gap:3px;padding:5px 6px;background:linear-gradient(145deg,#2c241d,#1b1714);font-variant-numeric:tabular-nums}
#scoreDock #scores{gap:4px;align-items:stretch}
#scoreDock .score-heading{grid-column:1/-1;color:#d9b685;text-align:center;text-transform:uppercase;letter-spacing:.07em;font-size:10px;font-weight:700}
#scoreDock .score{border-width:1px;border-radius:8px;padding:5px 2px;background:#28221e;position:relative}
#scoreDock .score.active{border-color:#f8c56d;box-shadow:inset 0 0 0 1px #f8c56d;background:linear-gradient(150deg,#513c25,#32271d)}
#scoreDock .score.active .score-name{color:#ffd58b;font-weight:700}
#scoreDock .score.winner{border-color:#64cc91}
#scoreDock .score strong{font-size:clamp(23px,6.6vw,34px);line-height:1.04}
#scoreDock .score-meta{color:#cbb69f;font-size:10px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
#scoreDock .cricket-matrix{grid-column:1/-1;table-layout:fixed;border-collapse:separate;border-spacing:3px 2px;width:100%;font-size:11px;background:#191613;border-radius:7px;padding:2px}
.cricket-matrix th:first-child{width:24%;text-align:left;padding-left:3px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.cricket-matrix th{font-weight:650;color:#dbb988;text-align:center}
.cricket-matrix td{padding:0;text-align:center}
.cricket-matrix .current .cricket-name{color:#ffdc89}
.cricket-mark{display:grid;place-items:center;min-height:20px;line-height:1;border-radius:4px;background:#2e2722;color:#f9ce87;font-size:16px;font-weight:800}
.cricket-mark.mark-0{color:#8e8072}.cricket-mark.mark-3{background:#244a35;color:#a6eab7}.cricket-mark.all-closed{opacity:.63}
#scoreDock #throws{align-items:center;gap:4px;min-height:22px}
#scoreDock #throws .throw-label{color:#cbb69f;font-size:10px;margin-right:3px}
#scoreDock #throws .throw-chip{padding:3px 5px;min-width:34px;background:#493626;line-height:1}
#scoreDock #throws .empty{color:#8d7a67;background:#2d2722}
#scoreDock #checkout[hidden]{display:none!important}
#scoreDock[data-mode^="cricket"] .score strong{font-size:clamp(20px,5.5vw,28px)}
@media(max-height:700px){#scoreDock .cricket-mark{min-height:17px;font-size:14px}#scoreDock .score{padding:3px 1px}#scoreDock .score-heading{font-size:9px}#scoreDock .cricket-matrix{border-spacing:2px 1px}}

/* V337: reference-style number ring, foreground dart, and live checkout. */
#game #court{background:radial-gradient(ellipse at 50% 32%,#47352d,#211816 85%)}
#game #throwpad{flex-basis:68px;height:68px;min-height:68px}
#game #court>#dart{width:39px;height:85px;bottom:4px}
#scoreDock #checkout:not(:empty){font-size:clamp(13px,3.8vw,16px);font-weight:850;line-height:1.2;color:#ffe55e;background:#292616;border:1px solid #82713a;border-radius:6px;padding:4px 6px;min-height:24px}
@media(max-height:700px){#game #throwpad{flex-basis:48px;height:48px;min-height:48px}#game #court>#dart{height:63px}}

/* V339: leave space for the foreground and apex without resizing mid-throw. */
#game #court{padding-top:30px}
#game #throwpad{flex-basis:clamp(100px,17svh,148px);height:clamp(100px,17svh,148px);min-height:clamp(100px,17svh,148px)}
#game #court>#dart{bottom:10px;width:39px;height:82px;transform:translateX(-50%) rotate(-18deg);transform-origin:50% 0}
@media(max-height:700px){#game #court{padding-top:20px}#game #throwpad{flex-basis:90px;height:90px;min-height:90px}#game #court>#dart{height:65px}}

/* V340: finger owns the dart position throughout the complete upward drag. */
#game #court.aiming #throwpad{opacity:1}#game #court,#game #board{touch-action:none;overscroll-behavior:none}

/* v343: no visual state/layout changes during the drag. */
#game #court>#dart{transform:translateX(-50%) rotate(-6deg)}
#game #court.aiming #throwpad{opacity:1}#game #court.aiming>#dart{visibility:hidden}
#game #board{contain:style}#game #court{touch-action:none}

/* v344: one rear-view SVG dart, including the idle state. The old HTML dart
   is only a legacy element; never alternate between two differently scaled graphics. */
#game #court>#dart{visibility:hidden!important;pointer-events:none}
#game #board{filter:none;contain:style}
#game #court.aiming #throwpad{opacity:1}

/* v350: reference tablet is 1080 x 1728; rim occupies ~87% of screen width.
   Use the available width rather than a fixed 680px playing column. The
   scoring geometry is unchanged; every field scales with the whole board. */
body.darts-playing main{max-width:min(1100px,100vw);padding-left:3px;padding-right:3px}
#game #court{padding-top:4px;min-height:190px}
#game #throwpad{flex-basis:clamp(72px,11svh,148px);height:clamp(72px,11svh,148px);min-height:clamp(72px,11svh,148px)}
body.darts-playing #game #board{width:100%;margin-inline:auto;max-width:none;flex:1 1 0;min-height:0}
@media (min-width:600px) and (orientation:portrait){body.darts-playing #game #board{max-width:90vw}body.darts-playing main{max-width:1100px}}
@media(max-height:700px){#game #court{padding-top:2px}#game #throwpad{flex-basis:66px;height:66px;min-height:66px}}
