/* ===========================================================================
   Quizarena — Theme
   Dunkel, elegant, EINE Akzentfarbe (Amber). Display-Font: Fraunces. Body: Inter.
   =========================================================================== */

:root {
  --bg:        #0f0f15;
  --bg-soft:   #16161f;
  --surface:   #1a1a25;
  --surface-2: #20202d;
  --line:      #2b2b3a;
  --text:      #ececf3;
  --muted:     #9a9aad;
  --muted-2:   #6f6f82;

  --accent:    #ffb43f;   /* Amber */
  --accent-2:  #ff8a3d;   /* warmer Verlaufspartner */
  --accent-ink:#1a1205;   /* Text auf Akzentfläche */

  --good:      #4fd08a;
  --bad:       #ff5d6c;

  --radius:    18px;
  --radius-sm: 12px;
  --shadow:    0 24px 60px -20px rgba(0,0,0,.65);
  --maxw:      720px;

  --display: "Fraunces", Georgia, "Times New Roman", serif;
  --body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Hintergrund-Lichter */
.bg-orbs { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.bg-orbs span {
  position: absolute; border-radius: 50%; filter: blur(90px); opacity: .28;
}
.bg-orbs span:nth-child(1){ width: 460px; height: 460px; background: var(--accent);
  top: -160px; right: -120px; }
.bg-orbs span:nth-child(2){ width: 380px; height: 380px; background: #6d5cff;
  bottom: -140px; left: -120px; opacity: .22; }
.bg-orbs span:nth-child(3){ width: 300px; height: 300px; background: var(--accent-2);
  top: 40%; left: 55%; opacity: .12; }

/* Header */
.site-header {
  max-width: var(--maxw); margin: 0 auto; padding: 22px 20px 8px;
  display: flex; align-items: center; justify-content: center;
}
.brand { display: flex; align-items: center; gap: 10px; letter-spacing: .3px; }
.brand-mark { color: var(--accent); font-size: 1.1rem; transform: translateY(1px); }
.brand-name { font-weight: 600; font-size: 1.15rem; }
.brand-name em { color: var(--accent); font-style: normal; }

/* Layout */
#app { max-width: var(--maxw); margin: 0 auto; padding: 12px 20px 80px; position: relative; }

.screen { display: none; animation: screen-in .45s cubic-bezier(.2,.7,.2,1); }
.screen.is-active { display: block; }
@keyframes screen-in {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

.card {
  background: linear-gradient(180deg, var(--surface), var(--bg-soft));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: var(--shadow);
}

/* ---------- Hero / Start ---------- */
.hero { text-align: center; padding: 26px 4px 30px; }
.eyebrow {
  text-transform: uppercase; letter-spacing: .28em; font-size: .72rem;
  color: var(--accent); font-weight: 600; margin: 0 0 14px;
}
.display {
  font-family: var(--display);
  font-weight: 900; font-size: clamp(2.3rem, 7vw, 3.6rem);
  line-height: 1.02; margin: 0 0 16px; letter-spacing: -.5px;
}
.display-sm { font-family: var(--display); font-weight: 700; font-size: 1.6rem; margin: 0; }
.lead { color: var(--muted); max-width: 48ch; margin: 0 auto; font-size: 1.02rem; }

.setup { margin-top: 8px; }
.field { border: 0; padding: 0; margin: 0 0 22px; }
.field legend {
  font-size: .78rem; text-transform: uppercase; letter-spacing: .14em;
  color: var(--muted); padding: 0; margin-bottom: 12px;
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 22px; }
.field-timer { grid-column: 1 / -1; }

/* Chips (Kategorien) */
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  appearance: none; cursor: pointer;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 10px 16px; font: inherit; font-size: .94rem; font-weight: 500;
  display: inline-flex; align-items: center; gap: 8px;
  transition: transform .15s, border-color .2s, background .2s, color .2s;
}
.chip:hover { transform: translateY(-2px); border-color: var(--accent); }
.chip .count {
  font-size: .76rem; color: var(--muted-2);
  background: rgba(255,255,255,.05); padding: 1px 8px; border-radius: 999px;
}
.chip.is-active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--accent-ink); border-color: transparent; font-weight: 600;
}
.chip.is-active .count { color: rgba(26,18,5,.7); background: rgba(0,0,0,.08); }
.chip.chip-mix { border-style: dashed; }

/* Segmented control */
.seg {
  display: inline-flex; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 12px; padding: 4px; gap: 2px; width: 100%;
}
.seg-btn {
  flex: 1; appearance: none; cursor: pointer; border: 0; background: transparent;
  color: var(--muted); font: inherit; font-weight: 600; font-size: .9rem;
  padding: 9px 8px; border-radius: 9px; transition: color .2s, background .2s;
}
.seg-btn:hover { color: var(--text); }
.seg-btn.is-active { background: var(--accent); color: var(--accent-ink); }

/* Switch */
.switch { display: inline-flex; align-items: center; gap: 12px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
  width: 46px; height: 26px; border-radius: 999px; background: var(--surface-2);
  border: 1px solid var(--line); position: relative; transition: background .2s;
}
.switch-thumb {
  position: absolute; top: 2px; left: 2px; width: 20px; height: 20px;
  border-radius: 50%; background: var(--muted); transition: transform .2s, background .2s;
}
.switch input:checked + .switch-track { background: rgba(255,180,63,.25); border-color: var(--accent); }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(20px); background: var(--accent); }
.switch-label { color: var(--muted); font-size: .92rem; }

/* Buttons */
.btn {
  appearance: none; cursor: pointer; font: inherit; font-weight: 600;
  border-radius: 12px; border: 1px solid transparent; padding: 13px 20px;
  transition: transform .15s, box-shadow .2s, background .2s, border-color .2s, opacity .2s;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--accent-ink); box-shadow: 0 12px 30px -10px rgba(255,150,60,.6);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 18px 40px -12px rgba(255,150,60,.7); }
.btn-lg { width: 100%; padding: 16px; font-size: 1.05rem; margin-top: 6px; }
.btn-ghost {
  background: var(--surface-2); color: var(--text); border-color: var(--line);
}
.btn-ghost:hover { border-color: var(--accent); transform: translateY(-2px); }
.btn-sm { padding: 8px 14px; font-size: .88rem; }
.arrow { display: inline-block; transition: transform .2s; }
.btn:hover .arrow { transform: translateX(4px); }

.link-btn {
  display: block; margin: 22px auto 0; background: none; border: 0; cursor: pointer;
  color: var(--muted); font: inherit; font-weight: 600; padding: 8px;
  transition: color .2s;
}
.link-btn:hover { color: var(--accent); }

.start-hint {
  margin-top: 14px; text-align: center; color: var(--bad); font-size: .92rem;
}
.muted { color: var(--muted); }

/* ---------- Quiz ---------- */
.quiz-top { display: flex; align-items: center; gap: 16px; padding: 6px 0 22px; }
.icon-btn {
  appearance: none; cursor: pointer; width: 38px; height: 38px; flex: none;
  border-radius: 50%; border: 1px solid var(--line); background: var(--surface-2);
  color: var(--muted); font-size: 1rem; transition: color .2s, border-color .2s;
}
.icon-btn:hover { color: var(--bad); border-color: var(--bad); }

.progress { flex: 1; display: flex; align-items: center; gap: 12px; }
.progress-bar { flex: 1; height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.progress-bar span {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 999px; transition: width .5s cubic-bezier(.2,.7,.2,1);
}
.progress-text { font-size: .82rem; color: var(--muted); font-weight: 600; white-space: nowrap; }

/* Timer-Ring */
.timer-ring { position: relative; width: 44px; height: 44px; flex: none; }
.timer-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.timer-ring .ring-bg { fill: none; stroke: var(--surface-2); stroke-width: 4; }
.timer-ring .ring-fg {
  fill: none; stroke: var(--accent); stroke-width: 4; stroke-linecap: round;
  stroke-dasharray: 106.8; stroke-dashoffset: 0; transition: stroke-dashoffset 1s linear, stroke .3s;
}
.timer-ring.is-low .ring-fg { stroke: var(--bad); }
.timer-ring span {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: .82rem; font-weight: 700;
}

.q-meta { display: flex; gap: 8px; margin-bottom: 14px; }
.tag {
  font-size: .74rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  padding: 5px 11px; border-radius: 999px;
  background: rgba(255,180,63,.14); color: var(--accent);
}
.tag-ghost { background: var(--surface-2); color: var(--muted); }

.q-graphic { margin: 4px 0 20px; display: none; }
.q-graphic.has-graphic { display: block; }

.map-wrap {
  background: radial-gradient(circle at 50% 30%, #11203a, #0b1322);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 10px; overflow: hidden;
}
.map-wrap svg { width: 100%; height: auto; display: block; max-height: 340px; }
.map-wrap .ocean { fill: transparent; }
.map-wrap .graticule line { stroke: rgba(255,255,255,.05); stroke-width: .3; }
.map-wrap .land path { fill: #2c3b52; stroke: #46597a; stroke-width: .3; }
.map-wrap .land path.country-highlight { fill: var(--accent); stroke: #fff; }
.pin-halo { fill: var(--accent); opacity: .35; transform-box: fill-box; transform-origin: center;
  animation: pin-pulse 1.6s ease-out infinite; }
.pin-dot { fill: var(--accent); stroke: #fff; stroke-width: .4; }
@keyframes pin-pulse {
  0%   { transform: scale(.5); opacity: .55; }
  70%  { transform: scale(1.7); opacity: 0; }
  100% { transform: scale(1.7); opacity: 0; }
}

.flag-display {
  font-size: clamp(5rem, 26vw, 9rem); line-height: 1; text-align: center;
  filter: drop-shadow(0 14px 26px rgba(0,0,0,.5));
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 26px 10px;
  animation: flag-pop .5s cubic-bezier(.2,.9,.2,1);
}
@keyframes flag-pop { from { transform: scale(.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.chart-wrap {
  position: relative; height: 280px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 14px;
}

.q-text {
  font-family: var(--display); font-weight: 700;
  font-size: clamp(1.45rem, 4.5vw, 2rem); line-height: 1.18;
  margin: 0 0 22px; letter-spacing: -.3px;
}

/* Optionen */
.options { display: grid; gap: 12px; }
.option {
  appearance: none; cursor: pointer; text-align: left; font: inherit; font-size: 1.02rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 16px 18px; color: var(--text);
  display: flex; align-items: center; gap: 14px;
  transition: transform .12s, border-color .2s, background .2s;
}
.option:hover:not(:disabled) { transform: translateY(-2px); border-color: var(--accent); }
.option:disabled { cursor: default; }
.option .key {
  flex: none; width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center;
  background: var(--surface-2); color: var(--muted); font-weight: 700; font-size: .85rem;
  transition: background .2s, color .2s;
}
.option.is-correct {
  border-color: var(--good); background: rgba(79,208,138,.12);
  animation: correct-flash .5s ease;
}
.option.is-correct .key { background: var(--good); color: #07140c; }
.option.is-wrong {
  border-color: var(--bad); background: rgba(255,93,108,.1);
  animation: shake .4s ease;
}
.option.is-wrong .key { background: var(--bad); color: #fff; }
.option.is-dimmed { opacity: .45; }
@keyframes correct-flash {
  0% { transform: scale(1); } 40% { transform: scale(1.02); } 100% { transform: scale(1); }
}
@keyframes shake {
  0%,100% { transform: translateX(0); } 20% { transform: translateX(-7px); }
  40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(3px); }
}

/* Feedback */
.feedback {
  margin-top: 20px; padding: 18px 20px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--line);
  animation: feedback-in .35s cubic-bezier(.2,.8,.2,1);
}
@keyframes feedback-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.feedback-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.feedback-icon { font-size: 1.3rem; }
.feedback-title { font-weight: 700; font-size: 1.1rem; }
.feedback.good .feedback-title { color: var(--good); }
.feedback.bad .feedback-title { color: var(--bad); }
.feedback-points { margin-left: auto; font-weight: 700; color: var(--accent); }
.feedback-explain { color: var(--muted); margin: 0 0 16px; }

/* Klickbares Feedback + Auto-Advance-Leiste */
.feedback[role="button"] { cursor: pointer; }
.feedback[role="button"]:hover { border-color: var(--line); }
.feedback:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.auto-advance { display: flex; align-items: center; gap: 12px; }
.auto-bar {
  flex: 1; height: 5px; border-radius: 999px; background: var(--surface-2); overflow: hidden;
}
.auto-bar span {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 999px;
}
.feedback.bad .auto-bar span { background: linear-gradient(90deg, var(--bad), #ff8a93); }
.auto-hint {
  font-size: .78rem; color: var(--muted-2); white-space: nowrap; user-select: none;
}

/* ---------- Ergebnis ---------- */
.result { text-align: center; }
.score-ring { position: relative; width: 168px; height: 168px; margin: 18px auto 10px; }
.score-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.score-ring .ring-bg { fill: none; stroke: var(--surface-2); stroke-width: 9; }
.score-ring .ring-fg {
  fill: none; stroke: url(#g) var(--accent); stroke: var(--accent); stroke-width: 9; stroke-linecap: round;
  stroke-dasharray: 326.7; stroke-dashoffset: 326.7;
  transition: stroke-dashoffset 1.1s cubic-bezier(.2,.7,.2,1);
}
.score-ring-num { position: absolute; inset: 0; display: grid; place-content: center; gap: 2px; }
.score-ring-num strong { font-family: var(--display); font-size: 2.6rem; font-weight: 900; line-height: 1; }
.score-ring-num span { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; }
.result-summary { color: var(--muted); margin: 6px 0 22px; }

.save-form { display: flex; gap: 10px; margin-bottom: 8px; }
input[type="text"] {
  flex: 1; font: inherit; padding: 13px 16px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text);
  transition: border-color .2s;
}
input[type="text"]:focus { outline: none; border-color: var(--accent); }
input[type="text"]::placeholder { color: var(--muted-2); }
.save-status { color: var(--good); font-size: .92rem; margin: 6px 0 0; }
.save-status.err { color: var(--bad); }
.result-actions { display: flex; gap: 12px; margin-top: 22px; }
.result-actions .btn { flex: 1; }

/* ---------- Bestenliste ---------- */
.scores-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.chips-sm { margin-bottom: 18px; }
.chips-sm .chip { padding: 7px 13px; font-size: .85rem; }
.scores-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; counter-reset: rank; }
.scores-list li {
  display: flex; align-items: center; gap: 14px; padding: 12px 14px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.scores-list li .rank {
  flex: none; width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
  font-weight: 700; background: var(--surface); color: var(--muted);
}
.scores-list li:nth-child(1) .rank { background: linear-gradient(135deg,#ffd76a,#ffb43f); color: #2a1d04; }
.scores-list li:nth-child(2) .rank { background: #c9cdd6; color: #20242c; }
.scores-list li:nth-child(3) .rank { background: #d8915a; color: #2a1605; }
.scores-list .s-name { font-weight: 600; }
.scores-list .s-meta { font-size: .76rem; color: var(--muted-2); }
.scores-list .s-right { margin-left: auto; text-align: right; }
.scores-list .s-score { font-weight: 700; color: var(--accent); font-size: 1.05rem; }
.scores-empty { color: var(--muted); text-align: center; padding: 24px; }

/* ---------- Überblick / Review ---------- */
.btn-review { width: 100%; margin: 18px 0 4px; }
.review { text-align: left; }
.review-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 12px; }
.review-item {
  background: var(--surface-2); border: 1px solid var(--line);
  border-left-width: 4px; border-radius: var(--radius-sm); padding: 14px 16px;
}
.review-item.is-right { border-left-color: var(--good); }
.review-item.is-wrong { border-left-color: var(--bad); }
.rv-head { display: flex; gap: 10px; align-items: baseline; margin-bottom: 8px; }
.rv-badge {
  flex: none; width: 24px; height: 24px; border-radius: 7px; display: grid; place-items: center;
  font-weight: 700; font-size: .8rem; color: #07140c;
}
.is-right .rv-badge { background: var(--good); }
.is-wrong .rv-badge { background: var(--bad); color: #fff; }
.rv-q { font-weight: 600; line-height: 1.35; }
.rv-line { margin: 2px 0; font-size: .94rem; }
.rv-ok strong { color: var(--good); }
.rv-bad strong { color: var(--bad); }
.rv-explain {
  margin: 8px 0 0; padding-top: 8px; border-top: 1px solid var(--line);
  color: var(--muted); font-size: .9rem;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ---------- Responsive ---------- */
@media (max-width: 560px) {
  .field-row { grid-template-columns: 1fr; }
  .save-form { flex-direction: column; }
  .result-actions { flex-direction: column; }
  #app { padding: 8px 16px 64px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
