:root {
  --bg: #0b0b10;
  --bg-2: #121115;
  --panel: #16181f;
  --panel-2: #1c2030;
  --line: #2a3550;
  --text: #f4f7fb;
  --muted: #b7c4d6;
  --blue: #2e9bdb;
  --blue-2: #1a9be0;
  --navy: #1c4384;
  --ink: #071018;
  --danger: #ff6b63;
  --tap: 48px;
  color-scheme: dark;
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*,
*::before,
*::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  height: 100vh;
  height: 100dvh;
  height: 100svh;
  max-height: 100vh;
  max-height: 100dvh;
  max-height: 100svh;
  overflow: hidden;
  color: var(--text);
  background:
    linear-gradient(115deg, transparent 0 42%, rgba(26, 155, 224, 0.08) 42% 46%, transparent 46% 58%, rgba(28, 67, 132, 0.35) 58% 62%, transparent 62%),
    var(--bg);
  overscroll-behavior: none;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
img { display: block; max-width: 100%; }
h1, h2, p { margin: 0; }
#app { height: 100%; min-height: 0; }

.screen {
  height: 100%;
  min-height: 0;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  padding: max(6px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
}

.screen-home,
.screen-setup,
.screen-result,
.screen-confirm { overflow: auto; overscroll-behavior: contain; }

.screen-live {
  overflow: hidden;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: clamp(4px, 0.7svh, 8px);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  position: relative;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid var(--navy);
}

.wordmark {
  font-family: Impact, "Arial Black", sans-serif;
  letter-spacing: 0.05em;
  font-size: 1.35rem;
  line-height: 0.9;
  color: #fff;
  -webkit-text-stroke: 1px #1a9be0;
  paint-order: stroke fill;
}

.wordmark span { display: block; font-size: 0.72em; letter-spacing: 0.18em; }
.top-actions { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }

.ghost, .primary, .danger, .choice, .key, .tiny {
  min-height: var(--tap);
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  font-weight: 750;
}

.ghost, .tiny { padding: 0 12px; }
.tiny { min-height: 36px; font-size: 0.85rem; }
.primary { background: var(--blue); color: var(--ink); border-color: transparent; padding: 0 16px; }
.danger { background: transparent; color: var(--danger); border-color: #6a3030; }
.primary:disabled, .ghost:disabled { opacity: 0.45; }

.home-scroll, .setup-scroll, .result-scroll { display: flex; flex-direction: column; gap: 12px; padding-bottom: 16px; }
.hero {
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid var(--navy);
  background: #07080c;
}
.hero img {
  width: 100%;
  height: auto;
  max-height: 46svh;
  object-fit: contain;
  object-position: center;
  margin: 0 auto;
}
.group h2 {
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--blue);
  margin: 8px 0;
}
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 8px; }
.tile {
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 96px;
}
.tile strong { font-size: 1.05rem; }
.tile span { color: var(--muted); font-weight: 600; font-size: 0.92rem; }
.tile-row { display: flex; gap: 8px; }
.tile-row .tile { flex: 1; }
.quick { align-self: flex-start; }

.resume {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  background: #102033;
  border: 1px solid var(--navy);
  border-radius: 14px;
  padding: 10px 12px;
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .setup-block h2 { font-size: 0.82rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.row { display: flex; flex-wrap: wrap; gap: 8px; }
select, .texty {
  min-height: var(--tap);
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  padding: 0 12px;
}
.texty { width: 100%; }
.choice.on, .key.on, .mult.on { background: var(--blue); color: var(--ink); border-color: transparent; }
.summary {
  background: #10151f;
  border-radius: 14px;
  padding: 12px;
  color: var(--muted);
  line-height: 1.4;
}
.player-card, .stat-card, .score-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 8px 10px;
  min-width: 0;
}
.score-card.active { border-color: var(--swatch, var(--blue)); box-shadow: inset 3px 0 0 var(--swatch, var(--blue)); }
.score-card.out { opacity: 0.55; }
.score-card .primary-score, .stat-card strong { font-variant-numeric: tabular-nums; font-weight: 800; }
.score-card .primary-score { font-size: clamp(1.3rem, 3.4svh, 2rem); }
.muted { color: var(--muted); font-weight: 650; }
.name { font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.score-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 6px;
  min-height: 0;
}
.live-main {
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 6px;
  overflow: hidden;
  padding-top: 4px;
}
.headline {
  font-size: clamp(3rem, 11svh, 6.4rem);
  line-height: 0.86;
  font-weight: 850;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}
.subhead { font-size: clamp(1rem, 2.4svh, 1.4rem); font-weight: 750; }
.suggestions { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border-radius: 999px;
  padding: 6px 10px;
  background: #102033;
  border: 1px solid var(--navy);
  color: var(--text);
  font-weight: 750;
  font-size: 0.85rem;
}
.darts-row { display: flex; gap: 6px; }
.dart-chip, .dart-empty {
  min-width: 64px;
  min-height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--panel);
  border: 1px dashed var(--line);
  font-weight: 800;
}
.dart-chip { border-style: solid; border-color: var(--blue); }
.pad {
  min-height: 0;
  overflow: hidden;
  background: #10131a;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.switcher, .mults, .extra-row { display: flex; gap: 6px; flex-wrap: wrap; }
.nums, .keys {
  display: grid;
  gap: 6px;
}
.nums { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.keys { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.key, .num, .mult { min-height: clamp(40px, 6.2svh, 54px); }
.wide { grid-column: span 2; }
.board-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 72px; gap: 6px; min-height: 0; flex: 1; overflow: hidden; }
.board-wrap svg { width: 100%; height: 100%; max-height: none; }
.board-side { display: flex; flex-direction: column; gap: 4px; min-height: 0; }
.board-side .mults { flex-direction: column; }
.board-side .mult, .board-side .ghost, .board-side .primary { flex: 1; min-height: 0; padding: 0 4px; }
.board-wrap path { stroke: #0b0b10; stroke-width: 0.01; }
.banner {
  background: #102033;
  border: 1px solid var(--blue);
  border-radius: 14px;
  padding: 10px 12px;
}
.banner h2 { font-size: 1.25rem; }
.end-grid, .setup-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px; }
.stat-line { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; border-bottom: 1px solid #243044; }
.modal-back {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 5;
}
.modal {
  width: min(440px, 100%);
  background: var(--bg-2);
  border: 1px solid var(--navy);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.toast {
  position: fixed;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  background: #102033;
  border: 1px solid var(--blue);
  color: white;
  border-radius: 12px;
  padding: 10px 14px;
  z-index: 6;
  max-width: 90vw;
}
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.noscript { padding: 24px; }

@media (orientation: landscape) {
  .screen-live {
    grid-template-columns: minmax(0, 1fr) minmax(300px, 430px);
    grid-template-rows: auto auto minmax(0, 1fr);
  }
  .topbar { grid-column: 1 / -1; grid-row: 1; }
  .score-strip { grid-column: 1 / -1; grid-row: 2; }
  .live-main { grid-column: 1; grid-row: 3; }
  .pad { grid-column: 2; grid-row: 3; }
  .hero img { max-height: 52svh; }
}

@media (orientation: portrait) {
  .live-main { justify-content: center; }
}

@media (max-height: 760px) and (orientation: landscape) {
  :root { --tap: 42px; }
  .headline { font-size: clamp(2.6rem, 9svh, 4.6rem); }
  .score-card { padding: 4px 8px; }
  .score-card .primary-score { font-size: 1.25rem; }
}

.screen-live .nums,
.screen-live .keys {
  flex: 1 1 auto;
  min-height: 0;
  grid-template-rows: repeat(4, minmax(0, 1fr));
}
.screen-live .key,
.screen-live .num,
.screen-live .mult,
.screen-live .ghost,
.screen-live .primary,
.screen-live .danger {
  min-height: 0;
}
.screen-live .setup-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  min-height: 0;
  overflow: hidden;
}
.screen-live .extra-row { min-height: 0; align-items: center; }
.screen-live .suggestions { flex: 0 1 auto; min-height: 0; }

@media (orientation: landscape) {
  html[data-lock="landscape"] .screen-live .headline { font-size: clamp(1.8rem, 7.4dvh, 3.4rem); }
  html[data-lock="landscape"] .screen-live .subhead { font-size: clamp(0.95rem, 2.2dvh, 1.2rem); }
  html[data-lock="landscape"] .score-card { padding: 4px 8px; }
  html[data-lock="landscape"] .score-card .primary-score { font-size: clamp(1.15rem, 3.2dvh, 1.7rem); }
  html[data-lock="landscape"] .screen-live { gap: 4px; }
}

@media (orientation: portrait) {
  html[data-lock="portrait"] .screen-live {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto minmax(0, 0.72fr) minmax(0, 1.15fr);
    overflow: hidden;
  }
  html[data-lock="portrait"] .screen-live .topbar { grid-column: 1; grid-row: 1; }
  html[data-lock="portrait"] .screen-live .score-strip { grid-column: 1; grid-row: 2; }
  html[data-lock="portrait"] .screen-live .live-main {
    grid-column: 1;
    grid-row: 3;
    overflow: hidden;
    justify-content: center;
  }
  html[data-lock="portrait"] .screen-live .pad {
    grid-column: 1;
    grid-row: 4;
    overflow: hidden;
  }
  html[data-lock="portrait"] .screen-live .headline { font-size: clamp(2.2rem, 7dvh, 4rem); }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
