/* KI Reaction Challenge – eigenes, jugendliches Design (bewusst nicht das Workflows-Leitstand-Design). */
:root {
    --bg: #0d0b1e;
    --bg-2: #16122f;
    --panel: rgba(255, 255, 255, 0.055);
    --panel-2: rgba(255, 255, 255, 0.09);
    --line: rgba(255, 255, 255, 0.13);
    --text: #f5f3ff;
    --muted: #b1abd3;
    --violet: #8b6cff;
    --pink: #ff4d8d;
    --orange: #ffb13d;
    --mint: #2ee6b6;
    --danger: #ff6b6b;
    --grad: linear-gradient(120deg, var(--violet), var(--pink) 55%, var(--orange));
    --radius: 22px;
    --font: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, "Segoe UI", Roboto, sans-serif;
    color-scheme: dark;
}

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

html, body { height: 100%; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

.bg-glow {
    position: fixed; inset: 0; z-index: -1; pointer-events: none;
    background:
        radial-gradient(40rem 30rem at 12% 8%, rgba(139, 108, 255, 0.28), transparent 60%),
        radial-gradient(36rem 28rem at 92% 18%, rgba(255, 77, 141, 0.18), transparent 60%),
        radial-gradient(40rem 30rem at 60% 110%, rgba(46, 230, 182, 0.12), transparent 60%),
        var(--bg);
}

svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Bildschirme ---------- */
.screen { min-height: 100dvh; animation: screen-in 0.35s ease both; }
@keyframes screen-in { from { opacity: 0; } to { opacity: 1; } }

.screen-start, .screen-end {
    display: grid; place-items: center;
    padding: max(20px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}
.start-grid, .end-grid {
    width: 100%; max-width: 1040px;
    display: grid; gap: 20px;
    grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
    align-items: start;
}
@media (max-width: 820px) {
    .start-grid, .end-grid { grid-template-columns: 1fr; max-width: 560px; }
}

.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: clamp(20px, 4vw, 36px);
    backdrop-filter: blur(12px);
}

.kicker {
    display: inline-flex; align-items: center; gap: 8px; margin: 0 0 14px;
    font-size: 13px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted);
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--mint); box-shadow: 0 0 12px var(--mint); }

.title {
    margin: 0; font-size: clamp(38px, 7vw, 64px); line-height: 1.02; font-weight: 900; letter-spacing: -0.03em;
}
.title span { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lead { margin: 14px 0 26px; font-size: 18px; color: var(--muted); max-width: 34ch; }

/* ---------- Formular ---------- */
.start-form { display: grid; gap: 10px; }
.field-label { font-size: 14px; font-weight: 800; color: var(--text); padding: 0; margin-bottom: 2px; }
.input {
    width: 100%; min-height: 58px; padding: 0 18px;
    font: inherit; font-size: 20px; font-weight: 700; color: var(--text);
    background: rgba(0, 0, 0, 0.28); border: 2px solid var(--line); border-radius: 16px;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.input::placeholder { color: rgba(177, 171, 211, 0.65); font-weight: 600; }
.input:focus { outline: none; border-color: var(--violet); box-shadow: 0 0 0 4px rgba(139, 108, 255, 0.25); }
.input.is-invalid { border-color: var(--danger); animation: shake 0.35s; }
.field-error { margin: 0; color: var(--danger); font-weight: 700; font-size: 14px; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

.levels { border: 0; margin: 12px 0 0; padding: 0; min-width: 0; }
.level-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 8px; }
.level { position: relative; cursor: pointer; }
.level input { position: absolute; opacity: 0; pointer-events: none; }
.level-box {
    display: grid; gap: 4px; height: 100%; padding: 14px 12px;
    background: rgba(0, 0, 0, 0.22); border: 2px solid var(--line); border-radius: 16px;
    transition: border-color 0.15s, background 0.15s, transform 0.15s;
}
.level:hover .level-box { border-color: rgba(255, 255, 255, 0.3); }
.level input:checked + .level-box { border-color: var(--violet); background: rgba(139, 108, 255, 0.16); }
.level input:focus-visible + .level-box { box-shadow: 0 0 0 4px rgba(139, 108, 255, 0.35); }
.level-name { font-weight: 900; font-size: 18px; }
.level-hint { font-size: 13px; color: var(--muted); line-height: 1.3; }
.level-dot { border-radius: 50%; background: var(--grad); margin-bottom: 4px; }
.level-dot-leicht { width: 22px; height: 22px; }
.level-dot-mittel { width: 16px; height: 16px; margin-top: 3px; margin-bottom: 7px; }
.level-dot-schwer { width: 10px; height: 10px; margin-top: 6px; margin-bottom: 10px; }
@media (max-width: 420px) {
    .level-box { padding: 12px 8px; }
    .level-hint { font-size: 12px; }
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 10px;
    min-height: 58px; padding: 0 28px; border: 0; border-radius: 18px; cursor: pointer;
    font: inherit; font-weight: 900; font-size: 18px; color: var(--text); text-decoration: none;
    transition: transform 0.12s, box-shadow 0.2s, filter 0.2s;
    touch-action: manipulation;
}
.btn:active { transform: scale(0.97); }
.btn:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
.btn-start {
    margin-top: 16px; min-height: 72px; font-size: 26px; letter-spacing: 0.08em;
    background: var(--grad); color: #1a0f2e;
    box-shadow: 0 12px 34px -10px rgba(255, 77, 141, 0.7);
}
.btn-start:hover { filter: brightness(1.08); box-shadow: 0 16px 40px -10px rgba(255, 77, 141, 0.85); }
.btn-ghost { background: var(--panel-2); border: 1px solid var(--line); }
.btn-ghost:hover { background: rgba(255, 255, 255, 0.14); }

/* ---------- Bestenliste ---------- */
.board-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.board-title { display: flex; align-items: center; gap: 10px; margin: 0; font-size: 22px; font-weight: 900; }
.board-title svg { width: 24px; height: 24px; color: var(--orange); }
.seg { display: inline-flex; padding: 4px; background: rgba(0, 0, 0, 0.3); border-radius: 12px; }
.seg-btn, .tab {
    font: inherit; font-weight: 800; font-size: 14px; color: var(--muted); cursor: pointer;
    background: transparent; border: 0; border-radius: 9px; padding: 8px 12px; min-height: 38px;
}
.seg-btn.is-active { background: var(--panel-2); color: var(--text); }
.tabs { display: flex; gap: 8px; margin: 16px 0 12px; }
.tab { flex: 1; border: 1px solid var(--line); }
.tab.is-active { color: var(--text); border-color: var(--violet); background: rgba(139, 108, 255, 0.16); }
.seg-btn:focus-visible, .tab:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

.board { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; counter-reset: rank; }
.board li {
    display: grid; grid-template-columns: 38px 1fr auto; align-items: center; gap: 10px;
    padding: 10px 12px; border-radius: 14px; background: rgba(0, 0, 0, 0.2);
    font-weight: 700;
}
.board li.is-me { background: rgba(46, 230, 182, 0.16); outline: 2px solid var(--mint); }
.board .rank {
    display: grid; place-items: center; width: 32px; height: 32px; border-radius: 10px;
    background: var(--panel-2); font-size: 15px; font-weight: 900; font-variant-numeric: tabular-nums;
}
.board li:nth-child(1) .rank { background: #ffcf4a; color: #2a1d00; }
.board li:nth-child(2) .rank { background: #d9deea; color: #1c2130; }
.board li:nth-child(3) .rank { background: #e39a62; color: #2a1405; }
.board .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board .pts { font-size: 18px; font-weight: 900; font-variant-numeric: tabular-nums; }
.board .empty { display: block; padding: 18px 12px; color: var(--muted); font-weight: 600; text-align: center; background: transparent; }

/* ---------- Spiel ---------- */
.screen-game {
    position: fixed; inset: 0; display: flex; flex-direction: column;
    padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
    gap: 10px; overscroll-behavior: none;
}
.hud {
    position: relative; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
    padding: 12px 18px 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 20px;
}
.hud-item { display: grid; gap: 0; }
.hud-time { text-align: center; }
.hud-right { display: flex; justify-content: flex-end; align-items: center; gap: 12px; }
.hud-level { padding: 6px 12px; border-radius: 999px; background: rgba(139, 108, 255, 0.18); border: 1px solid rgba(139, 108, 255, 0.45); color: var(--text); }
.hud-label { font-size: 12px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.hud-value { font-size: clamp(30px, 6vw, 44px); font-weight: 900; line-height: 1.05; font-variant-numeric: tabular-nums; }
#hud-score.bump { animation: bump 0.25s ease; }
@keyframes bump { 40% { transform: scale(1.25); color: var(--mint); } }
.hud-time.is-final .hud-value { color: var(--danger); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.55; } }
.hud-quit {
    display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; cursor: pointer;
    color: var(--muted); background: var(--panel-2); border: 1px solid var(--line);
}
.hud-quit:hover { color: var(--text); }
.time-bar { position: absolute; left: 18px; right: 18px; bottom: 7px; height: 4px; border-radius: 4px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.time-bar span { display: block; height: 100%; width: 100%; background: var(--grad); transform-origin: left; }
.hud-time.is-final ~ .time-bar span { background: var(--danger); }

.arena {
    position: relative; flex: 1; overflow: hidden; border-radius: 24px;
    background:
        radial-gradient(circle at 50% 50%, rgba(139, 108, 255, 0.10), transparent 70%),
        repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 48px),
        repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 48px),
        rgba(0, 0, 0, 0.25);
    border: 1px solid var(--line);
    touch-action: none; user-select: none; -webkit-user-select: none; cursor: crosshair;
}
.arena.flash { animation: arena-flash 0.3s ease; }
@keyframes arena-flash { 30% { box-shadow: inset 0 0 0 3px rgba(46, 230, 182, 0.6); } }

.target {
    position: absolute; left: 0; top: 0; padding: 0; border: 0; border-radius: 50%; cursor: pointer;
    background: transparent; touch-action: none;
    width: var(--size, 80px); height: var(--size, 80px);
}
.target-ring, .target-core { position: absolute; border-radius: 50%; pointer-events: none; }
.target-ring {
    inset: 0; background: var(--grad);
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.9), 0 0 30px 6px rgba(255, 77, 141, 0.55);
}
.target-core { inset: 28%; background: #fff; box-shadow: inset 0 0 0 5px var(--pink); }
.target.spawn { animation: spawn 0.22s cubic-bezier(0.3, 1.5, 0.5, 1) both; }
@keyframes spawn { from { transform: translate(var(--x), var(--y)) scale(0.2); opacity: 0; } to { transform: translate(var(--x), var(--y)) scale(1); opacity: 1; } }
.target { transform: translate(var(--x, 0), var(--y, 0)); }
.target:focus-visible { outline: 3px solid #fff; outline-offset: 4px; }

.burst, .miss {
    position: absolute; pointer-events: none; border-radius: 50%;
    transform: translate(-50%, -50%);
}
.burst { width: var(--size); height: var(--size); border: 4px solid var(--mint); animation: burst 0.5s ease-out forwards; }
@keyframes burst { from { opacity: 1; transform: translate(-50%, -50%) scale(0.6); } to { opacity: 0; transform: translate(-50%, -50%) scale(2.2); } }
.plus {
    position: absolute; pointer-events: none; font-weight: 900; font-size: 26px; color: var(--mint);
    text-shadow: 0 2px 12px rgba(46, 230, 182, 0.6); transform: translate(-50%, -50%);
    animation: plus 0.7s ease-out forwards;
}
@keyframes plus { to { opacity: 0; transform: translate(-50%, -150%); } }
.spark {
    position: absolute; width: 8px; height: 8px; border-radius: 50%; pointer-events: none;
    background: var(--c, var(--orange)); animation: spark 0.55s ease-out forwards;
}
@keyframes spark { to { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(0.3); } }
.miss { width: 26px; height: 26px; border: 2px solid rgba(255, 107, 107, 0.7); animation: miss 0.4s ease-out forwards; }
@keyframes miss { to { opacity: 0; transform: translate(-50%, -50%) scale(1.8); } }

.countdown {
    position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none;
    font-size: clamp(90px, 22vw, 180px); font-weight: 900; line-height: 1;
}
.countdown:empty { display: none; }
.countdown span { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; animation: count 0.9s ease-out both; }
@keyframes count { from { transform: scale(1.6); opacity: 0; } 30% { transform: scale(1); opacity: 1; } to { transform: scale(0.8); opacity: 0; } }

/* ---------- Ende ---------- */
.end-card { text-align: center; }
.end-title { margin: 0; font-size: clamp(34px, 6.5vw, 56px); line-height: 1.05; font-weight: 900; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.end-title span { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.end-score { margin: 18px 0 8px; display: flex; align-items: baseline; justify-content: center; gap: 12px; }
#end-score { font-size: clamp(84px, 18vw, 140px); line-height: 1; font-weight: 900; font-variant-numeric: tabular-nums; }
.end-unit { font-size: 22px; font-weight: 800; color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 18px 0 0; }
.stats div { padding: 12px 8px; border-radius: 14px; background: rgba(0, 0, 0, 0.22); }
.stats dt { font-size: 12px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.stats dd { margin: 2px 0 0; font-size: 20px; font-weight: 900; }
.end-status { min-height: 1.5em; margin: 18px 0 0; font-weight: 800; font-size: 17px; }
.end-status.is-good { color: var(--mint); }
.end-status.is-warn { color: var(--orange); }
.end-actions { display: grid; gap: 10px; margin-top: 8px; }
.end-actions .btn-start { margin-top: 8px; }

/* ---------- Bewegung reduzieren ---------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
    .countdown span, .target.spawn { animation: none !important; }
}
