:root {
  --bg: #0a0b24;
  --bg-2: #13154a;
  --surface: rgba(255, 255, 255, 0.06);
  --surface-2: rgba(255, 255, 255, 0.1);
  --border: rgba(255, 255, 255, 0.12);
  --text: #f3f1ff;
  --muted: #a6a3d6;
  --primary: #7c5cff;
  --primary-2: #b06bff;
  --accent: #33e1ff;
  --pink: #ff4f8b;
  --gold: #ffd166;
  --good: #3ee08f;
  --bad: #ff5d73;
  --warn: #ffb547;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --font-head: "Outfit", system-ui, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(ellipse at 50% -10%, #2a1d7a 0%, var(--bg) 55%) fixed, var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
#stars { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }
#app { position: relative; z-index: 1; max-width: 640px; margin: 0 auto; min-height: 100%; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--font-head); margin: 0; }

/* ---------- Screens ---------- */
.screen { display: none; min-height: 100vh; min-height: 100dvh; flex-direction: column; padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
.screen.active { display: flex; animation: fadeIn .25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.content { padding: 8px 16px 24px; display: flex; flex-direction: column; gap: 14px; flex: 1; }

/* ---------- Home ---------- */
.home-wrap { padding: 32px 16px 32px; display: flex; flex-direction: column; gap: 16px; }
.logo { text-align: center; margin-bottom: 8px; }
.logo-ship { width: 84px; height: 84px; margin: 0 auto 4px; animation: float 3.2s ease-in-out infinite; filter: drop-shadow(0 8px 24px rgba(124, 92, 255, .6)); }
.rocket-svg { width: 100%; height: 100%; }
.rk-flame { animation: flame .18s ease-in-out infinite alternate; transform-origin: 32px 46px; }
@keyframes flame { from { transform: scaleY(.85); } to { transform: scaleY(1.15); } }
@keyframes float { 0%,100% { transform: translateY(0) rotate(-6deg); } 50% { transform: translateY(-10px) rotate(6deg); } }
.logo h1 { font-size: clamp(2.6rem, 11vw, 4rem); font-weight: 900; letter-spacing: -0.02em; line-height: 1; }
.logo h1 span { background: linear-gradient(90deg, var(--accent), var(--primary-2), var(--pink)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.tagline { color: var(--muted); margin: 10px 0 0; font-size: 1.02rem; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.label { display: block; font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; margin-bottom: 8px; }
.input, .select {
  width: 100%; background: rgba(0, 0, 0, .25); border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px 14px; outline: none; transition: border-color .15s, box-shadow .15s; min-width: 0;
}
.input:focus, .select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(124, 92, 255, .25); }
.select { appearance: none; -webkit-appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 52%, calc(100% - 13px) 52%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 34px; }
.select option { background: var(--bg-2); }
.select:disabled { opacity: .7; }
.row { display: flex; gap: 8px; }
.code-input { text-transform: uppercase; letter-spacing: .25em; font-weight: 700; font-family: var(--font-head); text-align: center; }

.mode-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.mode-btn {
  border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 14px; text-align: left;
  display: flex; flex-direction: column; gap: 6px; position: relative; overflow: hidden;
  transition: transform .12s ease, box-shadow .2s ease;
}
.mode-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.mode-btn:active { transform: scale(.98); }
.mode-solo { background: linear-gradient(140deg, #4a2fd8, #8a3dd8); }
.mode-party { background: linear-gradient(140deg, #0f8fb5, #3b4fd8); }
.mode-icon { font-size: 2rem; }
.mode-title { font-family: var(--font-head); font-weight: 800; font-size: 1.15rem; }
.mode-sub { font-size: .85rem; opacity: .85; }
@media (max-width: 380px) { .mode-grid { grid-template-columns: 1fr; } }

/* ---------- Buttons ---------- */
.btn { border: 0; border-radius: var(--radius-sm); padding: 12px 18px; font-weight: 700; transition: transform .1s, filter .15s, opacity .15s; white-space: nowrap; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; box-shadow: 0 6px 20px rgba(124, 92, 255, .4); }
.btn-primary:hover { filter: brightness(1.1); }
.btn-secondary { background: var(--surface-2); border: 1px solid var(--border); }
.btn-secondary:hover { background: rgba(255, 255, 255, .16); }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--muted); }
.btn-big { width: 100%; padding: 16px; font-size: 1.1rem; font-family: var(--font-head); }
.link-btn { background: none; border: 0; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; padding: 8px; align-self: center; }
.link-btn:hover { color: var(--text); }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); font-size: 1.1rem; display: grid; place-items: center; }

/* ---------- Topbar ---------- */
.topbar { display: grid; grid-template-columns: 48px 1fr 48px; align-items: center; padding: 12px 16px; gap: 8px; }
.topbar h2 { text-align: center; font-size: 1.2rem; font-weight: 800; }
.game-topbar { grid-template-columns: 48px 1fr 1fr; }
#screen-mp-round .game-topbar { grid-template-columns: 1fr auto 1fr; }
.stat { display: flex; flex-direction: column; align-items: center; }
.stat-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.stat-value { font-family: var(--font-head); font-weight: 800; font-size: 1.25rem; }
.conn-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--warn); justify-self: end; box-shadow: 0 0 10px currentColor; }
.conn-dot.ok { background: var(--good); }
.conn-dot.bad { background: var(--bad); }

.section-title { font-size: 1.05rem; font-weight: 800; margin-top: 4px; display: flex; align-items: center; gap: 8px; }
.section-title.small { font-size: .95rem; color: var(--muted); }
.count { font-size: .85rem; color: var(--muted); font-weight: 600; }
.muted { color: var(--muted); margin: 0; }
.center { text-align: center; }

/* ---------- Kategorien ---------- */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.cat-chip {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1.5px solid var(--border); text-align: left; font-weight: 600; font-size: .9rem;
  transition: background .15s, border-color .15s, opacity .15s;
}
.cat-chip .ci { font-size: 1.15rem; }
.cat-chip.on { background: rgba(124, 92, 255, .22); border-color: var(--primary); }
.cat-chip:not(.on) { opacity: .55; }
.cat-chip.all { justify-content: center; }
.cat-grid.readonly .cat-chip { cursor: default; }

.sticky-actions { position: sticky; bottom: 0; margin: 8px -16px -24px; padding: 14px 16px calc(16px + env(safe-area-inset-bottom)); background: linear-gradient(to top, var(--bg) 70%, transparent); display: flex; flex-direction: column; gap: 8px; }
.highscore { text-align: center; color: var(--gold); font-weight: 600; font-size: .9rem; min-height: 1.2em; }

/* ---------- Spiel ---------- */
.journey { position: relative; height: 56px; margin: 0 16px; }
.journey .track { position: absolute; left: 12px; right: 12px; top: 50%; height: 2px; background: repeating-linear-gradient(90deg, rgba(255,255,255,.3) 0 6px, transparent 6px 12px); }
.journey .planet { position: absolute; top: 50%; width: 14px; height: 14px; border-radius: 50%; transform: translate(-50%, -50%); background: rgba(255,255,255,.15); border: 2px solid rgba(255,255,255,.25); transition: all .4s; }
.journey .planet.done { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 10px var(--accent); }
.journey .planet.goal { width: 26px; height: 26px; background: radial-gradient(circle at 35% 35%, #ffe28a, #ff7a3d); border: 0; box-shadow: 0 0 16px rgba(255, 170, 60, .7); }
.journey .ship { position: absolute; top: 50%; width: 34px; height: 34px; transform: translate(-50%, -50%) rotate(90deg); transition: left .8s cubic-bezier(.5, 0, .2, 1); filter: drop-shadow(0 0 8px rgba(124,92,255,.8)); }
.journey .ship svg { width: 100%; height: 100%; }

.gas-wrap { margin: 4px 16px 6px; }
.gas-label { display: flex; justify-content: space-between; font-size: .8rem; font-weight: 700; color: var(--muted); margin-bottom: 4px; }
.gas-bar { height: 14px; border-radius: 99px; background: rgba(255,255,255,.08); border: 1px solid var(--border); overflow: hidden; }
.gas-fill { height: 100%; width: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--good), #9be15d); transition: width .12s linear, background .3s; }
.gas-fill.mid { background: linear-gradient(90deg, var(--warn), #ffd166); }
.gas-fill.low { background: linear-gradient(90deg, var(--bad), #ff8a5d); animation: pulse .6s ease-in-out infinite alternate; }
@keyframes pulse { from { opacity: 1; } to { opacity: .55; } }
.gas-wrap.boost .gas-fill { box-shadow: 0 0 16px var(--good); }

.game-content { gap: 12px; }
.prompt-card {
  background: linear-gradient(160deg, rgba(124, 92, 255, .25), rgba(51, 225, 255, .08));
  border: 1px solid rgba(124, 92, 255, .45); border-radius: var(--radius); padding: 18px 16px; text-align: center;
  box-shadow: var(--shadow);
}
.prompt-card.compact { padding: 12px 14px; }
.prompt-card.compact .prompt-q { font-size: 1.15rem; }
.prompt-card.pop { animation: pop .45s ease; }
@keyframes pop { 0% { transform: scale(.92); opacity: .3; } 60% { transform: scale(1.03); } 100% { transform: none; opacity: 1; } }
.prompt-cat { font-size: .78rem; text-transform: uppercase; letter-spacing: .1em; color: var(--accent); font-weight: 700; margin-bottom: 6px; }
.prompt-q { font-family: var(--font-head); font-weight: 800; font-size: clamp(1.3rem, 5.5vw, 1.75rem); line-height: 1.15; }
.prompt-progress { display: flex; justify-content: center; gap: 6px; margin-top: 12px; }
.prompt-progress .pip { width: 12px; height: 12px; border-radius: 50%; background: rgba(255,255,255,.15); transition: background .2s, transform .2s; }
.prompt-progress .pip.on { background: var(--accent); transform: scale(1.15); box-shadow: 0 0 8px var(--accent); }

.answer-form { display: flex; gap: 8px; }
.answer-input { font-size: 1.1rem; padding: 14px 16px; }
.answer-form .btn { padding: 0 20px; font-size: 1.2rem; }
.answer-form.shake { animation: shake .35s; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.answer-form.disabled { opacity: .5; pointer-events: none; }

.feedback { min-height: 1.4em; text-align: center; font-weight: 600; font-size: .95rem; }
.feedback.good { color: var(--good); }
.feedback.niche { color: var(--gold); }
.feedback.bad { color: var(--bad); }
.feedback.info { color: var(--muted); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 6px 12px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); font-size: .9rem; font-weight: 600; animation: chipIn .25s ease; display: inline-flex; align-items: center; gap: 4px; }
.chip.niche { background: rgba(255, 209, 102, .16); border-color: rgba(255, 209, 102, .6); color: var(--gold); }
.chip.valid { border-color: rgba(62, 224, 143, .5); }
.chip.unknown { border-style: dashed; color: var(--muted); }
.chip.missed { background: transparent; color: var(--muted); }
.chip.missed.niche { color: var(--gold); }
button.chip { cursor: pointer; }
@keyframes chipIn { from { transform: scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }
.skip-btn { margin-top: auto; }

.overlay-msg { position: fixed; inset: 0; display: none; place-items: center; z-index: 20; pointer-events: none; text-align: center; padding: 16px; }
.overlay-msg.show { display: grid; animation: fadeIn .2s; }
.overlay-msg .om-box { background: rgba(10, 11, 36, .9); border: 1px solid var(--border); border-radius: 24px; padding: 24px 28px; box-shadow: var(--shadow); max-width: 92vw; }
.overlay-msg .om-emoji { font-size: 3rem; }
.overlay-msg .om-title { font-family: var(--font-head); font-weight: 900; font-size: 1.6rem; }
.overlay-msg .om-sub { color: var(--muted); margin-top: 4px; }
.overlay-msg .om-count { font-family: var(--font-head); font-weight: 900; font-size: 5rem; line-height: 1; background: linear-gradient(135deg, var(--accent), var(--primary-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ---------- Ende ---------- */
.end-content { padding-top: 32px; }
.end-hero { text-align: center; }
.end-emoji { font-size: 4rem; animation: float 3s ease-in-out infinite; }
.end-hero h2 { font-size: 2rem; font-weight: 900; }
.end-hero p { color: var(--muted); margin: 6px 0 0; }
.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; text-align: center; }
.stat-card .v { font-family: var(--font-head); font-weight: 900; font-size: 1.6rem; }
.stat-card .l { color: var(--muted); font-size: .8rem; }
.stat-card.hl .v { color: var(--gold); }
.end-actions { display: flex; flex-direction: column; gap: 10px; margin-top: auto; }

/* ---------- Lobby ---------- */
.invite-card { text-align: center; }
.lobby-code { font-family: var(--font-head); font-size: 2.6rem; font-weight: 900; letter-spacing: .25em; margin: 0 0 10px .25em; background: linear-gradient(90deg, var(--accent), var(--primary-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.invite-row { display: flex; gap: 8px; }
.invite-link { font-size: .85rem; color: var(--muted); }
.share-btn { margin-top: 8px; width: 100%; }
.players { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.player { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px; min-width: 0; }
.player.off { opacity: .45; }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-family: var(--font-head); flex: none; color: #0a0b24; }
.player .pname { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player .tag { font-size: .7rem; color: var(--gold); display: block; }
.settings { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.setting label { display: block; font-size: .8rem; color: var(--muted); margin-bottom: 6px; font-weight: 600; }

.crew-progress { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: auto; padding-top: 8px; }
.crew-pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 4px; border-radius: 99px; background: var(--surface); border: 1px solid var(--border); font-size: .8rem; }
.crew-pill .avatar { width: 22px; height: 22px; font-size: .7rem; }
.crew-pill b { font-family: var(--font-head); }

.timer { position: relative; width: 52px; height: 52px; justify-self: center; }
.timer svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.timer circle { fill: none; stroke-width: 4; }
.timer-bg { stroke: rgba(255,255,255,.12); }
.timer-fg { stroke: var(--accent); stroke-linecap: round; stroke-dasharray: 119.4; transition: stroke-dashoffset .25s linear, stroke .3s; }
.timer.low .timer-fg { stroke: var(--bad); }
.timer span { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--font-head); font-weight: 800; font-size: 1.1rem; }

/* ---------- Auswertung ---------- */
.small-note { font-size: .85rem; text-align: center; }
.review-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.review-item { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; }
.review-item.invalid { opacity: .55; }
.review-item.invalid .ri-answer { text-decoration: line-through; }
.ri-answer { font-weight: 700; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ri-badge { font-size: .68rem; font-weight: 700; padding: 2px 7px; border-radius: 99px; text-transform: uppercase; letter-spacing: .04em; }
.ri-badge.unique { background: rgba(51, 225, 255, .18); color: var(--accent); }
.ri-badge.niche { background: rgba(255, 209, 102, .18); color: var(--gold); }
.ri-badge.unknown { background: rgba(255, 181, 71, .18); color: var(--warn); }
.ri-who { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 4px; }
.ri-who .who { font-size: .75rem; padding: 2px 8px; border-radius: 99px; background: rgba(255,255,255,.07); color: var(--muted); }
.ri-right { display: flex; align-items: center; gap: 8px; }
.ri-points { font-family: var(--font-head); font-weight: 900; font-size: 1.15rem; min-width: 32px; text-align: right; }
.ri-points.zero { color: var(--muted); }
.ri-toggle { width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); font-size: 1rem; }
.ri-toggle.ok { background: rgba(62, 224, 143, .2); border-color: var(--good); color: var(--good); }
.ri-toggle.no { background: rgba(255, 93, 115, .18); border-color: var(--bad); color: var(--bad); }
.ri-toggle[disabled] { cursor: default; }
.empty { text-align: center; color: var(--muted); padding: 16px; }

.scoreboard { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.score-row { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 12px; }
.score-row .rank { font-family: var(--font-head); font-weight: 800; width: 22px; color: var(--muted); }
.score-row .pname { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score-row .plus { color: var(--good); font-weight: 700; font-size: .9rem; }
.score-row .total { font-family: var(--font-head); font-weight: 900; font-size: 1.15rem; min-width: 40px; text-align: right; }
.score-row.me { border-color: var(--primary); }

.podium { display: flex; justify-content: center; align-items: flex-end; gap: 10px; margin: 8px 0; }
.pod { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 30%; max-width: 140px; }
.pod .avatar { width: 48px; height: 48px; font-size: 1.2rem; }
.pod .pname { font-weight: 700; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.pod .block { width: 100%; border-radius: 12px 12px 4px 4px; display: grid; place-items: center; font-family: var(--font-head); font-weight: 900; font-size: 1.4rem; }
.pod.p1 .block { height: 120px; background: linear-gradient(180deg, #ffd166, #e09b2d); color: #3a2400; }
.pod.p2 .block { height: 90px; background: linear-gradient(180deg, #d9dcf5, #9aa0c8); color: #1d2040; }
.pod.p3 .block { height: 70px; background: linear-gradient(180deg, #f0a37a, #b8653a); color: #331500; }
.pod .pts { color: var(--muted); font-size: .85rem; }

/* ---------- Modal & Toast ---------- */
.modal { border: 1px solid var(--border); border-radius: 22px; background: #14164a; color: var(--text); padding: 0; max-width: min(520px, calc(100vw - 32px)); box-shadow: var(--shadow); }
.modal::backdrop { background: rgba(5, 6, 20, .7); backdrop-filter: blur(4px); }
.modal-body { padding: 22px 20px; display: flex; flex-direction: column; gap: 12px; }
.howto-list { padding-left: 20px; margin: 0; display: flex; flex-direction: column; gap: 10px; color: #dcdaf7; }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(120px); background: #1d1f5c; border: 1px solid var(--border); padding: 10px 18px; border-radius: 99px; z-index: 50; transition: transform .3s ease; box-shadow: var(--shadow); max-width: calc(100vw - 32px); text-align: center; font-weight: 600; }
.toast.show { transform: translateX(-50%) translateY(0); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
