:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #14141f;
  --bg-tertiary: #1e1e2e;
  --text-primary: #ffffff;
  --text-secondary: #a0a0b0;
  --text-muted: #606070;
  --accent: #00d4ff;
  --accent-secondary: #00ff88;
  --danger: #ff4466;
  --focus-ring: #00d4ff;
  --focus-glow: rgba(0, 212, 255, 0.4);
  --radius-md: 12px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  width: 600px; height: 600px; overflow: hidden;
  background: #000;
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
#app { width: 100%; height: 100%; position: relative; }
.screen { width: 100%; height: 100%; position: absolute; top: 0; left: 0; display: flex; flex-direction: column; }
.screen.hidden { display: none; }
.focusable { transition: all 0.15s ease; border: 2px solid transparent; cursor: pointer; outline: none; }
.focusable:focus { border-color: var(--focus-ring); box-shadow: 0 0 20px var(--focus-glow); }
.hidden { display: none !important; }

/* ---------- Buttons ---------- */
.btn {
  width: 100%;
  min-height: 88px;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 24px;
  font-weight: 600;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1.2;
}
.btn-primary {
  background: var(--accent);
  color: #001620;
  font-weight: 700;
}
.btn-primary:focus { box-shadow: 0 0 24px rgba(0, 212, 255, 0.7); }
.btn-ghost {
  background: transparent;
  border: 2px solid var(--bg-tertiary);
  color: var(--text-secondary);
  min-height: 64px;
  font-size: 20px;
}
.btn-ghost.focusable:focus { color: var(--text-primary); border-color: var(--focus-ring); }

/* ---------- Home ---------- */
.home-inner {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px 48px;
}
.logo { margin-bottom: 4px; }
.logo svg { display: block; filter: drop-shadow(0 6px 14px rgba(0,0,0,0.6)); }
h1 {
  font-size: 44px;
  font-weight: 800;
  letter-spacing: -0.5px;
}
.subtitle {
  font-size: 20px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.best-chip {
  font-size: 18px;
  font-weight: 600;
  color: var(--accent);
  background: var(--bg-secondary);
  padding: 8px 18px;
  border-radius: 999px;
  margin-bottom: 16px;
}
.home-inner .btn { max-width: 420px; }
.hint {
  text-align: center;
  color: var(--text-muted);
  font-size: 15px;
  padding: 14px;
}

/* ---------- Top bar ---------- */
.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 60px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--bg-tertiary);
}
.bar-side { font-size: 20px; font-weight: 700; color: var(--text-secondary); min-width: 70px; }
.bar-side.score { text-align: right; color: var(--accent-secondary); }
.bar-side .star { color: #ffce00; }
.bar-title { font-size: 22px; font-weight: 700; color: var(--text-primary); }

/* ---------- Flag stage ---------- */
.flag-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  min-height: 0;
}
.flag {
  width: 300px;
  height: 200px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-tertiary);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
}
.flag svg { display: block; width: 100%; height: 100%; animation: pop 0.25s ease; }
@keyframes pop {
  from { opacity: 0; transform: scale(0.94); }
  to   { opacity: 1; transform: scale(1); }
}

/* ---------- Options ---------- */
.options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 0 18px 12px;
}
.opt {
  min-height: 84px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 22px;
  font-weight: 600;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1.15;
  border: 2px solid transparent;
  transition: all 0.15s ease;
  outline: none;
}
.opt.focusable:focus { border-color: var(--focus-ring); box-shadow: 0 0 20px var(--focus-glow); }
.opt.locked { cursor: default; }
.opt.correct {
  background: rgba(0, 255, 136, 0.22);
  border-color: var(--accent-secondary);
  color: #eafff5;
}
.opt.wrong {
  background: rgba(255, 68, 102, 0.22);
  border-color: var(--danger);
  color: #ffe9ee;
}

/* ---------- Foot / Next ---------- */
.foot {
  padding: 0 18px 18px;
  min-height: 18px;
}
.next-btn { width: 100%; }
.study-nav { padding-bottom: 6px; }

/* ---------- Study ---------- */
.study-name {
  text-align: center;
  font-size: 30px;
  font-weight: 800;
  padding: 6px 18px 14px;
  color: var(--accent);
}

/* ---------- Results ---------- */
.results-inner {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px 48px;
}
.grade-badge {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: var(--bg-secondary);
  border: 4px solid var(--accent);
  display: flex;
  align-items: baseline;
  justify-content: center;
  box-shadow: 0 0 40px rgba(0, 212, 255, 0.3);
  margin-bottom: 6px;
}
.grade-num { font-size: 84px; font-weight: 800; color: var(--text-primary); }
.grade-total { font-size: 34px; font-weight: 700; color: var(--text-secondary); }
.grade-label { font-size: 30px; font-weight: 800; }
.results-inner .btn { max-width: 420px; }
