:root {
  --bg: #0d1028;
  --bg-2: #171b3d;
  --panel: rgba(255, 255, 255, 0.06);
  --panel-border: rgba(255, 255, 255, 0.12);
  --text: #f4f5ff;
  --muted: #a3a8d1;
  --accent: #ffcc33;
  --accent-text: #1b1400;
  --good: #2ecc71;
  --bad: #ff5c6c;
  --opt-0: #e74c6c;
  --opt-1: #3d8bfd;
  --opt-2: #f1a71b;
  --opt-3: #2bb673;
  --opt-4: #9b5de5;
  --opt-5: #00b8c9;
  --radius: 16px;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  font-family: var(--font);
  color: var(--text);
  background: radial-gradient(ellipse at top, #2a2f6b 0%, var(--bg) 60%) fixed, var(--bg);
  line-height: 1.45;
}

h1, h2, h3 { margin: 0 0 0.5em; line-height: 1.15; }

button, input, select, textarea { font: inherit; color: inherit; }

.hidden { display: none !important; }

.container { max-width: 1100px; margin: 0 auto; padding: 24px 16px 48px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 24px;
  backdrop-filter: blur(6px);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 12px; padding: 12px 22px;
  font-weight: 700; cursor: pointer;
  background: var(--accent); color: var(--accent-text);
  transition: transform 0.08s ease, filter 0.15s ease, opacity 0.15s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.secondary { background: rgba(255, 255, 255, 0.12); color: var(--text); }
.btn.danger { background: var(--bad); color: #fff; }
.btn.small { padding: 6px 12px; font-size: 0.9rem; border-radius: 8px; }
.btn.big { padding: 18px 36px; font-size: 1.3rem; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label { font-size: 0.9rem; color: var(--muted); font-weight: 600; }
.input, select.input, textarea.input {
  width: 100%; padding: 12px 14px; border-radius: 10px;
  border: 1px solid var(--panel-border); background: rgba(0, 0, 0, 0.25);
  outline: none;
}
.input:focus { border-color: var(--accent); }
select.input option { background: var(--bg-2); }

.error-msg { color: var(--bad); min-height: 1.4em; font-weight: 600; }
.muted { color: var(--muted); }

.chip {
  display: inline-block; padding: 4px 12px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.1); font-size: 0.85rem; font-weight: 600;
}

/* ---------- Player ---------- */

.brand {
  text-align: center; font-size: clamp(2.2rem, 6vw, 4rem); font-weight: 900;
  letter-spacing: -0.02em; margin: 16px 0 24px;
  background: linear-gradient(90deg, #ffcc33, #ff6f91, #7c83ff);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

.start-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 24px; align-items: start; }
@media (max-width: 800px) { .start-grid { grid-template-columns: 1fr; } }

.rules { margin: 0 0 20px; padding-left: 20px; color: var(--muted); }
.rules li { margin-bottom: 4px; }

.q-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.q-progress { font-weight: 700; color: var(--muted); }
.q-score { font-weight: 800; color: var(--accent); font-size: 1.2rem; }

.timer { height: 10px; background: rgba(255, 255, 255, 0.1); border-radius: 999px; overflow: hidden; margin-bottom: 24px; }
.timer-bar { height: 100%; width: 100%; background: linear-gradient(90deg, var(--good), var(--accent)); transition: width 0.2s linear; }
.timer-bar.warn { background: var(--bad); }
.timer-text { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); margin: -18px 0 18px; font-size: 0.9rem; }

.q-text {
  font-size: clamp(1.4rem, 3.5vw, 2.4rem); font-weight: 800; text-align: center;
  margin: 12px 0 32px; min-height: 2.5em;
}

.options { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 600px) { .options { grid-template-columns: 1fr; } }

.option {
  position: relative; border: 0; border-radius: var(--radius); padding: 22px 20px 22px 64px;
  text-align: left; font-size: 1.2rem; font-weight: 700; color: #fff; cursor: pointer; min-height: 84px;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.25); transition: transform 0.08s, opacity 0.2s, box-shadow 0.2s;
}
.option:hover { transform: translateY(-2px); }
.option:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0, 0, 0, 0.25); }
.option .letter {
  position: absolute; left: 16px; top: 50%; transform: translateY(-50%);
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: rgba(0, 0, 0, 0.25); font-size: 1rem;
}
.option:nth-child(1) { background: var(--opt-0); }
.option:nth-child(2) { background: var(--opt-1); }
.option:nth-child(3) { background: var(--opt-2); }
.option:nth-child(4) { background: var(--opt-3); }
.option:nth-child(5) { background: var(--opt-4); }
.option:nth-child(6) { background: var(--opt-5); }
.option.tf-true { background: var(--opt-3); }
.option.tf-false { background: var(--opt-0); }
.options.answered .option { cursor: default; }
.options.answered .option:not(.is-correct):not(.is-chosen) { opacity: 0.35; }
.option.is-correct { outline: 4px solid #fff; box-shadow: 0 0 0 8px rgba(46, 204, 113, 0.6); }
.option.is-chosen:not(.is-correct) { outline: 4px solid var(--bad); }

.estimate { display: flex; gap: 12px; max-width: 560px; margin: 0 auto; align-items: stretch; flex-wrap: wrap; }
.estimate .input { flex: 1 1 200px; font-size: 1.6rem; text-align: center; font-weight: 800; }
.estimate .unit { align-self: center; font-size: 1.4rem; font-weight: 700; color: var(--muted); }

.feedback {
  margin-top: 28px; padding: 20px; border-radius: var(--radius); text-align: center;
  animation: pop 0.25s ease;
}
.feedback.good { background: rgba(46, 204, 113, 0.15); border: 2px solid var(--good); }
.feedback.bad { background: rgba(255, 92, 108, 0.15); border: 2px solid var(--bad); }
.feedback .fb-title { font-size: 1.6rem; font-weight: 900; margin-bottom: 4px; }
.feedback .fb-points { font-size: 1.2rem; font-weight: 800; color: var(--accent); }
.feedback .fb-expl { color: var(--muted); margin-top: 8px; }
.feedback .btn { margin-top: 16px; }

@keyframes pop { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.result { text-align: center; }
.result .lb { text-align: left; }
.result .big-score { font-size: clamp(3rem, 10vw, 6rem); font-weight: 900; color: var(--accent); line-height: 1; margin: 8px 0; }
.result .rank { font-size: 1.4rem; font-weight: 700; margin-bottom: 24px; }
.result .actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 24px; }

/* ---------- Leaderboard ---------- */

.lb { width: 100%; border-collapse: collapse; }
.lb th { text-align: left; color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; padding: 8px; }
.lb td { padding: 10px 8px; border-top: 1px solid var(--panel-border); }
.lb td.num, .lb th.num { text-align: right; font-variant-numeric: tabular-nums; }
.lb .rank-cell { width: 48px; font-weight: 900; }
.lb tr.me td { background: rgba(255, 204, 51, 0.15); }
.lb tr.me td:first-child { border-radius: 10px 0 0 10px; }
.lb tr.me td:last-child { border-radius: 0 10px 10px 0; }
.medal { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; color: #1b1400; font-size: 0.9rem; }
.medal.m1 { background: #ffd54a; }
.medal.m2 { background: #d6dbe6; }
.medal.m3 { background: #e0995a; }
.lb-empty { text-align: center; color: var(--muted); padding: 24px; }

.screen-lb { max-width: 1200px; }
.screen-lb .lb td { font-size: clamp(1.1rem, 2.4vw, 2rem); padding: 14px 12px; }
.screen-lb .medal { width: 44px; height: 44px; font-size: 1.2rem; }
.screen-lb .lb tr.fresh td { animation: flash 2s ease; }
@keyframes flash { 0%, 40% { background: rgba(255, 204, 51, 0.35); } 100% { background: transparent; } }

/* ---------- Admin ---------- */

.admin-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 20px; }
.tab { background: transparent; border: 1px solid var(--panel-border); border-radius: 10px; padding: 10px 16px; cursor: pointer; font-weight: 600; }
.tab.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.toolbar .input { width: auto; flex: 1 1 200px; }

.table-wrap { overflow-x: auto; }
.qtable { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.qtable th { text-align: left; color: var(--muted); font-size: 0.8rem; text-transform: uppercase; padding: 8px; white-space: nowrap; }
.qtable td { padding: 10px 8px; border-top: 1px solid var(--panel-border); vertical-align: top; }
.qtable tr.inactive td { opacity: 0.45; }
.qtable .actions { white-space: nowrap; text-align: right; }
.type-badge { font-size: 0.75rem; font-weight: 800; padding: 3px 8px; border-radius: 6px; white-space: nowrap; }
.type-mc { background: rgba(61, 139, 253, 0.25); color: #9cc3ff; }
.type-tf { background: rgba(43, 182, 115, 0.25); color: #8ff0bf; }
.type-estimate { background: rgba(241, 167, 27, 0.25); color: #ffd27f; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 640px) { .grid-2 { grid-template-columns: 1fr; } }

.opt-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.opt-row input[type='radio'] { width: 20px; height: 20px; accent-color: var(--good); flex: none; }
.check { display: flex; align-items: center; gap: 10px; cursor: pointer; margin-bottom: 16px; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }

dialog {
  border: 1px solid var(--panel-border); border-radius: var(--radius); padding: 24px;
  background: var(--bg-2); color: var(--text); width: min(680px, calc(100vw - 32px)); max-height: calc(100vh - 32px);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }

pre.code { background: rgba(0, 0, 0, 0.35); padding: 14px; border-radius: 10px; overflow-x: auto; font-size: 0.85rem; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--bg-2); border: 1px solid var(--panel-border); padding: 12px 20px; border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4); z-index: 100; animation: pop 0.2s ease;
}

.nav-links { display: flex; gap: 16px; justify-content: center; margin-top: 32px; }
.nav-links a { color: var(--muted); text-decoration: none; font-size: 0.9rem; }
.nav-links a:hover { color: var(--text); }

/* ---------- Spielauswahl ---------- */

.game-list { display: flex; flex-direction: column; gap: 12px; }
.game-card {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 20px 24px; border-radius: var(--radius); text-decoration: none; color: var(--text);
  background: rgba(255, 255, 255, 0.08); border: 1px solid var(--panel-border); font-size: 1.25rem;
  transition: background 0.15s, transform 0.08s;
}
.game-card:hover { background: rgba(255, 204, 51, 0.15); border-color: var(--accent); }
.game-card:active { transform: scale(0.99); }
.game-card span { color: var(--accent); font-weight: 900; }

.game-meta { display: flex; gap: 6px 14px; flex-wrap: wrap; color: var(--muted); font-size: 0.9rem; margin-top: 4px; }
.game-row { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: flex-start;
  padding: 16px 0; border-top: 1px solid var(--panel-border); }
.game-row:first-child { border-top: 0; }
.game-row .actions { display: flex; gap: 6px; flex-wrap: wrap; }
.cat-checks { display: flex; flex-wrap: wrap; gap: 4px 18px; }
.cat-checks .check { margin-bottom: 6px; }
code.inline { background: rgba(0, 0, 0, 0.3); padding: 2px 6px; border-radius: 6px; font-size: 0.85rem; }
