:root {
  --bg: #14181f;
  --card: #1e242e;
  --line: #2f3744;
  --text: #eef1f5;
  --muted: #9aa5b4;
  --accent: #2fb36b;
  --danger: #e2504c;
  --warn: #f0b43c;
  --board-dark: #1b1b1b;
  --board-light: #efe2c2;
  --board-red: #d0302b;
  --board-green: #1f8a4c;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body { min-height: 100vh; display: flex; flex-direction: column; }

.banner {
  background: var(--warn);
  color: #222;
  text-align: center;
  font-weight: 600;
  padding: 6px 16px;
  font-size: 15px;
}

.tabs {
  position: relative;
  display: flex;
  gap: 4px;
  padding: 8px 16px 0;
  border-bottom: 1px solid var(--line);
}
.tabs button {
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  color: var(--muted);
  padding: 10px 14px;
  flex-shrink: 0;
  white-space: nowrap;
}
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
.tabs .abort { margin-left: auto; border-bottom: none; text-decoration: underline; }

/* Was nicht in die Zeile passt, kommt ins Menü rechts (siehe fitTabs). */
.more { margin-left: auto; flex-shrink: 0; }
.abort:not([hidden]) ~ .more { margin-left: 0; }
.more-menu {
  position: absolute; right: 8px; top: 100%; z-index: 10; min-width: 200px;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 4px 0;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .4);
}
.tabs .more-menu button { display: block; width: 100%; text-align: left; border-bottom: none; border-left: 3px solid transparent; }
.tabs .more-menu button.active { border-left-color: var(--accent); }
.tabs.no-brand .brand { display: none; }

/* Im Spiel: Kopfzeile schmal, damit die Scheibe Platz hat. */
body.playing .banner { padding: 3px 12px; font-size: 13px; }
body.playing .tabs { padding-top: 2px; }
body.playing .tabs button { padding: 6px 12px; min-height: 40px; }

.view { padding: 16px; flex: 1; width: 100%; max-width: 1400px; margin: 0 auto; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 16px;
}
h2 { margin: 0 0 8px; font-size: 21px; }
h2 small { color: var(--muted); font-weight: 400; font-size: 14px; }
h3 { margin: 20px 0 6px; font-size: 17px; }
details.hint summary { cursor: pointer; color: var(--text); }
details.hint pre { overflow-x: auto; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px; font-size: 13px; color: var(--text); }
.hint { color: var(--muted); font-size: 15px; margin: 4px 0 12px; }

button, .button, select, input {
  font: inherit;
  color: var(--text);
  background: #2a3240;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 16px;
  min-height: 48px;
  cursor: pointer;
}
.button { display: inline-flex; align-items: center; }
input { cursor: text; flex: 1; min-width: 0; }
button:disabled { opacity: .4; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.big { width: 100%; min-height: 60px; font-size: 20px; margin-top: 12px; }
button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
button.link { background: none; border: none; color: var(--muted); text-decoration: underline; min-height: 40px; }

.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; margin: 8px 0; }
.row label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 14px; }
.row.buttons > * { flex: 1; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button { position: relative; }
.chips button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chips button .order {
  display: inline-block; min-width: 22px; margin-right: 6px;
  background: #fff; color: var(--accent); border-radius: 11px; font-weight: 700; font-size: 14px;
}
.chips.static span {
  background: #2a3240; border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: 15px;
}
.badge { font-size: 13px; color: var(--muted); margin-left: 8px; font-weight: 600; }
.badge.best { color: var(--warn); }

.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.segmented button { border: none; border-radius: 0; background: none; color: var(--muted); }
.segmented button.active { background: #2a3240; color: var(--text); }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid2 .card { margin-bottom: 0; }
.grid2 + .card { margin-top: 16px; }

table { width: 100%; border-collapse: collapse; font-size: 16px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 500; font-size: 14px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td .del { min-height: 36px; padding: 4px 10px; font-size: 14px; }

.list { list-style: none; padding: 0; margin: 12px 0 0; }
.list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }

/* Spiel: die Seite füllt genau den Bildschirm, die Scheibe nimmt den Platz, der übrig bleibt. */
body.playing { height: 100vh; height: 100dvh; overflow: hidden; }
.view#view-play { max-width: none; padding: 8px 12px; display: flex; min-height: 0; }
.play { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) clamp(260px, 30vw, 380px); gap: 12px; }
.board-wrap { display: flex; align-items: center; justify-content: center; min-height: 0; min-width: 0; }
#board { width: 100%; height: 100%; touch-action: manipulation; user-select: none; }
#board .seg { cursor: crosshair; }
#board .num { fill: var(--text); font-size: 21px; font-weight: 700; text-anchor: middle; dominant-baseline: central; pointer-events: none; }
#board .wire { fill: none; stroke: #9aa0a6; stroke-width: .8; pointer-events: none; }
#board .mark circle { fill: #fff; stroke: #111; stroke-width: 2; }
#board .mark text { fill: #111; font-size: 13px; font-weight: 800; text-anchor: middle; dominant-baseline: central; }
#board .seg, #board .num { transition: opacity .2s; }
#board .dim { opacity: .3; }
#board .flash { pointer-events: none; animation: flash .35s ease-out forwards; }
@keyframes flash { from { opacity: .7; } to { opacity: 0; } }

.panel { display: flex; flex-direction: column; gap: 12px; min-height: 0; overflow: auto; }

.scores { display: grid; gap: 6px; }
.score {
  display: flex; justify-content: space-between; align-items: baseline;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px;
}
.score.current { border-color: var(--accent); box-shadow: inset 4px 0 0 var(--accent); }
.score .name { font-weight: 600; }
.score .avg { color: var(--muted); font-size: 13px; margin-left: 8px; font-weight: 400; }
.score .pts { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Cricket-Tafel */
.cricket { font-size: 18px; text-align: center; background: var(--card); border: 1px solid var(--line); border-radius: 10px; }
.cricket th, .cricket td { text-align: center; padding: 3px 4px; }
.cricket th { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 90px; }
.cricket th.current { color: var(--text); font-weight: 700; }
.cricket td.current { background: rgba(47, 179, 107, .12); }
.cricket .total td { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.cricket .field { color: var(--muted); font-weight: 700; }
.cricket tr.done td { opacity: .35; }
.cricket .closed {
  display: inline-block; width: 26px; height: 26px; line-height: 22px;
  border: 2px solid var(--accent); border-radius: 50%; color: var(--accent);
}
.cricket tr:last-child td { border-bottom: none; }

.turn { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.turn-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 22px; font-weight: 700; }
.rest { font-size: 40px; font-variant-numeric: tabular-nums; }
.darts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0 6px; }
.dart {
  min-height: 64px; font-size: 24px; font-weight: 700; display: flex; flex-direction: column;
  align-items: center; justify-content: center; line-height: 1.1;
}
.dart small { font-size: 12px; color: var(--muted); font-weight: 400; }
.dart.empty { color: var(--muted); border-style: dashed; background: none; }
.dart.void { text-decoration: line-through; opacity: .5; }
.turn-info { min-height: 26px; font-size: 16px; color: var(--muted); }
.turn-info.bust { color: var(--danger); font-weight: 700; }
.turn-info.win { color: var(--accent); font-weight: 700; }

.mult-pick { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; margin-bottom: 6px; }

.overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .65);
  display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 10;
}
.overlay .card { width: 100%; max-width: 460px; text-align: center; }
.overlay h2 { font-size: 30px; }

.rules ul, .rules ol { padding-left: 22px; margin: 4px 0; }
.rules li { margin: 4px 0; }

@media (max-width: 900px) {
  .grid2 { grid-template-columns: 1fr; }
}

/* Hochformat: Scheibe oben, darunter kompakt Punktestände und Erfassung. */
@media (orientation: portrait) {
  .play { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; gap: 10px; }
  .panel { gap: 8px; overflow: visible; }
  .scores { grid-auto-flow: column; grid-auto-columns: 1fr; }
  .score { padding: 4px 10px; align-items: center; }
  .score .name { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .score .avg { display: block; margin-left: 0; font-size: 12px; }
  .score .pts { font-size: 22px; }
  .scores.has-table { display: block; }
  .cricket { font-size: 15px; }
  .cricket th, .cricket td { padding: 1px 4px; }
  .cricket .total td { font-size: 17px; }
  .cricket .closed { width: 20px; height: 20px; line-height: 16px; }
  /* Erfassung in zwei Zeilen: Pfeile + Rückgängig, Daneben + Bestätigen. Der Rest steht in der Spielerkarte. */
  .turn {
    padding: 8px 10px; display: grid; gap: 6px 8px; grid-template-columns: repeat(4, 1fr);
    grid-template-areas: "darts darts darts undo" "info info info info" "miss confirm confirm confirm";
  }
  .turn-head { display: none; }
  .turn .row.buttons { display: contents; }
  #darts { grid-area: darts; margin: 0; }
  #btn-undo { grid-area: undo; }
  #btn-miss { grid-area: miss; }
  #btn-confirm { grid-area: confirm; margin: 0; min-height: 52px; font-size: 18px; }
  .turn-info { grid-area: info; min-height: 20px; font-size: 14px; }
  .dart { min-height: 52px; font-size: 20px; }
}

.brand { align-self: center; font-weight: 700; margin-right: 12px; white-space: nowrap; }
body.playing .brand { display: none; }
.hint.warn { color: var(--warn); }
.row label.grow { flex: 1; min-width: 240px; }
.about { text-align: center; color: var(--muted); font-size: 13px; }
.about a { color: var(--muted); }
.rank-filter { align-items: center; }
.rank-filter select { min-width: 180px; }
#table-honors tr.year td, #table-honors tr.quarter td:first-child { font-weight: 700; }
#table-honors tr.year td { color: var(--warn); }
#win-back { margin-top: 8px; font-size: 15px; }
