:root {
  --bg-0: #06090c;
  --bg-1: #0b0f14;
  --bg-2: #141b24;
  --panel: #1a222c;
  --panel-border: rgba(255,255,255,.08);
  --ink: #eef2f6;
  --ink-dim: #90a0af;
  --gold: #cda449;
  --gold-soft: #e6c374;
  --gold-dim: #8a6d33;
  --correct: #3fa06d;
  --correct-dim: #1f5c3c;
  --wrong: #b1554f;
  --wrong-dim: #6b322e;
  --radius: 20px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  margin: 0;
  overscroll-behavior: none;
  touch-action: manipulation;
}

body {
  font-family: "Poppins", system-ui, -apple-system, "Segoe UI", sans-serif;
  background:
    radial-gradient(ellipse 70% 50% at 50% 30%, #1c2734 0%, transparent 60%),
    linear-gradient(180deg, var(--bg-1) 0%, var(--bg-0) 100%);
  color: var(--ink);
  user-select: none;
  overflow: hidden;
}

button { font-family: inherit; }

.screen {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  padding: calc(16px + var(--safe-top)) 16px calc(16px + var(--safe-bottom));
  overflow-y: auto;
}
.screen.active { display: flex; }

/* ---------- Start screen ---------- */
.start-content {
  margin: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  text-align: center;
}
.brand-logo {
  width: min(30vw, 128px);
  filter: drop-shadow(0 10px 16px rgba(0,0,0,.45));
  animation: roll 7s linear infinite;
}
@keyframes roll {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
  .brand-logo { animation: none; }
}
.start-content h1 {
  font-size: clamp(2rem, 8vw, 3rem);
  font-weight: 800;
  margin: 0;
  letter-spacing: .01em;
  color: var(--ink);
}
.subtitle {
  margin: 0 0 10px;
  font-size: clamp(1rem, 3.6vw, 1.25rem);
  font-weight: 400;
  color: var(--ink-dim);
}

.big-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-size: clamp(1.15rem, 4.4vw, 1.45rem);
  font-weight: 700;
  color: #241a08;
  background: linear-gradient(180deg, var(--gold-soft), var(--gold));
  border: none;
  border-radius: 999px;
  padding: 17px 42px;
  box-shadow: 0 10px 24px rgba(0,0,0,.4), inset 0 1px 0 rgba(255,255,255,.35);
  cursor: pointer;
  min-width: 260px;
}
.big-button:active { transform: translateY(2px); box-shadow: 0 5px 14px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.3); }
.big-button.secondary {
  color: var(--ink);
  background: rgba(255,255,255,.05);
  border: 1px solid var(--panel-border);
  box-shadow: none;
}
.big-button.secondary:active { transform: translateY(2px); background: rgba(255,255,255,.08); }
.big-button-icon { font-size: 1.15em; line-height: 1; display: flex; align-items: center; justify-content: center; }

.icon-button svg, .big-button-icon svg, .speak-btn svg, .inline-icon svg, .trophy svg {
  width: 1em;
  height: 1em;
  display: block;
}
.inline-icon {
  display: inline-flex;
  width: .95em;
  height: .95em;
  vertical-align: -0.15em;
  color: var(--gold-soft);
}

.pulse { animation: glow 2.4s ease-in-out infinite; }
@keyframes glow {
  0%, 100% { box-shadow: 0 10px 24px rgba(0,0,0,.4), inset 0 1px 0 rgba(255,255,255,.35), 0 0 0 rgba(205,164,73,0); }
  50% { box-shadow: 0 10px 26px rgba(0,0,0,.4), inset 0 1px 0 rgba(255,255,255,.35), 0 0 24px rgba(205,164,73,.55); }
}

/* ---------- Liga-Auswahl ---------- */
.mode-content {
  margin: auto;
  width: min(480px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}
.mode-title {
  color: var(--ink);
  font-size: clamp(1.4rem, 5vw, 1.8rem);
  margin: 0;
}
.mode-grid {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.mode-tile {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  padding: 14px 18px;
  cursor: pointer;
  text-align: left;
  transition: transform .1s, border-color .2s;
}
.mode-tile:not(:disabled):active { transform: translateY(2px); }
.mode-tile:not(:disabled) { border-color: var(--gold-dim); box-shadow: 0 0 0 1px rgba(205,164,73,.25); }
.mode-tile img {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  object-fit: cover;
  object-position: top center;
  background: #fff;
  flex-shrink: 0;
}
.mode-label {
  font-weight: 700;
  font-size: 1.08rem;
  color: var(--ink);
}
.mode-badge {
  margin-left: auto;
  font-size: .68rem;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.07);
  color: var(--ink-dim);
  white-space: nowrap;
}
.mode-tile:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.icon-button {
  background: rgba(255,255,255,.06);
  border: 1px solid var(--panel-border);
  border-radius: 50%;
  width: 50px;
  height: 50px;
  font-size: 1.35rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--ink);
}
.icon-button:active { transform: scale(.92); background: rgba(255,255,255,.12); }
.icon-button.large { width: 72px; height: 72px; font-size: 1.9rem; }
.icon-button.corner { position: absolute; top: calc(14px + var(--safe-top)); right: 14px; opacity: .8; }

/* ---------- Settings ---------- */
.panel {
  margin: auto;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 24px;
  width: min(420px, 100%);
  box-shadow: 0 20px 50px rgba(0,0,0,.5);
}
.panel h2 { margin-top: 0; text-align: center; font-weight: 700; }
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 0;
  border-bottom: 1px solid var(--panel-border);
  font-size: 1rem;
  color: var(--ink);
}
.setting-row select, .setting-row input[type="range"] { width: 150px; }
.setting-row select {
  background: var(--bg-2);
  color: var(--ink);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 6px 8px;
}
.setting-row input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--gold); }
.setting-row input[type="range"] { accent-color: var(--gold); }
.text-button {
  display: block;
  margin: 16px auto 6px;
  background: none;
  border: none;
  color: var(--wrong);
  opacity: .85;
  font-size: .9rem;
  text-decoration: underline;
  cursor: pointer;
}

/* ---------- Quiz header ---------- */
.quiz-header {
  width: 100%;
  max-width: 640px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.progress-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  justify-content: center;
  max-width: 60%;
}
.progress-dots .dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: rgba(255,255,255,.15);
}
.progress-dots .dot.done { background: var(--gold); box-shadow: 0 0 6px rgba(205,164,73,.7); }

/* ---------- Crest ---------- */
.crest-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  position: relative;
}
.crest-stage::before {
  content: "";
  position: absolute;
  width: min(70vw, 380px);
  height: min(70vw, 380px);
  background: radial-gradient(circle, rgba(205,164,73,.16) 0%, transparent 68%);
  pointer-events: none;
}
.crest {
  position: relative;
  width: min(44vw, 240px);
  height: min(44vw, 240px);
  border-radius: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: clamp(1.8rem, 9vw, 3rem);
  color: #fff;
  text-shadow: 0 2px 6px rgba(0,0,0,.4);
  box-shadow: 0 18px 40px rgba(0,0,0,.55), inset 0 0 0 1px rgba(255,255,255,.15);
  background-size: cover;
  background-position: center;
  transition: transform .25s ease;
}
.crest.big { width: min(58vw, 280px); height: min(58vw, 280px); }
.crest.bounce { animation: bounce .6s ease; }
@keyframes bounce {
  0% { transform: scale(1); }
  35% { transform: scale(1.1); }
  60% { transform: scale(.97); }
  100% { transform: scale(1); }
}
.crest.shake { animation: shake .4s ease; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-7px); }
  75% { transform: translateX(7px); }
}

.hint-text {
  color: var(--ink-dim);
  font-size: .95rem;
  margin: 6px 0 14px;
  text-align: center;
}

.facts-panel {
  width: 100%;
  max-width: 520px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 14px 18px;
  margin: 10px 0;
  text-align: center;
}
.facts-text {
  margin: 0 0 10px;
  color: var(--ink);
  font-size: .95rem;
  line-height: 1.45;
}
.facts-replay {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,.06);
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: .85rem;
  font-weight: 600;
  color: var(--gold-soft);
  cursor: pointer;
}
.facts-replay:active { transform: translateY(1px); }
.facts-replay .inline-icon { color: inherit; }

/* ---------- Choices ---------- */
.choices {
  width: 100%;
  max-width: 560px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  padding-bottom: 8px;
}
@media (min-width: 560px) {
  .choices { grid-template-columns: 1fr 1fr; }
}
.choice-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
  width: 100%;
}
.choice-btn {
  flex: 1;
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 16px 16px;
  font-size: clamp(1.02rem, 3.6vw, 1.2rem);
  font-weight: 600;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: background .2s, border-color .2s, transform .1s;
}
.choice-btn:active { transform: translateY(2px); }
.choice-btn.correct { background: linear-gradient(180deg, var(--correct), var(--correct-dim)); border-color: transparent; color: #fff; }
.choice-btn.wrong { background: linear-gradient(180deg, var(--wrong), var(--wrong-dim)); border-color: transparent; color: #fff; }
.choice-btn:disabled { pointer-events: none; }

.speak-btn {
  flex: 0 0 auto;
  width: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,.05);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  font-size: 1.25rem;
  color: var(--gold-soft);
  cursor: pointer;
}
.speak-btn:active { transform: scale(.92); background: rgba(255,255,255,.12); }

/* ---------- Feedback overlay ---------- */
.feedback-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.confetti {
  position: absolute;
  top: -20px;
  width: 9px; height: 14px;
  border-radius: 2px;
  animation: fall linear forwards;
}
@keyframes fall {
  to { transform: translateY(115vh) rotate(540deg); opacity: .9; }
}

/* ---------- Discover mode ---------- */
.discover-counter { color: var(--ink-dim); font-weight: 600; }
.discover-name {
  margin-top: 18px;
  font-size: clamp(1.3rem, 5.6vw, 2rem);
  font-weight: 700;
  color: var(--ink);
  text-align: center;
  min-height: 1.4em;
}
.discover-league {
  margin-top: 2px;
  font-size: .82rem;
  font-weight: 600;
  color: var(--gold-soft);
  text-align: center;
  min-height: 1.2em;
  letter-spacing: .02em;
}
.discover-nav {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 22px;
  padding-top: 20px;
}

.league-filter {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  flex-wrap: wrap;
  justify-content: center;
}
.filter-btn {
  background: rgba(255,255,255,.05);
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: .85rem;
  font-weight: 600;
  color: var(--ink-dim);
  cursor: pointer;
}
.filter-btn.active {
  background: linear-gradient(180deg, var(--gold-soft), var(--gold));
  border-color: transparent;
  color: #241a08;
}
.filter-btn:active { transform: translateY(1px); }

/* ---------- Complete screen ---------- */
.trophy { font-size: 4.4rem; filter: drop-shadow(0 8px 18px rgba(205,164,73,.35)); }
