:root {
  --bg: #08070d;
  --bg2: #151018;
  --panel: rgba(255,255,255,.08);
  --panel2: rgba(255,255,255,.12);
  --text: #fff;
  --muted: rgba(255,255,255,.72);
  --line: rgba(255,255,255,.14);
  --red: #f20b0b;
  --red2: #ff3b3b;
  --green: #4ee173;
  --yellow: #ffd34d;
  --shadow: 0 24px 70px rgba(0,0,0,.45);
}
body.light {
  --bg: #f6f6fb;
  --bg2: #ffffff;
  --panel: rgba(255,255,255,.82);
  --panel2: rgba(255,255,255,.96);
  --text: #15151d;
  --muted: rgba(21,21,29,.68);
  --line: rgba(18,18,26,.13);
  --shadow: 0 18px 45px rgba(30,30,45,.14);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  background:
    radial-gradient(circle at 8% 6%, rgba(242,11,11,.45), transparent 28%),
    radial-gradient(circle at 92% 18%, rgba(255,67,67,.18), transparent 32%),
    linear-gradient(135deg, var(--bg), var(--bg2) 48%, var(--bg));
  overflow-x: hidden;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .12;
  background-image: linear-gradient(45deg, currentColor 25%, transparent 25%), linear-gradient(-45deg, currentColor 25%, transparent 25%);
  background-size: 70px 70px;
  mask-image: radial-gradient(circle at center, #000, transparent 78%);
}
button, input { font: inherit; }
button { cursor: pointer; touch-action: manipulation; }
a { color: inherit; text-decoration: none; }
.app-shell { width: min(980px, 100%); min-height: 100svh; margin: 0 auto; padding: clamp(10px, 2.2vw, 22px); position: relative; }
.topbar {
  min-height: 60px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: linear-gradient(135deg, rgba(242,11,11,.36), var(--panel));
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}
.back-btn, .mode-btn {
  min-height: 42px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel2);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 950;
  padding: 0 14px;
}
.mode-btn { width: 48px; padding: 0; font-size: 18px; }
.brand-logo { height: clamp(24px, 5vw, 43px); max-width: min(230px, 54vw); object-fit: contain; justify-self: center; filter: drop-shadow(0 10px 24px rgba(242,11,11,.35)); }
.screen { display: none; animation: fadeIn .25s ease both; }
.screen.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.hero-card, .hud-card, .question-card, .result-card {
  border: 1px solid var(--line);
  background: linear-gradient(135deg, rgba(242,11,11,.20), var(--panel));
  border-radius: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}
.hero-card {
  margin-top: 16px;
  padding: clamp(18px, 4vw, 38px);
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: clamp(14px, 4vw, 28px);
}
.hero-icon { width: clamp(72px, 16vw, 142px); filter: drop-shadow(0 18px 34px rgba(242,11,11,.34)); }
.eyebrow { margin: 0 0 6px; color: #fff; background: var(--red); display: inline-flex; padding: 7px 11px; border-radius: 999px; font-size: 12px; font-weight: 1000; text-transform: uppercase; letter-spacing: .1em; }
h1 { margin: 0 0 8px; font-size: clamp(36px, 7vw, 76px); line-height: .95; letter-spacing: -.06em; }
.lead { margin: 0; color: var(--muted); font-size: clamp(15px, 2.2vw, 20px); line-height: 1.45; font-weight: 650; }
.class-grid { margin-top: 16px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.class-card {
  min-height: 112px;
  border: 1px solid var(--line);
  border-radius: 22px;
  color: var(--text);
  background: linear-gradient(135deg, rgba(255,255,255,.10), rgba(242,11,11,.10));
  box-shadow: 0 16px 38px rgba(0,0,0,.18);
  transition: transform .18s ease, border-color .18s ease;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 12px;
}
.class-card:hover { transform: translateY(-4px); border-color: rgba(255,59,59,.8); }
.class-card strong { display: block; font-size: 34px; line-height: 1; }
.class-card span { color: var(--muted); font-weight: 850; font-size: 13px; }
.hud-card { margin-top: 12px; padding: 14px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.hud-card div { background: rgba(0,0,0,.14); border: 1px solid var(--line); border-radius: 16px; padding: 10px; }
.hud-card span { display: block; color: var(--muted); font-weight: 1000; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.hud-card strong { display: block; margin-top: 4px; font-size: clamp(22px, 4vw, 34px); line-height: 1; }
.battle-row { margin: 12px 0; display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; }
.quest-avatar { width: 58px; height: 58px; display: grid; place-items: center; font-size: 30px; border-radius: 18px; background: var(--panel2); border: 1px solid var(--line); box-shadow: 0 10px 24px rgba(0,0,0,.15); }
.power-wrap { height: 16px; background: rgba(255,255,255,.12); border-radius: 999px; overflow: hidden; border: 1px solid var(--line); }
.power-bar { height: 100%; width: 100%; background: linear-gradient(90deg, var(--red), var(--yellow), var(--green)); border-radius: inherit; transition: width .25s ease; }
.timer-box { width: 72px; height: 72px; border-radius: 22px; display: grid; place-items: center; background: var(--panel); border: 1px solid var(--line); }
.timer-box strong { font-size: 28px; line-height: 1; }
.timer-box span { margin-top: -12px; color: var(--muted); font-weight: 900; font-size: 12px; }
.question-card { padding: clamp(14px, 3vw, 24px); text-align: center; position: relative; }
.level-pill { position: absolute; left: 16px; top: 14px; padding: 8px 12px; border-radius: 999px; background: var(--red); color: #fff; font-size: 12px; font-weight: 1000; }
.question-type { margin: 26px 0 8px; color: var(--muted); font-weight: 1000; letter-spacing: .08em; text-transform: uppercase; }
.question-card h2 { margin: 0; font-size: clamp(34px, 9vw, 78px); line-height: 1.05; letter-spacing: -.05em; word-break: break-word; }
.question-help { margin: 8px 0 14px; color: var(--muted); font-weight: 750; }
.answer-input { width: 100%; min-height: 58px; border-radius: 18px; border: 2px solid var(--red); background: rgba(0,0,0,.28); color: var(--text); text-align: center; font-size: clamp(22px, 5vw, 34px); font-weight: 1000; outline: none; }
body.light .answer-input { background: rgba(255,255,255,.72); }
.option-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 10px; }
.option-btn, .letter-btn {
  min-height: 50px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--panel2);
  color: var(--text);
  font-weight: 1000;
  font-size: 18px;
}
.letter-bank { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 12px; }
.letter-btn { min-width: 46px; padding: 0 12px; }
.actions { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin-top: 12px; }
.primary, .secondary {
  min-height: 54px;
  border-radius: 18px;
  border: 1px solid var(--line);
  color: #fff;
  font-weight: 1000;
  font-size: 16px;
}
.primary { background: linear-gradient(135deg, #ff4242, #bd0000); box-shadow: 0 12px 28px rgba(242,11,11,.26); }
.secondary { background: var(--panel2); color: var(--text); }
.feedback { min-height: 42px; margin-top: 10px; text-align: center; color: var(--muted); font-weight: 900; }
.feedback.good { color: var(--green); }
.feedback.bad { color: var(--red2); }
.hidden { display: none !important; }
.result-card { margin-top: 18px; padding: clamp(24px, 5vw, 50px); text-align: center; }
.result-icon { width: clamp(90px, 18vw, 150px); filter: drop-shadow(0 18px 34px rgba(242,11,11,.32)); }
.result-card h2 { margin: 10px 0; font-size: clamp(36px, 7vw, 70px); letter-spacing: -.06em; }
.result-card p { color: var(--muted); font-weight: 750; }
.result-score { font-size: clamp(44px, 12vw, 110px); font-weight: 1000; color: var(--red2); line-height: 1; }
.result-actions { max-width: 520px; margin-left: auto; margin-right: auto; grid-template-columns: 1fr 1fr; }
@media (max-width: 740px) {
  .app-shell { padding: 8px; }
  .topbar { border-radius: 18px; min-height: 54px; padding: 8px; }
  .back-btn { min-height: 38px; padding: 0 10px; font-size: 13px; }
  .mode-btn { width: 40px; min-height: 38px; }
  .hero-card { grid-template-columns: 1fr; text-align: center; padding: 18px; }
  .hero-icon { margin: 0 auto; width: 78px; }
  .class-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .class-card { min-height: 88px; }
  .hud-card { grid-template-columns: repeat(2, 1fr); padding: 10px; gap: 8px; }
  .hud-card div { padding: 8px; }
  .battle-row { gap: 8px; }
  .quest-avatar { width: 46px; height: 46px; font-size: 24px; border-radius: 15px; }
  .timer-box { width: 58px; height: 58px; border-radius: 18px; }
  .timer-box strong { font-size: 24px; }
  .question-card { border-radius: 22px; }
  .question-type { margin-top: 22px; }
  .answer-input { min-height: 52px; }
  .actions { grid-template-columns: 1fr; }
  .primary, .secondary { min-height: 48px; }
}
@media (max-height: 720px) and (max-width: 740px) {
  .hud-card { grid-template-columns: repeat(4, 1fr); }
  .hud-card div { text-align: center; }
  .hud-card strong { font-size: 20px; }
  .hud-card span { font-size: 9px; }
  .battle-row { margin: 8px 0; }
  .question-card h2 { font-size: clamp(30px, 8vw, 54px); }
  .question-help { margin-bottom: 8px; }
}
