/* Fußball TicTacToe – Night-Stadium Design
   Stil: Vibrant & Block-based (ui-ux-pro-max), Fonts: Russo One / Chakra Petch */
:root {
  --bg: #06140d;
  --bg-2: #0a2216;
  --pitch-a: rgba(255, 255, 255, 0.018);
  --surface: rgba(255, 255, 255, 0.045);
  --surface-2: rgba(255, 255, 255, 0.08);
  --surface-solid: #0f2a1c;
  --line: rgba(255, 255, 255, 0.12);
  --line-strong: rgba(255, 255, 255, 0.28);
  --text: #f1f7f2;
  --muted: #a3bcad;
  --p1: #c6ff3d;
  --p1-ink: #0b1a06;
  --p1-soft: rgba(198, 255, 61, 0.16);
  --p2: #ff5d73;
  --p2-ink: #22050a;
  --p2-soft: rgba(255, 93, 115, 0.16);
  --gold: #f5c542;
  --ok: #3ee08f;
  --bad: #ff6b6b;
  --radius: 16px;
  --radius-sm: 10px;
  --font-display: 'Russo One', 'Arial Black', system-ui, sans-serif;
  --font-body: 'Chakra Petch', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    repeating-linear-gradient(90deg, transparent 0 56px, var(--pitch-a) 56px 112px),
    linear-gradient(180deg, var(--bg-2) 0%, var(--bg) 70%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  overflow-x: hidden;
}
.floodlight {
  position: fixed; inset: -20vh -20vw auto; height: 70vh; pointer-events: none; z-index: 0;
  background:
    radial-gradient(40% 60% at 15% 0%, rgba(214, 255, 230, 0.10), transparent 70%),
    radial-gradient(40% 60% at 85% 0%, rgba(214, 255, 230, 0.10), transparent 70%);
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; border-radius: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Screens */
.screen {
  display: none; position: relative; z-index: 1;
  max-width: 560px; margin: 0 auto;
  padding: calc(16px + var(--safe-top)) 16px calc(24px + var(--safe-bottom));
  min-height: 100dvh;
}
.screen.is-active { display: flex; flex-direction: column; animation: screenIn 0.35s var(--ease-out); }
@keyframes screenIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* HOME */
.hero { text-align: center; padding: 12px 0 18px; }
.logo {
  width: 92px; height: 92px; margin: 0 auto 14px;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px;
  padding: 6px; border-radius: 22px;
  background: var(--surface-2); border: 1px solid var(--line);
  box-shadow: 0 10px 40px rgba(198, 255, 61, 0.12);
}
.logo span { display: grid; place-items: center; border-radius: 6px; background: rgba(255, 255, 255, 0.05); font-family: var(--font-display); font-size: 16px; line-height: 1; }
.logo .x { color: var(--p1); }
.logo .o { color: var(--p2); }
.logo .ball { background: radial-gradient(circle at 35% 35%, #fff, #cfd8d3 60%, #8fa39a); border-radius: 50%; margin: 3px; }
h1 { font-family: var(--font-display); font-weight: 400; font-size: clamp(34px, 10vw, 48px); line-height: 1; margin: 0; letter-spacing: 0.5px; text-transform: uppercase; }
h1 span { color: var(--p1); }
.tagline { color: var(--muted); margin: 10px 0 0; font-size: 15px; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px; backdrop-filter: blur(6px);
}
.label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 1.4px; color: var(--muted); margin: 0 0 10px; }

.players { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 8px; }
.vs { font-family: var(--font-display); color: var(--muted); font-size: 14px; }
.player-input {
  display: flex; align-items: center; gap: 8px; min-height: 52px; padding: 0 12px;
  background: rgba(0, 0, 0, 0.25); border: 2px solid var(--line); border-radius: 12px;
  transition: border-color 0.2s;
}
.player-input.p1:focus-within { border-color: var(--p1); }
.player-input.p2:focus-within { border-color: var(--p2); }
.player-input input { flex: 1; min-width: 0; width: 100%; background: none; border: 0; outline: 0; font-weight: 600; font-size: 16px; }
.player-input input::placeholder { color: rgba(241, 247, 242, 0.4); }

.mark { display: inline-grid; place-items: center; width: 22px; height: 22px; flex: none; font-family: var(--font-display); font-size: 0; }
.mark svg { width: 100%; height: 100%; stroke-width: 3.2; }
.p1 .mark, .mark.p1 { color: var(--p1); }
.p2 .mark, .mark.p2 { color: var(--p2); }

.levels { display: grid; gap: 8px; }
.level {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 4px 12px;
  text-align: left; min-height: 60px; padding: 10px 14px;
  background: rgba(0, 0, 0, 0.22); border: 2px solid var(--line); border-radius: 12px;
  transition: border-color 0.2s, background-color 0.2s, transform 0.15s;
}
.level:active { transform: scale(0.98); }
.level-name { font-family: var(--font-display); font-size: 18px; }
.level-desc { color: var(--muted); font-size: 13px; line-height: 1.3; }
.level-progress { font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.level[aria-checked='true'] { border-color: var(--gold); background: rgba(245, 197, 66, 0.10); }
.level[aria-checked='true'] .level-name { color: var(--gold); }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); cursor: pointer; }
.switch-title { display: block; font-weight: 600; }
.switch-sub { display: block; font-size: 13px; color: var(--muted); }
.switch { appearance: none; width: 52px; height: 30px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line-strong); position: relative; cursor: pointer; flex: none; transition: background-color 0.2s; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--text); transition: transform 0.2s var(--ease-out); }
.switch:checked { background: var(--p1); border-color: var(--p1); }
.switch:checked::after { transform: translateX(22px); background: var(--p1-ink); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px; border-radius: 12px; border: 2px solid transparent;
  font-weight: 700; font-size: 16px; transition: transform 0.15s, background-color 0.2s, opacity 0.2s;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background: var(--p1); color: var(--p1-ink); box-shadow: 0 8px 30px rgba(198, 255, 61, 0.25); }
.btn-xl { min-height: 60px; font-family: var(--font-display); font-weight: 400; font-size: 22px; text-transform: uppercase; letter-spacing: 1px; margin-top: 4px; }
.btn-ghost { background: var(--surface); border-color: var(--line-strong); }
.btn-text { background: none; color: var(--muted); }
.btn-ok { background: var(--ok); color: #03200f; }
.btn-bad { background: var(--bad); color: #2a0505; }
.btn-gold { background: var(--gold); color: #261c00; }
.home-links { display: flex; justify-content: center; align-items: center; gap: 10px; margin-top: 14px; color: var(--muted); }
.link { background: none; border: 0; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; min-height: 44px; padding: 0 4px; }
.series-line { text-align: center; color: var(--muted); font-size: 14px; margin: 4px 0 0; }

/* GAME */
.topbar { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; gap: 8px; }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); }
.icon-btn svg { width: 22px; height: 22px; }
.round-label { text-align: center; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 1.2px; color: var(--muted); }
.round-label b { color: var(--gold); font-weight: 700; }

.scoreboard { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; margin: 14px 0 10px; }
.score { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 8px 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); transition: background-color 0.3s, border-color 0.3s; }
.score.p2 { justify-content: flex-end; }
.score .sname { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.score .sval { font-family: var(--font-display); font-size: 22px; }
.score.p1 .sval { margin-left: auto; color: var(--p1); }
.score.p2 .sval { margin-right: auto; color: var(--p2); }
.score.active.p1 { background: var(--p1-soft); border-color: var(--p1); }
.score.active.p2 { background: var(--p2-soft); border-color: var(--p2); }
.score-sep { font-family: var(--font-display); color: var(--muted); }

.turn {
  position: relative; overflow: hidden; border-radius: 14px; padding: 12px 14px; margin-bottom: 12px;
  background: var(--turn-soft, var(--p1-soft)); border: 2px solid var(--turn, var(--p1));
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.turn.flash { animation: turnFlash 0.6s var(--ease-out); }
@keyframes turnFlash { 0% { transform: scale(0.96); } 60% { transform: scale(1.02); } 100% { transform: none; } }
.turn-text { font-family: var(--font-display); font-size: 18px; display: flex; align-items: center; gap: 8px; min-width: 0; }
.turn-text #turnName { color: var(--turn, var(--p1)); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.turn-mark { display: inline-grid; width: 22px; height: 22px; color: var(--turn); }
.turn-mark svg { width: 100%; height: 100%; stroke-width: 3.2; }
.timer { display: flex; align-items: center; gap: 8px; flex: none; }
.timer-num { font-family: var(--font-display); font-size: 18px; min-width: 2ch; text-align: right; font-variant-numeric: tabular-nums; }
.timer-bar { position: absolute; left: 0; bottom: 0; height: 4px; width: 100%; background: var(--turn); transform-origin: left; transition: transform 0.25s linear; }
.timer.low .timer-num { color: var(--bad); animation: pulse 0.5s ease-in-out infinite alternate; }
@keyframes pulse { to { opacity: 0.5; } }

.board-wrap { flex: 1; display: grid; place-items: center; }
.board {
  --gap: 6px;
  width: min(100%, 62dvh, 540px);
  display: grid; grid-template-columns: 0.92fr repeat(3, 1fr); grid-template-rows: 0.92fr repeat(3, 1fr);
  gap: var(--gap); aspect-ratio: 1 / 1;
}
.corner { display: grid; place-items: center; border-radius: var(--radius-sm); border: 1px dashed var(--line); color: var(--muted); font-size: 11px; text-align: center; padding: 4px; line-height: 1.2; }
.corner b { display: block; font-family: var(--font-display); font-weight: 400; color: var(--gold); font-size: 13px; }
.cat {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  text-align: center; padding: 4px; border-radius: var(--radius-sm); min-width: 0;
  background: rgba(0, 0, 0, 0.28); border: 1px solid var(--line);
}
.cat-icon { width: 34px; height: 34px; display: grid; place-items: center; flex: none; }
.cat-icon svg { width: 100%; height: 100%; }
.cat-name { font-size: 12px; font-weight: 600; line-height: 1.15; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 100%; word-break: break-word; hyphens: auto; }
.cat-kind { font-size: 9.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.8px; line-height: 1; }

.cell {
  position: relative; border-radius: var(--radius-sm); border: 2px solid var(--line);
  background: var(--surface); display: grid; place-items: center; padding: 4px; min-width: 0; overflow: hidden;
  transition: transform 0.15s, border-color 0.2s, background-color 0.2s;
}
.cell:not(.taken):hover { border-color: var(--turn); }
.cell:not(.taken):active { transform: scale(0.95); }
.cell .plus { width: 26px; height: 26px; color: rgba(255, 255, 255, 0.22); }
.cell.taken { cursor: default; }
.cell.taken.p1 { background: var(--p1-soft); border-color: var(--p1); }
.cell.taken.p2 { background: var(--p2-soft); border-color: var(--p2); }
.cell .big-mark { position: absolute; inset: 14%; opacity: 0.22; }
.cell.p1 .big-mark { color: var(--p1); }
.cell.p2 .big-mark { color: var(--p2); }
.cell .big-mark svg { width: 100%; height: 100%; stroke-width: 2.6; }
.cell .pname { position: relative; font-weight: 700; font-size: 12.5px; line-height: 1.15; text-align: center; word-break: break-word; hyphens: auto; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.cell .judged { position: absolute; top: 4px; right: 5px; font-size: 10px; color: var(--muted); }
.cell.claim { animation: claim 0.5s var(--ease-out); }
@keyframes claim { 0% { transform: scale(0.6); } 70% { transform: scale(1.06); } 100% { transform: none; } }
.cell.shake { animation: shake 0.4s; }
@keyframes shake { 20%, 60% { transform: translateX(-5px); } 40%, 80% { transform: translateX(5px); } }
.cell.win-line { box-shadow: 0 0 0 3px var(--gold), 0 0 24px rgba(245, 197, 66, 0.5); }
.cell.reveal { cursor: pointer; }
.cell .count { position: absolute; bottom: 3px; right: 6px; font-size: 10.5px; color: var(--muted); font-weight: 600; }
.board.revealing .cell:not(.taken) { border-style: dashed; }
.board.revealing .cell:not(.taken)::after { content: 'Lösungen'; font-size: 11px; color: var(--gold); font-weight: 600; }

.game-actions { display: flex; justify-content: center; gap: 10px; margin-top: 14px; }
.hint { text-align: center; color: var(--muted); font-size: 13px; margin: 10px 0 0; }

/* Overlays */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(2, 8, 5, 0.72); backdrop-filter: blur(4px); display: flex; align-items: flex-end; justify-content: center; animation: fadeIn 0.2s; }
.overlay.center { align-items: center; padding: 16px; }
.overlay[hidden] { display: none; }
@keyframes fadeIn { from { opacity: 0; } }
.sheet {
  width: 100%; max-width: 560px; max-height: 88dvh; display: flex; flex-direction: column;
  background: var(--surface-solid); border: 1px solid var(--line); border-bottom: 0;
  border-radius: 22px 22px 0 0; padding: 10px 16px calc(16px + var(--safe-bottom));
  animation: sheetIn 0.3s var(--ease-out);
}
@keyframes sheetIn { from { transform: translateY(100%); } }
.sheet-handle { width: 44px; height: 5px; border-radius: 9px; background: var(--line-strong); margin: 0 auto 12px; }
.guess-cats { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; margin-bottom: 12px; }
.guess-cats .cat { flex-direction: row; justify-content: flex-start; text-align: left; padding: 8px 10px; gap: 8px; }
.guess-cats .cat-icon { width: 30px; height: 30px; }
.guess-cats .cat-name { font-size: 13.5px; }
.guess-cats .times { font-family: var(--font-display); color: var(--muted); }
.search { display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 0 14px; border-radius: 12px; background: rgba(0, 0, 0, 0.35); border: 2px solid var(--turn, var(--p1)); }
.search svg { width: 20px; height: 20px; color: var(--muted); flex: none; }
.search input { flex: 1; min-width: 0; background: none; border: 0; outline: 0; font-size: 17px; font-weight: 600; }
.search input::-webkit-search-cancel-button { filter: invert(1); }
.suggestions { list-style: none; margin: 10px 0 0; padding: 0; overflow-y: auto; flex: 1; min-height: 120px; }
.suggestions li button {
  width: 100%; display: flex; align-items: center; gap: 12px; min-height: 50px; padding: 6px 10px;
  background: none; border: 0; border-bottom: 1px solid var(--line); text-align: left; border-radius: 8px;
}
.suggestions li button:hover, .suggestions li button:focus-visible { background: var(--surface-2); }
.suggestions li button:disabled { opacity: 0.4; cursor: not-allowed; }
.suggestions .flag { width: 27px; height: 18px; flex: none; border-radius: 3px; overflow: hidden; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.15); }
.suggestions .flag svg { width: 100%; height: 100%; display: block; }
.suggestions .sname { font-weight: 600; flex: 1; min-width: 0; }
.suggestions mark { background: none; color: var(--turn, var(--p1)); }
.suggestions .used { font-size: 12px; color: var(--muted); }
.suggestions .empty { color: var(--muted); padding: 16px 8px; font-size: 14px; text-align: center; }
.sheet-foot { display: grid; gap: 6px; margin-top: 10px; }

.modal {
  width: 100%; max-width: 420px; text-align: center;
  background: var(--surface-solid); border: 1px solid var(--line); border-radius: 22px; padding: 22px 18px 18px;
  animation: modalIn 0.3s var(--ease-out);
}
@keyframes modalIn { from { opacity: 0; transform: scale(0.94) translateY(10px); } }
.modal h2 { font-family: var(--font-display); font-weight: 400; font-size: 24px; margin: 0 0 8px; line-height: 1.15; }
.modal-icon { width: 56px; height: 56px; margin: 0 auto 10px; display: grid; place-items: center; border-radius: 50%; }
.modal-icon:empty { display: none; }
.modal-icon svg { width: 30px; height: 30px; stroke-width: 2.6; }
.modal-icon.ok { background: rgba(62, 224, 143, 0.15); color: var(--ok); }
.modal-icon.bad { background: rgba(255, 107, 107, 0.15); color: var(--bad); }
.modal-icon.gold { background: rgba(245, 197, 66, 0.15); color: var(--gold); }
.modal-icon.p1 { background: var(--p1-soft); color: var(--p1); }
.modal-icon.p2 { background: var(--p2-soft); color: var(--p2); }
.modal-body { color: var(--muted); font-size: 15px; }
.modal-body p { margin: 0 0 10px; }
.modal-body strong { color: var(--text); }
.modal-body ul { text-align: left; padding-left: 20px; margin: 8px 0; }
.modal-body li { margin-bottom: 6px; }
.modal-actions { display: grid; gap: 8px; margin-top: 16px; }
.modal-actions.two { grid-template-columns: 1fr 1fr; }
.facts { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 8px 0 4px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); font-size: 12.5px; color: var(--text); }
.chip .flag { width: 18px; height: 12px; border-radius: 2px; overflow: hidden; display: inline-block; }
.chip .flag svg { width: 100%; height: 100%; display: block; }
.solution-list { max-height: 45dvh; overflow-y: auto; text-align: left; margin: 8px 0 0; padding: 0; list-style: none; }
.solution-list li { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--line); color: var(--text); font-weight: 600; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-bottom)); z-index: 60;
  transform: translate(-50%, 140%); opacity: 0;
  padding: 12px 18px; border-radius: 12px; font-weight: 700; max-width: calc(100vw - 32px);
  background: var(--surface-solid); border: 1px solid var(--line-strong); box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  transition: transform 0.3s var(--ease-out), opacity 0.3s;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast.ok { border-color: var(--ok); color: var(--ok); }
.toast.bad { border-color: var(--bad); color: var(--bad); }

.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 70; overflow: hidden; }
.confetti i { position: absolute; top: -12px; width: 9px; height: 14px; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

@media (min-width: 600px) {
  .cat-name { font-size: 13.5px; }
  .cell .pname { font-size: 14px; }
  .cat-icon { width: 40px; height: 40px; }
}
@media (max-height: 700px) {
  .hero { padding: 0 0 10px; }
  .logo { width: 70px; height: 70px; }
  .hint { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
