:root {
  --bg: #0d1016;
  --panel: #151a22;
  --panel-2: #1b212c;
  --line: #262e3b;
  --text: #e9edf3;
  --muted: #8b95a5;
  --accent: #ffcc3d;
  --accent-2: #ff8a3d;
  --good: #3ddc84;
  --bad: #ff5d5d;
  --info: #66c2ff;
  --radius: 16px;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(1200px 600px at 20% -10%, #1a2130 0%, var(--bg) 60%) fixed, var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.hidden { display: none !important; }

/* slim dark scrollbars; the game screen does not scroll behind the start screen or account page */
* { scrollbar-width: thin; scrollbar-color: #3a4558 transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2c3544; border-radius: 999px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #3a4558; }
body:has(.setup:not(.hidden)) { overflow: hidden; }

/* desktop app: full screen without a title bar, these are its window buttons */
.win-ctl { position: fixed; top: 0; right: 0; z-index: 100; display: flex; }
.win-ctl button { font-family: "Segoe Fluent Icons", "Segoe MDL2 Assets", sans-serif; font-size: 11px; width: 50px; height: 34px;
  padding: 0; border: 0; border-radius: 0; background: transparent; color: var(--muted); }
.win-ctl button:hover { background: rgba(255, 255, 255, .08); color: var(--text); }
.win-ctl button.close:hover { background: #c42b1c; color: #fff; }
body.app-window .topbar { padding-right: 116px; }
.muted { color: var(--muted); font-weight: 400; }

button {
  font: inherit;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s;
}
button:hover { border-color: #3a4558; background: #212938; }
button:active { transform: translateY(1px); }
button.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #1a1205; border: 0; font-weight: 600; }
button.ghost { background: transparent; }
button.danger { color: var(--bad); border-color: rgba(255, 93, 93, .4); }
button.danger:hover { background: rgba(255, 93, 93, .1); border-color: var(--bad); }

/* top bar */
.topbar { display: flex; align-items: center; gap: 24px; padding: 14px 24px; }
.brand { font-weight: 800; letter-spacing: .2em; display: flex; align-items: center; gap: 10px; }
.brand .dot { width: 14px; height: 14px; border-radius: 50%; background: radial-gradient(circle, #ff4b4b 35%, #2fb36b 36% 60%, #e8dcc0 61%); }
.match-info { color: var(--muted); flex: 1; }
.actions { display: flex; gap: 10px; }

/* training progress */
.training { margin: 0 24px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; }
.training .tr-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.training .tr-head .muted { flex: 1; }
.training .tr-head button { padding: 6px 12px; }
.training .bar { height: 10px; background: var(--panel-2); border-radius: 999px; overflow: hidden; }
.training .fill { height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width .6s ease; }
.training.running .fill { background-size: 40px 40px;
  background-image: linear-gradient(90deg, var(--accent), var(--accent-2)),
    linear-gradient(45deg, rgba(255,255,255,.18) 25%, transparent 25% 50%, rgba(255,255,255,.18) 50% 75%, transparent 75%);
  background-blend-mode: overlay; animation: stripes 1s linear infinite; }
.training.installed .fill { background: var(--good); }
.training.failed .fill, .training.cancelled .fill { background: var(--bad); }
@keyframes stripes { from { background-position: 0 0; } to { background-position: 40px 0; } }

/* players: the remaining scores are the biggest thing on screen */
.players { display: flex; gap: 16px; padding: 0 24px; flex-wrap: wrap; }
.player {
  flex: 1 1 260px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 20px 16px;
  position: relative;
  transition: border-color .2s, box-shadow .2s, opacity .2s;
  opacity: .72;
}
.player.active { opacity: 1; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), 0 10px 40px -10px rgba(255, 204, 61, .35); }
.player.winner { border-color: var(--good); box-shadow: 0 0 0 1px var(--good), 0 10px 40px -10px rgba(61, 220, 132, .4); }
.player .name { font-size: 20px; font-weight: 600; display: flex; justify-content: space-between; align-items: baseline; }
.player .legs { color: var(--muted); font-size: 15px; }
.form { color: var(--muted); font-weight: 500; }
/* profile picture: the right side of the player tile, fading in from the left */
.player.has-pic { --pic: clamp(110px, 13vw, 240px); overflow: hidden; }
.player.has-pic > :not(.pic) { position: relative; } /* the picture is only a background: content on top, layout unchanged */
.player.has-pic .legs { text-shadow: 0 1px 3px rgba(0, 0, 0, .9); }
.player .pic { position: absolute; top: 0; right: 0; bottom: 0; width: var(--pic); pointer-events: none; opacity: .5;
  background: center 25% / cover no-repeat; -webkit-mask-image: linear-gradient(to right, transparent, #000 28%);
  mask-image: linear-gradient(to right, transparent, #000 28%); }
.cricket .cpic { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; vertical-align: middle; margin-right: 8px; }
.acc-head .pic-btns { display: flex; gap: 8px; }

/* live matches you are in on other boards: a banner, and a read-only scoreboard */
.live-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--bad);
  box-shadow: 0 0 0 0 rgba(255, 93, 93, .7); animation: live-pulse 1.6s infinite; margin-right: 10px; vertical-align: middle; }
@keyframes live-pulse { 70% { box-shadow: 0 0 0 9px rgba(255, 93, 93, 0); } 100% { box-shadow: 0 0 0 0 rgba(255, 93, 93, 0); } }
.live-banner { position: fixed; left: 50%; bottom: 52px; transform: translateX(-50%); z-index: 50; display: flex; align-items: center;
  gap: 4px; padding: 12px 18px; border-radius: 999px; background: rgba(21, 26, 34, .96); border: 1px solid rgba(255, 93, 93, .55);
  box-shadow: 0 12px 40px rgba(0, 0, 0, .55); font-size: 16px; max-width: calc(100vw - 32px); }
.live-banner b { margin-right: 6px; color: var(--bad); letter-spacing: .08em; }
.live-banner .watch { margin-left: 14px; color: var(--accent); font-weight: 700; }
.live-banner:hover { border-color: var(--bad); background: #1b212c; }
.setup.live { z-index: 45; }
.live .setup-head h1 { display: flex; align-items: center; }
.live-players { padding: 18px 0; }
.live-turn { display: flex; align-items: center; gap: 22px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 20px; min-height: 76px; }
.live-turn .who { font-size: 22px; font-weight: 600; min-width: 160px; }
.live-turn .chips { display: flex; gap: 10px; flex: 1; }
.live-turn .chip { min-width: 84px; text-align: center; font-size: 30px; font-weight: 800; padding: 6px 12px;
  border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); }
.live-turn .chip.empty { opacity: .4; }
.live-turn .value { font-size: 40px; font-weight: 800; }
.live-history { margin: 14px 0 0; padding-left: 22px; color: var(--muted); max-height: 220px; overflow: auto; }
@media (max-width: 700px) { /* phones: the banner spans the screen, "Watch" on the right */
  .live-banner { left: 12px; right: 12px; transform: none; max-width: none; border-radius: 16px; font-size: 14px;
    text-align: left; padding: 10px 14px; }
  .live-banner .muted { display: none; }
  .live-banner .watch { margin-left: auto; white-space: nowrap; }
}
.player .remaining { font-size: clamp(60px, min(9vw, 13vh), 148px); font-weight: 800; line-height: 1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; margin: 6px 0 8px; }
.player.active .remaining { color: var(--accent); }
.player .stats { display: flex; flex-wrap: wrap; gap: 6px 32px; color: var(--muted); font-size: 30px; }
.player .stats b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }

/* rolling digits (odometer): each digit is a strip of blank, 0-9 sliding in a 1em window */
.roll { display: inline-flex; vertical-align: top; }
.roll .digit { display: inline-block; height: 1em; width: 1ch; overflow: hidden; transition: width .45s ease; }
.roll .strip { display: block; transition: transform .7s cubic-bezier(.2, 1.3, .4, 1); will-change: transform; }
.roll .strip span { display: block; height: 1em; line-height: 1em; text-align: center; }
.turn-total strong { line-height: 1; }

/* play area */
.play { display: grid; grid-template-columns: minmax(300px, 520px) 1fr; gap: 20px; padding: 18px 24px; align-items: start; }
.board-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; position: relative; }
/* the board scales with the window height so it is never cut off */
#board { width: 100%; max-height: calc(100vh - 430px); min-height: 280px; display: block; margin: 0 auto; cursor: crosshair; user-select: none; }
.board-hint { text-align: center; color: var(--muted); font-size: 14px; margin-top: 4px; }
.dart-mark { cursor: pointer; }
.dart-mark circle.ring { fill: rgba(13, 16, 22, .55); stroke: #fff; stroke-width: 1.4; }
.dart-mark.selected circle.ring { stroke: var(--accent); stroke-width: 2.4; filter: drop-shadow(0 0 4px var(--accent)); }
.dart-mark text { fill: #fff; font-size: 10px; font-weight: 700; text-anchor: middle; dominant-baseline: central; pointer-events: none; }

.turn { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; }
.turn-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.turn-player { font-size: 22px; font-weight: 600; }
.turn-state { font-size: 22px; font-weight: 700; color: var(--info); }
.turn-state.bust { color: var(--bad); }
.turn-state.checkout, .turn-state.over { color: var(--good); }
.slots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.slot { background: var(--panel-2); border: 1px solid var(--line); border-radius: 14px; padding: 14px; text-align: center; cursor: pointer; min-height: 120px; display: flex; flex-direction: column; justify-content: center; }
.slot.selected { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.slot.empty { cursor: default; opacity: .45; }
.slot .label { font-size: clamp(36px, 4.2vw, 60px); font-weight: 800; line-height: 1.05; }
.slot .pts { color: var(--muted); }
.slot .src { color: var(--muted); font-size: 11px; margin-top: 4px; }
.slot .train { align-self: center; margin-top: 6px; font-size: 11px; font-weight: 700; color: var(--good);
  background: rgba(61, 220, 132, .12); border: 1px solid rgba(61, 220, 132, .35); border-radius: 999px; padding: 1px 8px; }
/* this visit's score: big, in the middle of the panel; the label stays on the left */
.turn-total { position: relative; display: flex; justify-content: center; align-items: center; min-height: 1.1em;
  font-size: 18px; color: var(--muted); }
.turn-total > span { position: absolute; left: 0; top: 50%; transform: translateY(-50%); }
.turn-total strong { font-size: clamp(55px, min(6.3vw, 10.4vh), 97px); font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; }
.checkout { display: flex; gap: 8px; min-height: 34px; align-items: center; }
.checkout .chip { background: rgba(61, 220, 132, .12); color: var(--good); border: 1px solid rgba(61, 220, 132, .35); border-radius: 999px; padding: 4px 12px; font-weight: 700; }
.turn-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.turn-actions .primary { margin-left: auto; }
.history summary { cursor: pointer; color: var(--muted); }
.history ol { margin: 8px 0 0; padding-left: 20px; max-height: 180px; overflow: auto; color: var(--muted); font-size: 14px; }

/* zoomed camera views */
/* fine-tuning panel: slides over the bottom of the window, always in view */
.zoom {
  position: fixed; left: 24px; right: 24px; bottom: 44px; z-index: 20;
  background: rgba(21, 26, 34, .97); border: 1px solid var(--accent); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: 0 -20px 60px rgba(0, 0, 0, .6); backdrop-filter: blur(6px);
  animation: slide-up .18s ease-out;
}
@keyframes slide-up { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.zoom-head { display: flex; align-items: center; gap: 16px; margin-bottom: 10px; }
.zoom-head > div:first-child { flex: 1; }
.zoom-label { font-size: 28px; font-weight: 800; color: var(--accent); min-width: 80px; text-align: right; }
.zoom-views { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.zoom-view { position: relative; }
.zoom-view canvas { width: 100%; aspect-ratio: 4 / 3; max-height: 44vh; display: block; border-radius: 12px; background: #000; cursor: none; }
.zoom-view .cap { position: absolute; left: 10px; top: 8px; font-size: 13px; color: #fff; text-shadow: 0 1px 3px #000; }

.cams { margin: 0 24px 18px; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.cams img { width: 100%; border-radius: 12px; border: 1px solid var(--line); }

.status { margin-top: auto; padding: 8px 24px; color: var(--muted); font-size: 13px; border-top: 1px solid var(--line); background: rgba(0, 0, 0, .25); }

/* start screen: game, players, options */
.setup { position: fixed; inset: 0; z-index: 40; overflow: auto; padding: 32px 16px;
  background: radial-gradient(1000px 500px at 50% -10%, #1f2738 0%, var(--bg) 60%) var(--bg); }
.setup-card { max-width: 1100px; margin: 0 auto; }
.setup-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.setup-head .head-btns { display: flex; gap: 10px; }
.setup-head h1 { margin: 0; font-size: 34px; letter-spacing: .02em; }
.games { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 26px; }
.game-tile { text-align: left; padding: 20px 22px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); }
.game-tile .gt-name { font-size: 28px; font-weight: 800; }
.game-tile .gt-tag { color: var(--muted); margin-top: 6px; }
.game-tile.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), 0 10px 40px -12px rgba(255, 204, 61, .45); }
.setup-grid { display: grid; grid-template-columns: 1fr 1.3fr; gap: 28px; }
.setup h3 { margin: 0 0 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .08em; font-size: 13px; }
.player-list { list-style: none; padding: 0; margin: 0 0 10px; display: flex; flex-direction: column; gap: 8px; }
.player-list li { display: flex; gap: 6px; align-items: center; }
.player-list .num { width: 26px; color: var(--muted); text-align: right; }
.player-list input { flex: 1; font: inherit; font-size: 18px; color: var(--text); background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; }
.player-list button { padding: 8px 10px; }
.player-btns { display: flex; gap: 8px; }
.player-list.shuffled li { animation: shuffle-in .35s ease-out backwards; }
.player-list.shuffled li:nth-child(2) { animation-delay: .05s; }
.player-list.shuffled li:nth-child(3) { animation-delay: .1s; }
.player-list.shuffled li:nth-child(n+4) { animation-delay: .15s; }
@keyframes shuffle-in { from { opacity: 0; transform: translateX(-14px); } }
.options { display: flex; flex-direction: column; gap: 18px; }
.opt .opt-label { color: var(--muted); margin-bottom: 8px; font-size: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chips button.on { background: rgba(255, 204, 61, .14); border-color: var(--accent); color: var(--accent); font-weight: 700; }
.chips input, .opt input[type=number] { width: 90px; font: inherit; color: var(--text); background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; }
.stepper { display: inline-flex; align-items: center; gap: 8px; }
.stepper span { min-width: 28px; text-align: center; font-size: 20px; font-weight: 700; }
.setup-foot { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 30px;
  border-top: 1px solid var(--line); padding-top: 20px; }
button.big { font-size: 20px; padding: 14px 34px; }
button:disabled { opacity: .35; cursor: not-allowed; transform: none; }

/* cricket scoreboard */
.cricket { flex: 1 1 100%; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; overflow-x: auto; }
.cricket table { width: 100%; border-collapse: collapse; }
.cricket th, .cricket td { text-align: center; padding: 4px 8px; }
.cricket th { vertical-align: bottom; }
.cricket .pname { font-size: 18px; font-weight: 600; }
.cricket .pscore { font-size: clamp(44px, min(6vw, 9vh), 110px); font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.cricket .pstats { color: var(--muted); font-size: 13px; font-weight: 400; }
.cricket th.active .pscore, .cricket th.active .pname { color: var(--accent); }
.cricket th.active { box-shadow: inset 0 -3px 0 var(--accent); }
.cricket td.num { font-size: 22px; font-weight: 800; color: var(--muted); width: 70px; }
.cricket td.mark { font-size: 30px; font-weight: 800; line-height: 1.1; }
.cricket td.mark.m3 { color: var(--good); }
.cricket tr.dead td { opacity: .3; }
.cricket tr + tr td { border-top: 1px solid var(--line); }
.cricket tr:nth-child(odd) + tr td { background: rgba(255, 255, 255, .045); } /* every other number row shaded */

/* account: sign-in, stats, history, friends */
button.account { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; }
.avatar { border-radius: 50%; object-fit: cover; flex: none; }
.avatar.letter { display: inline-grid; place-items: center; background: linear-gradient(135deg, var(--info), #3d7bff);
  color: #fff; font-weight: 800; font-size: 14px; }
.badge { background: var(--bad); color: #fff; border-radius: 999px; font-size: 12px; font-weight: 700; padding: 1px 7px; }
.acc-hero { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; max-width: 640px; }
.acc-hero h2 { margin: 0 0 10px; }
.acc-hero ol { color: var(--muted); line-height: 1.7; }
.acc-head { display: flex; align-items: center; gap: 18px; margin-bottom: 22px; }
.acc-head .who { flex: 1; }
.acc-head .acc-name { font-size: 26px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.acc-head .acc-name button, .acc-head .code button { padding: 4px 10px; font-size: 13px; }
.acc-head .code { color: var(--muted); margin-top: 4px; display: flex; align-items: center; gap: 8px; }
.acc-head .code b { color: var(--text); letter-spacing: .12em; font-size: 18px; }
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 18px; flex-wrap: wrap; }
.tabs button { background: transparent; border: 0; border-bottom: 2px solid transparent; border-radius: 0; padding: 10px 16px; color: var(--muted); }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); font-weight: 700; }
.tabs .badge { margin-left: 6px; }
.acc-who { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; color: var(--muted); }
select { font: inherit; color: var(--text); background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.stat-game { margin-bottom: 26px; }
.stat-game h3 { margin-bottom: 10px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
.stat .v { font-size: 34px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat .k { color: var(--muted); font-size: 14px; margin-top: 2px; }
.stat.main { border-color: var(--accent); }
.stat.main .v { color: var(--accent); font-size: 44px; }
.match-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.match { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px 16px; display: grid;
  grid-template-columns: 150px 1fr auto; gap: 14px; align-items: center; }
.match .when { color: var(--muted); font-size: 14px; }
.match .title { font-size: 13px; color: var(--muted); }
.match .ps { display: flex; flex-wrap: wrap; gap: 4px 22px; font-size: 18px; }
.match .ps .won { color: var(--good); font-weight: 700; }
.match .ps .avg { color: var(--muted); font-size: 14px; }
.match .btns { display: flex; gap: 8px; }
.friend-add { display: flex; gap: 8px; margin-bottom: 22px; }
.friend-add input { font: inherit; font-size: 18px; letter-spacing: .12em; text-transform: uppercase; width: 180px; color: var(--text);
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; }
.people { list-style: none; padding: 0; margin: 0 0 22px; display: flex; flex-direction: column; gap: 8px; }
.people li { display: flex; align-items: center; gap: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px; }
.people li .nm { flex: 1; font-size: 18px; }
.people li button { padding: 6px 12px; }
.acc-msg { color: var(--muted); padding: 14px 0; }
.acc-msg.err { color: var(--bad); }
.player-list select { max-width: 170px; }

dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius); padding: 0; width: min(440px, 92vw); }
dialog::backdrop { background: rgba(0, 0, 0, .6); backdrop-filter: blur(3px); }
.newgame { padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.newgame h2 { margin: 0 0 4px; }
.newgame label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
.newgame textarea, .newgame select, .newgame input { font: inherit; color: var(--text); background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.newgame .row { display: flex; gap: 14px; }
.newgame .row > label { flex: 1; }
.newgame .row.end { justify-content: flex-end; }

@media (max-width: 900px) {
  .play { grid-template-columns: 1fr; }
  .players, .play, .topbar { padding-left: 16px; padding-right: 16px; }
  .zoom, .cams { margin-left: 16px; margin-right: 16px; }
}
