:root {
  --bg:#14181a; --card:#1f2628; --card2:#283133; --line:#334044; --text:#f2f4f3; --muted:#93a19f;
  --you:#ff5a36; --bot:#1fb8a6; --chip:#cfe3dc; --chipText:#15201e; --good:#43d17f; --bad:#ff4d4d;
  --gold:#ffc53d;
  --num:"Avenir Next Condensed","Roboto Condensed","Arial Narrow",sans-serif-condensed,Impact,sans-serif;
  --tap:clamp(50px, 7.2dvh, 72px);
}
* { box-sizing:border-box; -webkit-tap-highlight-color:transparent; }
html, body { margin:0; background:var(--bg); color:var(--text); }
body {
  font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif; line-height:1.4;
  padding:env(safe-area-inset-top,0) env(safe-area-inset-right,0) calc(72px + env(safe-area-inset-bottom,0)) env(safe-area-inset-left,0);
  overscroll-behavior:none; -webkit-user-select:none; user-select:none;
}
body.playing { padding-bottom:env(safe-area-inset-bottom,0); }
input, textarea { -webkit-user-select:text; user-select:text; }
button { font:inherit; color:inherit; border:none; background:none; cursor:pointer; touch-action:manipulation; }
a { color:inherit; }
.hidden { display:none !important; }
.num { font-family:var(--num); font-weight:800; font-stretch:condensed; letter-spacing:-.01em; }
.muted { color:var(--muted); }
.wrap { max-width:560px; margin:0 auto; padding:16px; }
h1 { font-family:var(--num); font-weight:800; font-size:2.2rem; margin:.2em 0 .4em; text-transform:uppercase; letter-spacing:.01em; }
h2 { font-family:var(--num); font-weight:800; font-size:1.3rem; margin:1.2em 0 .5em; text-transform:uppercase; color:var(--muted); letter-spacing:.04em; }

/* bottom nav */
.nav {
  position:fixed; left:0; right:0; bottom:0; z-index:30; display:flex;
  background:color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter:blur(10px);
  border-top:1px solid var(--line); padding-bottom:env(safe-area-inset-bottom,0);
}
.nav a { flex:1; text-align:center; padding:8px 0 10px; text-decoration:none; color:var(--muted); font-size:.78rem; font-weight:600; }
.nav a span { display:block; font-size:1.35rem; line-height:1.3; filter:grayscale(1); opacity:.7; }
.nav a.on { color:var(--text); }
.nav a.on span { filter:none; opacity:1; }

/* buttons */
.btn {
  display:flex; align-items:center; justify-content:center; gap:8px; width:100%;
  min-height:var(--tap); border-radius:999px; font-weight:700; font-size:1.15rem;
  background:var(--card2); color:var(--text);
}
.btn.primary { background:var(--you); color:#fff; }
.btn.big { min-height:84px; font-size:1.7rem; font-family:var(--num); font-weight:800; text-transform:uppercase; letter-spacing:.03em; }
.btn.ghost { background:none; color:var(--text); }
.btn:active { transform:scale(.98); filter:brightness(1.1); }
.btn[disabled] { opacity:.4; }
.card { background:var(--card); border-radius:22px; padding:16px; }
.row { display:flex; gap:10px; }
.row > * { flex:1; }
.stack > * + * { margin-top:12px; }

/* segmented choices */
.seg { display:flex; flex-wrap:wrap; gap:8px; }
.seg button {
  flex:1 1 0; min-width:64px; min-height:54px; border-radius:16px; background:var(--card2);
  font-weight:700; font-size:1.05rem; padding:6px 8px; line-height:1.1;
}
.seg button small { display:block; font-weight:500; font-size:.72rem; color:var(--muted); margin-top:2px; }
.seg button.on { background:var(--you); color:#fff; }
.seg button.on small { color:#ffe1d8; }
.levels { display:grid; grid-template-columns:repeat(3, 1fr); gap:8px; }
.levels button { min-height:66px; border-radius:16px; background:var(--card2); font-weight:700; }
.levels button b { display:block; font-family:var(--num); font-size:1.5rem; line-height:1; }
.levels button small { color:var(--muted); font-size:.75rem; }
.levels button.on { background:var(--bot); color:#04211d; }
.levels button.on small { color:#04211d; }
.stepper { display:flex; align-items:center; gap:10px; }
.stepper button { width:54px; height:54px; border-radius:50%; background:var(--card2); font-size:1.6rem; font-weight:700; }
.stepper .v { flex:1; text-align:center; font-family:var(--num); font-weight:800; font-size:1.5rem; }
.toggle { display:flex; align-items:center; justify-content:space-between; min-height:56px; gap:12px; }
.switch { width:58px; height:34px; border-radius:99px; background:var(--card2); position:relative; flex:none; }
.switch::after { content:""; position:absolute; top:3px; left:3px; width:28px; height:28px; border-radius:50%; background:#fff; transition:.15s; }
.switch.on { background:var(--good); }
.switch.on::after { left:27px; }

/* home */
.hello { display:flex; align-items:center; gap:12px; margin:8px 0 18px; }
.avatar { width:56px; height:56px; border-radius:50%; display:grid; place-items:center; font-size:1.8rem; background:var(--card2); flex:none; position:relative; }
.avatar.lg { width:84px; height:84px; font-size:2.8rem; background:rgba(0,0,0,.25); }
.avatar .lv { position:absolute; bottom:-10px; left:50%; transform:translateX(-50%); background:var(--chip); color:var(--chipText); font-size:.8rem; font-weight:700; padding:1px 9px; border-radius:99px; white-space:nowrap; }
.resume { background:linear-gradient(135deg, var(--you), #ff8a3d); color:#fff; border-radius:22px; padding:16px; display:block; text-decoration:none; }
.resume b { font-family:var(--num); font-size:1.5rem; text-transform:uppercase; }
.tiles { display:grid; grid-template-columns:repeat(3, 1fr); gap:8px; }
.tile { background:var(--card); border-radius:18px; padding:12px 8px; text-align:center; }
.tile .v { font-family:var(--num); font-weight:800; font-size:1.9rem; line-height:1.05; }
.tile .k { font-size:.74rem; color:var(--muted); font-weight:600; }

/* ---- the match ---------------------------------------------------------- */
.game { display:flex; flex-direction:column; height:100dvh; max-width:560px; margin:0 auto; padding:6px 10px calc(8px + env(safe-area-inset-bottom,0)); gap:8px; }
.topbar { display:flex; align-items:center; gap:8px; }
.topbar .mid { flex:1; text-align:center; font-weight:700; font-size:.85rem; color:var(--muted); line-height:1.2; }
.topbar .mid b { color:var(--text); font-size:1rem; }
.icon-btn { width:46px; height:46px; border-radius:50%; background:var(--card); font-size:1.25rem; display:grid; place-items:center; }
.board-row { display:grid; grid-template-columns:1fr 1fr; gap:8px; }
.pl { background:var(--card); border-radius:22px; padding:10px 12px 12px; position:relative; transition:background .2s, transform .2s; overflow:hidden; }
.pl .who { display:flex; align-items:center; gap:6px; font-weight:800; font-size:1rem; text-transform:uppercase; letter-spacing:.04em; }
.pl .who .tag { margin-left:auto; font-size:.7rem; font-weight:800; padding:2px 8px; border-radius:99px; background:rgba(255,255,255,.18); }
.pl .rem { font-family:var(--num); font-weight:800; font-size:clamp(3rem, min(20vw, 10dvh), 7rem); line-height:.95; margin:2px 0; }
.pl .meta { display:flex; justify-content:space-between; font-size:.8rem; color:var(--muted); font-weight:600; }
.pl .legs { display:flex; gap:4px; margin-top:6px; min-height:12px; }
.pl .legs i { width:12px; height:12px; border-radius:50%; background:var(--card2); }
.pl .legs i.won { background:var(--gold); }
.pl .last { font-size:.85rem; font-weight:700; margin-top:2px; min-height:1.2em; }
.pl.active.you { background:var(--you); }
.pl.active.bot { background:var(--bot); color:#04211d; }
.pl.active .meta, .pl.active .last { color:inherit; opacity:.85; }
.pl.active .legs i { background:rgba(0,0,0,.2); }
.pl.active .legs i.won { background:#fff; }
.pl:not(.active) { opacity:.72; }
.turn-banner { text-align:center; font-family:var(--num); font-weight:800; font-size:1.25rem; letter-spacing:.06em; text-transform:uppercase; border-radius:14px; padding:6px; }
.turn-banner.you { background:rgba(255,90,54,.15); color:var(--you); }
.turn-banner.bot { background:rgba(31,184,166,.15); color:var(--bot); }
.checkout { display:flex; justify-content:center; gap:8px; min-height:48px; align-items:center; }
.checkout .d { font-family:var(--num); font-weight:800; font-size:2rem; background:var(--card); border-radius:12px; padding:2px 14px; }
.checkout .d.fin { background:var(--good); color:#062313; }
.checkout .none { color:var(--muted); font-weight:600; }
.entry { display:flex; align-items:center; justify-content:center; font-family:var(--num); font-weight:800; font-size:2.8rem; line-height:1; min-height:clamp(46px, 6.5dvh, 64px); background:var(--card); border-radius:18px; }
.entry.empty { color:var(--muted); font-size:1.4rem; font-family:inherit; font-weight:600; }
.entry.shake { animation:shake .3s; background:rgba(255,77,77,.25); }
@keyframes shake { 25%{transform:translateX(-8px)} 75%{transform:translateX(8px)} }
.quick { display:grid; grid-template-columns:repeat(5, 1fr); gap:6px; }
.quick button { min-height:clamp(40px, 5.6dvh, 56px); border-radius:14px; background:var(--card2); font-family:var(--num); font-weight:800; font-size:1.35rem; }
.quick button.bust { background:#4a2323; color:#ffb4b4; font-size:1rem; }
.pad { display:grid; grid-template-columns:repeat(3, 1fr); gap:6px; }
.pad button { min-height:var(--tap); border-radius:16px; background:var(--card); font-family:var(--num); font-weight:800; font-size:2.1rem; }
.pad button.ok { background:var(--you); color:#fff; font-size:1.5rem; }
.pad button.del { font-size:1.5rem; }
.pad button:active, .quick button:active, .darts-grid button:active { filter:brightness(1.35); transform:scale(.97); }
.mods { display:grid; grid-template-columns:repeat(3, 1fr); gap:6px; }
.mods button { min-height:clamp(40px, 5.4dvh, 52px); border-radius:14px; background:var(--card2); font-weight:800; font-size:1.05rem; }
.mods button.on { background:var(--you); color:#fff; }
.darts-grid { display:grid; grid-template-columns:repeat(5, 1fr); gap:5px; }
.darts-grid button { min-height:clamp(42px, 6dvh, 58px); border-radius:12px; background:var(--card); font-family:var(--num); font-weight:800; font-size:1.45rem; }
.darts-grid button.wide { grid-column:span 1; font-size:1.05rem; }
.thrown { display:flex; gap:6px; justify-content:center; min-height:48px; }
.thrown .d { min-width:74px; text-align:center; font-family:var(--num); font-weight:800; font-size:1.7rem; background:var(--card); border-radius:12px; padding:4px 8px; }
.thrown .d.empty { color:var(--line); }
.spacer { flex:1; }

/* the bot's visit */
.botturn { display:flex; flex-direction:column; align-items:center; gap:8px; background:var(--card); border-radius:22px; padding:10px; flex:1; justify-content:center; }
.botturn svg { width:min(62vw, 250px); height:auto; }
.botturn .darts { display:flex; gap:8px; }
.botturn .darts .d { min-width:76px; text-align:center; font-family:var(--num); font-weight:800; font-size:2rem; background:var(--card2); border-radius:12px; padding:2px 10px; opacity:0; transform:scale(.6); transition:.18s; }
.botturn .darts .d.show { opacity:1; transform:none; }
.botturn .total { font-family:var(--num); font-weight:800; font-size:2.6rem; line-height:1; min-height:2.6rem; }
.botturn .total.bust { color:var(--bad); }
.dot { transition:opacity .15s; }

/* sheets and toasts */
.sheet { position:fixed; inset:0; z-index:50; background:rgba(0,0,0,.55); display:flex; align-items:flex-end; justify-content:center; }
.sheet-card { width:100%; max-width:560px; background:var(--card); border-radius:26px 26px 0 0; padding:20px 16px calc(20px + env(safe-area-inset-bottom,0)); max-height:92dvh; overflow:auto; }
.sheet-card h3 { margin:0 0 4px; font-family:var(--num); font-weight:800; font-size:1.6rem; text-transform:uppercase; }
.sheet-card .q { font-weight:700; margin:14px 0 8px; color:var(--muted); }
.sheet-card .seg button { min-height:70px; font-family:var(--num); font-weight:800; font-size:2rem; }
.toast { position:fixed; left:50%; bottom:calc(90px + env(safe-area-inset-bottom,0)); transform:translateX(-50%) translateY(20px); opacity:0; pointer-events:none;
  background:#000; color:#fff; padding:12px 18px; border-radius:14px; font-weight:600; z-index:60; transition:.2s; max-width:90vw; text-align:center; }
.toast.show { opacity:1; transform:translateX(-50%); }
.toast.bad { background:#7a1d1d; }

/* celebrations */
.celebrate { position:fixed; inset:0; z-index:70; display:grid; place-items:center; background:rgba(10,12,13,.72); overflow:hidden; }
.celebrate .msg { text-align:center; animation:pop .45s cubic-bezier(.2,1.6,.4,1); padding:0 16px; }
.celebrate .msg b { display:block; font-family:var(--num); font-weight:800; font-size:clamp(4rem, 26vw, 9rem); line-height:.9; color:var(--gold); text-shadow:0 6px 30px rgba(255,197,61,.45); }
.celebrate .msg span { display:block; font-family:var(--num); font-weight:800; font-size:clamp(1.5rem, 8vw, 2.6rem); text-transform:uppercase; letter-spacing:.04em; margin-top:8px; }
.celebrate .msg small { display:block; color:var(--muted); margin-top:18px; font-weight:600; }
.confetti { position:absolute; top:-20px; width:10px; height:16px; border-radius:2px; animation:fall linear forwards; }
@keyframes pop { from { transform:scale(.3); opacity:0 } to { transform:none; opacity:1 } }
@keyframes fall { to { transform:translateY(110dvh) rotate(720deg); } }

/* summary (the stats card) */
.sum-head { background:var(--you); border-radius:26px; padding:18px 14px 20px; text-align:center; color:#fff; }
.sum-head h1 { margin:0; font-size:2.6rem; }
.sum-head .fmt { display:flex; gap:6px; justify-content:center; margin:6px 0 14px; }
.sum-head .fmt span { background:#1b2224; color:#fff; font-size:.78rem; font-weight:700; padding:4px 10px; border-radius:8px; }
.sum-head .players { display:grid; grid-template-columns:1fr auto 1fr; align-items:center; gap:6px; }
.sum-head .p { display:flex; flex-direction:column; align-items:center; gap:14px; font-weight:700; font-size:1.2rem; }
.sum-head .trophy { font-size:1.8rem; line-height:1; min-height:1.8rem; }
.score-box { display:flex; border-radius:10px; overflow:hidden; font-family:var(--num); font-weight:800; font-size:2.2rem; }
.score-box span { padding:2px 16px; background:#1b2224; color:#fff; }
.score-box span + span { background:#fff; color:#1b2224; }
.score-box.small { font-size:1.1rem; margin-top:6px; justify-content:center; }
.score-box.small span { padding:0 10px; }
.stat-table { background:var(--card); border-radius:22px; padding:6px 14px; margin-top:14px; }
.stat-table .r { display:grid; grid-template-columns:1fr auto 1fr; align-items:center; gap:6px; padding:9px 0; }
.stat-table .r + .r { border-top:1px solid var(--line); }
.stat-table .r .a, .stat-table .r .b { text-align:center; font-family:var(--num); font-weight:800; font-size:clamp(1.6rem, 8.5vw, 2.5rem); line-height:1; text-transform:uppercase; }
.stat-table .r .a.win, .stat-table .r .b.win { color:var(--gold); }
.stat-table .r .k { background:var(--chip); color:var(--chipText); font-size:.85rem; font-weight:700; padding:5px 12px; border-radius:10px; text-align:center; white-space:nowrap; }
.pager { display:flex; justify-content:center; align-items:center; gap:14px; margin:12px 0; }
.pager i { width:10px; height:10px; border-radius:50%; background:var(--line); display:inline-block; }
.pager i.on { background:#fff; }
.pager button { font-size:1.6rem; width:44px; height:44px; color:var(--text); }
.pager button[disabled] { opacity:.25; }
.visits { background:var(--card); border-radius:18px; padding:8px 12px; margin-top:10px; }
.visits .vr { display:grid; grid-template-columns:1fr 1fr; gap:8px; padding:5px 0; border-top:1px solid var(--line); font-size:.95rem; }
.visits .vr:first-of-type { border-top:none; }
.visits .vr div { display:flex; justify-content:space-between; gap:6px; }
.visits .vr b { font-family:var(--num); font-size:1.25rem; }
.visits .vr .co { color:var(--good); }
.visits .vr .bu { color:var(--bad); }

/* lists */
.list > * + * { margin-top:8px; }
.mrow { display:flex; align-items:center; gap:12px; background:var(--card); border-radius:18px; padding:12px 14px; text-decoration:none; }
.mrow .res { width:44px; height:44px; border-radius:12px; display:grid; place-items:center; font-family:var(--num); font-weight:800; font-size:1.4rem; flex:none; }
.mrow .res.w { background:var(--good); color:#062313; }
.mrow .res.l { background:var(--card2); color:var(--muted); }
.mrow .res.o { background:var(--card2); color:var(--gold); font-size:1rem; }
.mrow .t { flex:1; min-width:0; }
.mrow .t b { display:block; }
.mrow .t small { color:var(--muted); }
.mrow .n { text-align:right; font-family:var(--num); font-weight:800; font-size:1.4rem; line-height:1.1; }
.mrow .n small { display:block; font-family:inherit; font-size:.72rem; color:var(--muted); font-weight:600; }
.chart { background:var(--card); border-radius:18px; padding:12px 12px 6px; }
.chart svg { width:100%; height:auto; display:block; }
.chart .ttl { display:flex; justify-content:space-between; font-weight:700; font-size:.9rem; }
.chart .ttl span { color:var(--muted); font-weight:600; }
table.plain { width:100%; border-collapse:collapse; }
table.plain td, table.plain th { padding:8px 4px; text-align:left; border-top:1px solid var(--line); }
table.plain th { color:var(--muted); font-size:.8rem; border-top:none; }
table.plain td.n { text-align:right; font-family:var(--num); font-weight:800; font-size:1.2rem; }

/* forms */
.field { display:block; margin-bottom:12px; }
.field span { display:block; font-size:.85rem; color:var(--muted); margin-bottom:4px; font-weight:600; }
.field input, .field select { width:100%; font:inherit; font-size:1.1rem; padding:14px; border-radius:14px; border:1px solid var(--line); background:var(--card2); color:var(--text); }
.err { color:#ff9a9a; min-height:1.2em; font-weight:600; }
.login { max-width:380px; margin:0 auto; padding:10vh 16px 16px; }
.logo { font-family:var(--num); font-weight:800; font-size:3.4rem; text-transform:uppercase; line-height:.9; }
.logo em { font-style:normal; color:var(--you); }
.emojis { display:flex; flex-wrap:wrap; gap:6px; }
.emojis button { width:50px; height:50px; border-radius:14px; background:var(--card2); font-size:1.6rem; }
.emojis button.on { outline:3px solid var(--you); }
.doubles { display:grid; grid-template-columns:repeat(5, 1fr); gap:6px; }
.doubles button { min-height:48px; border-radius:12px; background:var(--card2); font-weight:800; position:relative; }
.doubles button.on { background:var(--good); color:#062313; }
.doubles button sup { position:absolute; top:3px; right:6px; font-size:.65rem; }
.offline-pill { position:fixed; top:calc(6px + env(safe-area-inset-top,0)); right:8px; z-index:40; background:#5a4214; color:#ffd98a; font-size:.72rem; font-weight:700; padding:3px 9px; border-radius:99px; }
.bull-choices { display:grid; gap:8px; }
.bull-choices button { min-height:64px; border-radius:18px; background:var(--card2); font-weight:800; font-size:1.25rem; }
.center { text-align:center; }
.coin { width:140px; height:140px; border-radius:50%; margin:30px auto; display:grid; place-items:center; font-size:3.5rem; background:radial-gradient(circle at 35% 30%, #ffe28a, #d49a14); color:#5a3d00; font-family:var(--num); font-weight:800; }
.coin.spin { animation:flip .9s ease-out; }
@keyframes flip { from { transform:rotateY(0) } to { transform:rotateY(1800deg) } }
.seg button[disabled] { opacity:.4; }
.botturn { min-height:0; }
.botturn svg { max-height:34dvh; }

input[type=range] { width:100%; height:44px; accent-color:var(--you); margin:0; }
