*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f0c29;
  --bg2: #1a1a3e;
  --accent: #f7b731;
  --accent2: #fc5c65;
  --green: #20bf6b;
  --text: #e8e8f0;
  --text-muted: #9999bb;
  --radius: 14px;
}

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: linear-gradient(135deg, var(--bg) 0%, var(--bg2) 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  overflow: hidden;
}

/* ── SCREENS ─────────────────────────────────── */

.screen {
  display: none;
  width: 100%;
  max-width: 780px;
  padding: 16px;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  animation: fadeIn .35s ease;
}

.screen.active { display: flex; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── START / END SCREEN CONTENT ──────────────── */

.screen-content {
  text-align: center;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 24px;
  padding: 48px 40px;
  max-width: 520px;
  width: 100%;
  backdrop-filter: blur(8px);
}

.train-icon, .result-icon {
  font-size: 64px;
  margin-bottom: 12px;
  display: block;
  animation: bounce 1.2s infinite alternate ease-in-out;
}

@keyframes bounce {
  from { transform: translateY(0); }
  to   { transform: translateY(-8px); }
}

h1 {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--accent);
  margin-bottom: 12px;
  text-shadow: 0 0 20px rgba(247,183,49,.4);
}

h2 {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 12px;
}

p {
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 20px;
  font-size: 1rem;
}

p strong { color: var(--text); }

.categories {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 28px;
}

.categories span {
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 20px;
  padding: 4px 14px;
  font-size: .85rem;
  color: var(--text-muted);
}

/* ── BUTTONS ─────────────────────────────────── */

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #f39c12);
  color: #1a1a0e;
  font-size: 1.1rem;
  font-weight: 700;
  border: none;
  border-radius: var(--radius);
  padding: 14px 40px;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
  box-shadow: 0 4px 20px rgba(247,183,49,.35);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(247,183,49,.5);
}

.btn-primary:active { transform: translateY(0); }

/* ── GAME SCREEN ─────────────────────────────── */

#progress-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 720px;
}

.progress-label {
  font-size: .8rem;
  color: var(--text-muted);
  white-space: nowrap;
}

#progress-dots {
  display: flex;
  gap: 6px;
}

.progress-dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(255,255,255,.12);
  border: 2px solid rgba(255,255,255,.2);
  transition: background .3s, border-color .3s, transform .3s;
  font-size: .65rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: transparent;
}

.progress-dot.done {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
  transform: scale(1.15);
}

.progress-dot.current {
  border-color: var(--accent);
  box-shadow: 0 0 8px rgba(247,183,49,.6);
}

/* ── CANVAS ──────────────────────────────────── */

#canvas-wrapper {
  border-radius: 16px;
  overflow: hidden;
  border: 2px solid rgba(255,255,255,.1);
  box-shadow: 0 8px 32px rgba(0,0,0,.5);
  width: 100%;
  max-width: 720px;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: auto;
}

/* ── QUESTION BOX ────────────────────────────── */

#question-box {
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: var(--radius);
  padding: 20px 24px;
  width: 100%;
  max-width: 720px;
  text-align: center;
}

#question-number {
  font-size: .8rem;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: .08em;
}

#question-text {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 16px;
  min-height: 2em;
}

#answer-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.btn-answer {
  flex: 1;
  max-width: 280px;
  padding: 13px 20px;
  border-radius: var(--radius);
  border: 2px solid rgba(255,255,255,.15);
  background: rgba(255,255,255,.07);
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .12s;
}

.btn-answer:hover:not(:disabled) {
  background: rgba(255,255,255,.14);
  border-color: var(--accent);
  transform: translateY(-2px);
}

.btn-answer:active:not(:disabled) { transform: translateY(0); }

.btn-answer:disabled { opacity: .45; cursor: default; }

.btn-answer.correct-flash {
  background: rgba(32,191,107,.3);
  border-color: var(--green);
  color: var(--green);
}

.btn-answer.wrong-flash {
  background: rgba(252,92,101,.3);
  border-color: var(--accent2);
  color: var(--accent2);
}

/* ── GAMEOVER EXTRAS ─────────────────────────── */

#gameover-score {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 20px;
}

#gameover-msg {
  margin-bottom: 8px;
}

/* ── SHAKE ───────────────────────────────────── */

@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%      { transform: translateX(-6px); }
  40%      { transform: translateX(6px); }
  60%      { transform: translateX(-4px); }
  80%      { transform: translateX(4px); }
}

.shake { animation: shake .4s ease; }
