:root {
  --bg: #0d1117; --bg2: #121822; --card: #182030; --card2: #1f2a3d; --line: #2a3650;
  --text: #eef2f8; --muted: #93a0b8; --green: #22c55e; --green-d: #16a34a; --red: #ef4444; --red-d: #dc2626;
  --gold: #fbbf24; --blue: #3b82f6; --radius: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
body { overscroll-behavior: none; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; touch-action: manipulation; }
button:disabled { opacity: .35; cursor: default; }
input { font: inherit; }
#app { max-width: 520px; margin: 0 auto; height: 100%; position: relative; }
.screen { display: none; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }
.screen.active { display: flex; }
.scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.pad { padding: 16px; }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; gap: 8px; padding: 10px 10px; min-height: 56px; background: var(--bg2); border-bottom: 1px solid var(--line); flex: none; }
.topbar h2 { margin: 0; font-size: 19px; flex: 1; text-align: center; }
.topbar .spacer { width: 44px; }
.icon-btn { width: 44px; height: 44px; border-radius: 12px; font-size: 30px; line-height: 1; display: grid; place-items: center; background: var(--card); }
.icon-btn:active { background: var(--card2); }
.icon-btn.undo { font-size: 24px; }

/* ---------- home ---------- */
#screen-home { padding: 20px 18px calc(12px + var(--safe-b)); overflow-y: auto; overflow-x: hidden;
  background: radial-gradient(120% 55% at 50% 0%, #3a0d12 0%, #1a0b0e 35%, var(--bg) 65%); }
.home-hero { text-align: center; margin-top: 4px; }
.app-name { margin: 10px 0 6px; display: flex; flex-direction: column; align-items: center; line-height: 1; }
.app-name .t-main { font-size: 50px; font-weight: 900; font-style: italic; text-transform: uppercase; letter-spacing: -1px;
  background: linear-gradient(180deg, #ff6b5b 0%, #e11d2e 55%, #9f1020 100%); -webkit-background-clip: text; background-clip: text; color: transparent;
  transform: skew(-6deg); filter: drop-shadow(0 3px 0 #000) drop-shadow(0 8px 18px rgba(225,29,46,.45)); padding: 0 8px; }
.app-name .t-sub { display: flex; align-items: center; gap: 12px; margin-top: 8px; font-size: 17px; font-weight: 800; letter-spacing: .55em; text-transform: uppercase; color: #f3f4f6; padding-left: .55em; }
.app-name .t-sub::before, .app-name .t-sub::after { content: ""; width: 34px; height: 3px; border-radius: 2px; background: linear-gradient(90deg, transparent, #e11d2e); }
.app-name .t-sub::after { transform: scaleX(-1); }
.tagline { color: var(--muted); margin: 14px 0 0; font-weight: 600; letter-spacing: .02em; }
.hello { display: block; margin: 22px auto 16px; padding: 10px 16px; border-radius: 999px; background: var(--card); color: var(--muted); font-size: 15px; }
.hello b { color: var(--text); }
.pencil { margin-left: 6px; }
.home-actions { display: flex; flex-direction: column; gap: 12px; }
.big-btn { display: flex; align-items: center; gap: 14px; text-align: left; padding: 16px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--line); min-height: 76px; }
.big-btn:active { transform: scale(.985); }
.big-btn .ico { font-size: 28px; width: 44px; height: 44px; display: grid; place-items: center; background: rgba(255,255,255,.06); border-radius: 12px; flex: none; }
.big-btn b { display: block; font-size: 18px; }
.big-btn small { display: block; color: var(--muted); font-size: 13.5px; margin-top: 2px; }
.big-btn.primary { background: linear-gradient(135deg, #15803d, #16a34a); border-color: #22c55e55; }
.big-btn.accent { background: linear-gradient(135deg, #b91c1c, #dc2626); border-color: #ef444455; }
.big-btn.primary small, .big-btn.accent small { color: rgba(255,255,255,.85); }
.foot { text-align: center; color: #56627a; font-size: 12px; margin-top: auto; padding-top: 18px; }
.foot p { margin: 0; }
.credits { color: #ef5350; font-size: 12.5px; font-weight: 600; line-height: 1.5; letter-spacing: .02em; padding: 0 12px 4px; text-wrap: balance; }
.credits span { white-space: nowrap; }
.credits i { font-style: normal; color: #b23a38; }
.foot .ver { font-size: 10.5px; opacity: .8; }

/* ---------- forms ---------- */
.field-label { display: block; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 18px 0 8px; }
.field-label:first-child { margin-top: 4px; }
.seg { display: flex; background: var(--card); border-radius: 14px; padding: 4px; gap: 4px; }
.seg button { flex: 1; padding: 13px 6px; border-radius: 10px; font-weight: 600; font-size: 16px; color: var(--muted); }
.seg button.on { background: var(--green-d); color: #fff; }
.stepper { display: flex; align-items: center; background: var(--card); border-radius: 14px; padding: 6px; }
.stepper button { width: 56px; height: 56px; border-radius: 12px; background: var(--card2); font-size: 28px; }
.stepper div { flex: 1; text-align: center; }
.stepper b { display: block; font-size: 26px; }
.stepper small { color: var(--muted); }
.player-row { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.player-row .num { width: 30px; height: 30px; border-radius: 50%; background: var(--card2); display: grid; place-items: center; font-size: 14px; color: var(--muted); flex: none; }
.player-row input, .text-input { flex: 1; min-width: 0; padding: 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg2); color: var(--text); font-size: 17px; }
.player-row .rm { width: 44px; height: 48px; border-radius: 12px; background: var(--card); color: var(--muted); font-size: 22px; }
.ghost-btn { padding: 12px 16px; border-radius: 12px; border: 1px dashed var(--line); color: var(--muted); font-weight: 600; width: 100%; }
.bottom-bar { padding: 12px 16px calc(12px + var(--safe-b)); background: var(--bg2); border-top: 1px solid var(--line); flex: none; }
.cta { width: 100%; padding: 17px; border-radius: 14px; background: var(--green-d); color: #fff; font-size: 18px; font-weight: 700; }
.cta:active { background: var(--green); }
.cta.accent { background: var(--red-d); }
.cta.secondary { background: var(--card2); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card h3 { margin: 0 0 4px; font-size: 19px; }
.card p { margin: 0 0 14px; }
.or { text-align: center; color: var(--muted); margin: 14px 0; position: relative; }
.or::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; border-top: 1px solid var(--line); }
.or span { background: var(--bg); padding: 0 12px; position: relative; }
.code-input { width: 100%; text-align: center; font-size: 34px; letter-spacing: .35em; font-weight: 800; text-transform: uppercase; padding: 12px 0 12px .35em; border-radius: 12px; border: 2px solid var(--line); background: var(--bg2); color: var(--text); margin-bottom: 12px; }
.code-input:focus { outline: none; border-color: var(--red); }
.conn-note { text-align: center; color: var(--muted); font-size: 13px; }

/* ---------- room ---------- */
.room-code { font-size: 56px; font-weight: 900; letter-spacing: .18em; padding: 18px 0 18px .18em; margin: 10px 0; border-radius: 20px; background: var(--card); border: 2px solid var(--green-d); color: #fff; font-variant-numeric: tabular-nums; }
.room-meta { color: var(--muted); margin-bottom: 14px; }
.row-btns { display: flex; gap: 10px; }
.row-btns .ghost-btn { border-style: solid; }
.waiting { margin: 26px 0 16px; font-size: 17px; display: flex; align-items: center; justify-content: center; gap: 12px; }
.dot-pulse { width: 12px; height: 12px; border-radius: 50%; background: var(--green); animation: pulse 1.2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(34,197,94,.7); } 100% { box-shadow: 0 0 0 14px rgba(34,197,94,0); } }
.room-players { display: flex; flex-direction: column; gap: 8px; margin: 10px 0 18px; }
.room-players div { background: var(--card); padding: 12px; border-radius: 12px; display: flex; justify-content: space-between; }

/* ---------- game ---------- */
.game-top { padding: 6px 10px; min-height: 52px; }
.game-title { flex: 1; text-align: center; line-height: 1.15; min-width: 0; }
.game-title b { font-size: 17px; display: block; }
.game-title small { color: var(--muted); font-size: 12.5px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#game-board { flex: none; padding: 10px 10px 0; }
#game-info { flex: none; padding: 8px 10px 0; }
#screen-game { overflow-y: auto; } /* fallback: never trap buttons off-screen */
#game-input { flex: 1 0 auto; display: flex; flex-direction: column; justify-content: flex-end; padding: 8px 10px calc(10px + var(--safe-b)); min-height: 0; }

.players { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.players.n1 { grid-template-columns: 1fr; }
.pcard { background: var(--card); border: 2px solid transparent; border-radius: var(--radius); padding: 10px 12px; position: relative; min-width: 0; }
.pcard.active { border-color: var(--green); background: linear-gradient(180deg, #17301f, var(--card)); }
.pcard .pname { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 36px; }
.pcard .legs { position: absolute; top: 9px; right: 10px; background: var(--card2); border-radius: 8px; padding: 2px 8px; font-size: 13px; font-weight: 700; }
.pcard .rem { font-size: 60px; font-weight: 800; line-height: 1.05; margin: 4px 0 2px; font-variant-numeric: tabular-nums; letter-spacing: -1px; }
.players.compact .rem { font-size: 36px; }
.players.compact .pcard { padding: 8px 10px; }
.players.compact .visits { display: none; }
.pcard .visits { color: var(--muted); font-size: 13px; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.pcard .visits s { color: var(--red); }
.pcard .meta { display: flex; justify-content: space-between; color: var(--muted); font-size: 12.5px; gap: 6px; }
.pcard .meta b { color: var(--text); font-weight: 600; }
.pcard .you-tag { font-size: 11px; background: var(--blue); color: #fff; padding: 1px 6px; border-radius: 6px; margin-left: 6px; vertical-align: 2px; }
.pcard .off { font-size: 11px; background: var(--red-d); color: #fff; padding: 1px 6px; border-radius: 6px; margin-left: 6px; vertical-align: 2px; }

.checkout { display: flex; align-items: center; gap: 10px; background: linear-gradient(90deg, #3b2f0b, #2a2410); border: 1px solid #fbbf2466; color: var(--gold); border-radius: 12px; padding: 9px 12px; font-weight: 700; }
.checkout .lbl { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; opacity: .85; }
.checkout .route { font-size: 20px; letter-spacing: .5px; color: #fde68a; }
.checkout.none { background: var(--card); border-color: var(--line); color: var(--muted); font-weight: 500; }
.turnline { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; min-height: 34px; }
.turnline .who { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chips { display: flex; gap: 6px; }
.chip { min-width: 46px; padding: 6px 8px; border-radius: 9px; background: var(--card); text-align: center; font-weight: 700; font-size: 14px; }
.chip.empty { color: #4b5770; }

.entry-tabs { display: flex; gap: 6px; margin-bottom: 8px; }
.entry-tabs button { flex: 1; padding: 8px; border-radius: 10px; background: var(--card); color: var(--muted); font-weight: 600; font-size: 14px; }
.entry-tabs button.on { background: var(--card2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }
.display { display: flex; align-items: center; justify-content: center; height: 58px; border-radius: 14px; background: var(--bg2); border: 1px solid var(--line); font-size: 38px; font-weight: 800; margin-bottom: 8px; font-variant-numeric: tabular-nums; }
.display.placeholder { font-size: 18px; color: var(--muted); font-weight: 500; }
.display.err { border-color: var(--red); color: var(--red); }
.quick { display: grid; grid-template-columns: repeat(8, 1fr); gap: 5px; margin-bottom: 8px; }
.quick button { padding: 10px 0; border-radius: 10px; background: var(--card); font-weight: 700; font-size: 14px; min-width: 0; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
/* pads grow to fill spare height on tall phones and shrink on short ones */
#game-input .keypad, #game-input .dartpad { flex: 1 1 auto; grid-auto-rows: minmax(44px, 1fr); min-height: 0; }
#game-input .keypad { max-height: 330px; }
#game-input .dartpad { max-height: 340px; }
#game-input .cpad { max-height: 300px; }
.keypad button { min-height: 44px; border-radius: 14px; background: var(--card2); font-size: 26px; font-weight: 700; }
.keypad button:active, .dartpad button:active, .quick button:active { filter: brightness(1.35); }
.keypad .ok { background: var(--green-d); font-size: 20px; }
.keypad .del { background: var(--card); font-size: 22px; }
.mults { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 8px; }
.mults button { padding: 11px 0; border-radius: 12px; background: var(--card); font-weight: 700; font-size: 16px; color: var(--muted); }
.mults button.on[data-mult="1"] { background: #334155; color: #fff; }
.mults button.on[data-mult="2"] { background: var(--green-d); color: #fff; }
.mults button.on[data-mult="3"] { background: var(--red-d); color: #fff; }
.dartpad { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.dartpad button { min-height: 44px; border-radius: 12px; background: var(--card2); font-size: 20px; font-weight: 700; }
.dartpad .sp { background: var(--card); font-size: 16px; }
.dartpad .wide2 { grid-column: span 2; }
.dartpad.m2 button.n { box-shadow: inset 0 -3px 0 var(--green); }
.dartpad.m3 button.n { box-shadow: inset 0 -3px 0 var(--red); }
.cpad { grid-template-columns: repeat(3, 1fr); }
.cpad button { font-size: 22px; }
.waitbox { background: var(--card); border-radius: var(--radius); padding: 22px 16px; text-align: center; color: var(--muted); font-size: 17px; }
.waitbox b { color: var(--text); }
.waitbox .dot-pulse { display: inline-block; margin-right: 8px; vertical-align: middle; }

/* cricket board */
.cboard { width: 100%; border-collapse: separate; border-spacing: 0 4px; table-layout: fixed; }
.cboard th { font-weight: 700; font-size: 14px; padding: 6px 4px; background: var(--card); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cboard th:first-child { border-radius: 12px 0 0 12px; }
.cboard th:last-child { border-radius: 0 12px 12px 0; }
.cboard th.active { background: #17301f; box-shadow: inset 0 -3px 0 var(--green); }
.cboard th .pts { display: block; font-size: 30px; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.cboard th .lg { font-size: 11px; color: var(--muted); font-weight: 600; }
.cboard td { text-align: center; background: var(--card); height: 38px; font-size: 22px; font-weight: 800; }
.cboard td:first-child { border-radius: 10px 0 0 10px; }
.cboard td:last-child { border-radius: 0 10px 10px 0; }
.cboard td.num { background: var(--card2); color: var(--text); font-size: 19px; }
.cboard tr.dead td { opacity: .35; }
.cboard .mk1 { color: #93c5fd; } .cboard .mk2 { color: #fcd34d; } .cboard .mk3 { color: var(--green); }

/* stats */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 8px; }
.stat { background: var(--card); border-radius: 12px; padding: 10px 6px; text-align: center; min-width: 0; }
.stat b { display: block; font-size: 22px; font-variant-numeric: tabular-nums; }
.stat small { color: var(--muted); font-size: 11.5px; }
.section-h { display: flex; justify-content: space-between; align-items: baseline; margin: 20px 0 8px; }
.section-h h3 { margin: 0; font-size: 17px; }
.linkish { color: var(--muted); font-size: 13px; text-decoration: underline; }
.hist { background: var(--card); border-radius: 14px; margin-bottom: 8px; border: 1px solid var(--line); overflow: hidden; }
.hist summary { list-style: none; padding: 12px 14px; cursor: pointer; }
.hist summary::-webkit-details-marker { display: none; }
.hist .h1 { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }
.hist .h2 { font-size: 17px; font-weight: 700; margin-top: 4px; }
.hist .h2 .w { color: var(--gold); }
.st-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.st-table th, .st-table td { padding: 7px 8px; text-align: right; border-top: 1px solid var(--line); }
.st-table th:first-child, .st-table td:first-child { text-align: left; color: var(--muted); font-weight: 500; }
.st-table thead th { color: var(--text); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 120px; }
.empty-note { text-align: center; color: var(--muted); padding: 30px 10px; }

/* modal + toast */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.65); display: flex; align-items: flex-end; justify-content: center; z-index: 50; padding: 12px; }
.modal-card { background: var(--bg2); border: 1px solid var(--line); border-radius: 22px; padding: 20px 16px calc(16px + var(--safe-b)); width: 100%; max-width: 500px; max-height: 92vh; overflow-y: auto; }
.modal-card h3 { margin: 0 0 6px; font-size: 22px; text-align: center; }
.modal-card p { text-align: center; color: var(--muted); margin: 0 0 16px; }
.modal-card .btns { display: flex; gap: 8px; margin-top: 12px; }
/* keep the dialog's buttons visible when its content is taller than the screen */
.modal-card .btns { position: sticky; bottom: calc(-16px - var(--safe-b)); background: var(--bg2); padding: 10px 0 calc(16px + var(--safe-b)); margin-bottom: calc(-16px - var(--safe-b)); box-shadow: 0 -12px 16px -8px var(--bg2); }
.modal-card .btns > * { flex: 1; }
.darts-choice { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.darts-choice button { height: 64px; border-radius: 14px; background: var(--card2); font-size: 26px; font-weight: 800; }
.trophy { font-size: 54px; text-align: center; }
.toast { position: fixed; left: 50%; top: 22%; transform: translateX(-50%); background: rgba(10,14,20,.94); border: 1px solid var(--line); padding: 14px 22px; border-radius: 16px; font-size: 22px; font-weight: 800; z-index: 60; text-align: center; max-width: 90vw; box-shadow: 0 10px 40px rgba(0,0,0,.5); animation: pop .18s ease-out; }
.toast.bust { color: var(--red); border-color: var(--red); }
.toast.good { color: var(--green); border-color: var(--green); }
.toast.gold { color: var(--gold); border-color: var(--gold); }
.toast.info { font-size: 16px; font-weight: 600; }
@keyframes pop { from { transform: translateX(-50%) scale(.85); opacity: 0; } to { transform: translateX(-50%) scale(1); opacity: 1; } }

/* ---------- teams (2 v 2) ---------- */
:root { --team-a: #3b82f6; --team-b: #f97316; }
.tdot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; flex: none; }
.tdot.ta { background: var(--team-a); } .tdot.tb { background: var(--team-b); }
.player-row .num.team-a { background: var(--team-a); color: #fff; font-weight: 700; }
.player-row .num.team-b { background: var(--team-b); color: #fff; font-weight: 700; }
.members { display: flex; gap: 4px; flex-wrap: nowrap; margin: 2px 0 4px; min-width: 0; }
.mem { font-size: 12.5px; padding: 2px 7px; border-radius: 7px; background: var(--card2); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; max-width: 100%; }
.mem.now { background: var(--green-d); color: #fff; font-weight: 700; flex: none; max-width: 70%; }
.mem i, .lp i { font-style: normal; font-size: 10.5px; padding: 0 4px; border-radius: 4px; vertical-align: 1px; }
i.me { background: var(--blue); color: #fff; }
i.offl { background: var(--red-d); color: #fff; }
.cboard th .members { justify-content: center; margin: 4px 2px 0; }
.cboard th .mem { font-size: 11.5px; padding: 1px 5px; }
.turnline .who .tdot { margin-right: 5px; }

/* lobby */
.lobby-status { margin: 18px 0 10px; font-size: 16px; display: flex; align-items: center; justify-content: center; gap: 10px; }
.teams { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; text-align: left; }
.team-col { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 8px; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.team-h { font-weight: 800; font-size: 15px; display: flex; align-items: center; padding: 2px 2px 2px; }
.team-h small { margin-left: auto; color: var(--muted); font-weight: 600; }
.lp { display: flex; align-items: center; gap: 4px; background: var(--card2); border-radius: 10px; padding: 6px 6px 6px 9px; min-height: 42px; min-width: 0; }
.lp.offline { opacity: .6; }
.lp.empty { background: transparent; border: 1px dashed var(--line); color: #56627a; font-size: 13.5px; justify-content: center; }
.lpn { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; font-size: 14.5px; }
.lpn .host { color: var(--gold); font-style: normal; margin-right: 4px; }
.ctl { display: flex; gap: 4px; flex: none; }
.mini { width: 32px; height: 32px; border-radius: 8px; background: var(--card); font-weight: 800; font-size: 15px; }
.mini.kick { color: var(--red); font-size: 18px; }
.join-team { padding: 10px; border-radius: 10px; font-weight: 700; font-size: 14.5px; color: #fff; }
.join-team.ta { background: var(--team-a); } .join-team.tb { background: var(--team-b); }
.unassigned { margin-top: 8px; background: var(--card); border: 1px dashed var(--line); border-radius: 14px; padding: 8px; text-align: left; display: flex; flex-direction: column; gap: 6px; }
#room-body .cta { margin-top: 4px; }
#room-body .small-wait { padding: 14px; font-size: 15px; margin-top: 4px; }
.tbl-h { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 14px 0 2px; text-align: left; }
.modal-card p.winners { color: var(--text); font-weight: 600; margin: -2px 0 6px; }
.st-table.compact { font-size: 13px; table-layout: fixed; }
.st-table.compact th, .st-table.compact td { padding: 6px 4px; }
.st-table.compact th:first-child, .st-table.compact td:first-child { width: 25%; }
.st-table.compact thead th { font-size: 12.5px; }
.st-table.compact .tdot { width: 7px; height: 7px; margin-right: 3px; }
.hist .h3 { font-size: 13px; color: var(--muted); margin-top: 2px; }

@media (max-height: 700px) {
  .pcard .rem { font-size: 44px; }
  .players.compact .rem { font-size: 32px; }
  .pcard .visits { display: none; }
  .entry-tabs { margin-bottom: 6px; }
  .entry-tabs button { padding: 6px; }
  .mults { margin-bottom: 6px; }
  .mults button { padding: 8px 0; }
  .turnline { margin-top: 4px; min-height: 30px; }
  .checkout { padding: 6px 10px; }
  .checkout .route { font-size: 18px; }
  .cboard th .pts { font-size: 24px; }
  .cboard { border-spacing: 0 3px; }
  #game-input .keypad, #game-input .dartpad { grid-auto-rows: minmax(42px, 1fr); }
  .display { height: 48px; font-size: 32px; }
  .cboard td { height: 27px; font-size: 18px; }
  .cboard th .pts { display: inline; }
  .cboard th .lg { display: inline; margin-left: 6px; }
  .cboard th .members { margin-top: 3px; }
}

/* ---------- home logo (user-supplied artwork: public/logo.webp) ----------
   Three copies of the same image are stacked and masked (masks generated by scripts/build-logo.js):
   board = everything except darts + lettering, darts = the three darts, letters = the "NO MERCY" band.
   Once every layer has landed they line up pixel-for-pixel, so the final frame is the original artwork.
   Timeline (~2.4s, once, starts when the image has decoded — JS adds #screen-home.nm-play):
   board fades/zooms in (0–0.6s) → darts drop from above (0.5–0.92s) → thud + shake → lettering slams in
   from large (1.0–1.35s) → quake, neon-green glow + splatter burst → "DARTS" + tagline. JS adds .nm-done at 3s. */
.nm-logo { position: relative; width: min(100%, 330px); aspect-ratio: 920 / 980; margin: -8px auto 0; mix-blend-mode: lighten; }
.nm-layer { position: absolute; inset: 0; display: block; }
.nm-layer img { display: block; width: 100%; height: 100%; }
.nm-l-darts, .nm-l-letters, .nm-splat { display: none; }
.app-name .t-main { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; } /* the artwork carries "NO MERCY" */
.app-name { margin-top: 0; }
#screen-home:not(.nm-play):not(.nm-done) .nm-logo, #screen-home:not(.nm-play):not(.nm-done) .app-name .t-sub,
#screen-home:not(.nm-play):not(.nm-done) .home-hero .tagline { visibility: hidden; }

#screen-home.nm-play:not(.nm-done) .nm-l-darts, #screen-home.nm-play:not(.nm-done) .nm-l-letters,
#screen-home.nm-play:not(.nm-done) .nm-splat { display: block; }
.nm-play .nm-l-board img { -webkit-mask: var(--nm-mask-board) 0 0 / 100% 100% no-repeat; mask: var(--nm-mask-board) 0 0 / 100% 100% no-repeat; }
.nm-play .nm-l-darts img { -webkit-mask: var(--nm-mask-darts) 0 0 / 100% 100% no-repeat; mask: var(--nm-mask-darts) 0 0 / 100% 100% no-repeat; }
.nm-play .nm-l-letters img { -webkit-mask: var(--nm-mask-letters) 0 0 / 100% 100% no-repeat; mask: var(--nm-mask-letters) 0 0 / 100% 100% no-repeat; }
.nm-done .nm-l-board img { -webkit-mask: none; mask: none; }

.nm-play .nm-l-board { animation: nm-board .6s cubic-bezier(.2,.8,.3,1) both, nm-hit .35s .92s ease-out; }
.nm-play .nm-l-darts { animation: nm-drop .42s .5s cubic-bezier(.55,0,1,.55) both, nm-settle .28s .92s ease-out; }
.nm-play .nm-logo { animation: nm-thud .3s .92s linear, nm-quake-big .45s 1.35s linear; }
.nm-l-letters { z-index: 2; transform-origin: 51% 65%; }
.nm-play .nm-l-letters { animation: nm-slam-in .5s 1s cubic-bezier(.55,0,.6,1) both, nm-glow-pulse 1.1s 1.33s ease-out; }
.nm-splat { position: absolute; z-index: 1; left: 0; right: 0; top: 30%; height: 70%; pointer-events: none; opacity: 0;
  background:
    radial-gradient(closest-side, rgba(57,255,20,.75), rgba(30,200,10,.35) 45%, transparent 70%) 50% 50% / 60% 40% no-repeat,
    radial-gradient(circle, #39ff14 0 45%, transparent 55%) 8% 30% / 9% 9% no-repeat,
    radial-gradient(circle, #2fd612 0 45%, transparent 55%) 90% 22% / 7% 7% no-repeat,
    radial-gradient(circle, #5bff3d 0 45%, transparent 55%) 18% 82% / 6% 6% no-repeat,
    radial-gradient(circle, #28b810 0 45%, transparent 55%) 82% 78% / 8% 8% no-repeat,
    radial-gradient(circle, #39ff14 0 45%, transparent 55%) 50% 2% / 5% 5% no-repeat,
    radial-gradient(circle, #2fd612 0 45%, transparent 55%) 97% 55% / 5% 5% no-repeat,
    radial-gradient(circle, #2fd612 0 45%, transparent 55%) 2% 60% / 5% 5% no-repeat; }
.nm-play .nm-splat { animation: nm-splat .75s 1.33s ease-out both; }
.nm-play .app-name .t-sub { animation: nm-rise .45s 1.65s ease-out both; }
.nm-play .home-hero .tagline { animation: nm-fade .5s 1.9s ease-out both; }

@keyframes nm-board { from { opacity: 0; transform: scale(.78); filter: blur(8px); } to { opacity: 1; transform: none; filter: none; } }
@keyframes nm-hit { 0% { filter: brightness(1.45); } 100% { filter: none; } }
@keyframes nm-drop { 0% { opacity: 0; transform: translateY(-75%); } 18% { opacity: 1; } 100% { opacity: 1; transform: none; } }
@keyframes nm-settle { 0% { transform: translateY(0) scaleY(.97); } 45% { transform: translateY(-1.4%); } 100% { transform: none; } }
@keyframes nm-thud { 0%, 100% { transform: none; } 15% { transform: translateY(5px); } 35% { transform: translate(-3px, -2px); } 55% { transform: translate(3px, 1px); } 75% { transform: translate(-1px, 0); } }
@keyframes nm-slam-in { 0% { opacity: 0; transform: scale(3.2) rotate(-5deg); } 25% { opacity: .7; } 66% { opacity: 1; transform: scale(.93) rotate(0); } 83% { transform: scale(1.04); } 100% { opacity: 1; transform: none; } }
@keyframes nm-glow-pulse { 0% { filter: drop-shadow(0 0 0 rgba(57,255,20,0)); } 18% { filter: drop-shadow(0 0 14px rgba(57,255,20,.95)) brightness(1.3); } 60% { filter: drop-shadow(0 0 8px rgba(57,255,20,.55)); } 100% { filter: drop-shadow(0 0 0 rgba(57,255,20,0)); } }
@keyframes nm-quake-big { 0%, 100% { transform: none; } 12% { transform: translate(-7px, 4px) rotate(-.8deg); } 28% { transform: translate(6px, -4px) rotate(.7deg); } 45% { transform: translate(-4px, 2px) rotate(-.4deg); } 62% { transform: translate(3px, -1px); } 80% { transform: translate(-1px, 1px); } }
@keyframes nm-splat { 0% { opacity: 0; transform: scale(.3); } 18% { opacity: .85; } 100% { opacity: 0; transform: scale(1.25); } }
@keyframes nm-rise { from { opacity: 0; transform: translateY(8px); letter-spacing: 1.1em; } to { opacity: 1; transform: none; } }
@keyframes nm-fade { from { opacity: 0; } to { opacity: 1; } }

/* plays once: after .nm-done (or with reduced motion) the home screen shows the plain, final artwork */
#screen-home.nm-done .home-hero, #screen-home.nm-done .home-hero * { animation: none !important; }
@media (prefers-reduced-motion: reduce) {
  .home-hero, .home-hero * { animation: none !important; }
  .nm-l-darts, .nm-l-letters, .nm-splat { display: none !important; }
  .nm-l-board img { -webkit-mask: none !important; mask: none !important; }
  #screen-home .nm-logo, #screen-home .app-name .t-sub, #screen-home .home-hero .tagline { visibility: visible !important; }
}
@media (max-height: 700px) { .nm-logo { width: min(100%, 250px); } .hello { margin: 12px auto 12px; } }

/* LOGO-MASKS:START (generated by scripts/build-logo.js — do not edit by hand) */
.nm-logo { --nm-mask-board: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 920 980' preserveAspectRatio='none'%3E%3Cpath fill-rule='evenodd' d='M0,0H920V980H0ZM178,160L200,108L238,78L282,74L308,98L330,150L342,200L331,213L466,438L452,470L424,462L289,237L248,229L204,206ZM372,100L388,40L424,8L482,12L534,38L550,82L534,132L486,192L480,440L458,466L437,440L436,190L384,162ZM560,196L585,116L622,78L676,70L720,94L746,148L734,195L682,219L632,238L491,459L468,472L449,446L576,218ZM22,815L72,650L116,508L186,446L288,502L375,490L425,496L525,508L650,496L750,490L860,426L916,446L878,588L828,700L842,752L700,772L450,760L188,772L112,828L48,842Z'/%3E%3C/svg%3E");
  --nm-mask-darts: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 920 980' preserveAspectRatio='none'%3E%3Cpolygon points='178,160 200,108 238,78 282,74 308,98 330,150 342,200 331,213 466,438 452,470 424,462 289,237 248,229 204,206'/%3E%3Cpolygon points='372,100 388,40 424,8 482,12 534,38 550,82 534,132 486,192 480,440 458,466 437,440 436,190 384,162'/%3E%3Cpolygon points='560,196 585,116 622,78 676,70 720,94 746,148 734,195 682,219 632,238 491,459 468,472 449,446 576,218'/%3E%3C/svg%3E");
  --nm-mask-letters: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 920 980' preserveAspectRatio='none'%3E%3Cpolygon points='22,815 72,650 116,508 186,446 288,502 375,490 425,496 525,508 650,496 750,490 860,426 916,446 878,588 828,700 842,752 700,772 450,760 188,772 112,828 48,842'/%3E%3C/svg%3E"); }
/* LOGO-MASKS:END */

/* ---------- voice scoring ---------- */
.icon-btn.mic { color: var(--muted); margin-right: 6px; position: relative; }
.icon-btn.mic:disabled { opacity: .35; }
.icon-btn.mic.on { color: #fff; background: var(--red-d); box-shadow: 0 0 0 0 rgba(239,68,68,.6); animation: mic-ring 1.4s infinite; }
.icon-btn.mic.hf::after { content: "HF"; position: absolute; right: 2px; bottom: 2px; font-size: 8px; font-weight: 800; letter-spacing: .02em; color: var(--gold); }
@keyframes mic-ring { 0% { box-shadow: 0 0 0 0 rgba(239,68,68,.55); } 70% { box-shadow: 0 0 0 10px rgba(239,68,68,0); } 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0); } }
.voice-strip { position: fixed; left: 10px; right: 10px; bottom: calc(10px + var(--safe-b)); max-width: 520px; margin: 0 auto; z-index: 45;
  background: rgba(16,21,31,.97); border: 1px solid var(--line); border-radius: 18px; padding: 12px; box-shadow: 0 -6px 30px rgba(0,0,0,.55); animation: v-up .16s ease-out; }
.voice-strip.confirm { border-color: var(--green); }
.voice-strip.error { border-color: var(--red); }
.voice-strip.listening { border-color: #7f1d1d; }
@keyframes v-up { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }
.v-row { display: flex; align-items: center; gap: 10px; }
.v-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.v-main b { font-size: 17px; }
.v-main small { color: var(--muted); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; }
.v-main small.v-err, .v-result.err span { color: #fca5a5; }
.v-main small.v-note { color: var(--gold); font-size: 12px; }
.v-mic { width: 34px; height: 34px; border-radius: 50%; flex: none; background: var(--red-d) center / 18px no-repeat
  url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='9' y='2.5' width='6' height='12' rx='3' fill='white'/%3E%3Cpath d='M5.5 11a6.5 6.5 0 0 0 13 0M12 17.5V21' fill='none' stroke='white' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E"); }
.v-mic.live { animation: mic-ring 1.2s infinite; }
.v-heard { color: var(--muted); font-size: 14px; margin-bottom: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.v-heard q, .v-main q { color: var(--text); font-style: italic; }
.v-result { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.v-result b { font-size: 30px; font-weight: 900; color: var(--green); letter-spacing: .01em; font-variant-numeric: tabular-nums; }
.v-result span { color: var(--text); font-size: 15px; }
.v-result.err b { color: var(--red); font-size: 22px; }
.v-result.info { display: block; }
.v-result.info b { display: block; color: var(--text); font-size: 18px; margin-bottom: 4px; }
.v-result.info span { color: var(--muted); font-size: 14.5px; line-height: 1.4; }
.v-bar { height: 4px; border-radius: 2px; background: var(--card2); overflow: hidden; margin: -2px 0 10px; }
.v-bar i { display: block; height: 100%; background: var(--green); transition: width .1s linear; }
.v-btns { display: grid; grid-template-columns: 1fr 1fr 1.4fr; gap: 8px; }
.v-btns:has(> :nth-child(2):last-child) { grid-template-columns: 1fr 1.4fr; }
.v-btn { padding: 12px 10px; border-radius: 12px; background: var(--card2); color: var(--text); font-weight: 700; font-size: 16px; white-space: nowrap; }
.v-btn.ok { background: var(--green-d); color: #fff; }
.v-btn.icon { width: 44px; padding: 10px 0; font-size: 19px; }
.v-row .v-btn { flex: none; }
.v-toggle { width: 100%; display: flex; align-items: center; gap: 12px; text-align: left; padding: 12px; margin: 8px 0; border-radius: 12px; background: var(--card2); color: var(--text); }
.v-toggle span { flex: 1; display: flex; flex-direction: column; gap: 3px; }
.v-toggle small { color: var(--muted); font-size: 13px; line-height: 1.35; }
.v-toggle .sw { flex: none; width: 46px; height: 28px; border-radius: 14px; background: #3a4458; position: relative; transition: background .15s; }
.v-toggle .sw::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .15s; }
.v-toggle .sw.on { background: var(--green-d); }
.v-toggle .sw.on::after { transform: translateX(18px); }
.v-warn { color: #fca5a5; line-height: 1.4; }
.v-help { line-height: 1.4; font-size: 14.5px; }
@media (prefers-reduced-motion: reduce) { .voice-strip, .icon-btn.mic.on, .v-mic.live { animation: none; } }
.v-debug { font: 11px/1.35 ui-monospace, SFMono-Regular, Menlo, monospace; color: #7c889f; margin: -4px 0 10px; word-break: break-word; }
.v-toggle:disabled { opacity: .55; }
.v-diag { margin: 10px 0 4px; color: var(--muted); font-size: 13px; }
.v-diag summary { cursor: pointer; padding: 6px 0; }
.v-diag .v-debug { margin: 4px 0 6px; }
.v-diag pre { margin: 0; max-height: 140px; overflow: auto; background: var(--bg2); border-radius: 8px; padding: 8px; font-size: 11px; line-height: 1.35; white-space: pre-wrap; color: #9fb0c8; }

/* ---------- video chat (1 v 1 online) ---------- */
.vpanel { flex: none; margin: 8px 10px 0; }
.vbar { display: flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 6px 6px 6px 12px; min-height: 44px; }
.vdot { width: 9px; height: 9px; border-radius: 50%; background: var(--line); flex: none; }
.vdot.live { background: var(--green); box-shadow: 0 0 0 3px rgba(34, 197, 94, .2); }
.vtxt { flex: 1; min-width: 0; font-size: 13.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vtxt b { color: var(--text); }
.vjoin, .vshow { background: var(--green); color: #04130a; font-weight: 700; font-size: 14px; border-radius: 10px; padding: 8px 12px; flex: none; }
.vshow { background: var(--card2); color: var(--text); }
.vstage { position: relative; height: 180px; border-radius: 14px; overflow: hidden; background: #000; border: 1px solid var(--line); }
.vtiles { position: absolute; inset: 0; }
.vtile { position: absolute; overflow: hidden; background: #05070b; }
.vtile.main { inset: 0; z-index: 0; }
.vtile.thumb { top: 8px; width: min(21%, 76px); aspect-ratio: 3 / 4; max-height: calc(100% - 58px); border-radius: 10px; border: 2px solid rgba(255, 255, 255, .55); z-index: 2; cursor: pointer; box-shadow: 0 4px 14px rgba(0, 0, 0, .5); }
.vremote { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #05070b; }
.vt-over { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; font-size: 10.5px; color: var(--muted); background: rgba(5, 7, 11, .6); padding: 2px; }
.vt-name { position: absolute; left: 0; right: 0; bottom: 0; font-size: 10px; line-height: 1.3; padding: 2px 4px; background: linear-gradient(transparent, rgba(0, 0, 0, .75)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vtile.main .vt-name { display: none; }
.vt-name .tdot, .vtag .tdot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 4px; vertical-align: 1px; }
.vtag .tdot:not(.ta):not(.tb) { display: none; }
.vpin { color: var(--muted); font-weight: 500; }
.vover { z-index: 1; position: absolute; inset: 0; display: flex; flex-direction: column; gap: 10px; align-items: center; justify-content: center; text-align: center; padding: 0 20% 44px 16px; color: var(--muted); font-size: 14px; background: rgba(5, 7, 11, .55); }
.vplay { background: var(--green); color: #04130a; font-weight: 700; border-radius: 10px; padding: 8px 14px; }
.vtag { z-index: 3; cursor: pointer; position: absolute; left: 8px; top: 8px; background: rgba(0, 0, 0, .55); border-radius: 8px; padding: 3px 8px; font-size: 12.5px; font-weight: 600; max-width: 60%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vpmic { color: var(--gold); font-weight: 500; }
/* Short phones (e.g. 375x667): before anyone joins, the "Join video" bar sits under the keypad so the
   whole keypad stays on screen; after joining, the panel moves back under the scores. */
@media (max-height: 760px) { #video-panel:not(.joined) { order: 5; margin: 0 10px calc(10px + var(--safe-b)); } }
/* 2v2 mesh: keep the big-tile label clear of the 3 thumbnails; status on its own line */
.mesh .vtag { max-width: calc(100% - 3 * (min(21%, 76px) + 6px) - 18px); white-space: normal; line-height: 1.25; }
.mesh .vtag .vname { display: inline-block; max-width: calc(100% - 12px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }
.mesh .vtag .vpmic:not(:empty), .mesh .vtag .vpin:not(:empty) { display: block; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vself { z-index: 2; position: absolute; right: 8px; top: 8px; width: 27%; max-width: 120px; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 10px; border: 2px solid rgba(255, 255, 255, .8); background: #111; box-shadow: 0 4px 14px rgba(0, 0, 0, .5); }
.vself.mirror { transform: scaleX(-1); }
.vself.off { opacity: .25; }
.vctl { z-index: 4; position: absolute; left: 0; right: 0; bottom: 6px; display: flex; justify-content: center; gap: 8px; }
.vround { width: 38px; height: 38px; border-radius: 50%; background: rgba(20, 26, 38, .78); border: 1px solid rgba(255, 255, 255, .18); display: grid; place-items: center; flex: none; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.vround.off { background: #f3f4f6; color: #111; }
.vround.ducked { color: var(--gold); }
.vround.end { background: var(--red-d); border-color: transparent; }
.vbar .vround { width: 34px; height: 34px; }
.vgrip { display: block; width: 100%; height: 18px; padding: 0; touch-action: none; cursor: ns-resize; }
.vgrip i { display: block; width: 44px; height: 5px; margin: 6px auto 0; border-radius: 3px; background: var(--line); }
.vmsg { font-size: 12.5px; color: var(--muted); padding: 4px 4px 0; line-height: 1.35; }
.vmsg.err { color: #fca5a5; }
