/* assets/css/app.css – qCircle
   Design wie qBingo: Nunito, dieselben Grundfarben, Kopfzeile in --ink.
   Keine Inline-Styles (CSP style-src 'self'): alles, was sich ändert, hängt
   an Klassen oder data-Attributen. */

@font-face {
  font-family: 'Nunito';
  src: local('Nunito'), url('/assets/fonts/nunito.woff2') format('woff2');
  font-weight: 200 1000;
  font-display: swap;
}

:root {
  --ink: #14213d;
  --bg: #f4f6fb;
  --card: #fff;
  --line: #dde2ec;
  --muted: #667085;
  --accent: #f59e0b;
  --ok: #059669;
  --err: #dc2626;
  --radius: 14px;

  /* Ring */
  --node: #fff;
  --node-line: #94a3b8;
  --node-root: #fef3c7;
  --node-root-line: #d97706;
  --solved: #2563eb;
  --net: #2563eb;
  --knobel: #7c3aed;
  --ref: #7c3aed;      /* Kreise, auf die die gewählte Aufgabe verweist – nicht orange wie Startfelder */
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.55 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

a { color: inherit; }

/* ---------- Kopfzeile ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 12px 20px; background: var(--ink); color: #fff;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-name { font-weight: 900; font-size: 20px; letter-spacing: .3px; }
.topbar-right { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px 14px; align-items: center; font-size: 14px; }
.tb-role { background: rgba(255,255,255,.15); padding: 2px 10px; border-radius: 999px; font-size: 12px; }
.tb-link { color: #fff; opacity: .8; }
.tb-link:hover { opacity: 1; }

/* ---------- Grundgerüst ---------- */
.wrap { max-width: 1040px; margin: 0 auto; padding: 32px 16px 64px; }
h1 { font-size: 34px; line-height: 1.15; margin: 0 0 12px; }
h2 { font-size: 20px; margin: 0 0 8px; }
.lead { font-size: 19px; color: #3a4660; max-width: 34em; }
.hint { color: var(--muted); font-size: 15px; margin-top: 0; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px; margin-top: 28px;
}
.flash { padding: 12px 16px; border-radius: 10px; margin-top: 20px; border: 1px solid var(--line); }
.flash.error { border-color: var(--err); background: #fef2f2; }

/* ---------- Knöpfe ----------
   Höhe über Polsterung, NICHT über inline-flex: sonst werden die Textstücke
   eines Knopfes zu Flex-Elementen und die Zwischenräume verschwinden. */
.btn {
  display: inline-block; padding: 11px 18px; min-height: 44px; border-radius: 10px;
  text-decoration: none; font: inherit; font-weight: 700; border: 2px solid var(--ink);
  background: transparent; color: var(--ink); cursor: pointer;
  margin: 0 8px 8px 0;
}
.btn.primary { background: var(--ink); color: #fff; }
.btn.primary:hover { filter: brightness(1.25); }
.btn.disabled { border-color: var(--line); color: var(--muted); cursor: not-allowed; }

/* ---------- Startseite ---------- */
.hero {
  display: grid; grid-template-columns: 1.2fr 1fr; gap: 40px; align-items: center;
}
.hero-ring { margin: 0; text-align: center; }
.hero-ring .ring { width: 100%; max-width: 400px; }
.hero-ring figcaption { color: var(--muted); font-size: 15px; margin-top: 6px; }

@media (max-width: 760px) {
  .hero { grid-template-columns: 1fr; gap: 16px; }
  h1 { font-size: 28px; }
}

.stages {
  list-style: none; padding: 0; margin: 12px 0 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px;
}
.stages li {
  border-radius: 12px; padding: 14px 16px; color: #fff; background: var(--solved);
  display: flex; flex-direction: column; position: relative;
}
.stages li.knobel { background: var(--knobel); }
.stages strong { font-size: 20px; line-height: 1.2; }
.stages span { font-size: 13px; opacity: .92; margin-top: 2px; }
.stages .soon {
  position: absolute; top: 10px; right: 10px; margin: 0;
  background: rgba(255,255,255,.25); padding: 0 8px; border-radius: 999px; font-size: 11px;
}

/* ---------- Ring ---------- */
.ring { display: block; margin: 0 auto; height: auto; overflow: visible; }
.ring-line { fill: none; stroke: var(--line); stroke-width: 2; }
.ring-node circle { fill: var(--node); stroke: var(--node-line); stroke-width: 2; }
.ring-node.is-root circle { fill: var(--node-root); stroke: var(--node-root-line); stroke-width: 3; }
.ring-node.is-solved circle { fill: var(--solved); stroke: var(--solved); }
.ring-node.is-root.is-solved circle { stroke: var(--node-root-line); stroke-width: 4; }
.ring-node text {
  text-anchor: middle; dominant-baseline: central;
  font-family: 'Nunito', system-ui, sans-serif; fill: var(--ink);
}
.ring-letter { font-size: 21px; font-weight: 900; }
.ring-letter.small { font-size: 11px; font-weight: 800; }
.ring-value { font-size: 17px; font-weight: 900; }
.ring-node.is-solved text { fill: #fff; }
.ring-net line { stroke: var(--net); stroke-width: 1.6; opacity: .45; }
.ring-arrow { fill: var(--net); opacity: .6; }

/* ---------- Vorschau ---------- */
.preview-form, .rank-filter {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin: 20px 0;
}
.preview-form label, .rank-filter label { display: flex; flex-direction: column; font-size: 13px; color: var(--muted); gap: 4px; }
.preview-form select, .preview-form input, .rank-filter select {
  font: inherit; font-size: 16px; min-height: 44px; padding: 6px 10px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink);
}
.preview-form input[type=number] { width: 9em; }
.preview-form .btn, .rank-filter .btn { margin: 0; }

.preview { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 28px; align-items: start; }
.preview-ring { margin: 0; text-align: center; }
.preview-ring figcaption { color: var(--muted); font-size: 14px; margin-top: 6px; }
@media (max-width: 860px) {
  .preview { grid-template-columns: 1fr; }
}

.tasks { width: 100%; border-collapse: collapse; background: var(--card); border-radius: var(--radius); overflow: hidden; }
.tasks th, .tasks td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.tasks thead th { font-size: 13px; color: var(--muted); font-weight: 700; }
.tasks tbody th { font-weight: 900; width: 2em; }
.tasks tr.root { background: var(--node-root); }
.tasks .num { text-align: right; font-weight: 800; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tasks .rel { color: var(--muted); font-size: 13px; }
@media (max-width: 520px) {
  .tasks .rel { display: none; }
}
.path span { display: inline-block; margin-right: 14px; }

/* ---------- Prüfseite ---------- */
.ok { color: #067647; }
.bad { color: #b42318; font-weight: 700; }

/* ---------- Einstellungen ---------- */
.setup fieldset { border: 0; padding: 0; margin: 0 0 22px; }
.setup legend { font-weight: 800; font-size: 18px; margin-bottom: 8px; }
.choices { display: flex; flex-wrap: wrap; gap: 10px; }
.stages-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
/* Markierung allein über input:checked + span – nie zusätzlich per Klasse */
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice span {
  display: flex; flex-direction: column; justify-content: center; min-height: 52px;
  padding: 10px 16px; border: 2px solid var(--line); border-radius: 12px;
  background: var(--card); cursor: pointer;
}
.choice.small span { min-width: 64px; align-items: center; }
.choice span small { color: var(--muted); font-size: 13px; }
.choice input:checked + span { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); background: #eef2ff; }
.choice input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
.choice.is-off span { opacity: .45; cursor: not-allowed; }
.check { display: flex; align-items: center; gap: 8px; margin-top: 12px; min-height: 44px; cursor: pointer; }
.check input { width: 20px; height: 20px; }
.btn.big { font-size: 20px; padding: 14px 30px; }
.btn.small { padding: 8px 14px; min-height: 40px; font-size: 15px; margin: 0; }

/* ---------- Spielfeld ---------- */
/* Ring nie höher als das Fenster: Uhr und Leiste sollen ohne Scrollen sichtbar sein */
.game { max-width: max(320px, min(620px, calc(100vh - 230px))); margin: 0 auto; }
.game-meta { color: var(--muted); font-size: 14px; margin: 0 0 8px; display: flex; flex-wrap: wrap; gap: 4px 6px; }
.game-meta .who { margin-left: auto; }

.ring-wrap { position: relative; }
.ring-wrap .ring { width: 100%; }
.ring.is-live .ring-node { cursor: pointer; }
.ring.is-live .ring-node:focus { outline: none; }
.ring.is-live .ring-node:focus-visible circle { stroke: var(--accent); stroke-width: 4; }
.ring.is-live .ring-node:hover circle { stroke: var(--ink); }
.ring-node.is-current circle { stroke: var(--ink); stroke-width: 4; }
.ring-node.is-ref circle { stroke: var(--ref); stroke-width: 4; }
.ring-node.is-revealed circle { fill: #e2e8f0; stroke: var(--node-line); stroke-dasharray: 4 3; }
.ring-node.is-revealed text { fill: var(--ink); }
.ring-node.is-solved.is-current circle { stroke: var(--ink); }
.ring-wrap.is-waiting .ring { opacity: .45; }

/* Aufgabe in der Ringmitte; unter 520 px unter dem Ring (sonst zu eng) */
.ring-center {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 56%; text-align: center;
}
.ring-center p { margin: 0 0 8px; }
/* Netzlinien laufen durch die Mitte – der Text bekommt einen ruhigen Grund */
.ring-center > div { background: rgba(244, 246, 251, .93); border-radius: 14px; padding: 8px 10px; }
.task-head { font-size: 15px; color: var(--muted); }
.task-head strong { color: var(--ink); font-size: 22px; }
.task-text { font-size: 19px; font-weight: 700; line-height: 1.35; }
.pick-msg { color: var(--muted); font-size: 17px; }
.done-title { font-size: 24px; font-weight: 900; }
.done-time { font-size: 40px; font-weight: 900; font-variant-numeric: tabular-nums; line-height: 1.1; }

.chip {
  font: inherit; font-weight: 900; color: var(--ink); background: #fff;
  border: 2px solid var(--ref); border-radius: 8px; padding: 0 6px; margin: 0 1px;
  min-width: 1.6em; line-height: 1.3; cursor: pointer;
}
.chip.self { border-color: var(--ink); }
.chip.solved { background: var(--solved); border-color: var(--solved); color: #fff; }

.answer { display: flex; gap: 6px; justify-content: center; margin: 4px 0 8px; }
.answer input {
  font: inherit; font-size: 20px; font-weight: 800; text-align: center;
  width: 7em; min-width: 0; min-height: 44px; padding: 4px 8px;
  border: 2px solid var(--ink); border-radius: 10px; background: #fff; color: var(--ink);
}
.answer .btn { margin: 0; }
.pm {
  font: inherit; font-size: 20px; font-weight: 900; min-width: 44px; min-height: 44px;
  border: 2px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); cursor: pointer;
}
.feedback { min-height: 1.5em; font-size: 15px; }
.feedback.ok { color: var(--ok); font-weight: 800; }
.feedback.bad { color: var(--err); font-weight: 800; }
.feedback.warn { color: #b45309; }
.shake { animation: shake .35s; }
@keyframes shake {
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}
@media (prefers-reduced-motion: reduce) { .shake { animation: none; } }

.game-bar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap; justify-content: center;
  margin-top: 8px; padding: 10px 16px; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius);
}
.game-bar .clock { font-size: 30px; font-weight: 900; font-variant-numeric: tabular-nums; }
.game-bar .penalty { color: var(--err); font-weight: 700; }
.game-bar .progress { color: var(--muted); }
.after { text-align: center; margin-top: 16px; }

@media (max-width: 520px) {
  .ring-center { position: static; transform: none; width: auto; margin-top: 4px; }
  .game-meta .who { margin-left: 0; }
}

/* ---------- Kopf und Fuß ---------- */
.tb-player {
  color: #fff; text-decoration: none; font-weight: 800;
  background: rgba(255,255,255,.12); padding: 4px 12px; border-radius: 999px;
}
.tb-player::before { content: '● '; color: var(--accent); }
.tb-player:hover { background: rgba(255,255,255,.22); }
.foot { text-align: center; padding: 8px 16px 32px; font-size: 14px; color: var(--muted); }
.foot a { color: var(--muted); }

/* ---------- Du ---------- */
.flash.ok { border-color: var(--ok); background: #ecfdf5; }
.big-name { font-size: 28px; font-weight: 900; margin: 0 0 6px; }
.code-card { border: 2px solid var(--accent); background: #fffbeb; }
.code { font-size: 34px; font-weight: 900; letter-spacing: 3px; font-family: ui-monospace, Consolas, monospace; margin: 4px 0 8px; }
.inline { display: inline; }
.name-form { margin-top: 18px; }
.name-form label { font-weight: 800; display: block; margin-bottom: 6px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row input, .stack input {
  font: inherit; font-size: 18px; min-height: 44px; padding: 6px 12px; flex: 1 1 12em;
  border: 2px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink);
}
.row .btn { margin: 0; }
.row-actions { margin-top: 16px; display: flex; flex-wrap: wrap; gap: 8px; }
.row-actions .btn { margin: 0; }
.narrow { max-width: 520px; }
.stack { display: flex; flex-direction: column; gap: 14px; align-items: stretch; }
.stack label { display: flex; flex-direction: column; gap: 4px; font-weight: 700; }
.stack .btn { align-self: flex-start; margin: 0; }

/* ---------- Tabellen (eigene Rätsel, Ranglisten) ---------- */
.table-scroll { overflow-x: auto; }
.list { width: 100%; border-collapse: collapse; }
.list th, .list td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.list thead th { font-size: 13px; color: var(--muted); }
.list .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.list .hint { font-size: 13px; }
.list tr.me td { background: #eef2ff; font-weight: 800; }
.list tr.gap td { text-align: center; color: var(--muted); }
.nowrap { white-space: nowrap; }
.rank td:nth-child(2) { overflow-wrap: anywhere; }
.done-rank { font-weight: 800; }

/* ---------- Impressum ---------- */
.rechtstext { max-width: 760px; }
.rechtstext h2 { margin-top: 22px; }

/* ---------- Verwaltung ---------- */
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 8px; border-bottom: 2px solid var(--line); }
.tabs a {
  text-decoration: none; padding: 10px 16px; min-height: 44px; font-weight: 700; color: var(--muted);
  border-bottom: 3px solid transparent; margin-bottom: -2px;
}
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--ink); }
.stat-tiles {
  list-style: none; padding: 0; margin: 20px 0 12px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px;
}
.stat-tiles li {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px;
  display: flex; flex-direction: column;
}
.stat-tiles strong { font-size: 28px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-tiles span { color: var(--muted); font-size: 14px; }
.list td.actions { white-space: nowrap; text-align: right; }
.list td.actions .btn { margin: 2px 0 2px 4px; }
.list tr.retired td { color: var(--muted); }
.stock td.empty a { color: var(--err); font-weight: 800; }
.tag {
  display: inline-block; font-size: 12px; font-weight: 700; vertical-align: middle;
  background: #fef2f2; color: var(--err); border: 1px solid var(--err); border-radius: 999px; padding: 0 8px;
}
.rank-filter input { font: inherit; font-size: 16px; min-height: 44px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; }
@media (max-width: 640px) {
  .list td.actions { white-space: normal; }
}

/* ---------- Meisterknobeln: Hinweis nur auf schmalen Bildschirmen ---------- */
.tablet-note { display: none; margin: 0 0 10px; font-size: 15px; }
@media (max-width: 767px) {
  .tablet-note { display: block; }
}
/* 16 Kreise: Aufgabentext in der Mitte etwas kleiner */
.ring[data-circles="14"] ~ .ring-center .task-text,
.ring[data-circles="16"] ~ .ring-center .task-text { font-size: 17px; }
