/* Opzet: donker als een dartkamer, kleuren van het bord. De score is het grootste op het scherm en de knoppen vullen wat over is. */
:root {
  color-scheme: dark;
  --bg: #12170f;
  --panel: #1c2318;
  --panel-2: #262e20;
  --line: #36402d;
  --sisal: #efe6cf;
  --muted: #a9ac96;
  --red: #d8323f;
  --red-deep: #b3202d;
  --green: #24824a;
  --green-bright: #49c47c;
  --amber: #e0a526;
  --display: "Bahnschrift", "DIN Condensed", "Roboto Condensed", sans-serif-condensed, "Arial Narrow", system-ui, sans-serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg); color: var(--sisal); font: 16px/1.4 var(--body);
  padding-left: max(12px, env(safe-area-inset-left, 0px));
  padding-right: max(12px, env(safe-area-inset-right, 0px));
  padding-top: max(8px, env(safe-area-inset-top, 0px));
  padding-bottom: max(10px, env(safe-area-inset-bottom, 0px));
}
h1 { font: 700 38px/1.05 var(--display); margin: 0; }
h2 { font: 700 19px/1.2 var(--display); margin: 0; letter-spacing: .02em; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.no { color: #ff8a8f; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

button {
  font: 700 19px/1.1 var(--display); color: var(--sisal); background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 8px; padding: 0 6px; min-height: 44px;
  cursor: pointer; touch-action: manipulation; user-select: none; -webkit-user-select: none;
}
button:active { filter: brightness(1.35); }
button:disabled { opacity: .4; cursor: default; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--amber); outline-offset: 1px; }
button.primary { background: var(--red); border-color: var(--red); color: #fff; }
button.big { min-height: 56px; font-size: 22px; width: 100%; }
button.ghost { background: transparent; border-color: transparent; color: var(--muted); padding: 0 8px; font: 600 16px var(--body); }
button.ghost[aria-pressed="true"] { color: #fff; background: var(--green); }
input {
  font: 600 18px var(--body); color: var(--sisal); background: var(--panel); min-width: 0; width: 100%;
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; min-height: 46px;
}
input::placeholder { color: var(--muted); opacity: .8; }

/* Startscherm */
#startScreen { max-width: 520px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; padding-block: 6px 10px; }
.hero { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; }
.board { width: min(52vw, 230px); height: auto; display: block; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.segments { display: flex; gap: 6px; }
.segments button { flex: 1 1 0; min-width: 0; min-height: 50px; }
.segments button[aria-pressed="true"] { background: var(--sisal); border-color: var(--sisal); color: var(--bg); }
.names { display: flex; gap: 8px; }
.names label { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--muted); }

/* Dartbord */
.seg-a { fill: #1a1a17; } .seg-b { fill: #e7dcc0; }
.ring-a { fill: var(--red); } .ring-b { fill: #1f8a4c; }
.wire { stroke: #8d8f7f; stroke-width: .7; }
.boardNum { fill: var(--sisal); font: 700 21px var(--display); text-anchor: middle; dominant-baseline: central; }
.outer { fill: #0b0d09; }
.board .lit { fill: var(--amber); filter: drop-shadow(0 0 7px var(--amber)); }

/* Spelscherm */
#gameScreen { max-width: 560px; margin: 0 auto; display: flex; flex-direction: column; gap: 7px; min-height: calc(100dvh - 18px); position: relative; }
.bar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; min-height: 34px; }
.bar > :first-child { justify-self: start; min-height: 34px; }
.bar > #speechToggle, .bar > #speechSpacer { justify-self: end; grid-column: 3; min-height: 34px; }
#legInfo { font-size: 14px; font-variant-numeric: tabular-nums; white-space: nowrap; }

#scores { display: grid; gap: 7px; }
#scores.two { grid-template-columns: 1fr 1fr; }
.card { background: var(--panel); border: 2px solid var(--line); border-radius: 10px; padding: 4px 10px 6px; min-width: 0; text-align: center; }
.card.active { border-color: var(--green-bright); background: #1b2a1d; }
.cardHead { display: flex; justify-content: space-between; gap: 6px; color: var(--muted); font-size: 14px; }
.cardName { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.card.active .cardName { color: var(--sisal); }
.cardLegs { white-space: nowrap; font-variant-numeric: tabular-nums; }
.rem { font: 700 clamp(58px, 12dvh, 92px)/1 var(--display); font-variant-numeric: tabular-nums; }
#scores.one .rem { font-size: clamp(72px, 15dvh, 120px); }
.card:not(.active) .rem { color: var(--muted); }
.cardStats { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }

#slots { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 6px; align-items: stretch; }
.slot { background: var(--panel); border: 1px dashed var(--line); border-radius: 7px; min-height: 36px; display: flex; align-items: center; justify-content: center; font: 700 20px var(--display); color: var(--muted); }
.slot:not(.filled) { font: 500 14px var(--body); }
.slot.filled { border-style: solid; color: var(--sisal); background: var(--panel-2); }
.slot.T { border-color: var(--red); } .slot.D { border-color: var(--green-bright); }
.turnTotal { display: flex; align-items: center; justify-content: flex-end; min-width: 48px; font: 700 24px var(--display); font-variant-numeric: tabular-nums; }
#status { font-size: 14px; min-height: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center; }

#advice { background: var(--panel); border-radius: 8px; padding: 5px 8px; display: flex; flex-direction: column; gap: 3px; justify-content: center; min-height: 64px; }
.route { display: grid; grid-template-columns: 42px 1fr 1fr 1fr; gap: 5px; align-items: center; }
.routeNo { color: var(--muted); font: 600 14px var(--body); text-align: left; }
.routeDart { text-align: center; font: 700 20px/30px var(--display); border-radius: 5px; background: var(--sisal); color: var(--bg); }
.routeDart.next { background: var(--amber); }
.route.alt .routeDart { background: transparent; color: var(--sisal); box-shadow: inset 0 0 0 2px var(--sisal); }
.adviceText { text-align: center; color: var(--muted); font-size: 15px; }
.adviceText b { color: var(--sisal); font-family: var(--display); font-size: 18px; }

#dartPad { display: flex; flex-direction: column; gap: 5px; flex: 1 1 auto; }
.multipliers { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 5px; }
.multipliers button { min-height: 46px; }
.multipliers [data-mult="D"][aria-pressed="true"] { background: var(--green); border-color: var(--green-bright); color: #fff; }
.multipliers [data-mult="T"][aria-pressed="true"] { background: var(--red); border-color: var(--red); color: #fff; }
.multipliers [data-mult="S"][aria-pressed="true"] { background: var(--sisal); border-color: var(--sisal); color: var(--bg); }
button.switch { background: transparent; color: var(--muted); font: 600 14px/1.1 var(--body); }
.numbers { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; flex: 1 1 auto; grid-auto-rows: minmax(44px, 1fr); }
.numbers button { font-size: 24px; font-variant-numeric: tabular-nums; }
#dartPad[data-active="D"] .numbers button { background: #1c3a27; border-color: var(--green); }
#dartPad[data-active="T"] .numbers button { background: #451a1e; border-color: var(--red-deep); }
.specials { display: grid; grid-template-columns: 1fr 1fr 1fr 1.2fr; gap: 5px; }
.specials button { min-height: 48px; }
button.undo { background: transparent; border-color: var(--amber); color: var(--amber); }

#turnPad { display: flex; flex-direction: column; gap: 8px; }
.turnRow { display: grid; grid-template-columns: 1fr 84px; gap: 6px; }
.turnRow input { font: 700 26px var(--display); text-align: center; min-height: 54px; }
.finishDarts { display: grid; grid-template-columns: auto 1fr 1fr 1fr; gap: 6px; align-items: center; }
.quick { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; }
.quick button { font-size: 20px; }
.turnActions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }

/* Bust, 180 en finish verschijnen kort over de invoer heen zonder tikken tegen te houden. */
#flash { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; opacity: 0; font: 700 clamp(90px, 30vw, 170px)/1 var(--display); text-shadow: 0 4px 30px #000; z-index: 5; }
#flash.show { animation: flash 1.1s ease-out; }
#flash.bust { color: var(--red); } #flash.oneEighty { color: var(--amber); }
@keyframes flash { 0% { opacity: 0; transform: scale(.7); } 15% { opacity: 1; transform: scale(1.05); } 70% { opacity: 1; } 100% { opacity: 0; transform: scale(1); } }

#legOver { position: fixed; inset: 0; background: #0a0d08e6; display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 10; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 20px 16px; width: min(100%, 420px); display: flex; flex-direction: column; gap: 12px; text-align: center; animation: rise .25s ease-out; }
.panel h2 { font-size: 30px; }
.finishValue { font: 700 72px/1 var(--display); color: var(--amber); font-variant-numeric: tabular-nums; }
.statGrid { display: grid; grid-template-columns: auto 1fr 1fr; gap: 3px 10px; text-align: right; font-variant-numeric: tabular-nums; font-size: 15px; }
.statGrid.solo { grid-template-columns: auto 1fr; }
.statGrid > :nth-child(3n+1) { text-align: left; color: var(--muted); }
.statGrid.solo > :nth-child(3n+1) { color: inherit; text-align: right; }
.statGrid.solo > :nth-child(2n+1) { text-align: left; color: var(--muted); }
.statGrid b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@keyframes rise { from { transform: translateY(14px); opacity: 0; } }

/* Kleine telefoons: het tweede en derde advies wijken voor de knoppen, en alles wordt iets lager. */
@media (max-height: 640px) {
  .routeDart { font-size: 18px; line-height: 23px; }
  #advice { padding-block: 3px; gap: 2px; min-height: 54px; }
  .board { width: 120px; }
  #startScreen { gap: 12px; }
  .rem { font-size: 56px; }
  #scores.one .rem { font-size: 62px; }
  .slot { min-height: 32px; }
  .numbers { grid-auto-rows: minmax(38px, 1fr); }
  .numbers button { min-height: 38px; }
  .multipliers button { min-height: 40px; }
  .specials button { min-height: 42px; }
}
@media (prefers-reduced-motion: reduce) {
  #flash.show { animation-duration: .01s; animation-delay: 0s; }
  .panel { animation: none; }
}
