/* Stadt, Land, Fluss – Karopapier, Graphit, Fineliner und Rotstift */
:root {
  --paper: #FAFBFC;
  --grid: #E2E8EF;
  --ink: #1E2329;
  --pencil: #6A7280;
  --line: #C9D2DC;
  --blue: #1D4ED8;
  --blue-soft: #E7EEFC;
  --red: #D7263D;
  --red-soft: #FCE9EC;
  --cell: 22px;
  --hand: var(--sans);
  --sans: 'Instrument Sans', system-ui, -apple-system, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #15191F; --grid: #212832; --ink: #E6E9ED; --pencil: #8C95A1; --line: #39424E;
    --blue: #82A6FF; --blue-soft: #1D2740; --red: #FF5C70; --red-soft: #3A1E25;
  }
}
:root[data-theme="dark"] {
  --paper: #15191F; --grid: #212832; --ink: #E6E9ED; --pencil: #8C95A1; --line: #39424E;
  --blue: #82A6FF; --blue-soft: #1D2740; --red: #FF5C70; --red-soft: #3A1E25;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  color: var(--ink);
  font: 17px/1.5 var(--sans);
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: var(--cell) var(--cell);
  background-position: -1px -1px;
}
.sheet {
  max-width: 560px;
  margin: 0 auto;
  padding: 28px 16px calc(120px + env(safe-area-inset-bottom));
}
h1, h2, h3, p { margin: 0; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- Start: Kopfzeile wie auf dem Block ---------- */
.blockhead {
  display: grid;
  grid-template-columns: repeat(3, 1fr) 76px;
  border: 2px solid var(--ink);
  background: var(--paper);
}
.blockhead span {
  padding: 14px 10px 10px;
  font: 700 clamp(18px, 5.5vw, 26px)/1 var(--hand);
  border-right: 1.5px solid var(--ink);
}
.blockhead span:last-child { border-right: 0; color: var(--pencil); padding-inline: 14px; }
.blockrow {
  display: grid; grid-template-columns: repeat(3, 1fr) 76px;
  border: 2px solid var(--ink); border-top: 0; margin-bottom: 36px;
  background: var(--paper);
}
.blockrow span { height: 34px; border-right: 1.5px solid var(--ink); }
.blockrow span:last-child { border-right: 0; }

.field { display: grid; gap: 6px; margin-bottom: 18px; }
.field label, .label { font-size: 15px; color: var(--pencil); font-weight: 500; }
.text {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 4px;
  background: var(--paper);
  font-size: 18px;
}
.text:focus { border-color: var(--blue); outline: none; box-shadow: 0 0 0 3px var(--blue-soft); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 0 22px;
  border: 2px solid var(--ink); border-radius: 4px;
  background: var(--paper); font-weight: 600; font-size: 17px;
  cursor: pointer; touch-action: manipulation;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.stop { background: var(--red); border-color: var(--red); color: #fff; font-size: 20px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.wide { width: 100%; }
.link {
  background: none; border: 0; padding: 6px 0; color: var(--pencil);
  text-decoration: underline; text-underline-offset: 3px; cursor: pointer; font-size: 15px;
}
.or { display: flex; align-items: center; gap: 12px; color: var(--pencil); font-size: 15px; margin: 30px 0 18px; }
.or::before, .or::after { content: ''; flex: 1; border-top: 1.5px dashed var(--line); }

/* ---------- Code-Kästchen ---------- */
.code { display: flex; gap: 8px; }
.code .digit {
  width: calc(var(--cell) * 3); height: calc(var(--cell) * 3.4);
  display: grid; place-items: center;
  border: 2px solid var(--ink); border-radius: 4px; background: var(--paper);
  font: 700 40px/1 var(--hand);
}
.code input.digit { text-align: center; padding: 0; font-size: 36px; }
.code input.digit:focus { border-color: var(--blue); outline: none; box-shadow: 0 0 0 3px var(--blue-soft); }
.code.big .digit { width: 64px; height: 76px; font-size: 44px; }
.join-row { display: flex; gap: 10px; align-items: stretch; flex-wrap: wrap; }
.join-row .btn { flex: 1; min-width: 120px; }

/* ---------- Lobby ---------- */
.topline { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 18px; }
.section { margin-top: 34px; }
.section h2 { font-size: 17px; font-weight: 600; margin-bottom: 10px; }
.hint { color: var(--pencil); font-size: 15px; margin-top: 10px; }
.players { list-style: none; margin: 0; padding: 0; border-top: 1.5px solid var(--line); }
.players li {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 2px; border-bottom: 1.5px solid var(--line); background: var(--paper);
}
.players .name { flex: 1; font-weight: 500; }
.players .off { color: var(--pencil); font-weight: 400; }
.tag { font-size: 13px; color: var(--blue); border: 1.5px solid var(--blue); border-radius: 99px; padding: 1px 9px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #2F9E5B; flex: none; }
.dot.off { background: var(--line); }
.score { font: 700 20px/1 var(--hand); color: var(--ink); min-width: 40px; text-align: right; }

.cats { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.cats li {
  display: inline-flex; align-items: center; gap: 2px;
  border: 1.5px solid var(--ink); border-radius: 4px; background: var(--paper);
  padding: 6px 4px 6px 12px; font-weight: 500;
}
.cats li.ro { padding-right: 12px; }
.cats button {
  width: 30px; height: 30px; border: 0; background: none; border-radius: 4px;
  color: var(--pencil); cursor: pointer; font-size: 20px; line-height: 1;
}
.cats button:hover { color: var(--red); background: var(--red-soft); }
.addcat { display: flex; gap: 8px; margin-top: 12px; }
.addcat .text { flex: 1; }
.addcat .btn { min-height: 0; padding: 0 16px; }

.dock {
  position: fixed; left: 0; right: 0; bottom: 0;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--paper) 70%, transparent);
}
.dock > div { max-width: 560px; margin: 0 auto; display: grid; gap: 6px; }
.dock .hint { text-align: center; margin: 0; }

/* ---------- Spiel ---------- */
.letterbox { display: flex; align-items: flex-end; gap: 18px; margin: 4px 0 26px; }
.letter {
  font: 700 104px/1 var(--hand); color: var(--ink);
  width: calc(var(--cell) * 6); height: calc(var(--cell) * 6);
  display: grid; place-items: center;
  border: 2px solid var(--ink); background: var(--paper); border-radius: 4px;
}
.letter-meta { padding-bottom: 6px; }
.letter-meta .round { color: var(--pencil); font-size: 15px; }
.letter-meta p { font-weight: 500; }
.rows { border-top: 2px solid var(--ink); }
.row {
  display: grid; grid-template-columns: minmax(84px, 32%) 1fr;
  border-bottom: 1.5px solid var(--line); background: var(--paper);
}
.row label { padding: 14px 10px 14px 2px; color: var(--pencil); font-weight: 500; border-right: 1.5px solid var(--line); overflow-wrap: anywhere; }
.row input {
  border: 0; background: transparent; padding: 10px 12px;
  font: 600 20px/1.3 var(--hand); color: var(--ink); min-width: 0;
}
.row input:focus { outline: none; background: var(--blue-soft); }
.row input:disabled { color: var(--pencil); }

.countdown {
  position: fixed; inset: 0; display: grid; place-items: center; z-index: 5;
  background: color-mix(in srgb, var(--paper) 80%, transparent);
  pointer-events: none; text-align: center;
}
.countdown b { display: block; font: 700 72px/1.1 var(--hand); color: var(--ink); }
.countdown span { display: block; max-width: 300px; margin: 8px auto 0; }
.countdown span { font-size: 20px; font-weight: 600; }

/* ---------- 3-2-1 vor der Runde: deckend, damit nichts durchscheint ---------- */
.startcd {
  position: fixed; inset: 0; z-index: 30;
  display: grid; place-content: center; text-align: center; gap: 4px;
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: var(--cell) var(--cell);
  background-position: -1px -1px;
}
.startcd .round { color: var(--pencil); font-size: 17px; }
.startcd b { font: 700 160px/1 var(--sans); color: var(--ink); min-width: 3ch; }
.startcd p { font-weight: 600; font-size: 20px; }

/* ---------- Prüfen ---------- */
.checking { min-height: 60dvh; display: grid; place-content: center; text-align: center; gap: 6px; }
.checking .big { font: 700 32px/1.2 var(--hand); }
.checking svg { width: 220px; height: 24px; margin: 6px auto 0; }
.checking path { stroke: var(--red); stroke-width: 4; fill: none; stroke-linecap: round; stroke-dasharray: 260; stroke-dashoffset: 260; animation: draw 1.6s ease-in-out infinite; }
@keyframes draw { 60% { stroke-dashoffset: 0; } 100% { stroke-dashoffset: -260; } }

/* ---------- Ergebnis ---------- */
.board { list-style: none; margin: 0 0 8px; padding: 0; border-top: 2px solid var(--ink); }
.board li { display: flex; align-items: baseline; gap: 10px; padding: 10px 2px; border-bottom: 1.5px solid var(--line); background: var(--paper); }
.board .name { flex: 1; font-weight: 600; }
.board .plus { color: var(--pencil); font-size: 15px; }
.board li.lead .name::after { content: ' ★'; color: var(--ink); }

.cat { margin-top: 26px; }
.cat h3 { font-size: 15px; font-weight: 600; color: var(--pencil); padding-bottom: 4px; border-bottom: 2px solid var(--ink); }
.ans { display: grid; grid-template-columns: minmax(70px, 28%) 1fr auto; gap: 4px 10px; align-items: start; padding: 10px 2px; border-bottom: 1.5px solid var(--line); background: var(--paper); }
.ans .who { color: var(--pencil); font-size: 15px; padding-top: 3px; overflow-wrap: anywhere; }
.ans .what { font: 600 20px/1.3 var(--hand); color: var(--ink); overflow-wrap: anywhere; }
.ans .what.none { color: var(--line); }
.ans .pts { font: 700 20px/1.3 var(--hand); color: var(--ink); text-align: right; min-width: 34px; }
.ans .note { grid-column: 2 / 4; font-size: 14px; color: var(--pencil); display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; }
.ans .fix { font: 500 15px/1.3 var(--hand); color: var(--pencil); }

.ans.wrong .what { color: var(--pencil); text-decoration: line-through; text-decoration-color: var(--red); text-decoration-thickness: 3px; }
.ans.wrong .pts { color: var(--red); }
.ans.wrong .reason { font: 600 15px/1.3 var(--hand); color: var(--red); }
.ans.unsure .what { text-decoration: underline dashed var(--pencil); text-underline-offset: 6px; text-decoration-thickness: 1.5px; }
.chip {
  border: 1.5px solid currentColor; background: var(--paper); border-radius: 99px;
  padding: 3px 12px; font-size: 14px; font-weight: 600; cursor: pointer; min-height: 32px;
}
.chip.accept { color: var(--blue); }
.chip.reject { color: var(--red); }
.chip.quiet { color: var(--pencil); border-color: transparent; background: none; padding-inline: 0; font-weight: 500; text-decoration: underline; text-underline-offset: 3px; }
.manual { font-size: 13px; color: var(--pencil); font-style: italic; }
.checkinfo { margin-top: 26px; color: var(--pencil); font-size: 13px; }

/* ---------- Sonstiges ---------- */
.offline { position: sticky; top: 0; z-index: 10; background: var(--red); color: #fff; text-align: center; padding: 8px 16px; font-weight: 600; font-size: 15px; }
.toast {
  position: fixed; left: 50%; bottom: calc(110px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 4px; font-size: 15px;
  max-width: calc(100% - 32px); opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 20;
}
.toast.show { opacity: 1; }
.err { color: var(--red); font-size: 15px; margin-top: 10px; min-height: 1.5em; }

@media (max-width: 380px) {
  .code .digit, .code.big .digit { width: 56px; height: 66px; font-size: 38px; }
  .letter { font-size: 88px; width: calc(var(--cell) * 5); height: calc(var(--cell) * 5); }
}
@media (prefers-reduced-motion: reduce) {
  .checking path { animation: none; stroke-dashoffset: 0; }
  .toast { transition: none; }
}
