/* =====================================================================
   darts.cdizzle.de – Grundlayout
   Farben und Formen aus prototyp/darts-prototyp.html. Mobile zuerst.
   ===================================================================== */

:root {
  --bg: #0f1115;
  --card: #1a1d24;
  --card2: #242833;
  --line: #2e3340;
  --txt: #e9ecf1;
  --mut: #8b93a3;
  --acc: #2fbf71;      /* Grün: Hauptaktion, aktiver Spieler */
  --acc-bg: #16261e;
  --acc-txt: #04130b;
  --red: #e5484d;
  --gold: #f5b942;
  --r: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  background: var(--bg);
  color: var(--txt);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100%;
}
body { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
a { color: var(--acc); }
button, input, select { font: inherit; color: inherit; }
/* Alle Tasten: kein Doppeltipp-Zoom, keine Verzögerung am Handy */
button, .btn {
  border: 0;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

/* ---------- Kopfzeile ---------- */
header.top {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 18px; color: var(--txt); text-decoration: none; }
.badge {
  font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase;
  background: var(--card2); color: var(--gold); padding: 3px 8px; border-radius: 99px;
}
.nav { margin-left: auto; display: flex; align-items: center; gap: 16px; font-size: 14px; }
.nav a { color: var(--mut); text-decoration: none; }
.nav a:hover, .link:hover { color: var(--txt); }
.link { background: none; color: var(--mut); padding: 0; }
form.inline { display: inline; }

/* ---------- Inhalt ---------- */
.wrap { flex: 1; width: 100%; margin: 0 auto; padding: 20px; }
.wrap.narrow { max-width: 560px; }
h1 { font-size: 24px; margin-bottom: 12px; }
h2 {
  font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--mut);
  margin: 28px 0 10px;
}
p { margin-bottom: 12px; }
.hint { color: var(--mut); font-size: 14px; }

/* ---------- Meldungen ---------- */
.msg {
  border-radius: var(--r); padding: 12px 14px; margin-bottom: 14px;
  background: var(--card); border-left: 4px solid var(--mut);
}
.msg.ok { border-left-color: var(--acc); background: var(--acc-bg); }
.msg.error { border-left-color: var(--red); background: #2a1517; }
.msg.info { border-left-color: var(--gold); }
.msg .copy { margin-top: 10px; }

/* ---------- Formulare ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--mut); }
.form label.check { flex-direction: row; align-items: center; gap: 10px; color: var(--txt); font-size: 15px; }
.check input { width: 20px; height: 20px; accent-color: var(--acc); }
input[type=text], input[type=email], input[type=password], select, .copy {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 12px 14px;
  outline: none;
  color: var(--txt);
  font-size: 16px; /* verhindert automatisches Hineinzoomen auf iPhones */
}
input:focus, select:focus { border-color: var(--acc); }
input[readonly] { color: var(--mut); }

/* ---------- Tasten ---------- */
.btn {
  display: inline-block;
  text-align: center;
  text-decoration: none;
  padding: 14px 18px;
  border-radius: var(--r);
  background: var(--card2);
  color: var(--txt);
  font-weight: 700;
}
.btn:active { transform: scale(.97); }
.btn.pri { background: var(--acc); color: var(--acc-txt); }
.btn.big { width: 100%; padding: 18px; font-size: 18px; font-weight: 800; margin-top: 12px; }
.btn.small { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .35; cursor: not-allowed; transform: none; }

/* ---------- Tabellen ---------- */
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 14px; }
th, td { padding: 8px 6px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
td:last-child, th:last-child { text-align: right; }
th { color: var(--mut); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.tag { font-size: 12px; color: var(--gold); }

/* ---------- Fußzeile ---------- */
.foot { text-align: center; color: var(--mut); font-size: 12px; padding: 16px; }

/* =====================================================================
   Startseite
   ===================================================================== */
.card { background: var(--card); border-radius: var(--r); padding: 16px; margin: 12px 0; }
.card.running { border-left: 4px solid var(--acc); }
.cardtitle { font-weight: 700; font-size: 18px; }
a.btn.big { display: block; }

/* =====================================================================
   Spiel einrichten (aus dem Prototyp)
   ===================================================================== */
.seg { display: flex; gap: 8px; }
.seg button {
  flex: 1; padding: 14px; border-radius: var(--r); background: var(--card);
  font-size: 20px; font-weight: 700; border: 2px solid transparent;
}
.seg button.on { border-color: var(--acc); background: var(--acc-bg); }
.toggle {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  background: var(--card); padding: 14px 16px; border-radius: var(--r); margin-top: 8px; text-align: left;
}
.sw { width: 48px; height: 28px; border-radius: 99px; background: var(--card2); position: relative; transition: .15s; flex: none; }
.sw::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: .15s; }
.sw.on { background: var(--acc); }
.sw.on::after { left: 23px; }
.plist { display: flex; flex-direction: column; gap: 8px; }
.pl {
  display: flex; align-items: center; gap: 12px; background: var(--card); padding: 12px 14px;
  border-radius: var(--r); border: 2px solid transparent; text-align: left; width: 100%;
}
.pl.on { border-color: var(--acc); }
.pl .num {
  width: 28px; height: 28px; border-radius: 50%; background: var(--card2);
  display: grid; place-items: center; font-weight: 700; font-size: 14px; flex: none;
}
.pl.on .num { background: var(--acc); color: var(--acc-txt); }
.pl .nm { flex: 1; font-weight: 600; }
.pl .tag { font-size: 12px; color: var(--mut); }
form.add { display: flex; gap: 8px; margin-top: 10px; }
form.add input { flex: 1; }
.formmsg { margin-top: 16px; }
.formmsg .btn { margin: 6px 6px 0 0; }

/* =====================================================================
   Spielseite (aus dem Prototyp)
   ===================================================================== */
body.gamebody { min-height: 0; }
main.bare { flex: 1; display: flex; flex-direction: column; min-height: 0; }
#game { flex: 1; display: flex; flex-direction: column; min-height: 0; }
#game .loading { padding: 20px; }

.game { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.board { flex: 0 1 auto; overflow: auto; padding: 10px 12px 6px; max-height: 40dvh; }
.bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; color: var(--mut); font-size: 14px; }
.bar > button { background: var(--card); padding: 6px 12px; border-radius: 8px; font-size: 13px; flex: none; }
.bar > button.warn { background: var(--red); color: #fff; }
.savestate { flex: 1; text-align: center; color: var(--gold); font-size: 13px; }
.savestate.problem { color: var(--red); font-weight: 700; }
.savestate .btn { margin-left: 6px; }

.players { display: flex; flex-direction: column; gap: 6px; }
.pc {
  display: grid; grid-template-columns: 1fr auto; align-items: center;
  background: var(--card); border-radius: 10px; padding: 8px 12px; border-left: 4px solid transparent;
}
.pc.cur { border-left-color: var(--acc); background: var(--acc-bg); }
.pc .nm { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.pc .starter { font-size: 11px; font-weight: 600; color: var(--gold); text-transform: uppercase; letter-spacing: .04em; }
.pc .meta { font-size: 12px; color: var(--mut); }
.pc .last { font-size: 12px; color: var(--mut); font-variant-numeric: tabular-nums; }
.pc .last .bust { color: var(--red); font-weight: 700; }
.pc .rem { font-size: 28px; font-weight: 800; font-variant-numeric: tabular-nums; grid-row: span 3; grid-column: 2; grid-row-start: 1; }

.pad { flex: 1; display: flex; flex-direction: column; gap: 8px; padding: 8px 12px 12px; border-top: 1px solid var(--line); min-height: 0; }
.curhead { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; }
.curhead .who { font-size: 14px; color: var(--mut); }
.curhead .who b { color: var(--txt); font-size: 18px; display: block; }
.curhead .big { font-size: 44px; font-weight: 900; line-height: 1; font-variant-numeric: tabular-nums; }
.co { font-size: 14px; color: var(--gold); min-height: 20px; font-weight: 600; }
.co.none { color: var(--mut); font-weight: 400; }
.visit { display: grid; grid-template-columns: repeat(3, 1fr) auto; gap: 6px; }
.slot {
  background: var(--card); border-radius: 8px; padding: 8px; text-align: center; font-weight: 700;
  font-variant-numeric: tabular-nums; border: 1px dashed var(--line); min-height: 40px;
}
.slot.f { border-style: solid; border-color: transparent; background: var(--card2); }
.slot.next { border-color: var(--acc); }
.vsum { padding: 8px 12px; font-weight: 800; color: var(--mut); align-self: center; min-width: 52px; text-align: right; }
.mods { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.mods button { padding: 12px; border-radius: 10px; background: var(--card); font-weight: 800; font-size: 18px; border: 2px solid transparent; }
.mods .d.on { background: #14532d; border-color: var(--acc); }
.mods .t.on { background: #5b1a1c; border-color: var(--red); }
.grid { flex: 1; display: grid; grid-template-columns: repeat(5, 1fr); grid-auto-rows: minmax(46px, 1fr); gap: 6px; min-height: 0; }
.grid button, .bot button {
  border-radius: 10px; background: var(--card2); font-size: 22px; font-weight: 800;
  font-variant-numeric: tabular-nums; transition: transform .05s;
}
.grid button:active, .bot button:active, .mods button:active { transform: scale(.95); }
.grid.m2 button { background: #173b27; }
.grid.m3 button { background: #46191b; }
.grid button small { font-size: 12px; opacity: .7; margin-right: 1px; }
.bot { display: grid; grid-template-columns: 1fr 1fr 1fr 1.2fr 1.2fr; gap: 6px; }
.bot button { padding: 12px 0; font-size: 17px; }
.bot .miss { background: var(--card); }
.bot .undo, .bot .redo { background: var(--card); color: var(--gold); }
.bot .redo { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bot button:disabled { opacity: .3; }

.notice {
  position: fixed; left: 50%; top: 12px; transform: translateX(-50%); z-index: 10;
  background: var(--card2); border: 1px solid var(--line); border-left: 4px solid var(--gold);
  padding: 10px 14px; border-radius: var(--r); max-width: 92vw; box-shadow: 0 6px 20px rgba(0,0,0,.4);
}

/* Spielende */
.over { position: fixed; inset: 0; background: rgba(0,0,0,.75); display: grid; place-items: center; padding: 16px; z-index: 9; }
.over[hidden], .notice[hidden], .savestate[hidden] { display: none; }
.modal { background: var(--card); border-radius: 16px; padding: 22px; width: 100%; max-width: 640px; max-height: 90dvh; overflow: auto; }
.modal h3 { font-size: 24px; margin-bottom: 4px; }
.modal p { color: var(--mut); margin-bottom: 14px; }
.modal td, .modal th { text-align: right; }
.modal td:first-child, .modal th:first-child { text-align: left; }
.mbtn { display: flex; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.mbtn > * { flex: 1; padding: 14px; border-radius: var(--r); font-weight: 700; background: var(--card2); text-align: center; min-width: 120px; }
.mbtn .pri { background: var(--acc); color: var(--acc-txt); }

/* Großer Bildschirm: zweispaltig, Spielerkarten groß links, Eingabe rechts */
@media (min-width: 900px) {
  /* --padw setzt der verschiebbare Trennstrich (game-page.js), sonst Standardbreite */
  .game { display: grid; grid-template-columns: minmax(0, 1fr) var(--padw, minmax(440px, 540px)); }
  .board { max-height: none; padding: 24px; }
  .bar { font-size: 16px; margin-bottom: 16px; }
  .players { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; align-content: start; }
  .pc { padding: 18px 20px; border-left-width: 6px; border-radius: 14px; }
  .pc .nm { font-size: 20px; }
  .pc .rem { font-size: 64px; }
  .pc .last, .pc .meta { font-size: 14px; }
  .pad { border-top: 0; border-left: 1px solid var(--line); padding: 20px; position: relative; }
}

/* Verschiebbarer Trennstrich: breite, unsichtbare Greiffläche über der Linie links an der Eingabe */
.split { display: none; }
@media (min-width: 900px) {
  .split { display: block; position: absolute; left: -7px; top: 0; bottom: 0; width: 14px; z-index: 2;
    cursor: col-resize; touch-action: none; }
  .split::after { content: ''; position: absolute; left: 6px; top: 0; bottom: 0; width: 2px; background: transparent; transition: background .15s; }
  .split:hover::after, .split.drag::after { background: var(--acc); }
  .split::before { content: ''; position: absolute; left: 3px; top: 50%; width: 8px; height: 44px; margin-top: -22px;
    border-radius: 4px; background: var(--line); }
  .split:hover::before, .split.drag::before { background: var(--acc); }
}

/* =====================================================================
   Phase 1b: Scheibe, Umschalter, Tastatur, Siegerfenster, viele Spieler
   ===================================================================== */
[hidden] { display: none !important; }

/* Umschalter Scheibe / Zahlen */
.imode { display: flex; background: var(--card); border-radius: 10px; padding: 3px; gap: 3px; }
.imode button { flex: 1; padding: 8px; border-radius: 8px; background: none; font-weight: 700; font-size: 14px; color: var(--mut); }
.imode button.on { background: var(--card2); color: var(--txt); }

/* Dartscheibe */
.boardwrap { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; }
.boardwrap svg { width: 100%; height: 100%; max-height: 100%; touch-action: manipulation; cursor: crosshair; display: block;
  -webkit-tap-highlight-color: transparent; user-select: none; }
.boardwrap .seg { stroke: #0b0c0f; stroke-width: .35; }
.boardwrap .seg:hover { filter: brightness(1.35); }
.boardwrap text { fill: #e9ecf1; font-size: 9px; font-weight: 800; text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.boardwrap .hit { fill: var(--gold); stroke: #000; stroke-width: .8; pointer-events: none; }
.boardwrap .hitl { fill: #000; font-size: 4.5px; font-weight: 900; }

/* Zahlenraster als eigener Bereich (Double/Triple + Zahlen) */
.gridwrap { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px; }

/* Getippte Ziffern am PC und Tastaturhinweis (nur großer Bildschirm) */
.buf { color: var(--gold); font-weight: 700; }
.kbd { display: none; font-size: 12px; color: var(--mut); text-align: center; }
.kbd kbd { background: var(--card2); border-radius: 4px; padding: 1px 5px; font-family: inherit; }

/* Siegerfenster schließen */
.modal { position: relative; }
.modal .close { position: absolute; top: 10px; right: 10px; width: 40px; height: 40px; border-radius: 50%;
  background: var(--card2); color: var(--mut); font-size: 24px; line-height: 1; }
.modal .close:hover { color: var(--txt); }
.modal h3 { padding-right: 44px; }

@media (max-width: 899px) {
  /* Mit Scheibe braucht die Eingabe mehr Platz: Spielerbereich kleiner */
  .game.bm .board { max-height: 24dvh; }
  .game.bm .curhead .big { font-size: 34px; }
  .game.bm .pc { padding: 5px 10px; }
  .game.bm .pc .rem { font-size: 22px; }

  /* Ab 5 Spielern: eine Zeile pro Spieler mit Name, Rest und Leg-Stand */
  .game.many .pc { grid-template-columns: 1fr auto; padding: 4px 10px; }
  .game.many .pc .meta, .game.many .pc .last { display: none; }
  .game.many .pc .rem { font-size: 20px; grid-row: auto; }
  .game.many .players { gap: 4px; }
}

@media (min-width: 900px) {
  .kbd { display: block; }
}
.pc .legs { font-size: 12px; font-weight: 700; color: var(--acc); background: var(--acc-bg); padding: 1px 7px; border-radius: 99px; }
.seg.small button { font-size: 17px; padding: 10px 0; }
.btn.shuffle { width: 100%; margin-top: 10px; }
.pl.edit input[type=text] { flex: 1; padding: 8px 10px; }
.pl.archived .nm { color: var(--mut); }
/* Name, Leg-Stand und Anwurf dürfen umbrechen, aber nicht in die große Restzahl laufen */
.pc .nm { flex-wrap: wrap; row-gap: 2px; min-width: 0; }
.pc .legs, .pc .starter { white-space: nowrap; }
.pc .rem { padding-left: 10px; }
.problems { margin: 12px 0 0 18px; color: var(--gold); font-size: 14px; }
#recalc p .btn { margin: 0 8px 8px 0; }
