:root {
  --bg: #080d22;
  --panel: rgba(16, 25, 57, 0.92);
  --panel-strong: #151f42;
  --line: #344675;
  --text: #fff9ec;
  --muted: #b7c3e4;
  --gold: #ffd166;
  --cyan: #56d7ff;
  --violet: #7c5cfc;
  --pink: #ff6b8a;
  --mint: #58e6a9;
  --danger: #ff717d;
  color-scheme: dark;
  font-family: "DM Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; color: var(--text); background: var(--bg); overflow-x: hidden; }
button, a { font: inherit; }
a { color: inherit; text-decoration: none; }
button { color: inherit; }
.is-hidden { display: none !important; }

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background:
    linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    radial-gradient(circle at 50% 38%, #1c1754 0, var(--bg) 54%);
  background-size: 44px 44px, 44px 44px, auto;
}
.glow { position: absolute; border-radius: 50%; filter: blur(65px); opacity: .22; }
.glow-a { width: 38rem; height: 38rem; left: -18rem; top: -18rem; background: var(--cyan); }
.glow-b { width: 42rem; height: 42rem; right: -20rem; bottom: -22rem; background: var(--violet); }
.constellation { position: absolute; color: var(--gold); opacity: .7; text-shadow: 0 0 16px var(--gold); }
.c1 { top: 17%; left: 8%; }.c2 { top: 29%; right: 12%; }.c3 { bottom: 16%; left: 18%; }

.demo-nav {
  width: min(1160px, calc(100% - 40px));
  height: 84px;
  margin-inline: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand { display: inline-flex; align-items: center; gap: 11px; font: 900 20px Fraunces, serif; }
.brand img { width: 42px; height: 42px; border-radius: 12px; box-shadow: 0 8px 24px rgba(124, 92, 252, .38); }
.nav-actions { display: flex; align-items: center; gap: 10px; }
.preview-chip, .level-chip {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid rgba(86, 215, 255, .34);
  border-radius: 999px;
  color: var(--cyan);
  background: rgba(86, 215, 255, .08);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .12em;
}
.language-button, .close-button {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(21, 31, 66, .88);
  cursor: pointer;
  font-weight: 800;
}
.close-button { font-size: 26px; font-weight: 400; }
.ranking-nav-button {
  min-height: 42px;
  padding: 0 15px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid rgba(255, 209, 102, .35);
  border-radius: 999px;
  color: var(--gold);
  background: rgba(255, 209, 102, .08);
  cursor: pointer;
  font-weight: 800;
}
.ranking-nav-button:hover, .ranking-nav-button:focus-visible {
  border-color: var(--gold);
  outline: 3px solid rgba(255, 209, 102, .14);
}
.language-button:hover, .close-button:hover,
.language-button:focus-visible, .close-button:focus-visible { border-color: var(--cyan); outline: 3px solid rgba(86, 215, 255, .15); }

.demo-shell {
  width: min(820px, calc(100% - 32px));
  min-height: calc(100vh - 154px);
  margin-inline: auto;
  display: grid;
  place-items: center;
  padding: 32px 0 54px;
}
.panel {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 42px;
  background: linear-gradient(145deg, rgba(21, 31, 66, .96), rgba(13, 19, 45, .96));
  box-shadow: 0 36px 90px rgba(0, 0, 0, .38), inset 0 1px rgba(255, 255, 255, .04);
}
.start-view, .result-view {
  min-height: 640px;
  padding: 54px clamp(24px, 7vw, 72px);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.portal { width: 150px; height: 150px; position: relative; display: grid; place-items: center; margin-bottom: 20px; }
.portal img { width: 88px; height: 88px; border-radius: 24px; box-shadow: 0 18px 44px rgba(124, 92, 252, .48); transform: rotate(-4deg); }
.portal-orbit {
  position: absolute;
  inset: 0;
  border: 1px solid rgba(255, 209, 102, .38);
  border-radius: 48% 52% 50% 50%;
  animation: orbit 12s linear infinite;
}
.portal-orbit::before, .portal-orbit::after {
  content: "";
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 14px var(--gold);
}
.portal-orbit::before { top: 9px; left: 28px; }
.portal-orbit::after { right: 8px; bottom: 34px; background: var(--cyan); box-shadow: 0 0 14px var(--cyan); }
.portal-orbit-inner { inset: 16px; border-color: rgba(86, 215, 255, .34); animation-direction: reverse; animation-duration: 9s; }
@keyframes orbit { to { transform: rotate(360deg); } }

h1 { margin: 0; font-family: Fraunces, serif; letter-spacing: -.04em; line-height: 1.06; }
.start-view h1, .result-view h1 { max-width: 650px; margin-top: 18px; font-size: clamp(40px, 7vw, 64px); }
.start-view > p, .result-view > p { max-width: 620px; margin: 18px 0 26px; color: var(--muted); font-size: 16px; line-height: 1.65; }
.start-stats { display: flex; align-items: center; justify-content: center; gap: 22px; margin: 4px 0 30px; }
.start-stats > span { min-width: 75px; display: flex; flex-direction: column; }
.start-stats strong { color: var(--gold); font: 900 25px Fraunces, serif; }
.start-stats small { margin-top: 3px; color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .12em; }
.start-stats i { width: 1px; height: 34px; background: var(--line); }
.primary-button, .next-button, .secondary-button { min-height: 56px; border-radius: 999px; font-weight: 800; letter-spacing: .03em; }
.primary-button {
  min-width: 250px;
  padding: 0 24px;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border: 0;
  cursor: pointer;
  background: linear-gradient(110deg, var(--cyan), #6c63ff 50%, #a45cff);
  box-shadow: 0 15px 36px rgba(108, 99, 255, .38);
  transition: transform .2s, box-shadow .2s;
}
.primary-button:hover { transform: translateY(-2px); box-shadow: 0 19px 42px rgba(108, 99, 255, .5); }
.primary-button:focus-visible, .next-button:focus-visible, .secondary-button:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.ranking-link-button {
  min-height: 44px;
  margin-top: 14px;
  padding: 0 18px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 0;
  color: var(--gold);
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .06em;
}
.ranking-link-button:hover { color: var(--text); }
.ranking-link-button:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 999px; }
.start-note { margin-top: 13px; color: var(--muted); }

.game-view { padding: clamp(22px, 5vw, 42px); }
.game-top { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 20px; }
.phase-label, .score { display: flex; flex-direction: column; }
.score { text-align: right; }
.game-top small { color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .12em; }
.game-top strong { margin-top: 3px; font: 900 21px Fraunces, serif; }
.lives { display: flex; gap: 6px; }
.lives span { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 11px; color: white; background: var(--pink); box-shadow: 0 8px 18px rgba(255, 107, 138, .22); transition: opacity .2s, transform .2s; }
.lives span.lost { opacity: .18; transform: scale(.82); }
.progress { height: 8px; position: relative; margin: 24px 0 34px; border-radius: 99px; background: #0a1230; }
.progress i { display: block; width: 20%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--gold), #ff9f43); transition: width .35s ease; }
.progress span { position: absolute; left: 20%; top: 50%; color: var(--gold); transform: translate(-50%, -50%); text-shadow: 0 0 12px var(--gold); transition: left .35s ease; }
.question-card { padding: clamp(22px, 5vw, 38px); border: 1px solid var(--line); border-radius: 30px; background: rgba(8, 13, 34, .52); }
.question-meta { display: flex; justify-content: space-between; align-items: center; gap: 14px; color: var(--muted); font-size: 12px; font-weight: 700; }
.difficulty { padding: 5px 9px; border: 1px solid rgba(255, 209, 102, .3); border-radius: 999px; color: var(--gold); background: rgba(255, 209, 102, .08); font-size: 9px; letter-spacing: .12em; }
.question-timer {
  --timer-angle: 360deg;
  width: 54px;
  height: 54px;
  flex: 0 0 auto;
  padding: 3px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(var(--gold) var(--timer-angle), rgba(255, 255, 255, .08) 0);
  box-shadow: 0 0 20px rgba(255, 209, 102, .17);
}
.question-timer > span {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border-radius: 50%;
  color: var(--text);
  background: #0d1637;
}
.question-timer small { color: var(--gold); font-size: 12px; }
.question-timer strong { font: 900 18px Fraunces, serif; line-height: 1; }
.question-timer.is-urgent {
  background: conic-gradient(var(--danger) var(--timer-angle), rgba(255, 113, 125, .09) 0);
  box-shadow: 0 0 24px rgba(255, 113, 125, .28);
  animation: timer-pulse .75s ease-in-out infinite alternate;
}
.question-timer.is-urgent small, .question-timer.is-urgent strong { color: var(--danger); }
@keyframes timer-pulse {
  to { transform: scale(1.07); }
}
.question-card h1 { max-width: 680px; margin: 22px 0 26px; font-size: clamp(28px, 5vw, 42px); }
.answers { display: grid; gap: 11px; }
.answer {
  width: 100%;
  min-height: 58px;
  padding: 9px 16px 9px 10px;
  display: flex;
  align-items: center;
  gap: 13px;
  border: 1px solid var(--line);
  border-radius: 18px;
  text-align: left;
  color: var(--text);
  background: var(--panel-strong);
  cursor: pointer;
  transition: border-color .18s, background .18s, transform .18s;
}
.answer:hover:not(:disabled) { border-color: var(--cyan); transform: translateX(3px); }
.answer:focus-visible { outline: 3px solid rgba(86, 215, 255, .35); outline-offset: 2px; }
.answer:disabled { cursor: default; }
.answer-key { width: 38px; height: 38px; flex: 0 0 auto; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 12px; color: var(--muted); background: #0d1637; font-weight: 800; }
.answer.correct { border-color: var(--mint); background: rgba(88, 230, 169, .1); }
.answer.correct .answer-key { border-color: var(--mint); color: #071c14; background: var(--mint); }
.answer.wrong { border-color: var(--danger); background: rgba(255, 113, 125, .1); }
.answer.wrong .answer-key { border-color: var(--danger); color: #2c080e; background: var(--danger); }
.answer.dimmed { opacity: .52; }
.feedback { margin-top: 18px; padding: 18px; display: flex; align-items: flex-start; gap: 14px; border: 1px solid rgba(88, 230, 169, .3); border-radius: 20px; background: rgba(88, 230, 169, .07); }
.feedback.is-wrong { border-color: rgba(255, 113, 125, .32); background: rgba(255, 113, 125, .07); }
.feedback-icon { width: 38px; height: 38px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 12px; color: #071c14; background: var(--mint); font-weight: 900; }
.feedback.is-wrong .feedback-icon { color: #2c080e; background: var(--danger); }
.feedback strong { color: var(--mint); }
.feedback.is-wrong strong { color: var(--danger); }
.feedback p { margin: 5px 0 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.next-button { width: 100%; margin-top: 18px; padding: 0 22px; display: flex; justify-content: space-between; align-items: center; border: 0; cursor: pointer; color: #0b1027; background: var(--gold); }

.result-view { justify-content: center; }
.result-seal { width: 104px; height: 104px; margin-bottom: 22px; display: grid; place-items: center; border: 1px solid rgba(255, 209, 102, .45); border-radius: 34px; color: #4b3200; background: radial-gradient(circle at 35% 30%, #fff0ad, var(--gold) 60%, #f0a83e); box-shadow: 0 22px 48px rgba(255, 209, 102, .25); font-size: 44px; transform: rotate(-5deg); }
.result-score { min-width: 260px; margin: 2px 0 30px; padding: 22px 32px; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 24px; background: rgba(8, 13, 34, .52); }
.result-score small { color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .14em; }
.result-score strong { color: var(--gold); font: 900 58px Fraunces, serif; line-height: 1; margin: 8px 0; }
.result-score span { color: var(--mint); font-weight: 800; }
.result-actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.result-actions .primary-button { min-width: 220px; justify-content: center; }
.secondary-button { min-width: 190px; padding: 0 22px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line); background: var(--panel-strong); }
.secondary-button:hover { border-color: var(--cyan); }
.ranking-result-button { gap: 8px; color: var(--gold); cursor: pointer; }

.ranking-view { padding: clamp(22px, 5vw, 42px); }
.ranking-header {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}
.ranking-back-button {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
  background: var(--panel-strong);
  cursor: pointer;
  font-size: 22px;
}
.ranking-back-button:hover, .ranking-back-button:focus-visible { border-color: var(--cyan); color: var(--text); outline: 3px solid rgba(86, 215, 255, .14); }
.ranking-header > div:nth-child(2) > span {
  color: var(--cyan);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .16em;
}
.ranking-header h1 { margin-top: 3px; font-size: clamp(30px, 5vw, 44px); }
.week-chip {
  min-height: 40px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(8, 13, 34, .45);
  font-size: 12px;
}
.week-chip span { color: var(--gold); font-size: 16px; }
.player-league-card {
  min-height: 104px;
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  border-radius: 26px;
  color: white;
  background:
    radial-gradient(circle at 85% 20%, rgba(255,255,255,.16), transparent 30%),
    linear-gradient(115deg, #3b8ecb, #6658dd 50%, #994fca);
  box-shadow: 0 18px 38px rgba(89, 76, 204, .26);
}
.player-league-main { display: flex; align-items: center; gap: 12px; }
.player-avatar { font-size: 30px; }
.league-shield {
  width: 54px;
  height: 60px;
  display: grid;
  place-items: center;
  border: 2px solid rgba(255,255,255,.75);
  border-radius: 18px 18px 24px 24px;
  background: rgba(9, 15, 43, .25);
  box-shadow: inset 0 0 18px rgba(255,255,255,.12);
  font: 900 24px Fraunces, serif;
}
.player-league-main > span:last-child, .player-total { display: flex; flex-direction: column; }
.player-league-card small { color: rgba(255,255,255,.74); font-size: 9px; font-weight: 800; letter-spacing: .13em; }
.player-league-card strong { margin-top: 3px; font-size: 21px; }
.player-total { text-align: right; }
.player-total strong { font: 900 27px Fraunces, serif; }
.league-ladder { min-height: 62px; padding: 8px 12px; display: flex; align-items: center; justify-content: center; }
.league-ladder span {
  width: 36px;
  height: 40px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 12px 12px 16px 16px;
  color: var(--muted);
  background: var(--panel-strong);
  opacity: .36;
  font: 800 14px Fraunces, serif;
  transition: opacity .2s, transform .2s;
}
.league-ladder span.is-active { color: var(--gold); border-color: var(--gold); opacity: 1; transform: scale(1.12); box-shadow: 0 8px 20px rgba(255, 209, 102, .16); }
.league-ladder i { width: clamp(8px, 4vw, 35px); height: 1px; background: var(--line); }
.ranking-tabs {
  min-height: 50px;
  margin-bottom: 24px;
  padding: 4px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(8, 13, 34, .45);
}
.ranking-tabs button {
  border: 0;
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
}
.ranking-tabs button span:first-child { margin-right: 6px; font-size: 15px; }
.ranking-tabs button.is-active { color: #1f1806; background: var(--gold); }
.ranking-tabs button:focus-visible { outline: 3px solid rgba(255, 209, 102, .26); }
.podium {
  min-height: 190px;
  margin: 0 auto 20px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: clamp(8px, 3vw, 22px);
}
.podium-place { width: min(31%, 150px); display: flex; flex-direction: column; align-items: center; text-align: center; }
.podium-avatar {
  width: 54px;
  height: 54px;
  position: relative;
  display: grid;
  place-items: center;
  border: 2px solid var(--medal);
  border-radius: 50%;
  background: var(--panel-strong);
  font-size: 24px;
  box-shadow: 0 10px 28px rgba(0,0,0,.25);
}
.podium-avatar b {
  width: 22px;
  height: 22px;
  position: absolute;
  right: -6px;
  bottom: -5px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #171205;
  background: var(--medal);
  font-size: 10px;
}
.podium-crown { height: 23px; color: var(--gold); font-size: 20px; }
.podium-place strong { width: 100%; margin-top: 9px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.podium-place small { margin: 3px 0 8px; color: var(--cyan); font-weight: 800; }
.podium-block { width: 100%; height: var(--height); border-radius: 16px 16px 5px 5px; background: linear-gradient(180deg, color-mix(in srgb, var(--medal) 74%, white), color-mix(in srgb, var(--medal) 45%, #151f42)); opacity: .86; }
.ranking-list { display: grid; gap: 9px; }
.ranking-row {
  min-height: 58px;
  padding: 8px 16px;
  display: grid;
  grid-template-columns: 34px 38px 1fr auto;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(21, 31, 66, .86);
}
.ranking-row.is-me { border-color: var(--cyan); background: linear-gradient(90deg, rgba(86, 215, 255, .12), rgba(124, 92, 252, .13)); box-shadow: inset 3px 0 var(--cyan); }
.ranking-position { color: var(--muted); font: 900 16px Fraunces, serif; }
.ranking-row-avatar { font-size: 22px; }
.ranking-player { min-width: 0; display: flex; flex-direction: column; }
.ranking-player strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.ranking-player small { color: var(--muted); font-size: 10px; }
.ranking-points { color: var(--gold); font-weight: 800; }
.ranking-note {
  margin: 18px 0 0;
  padding: 12px 14px;
  display: flex;
  gap: 8px;
  border-radius: 14px;
  color: var(--muted);
  background: rgba(86, 215, 255, .06);
  font-size: 11px;
  line-height: 1.45;
}
.ranking-note > span:first-child { color: var(--cyan); }
.demo-footer { min-height: 70px; padding: 16px 24px; display: grid; place-items: center; text-align: center; color: var(--muted); font-size: 12px; }

@media (max-width: 620px) {
  .demo-nav { width: min(100% - 24px, 1160px); height: 72px; }
  .brand span, .preview-chip, .ranking-nav-button span:last-child { display: none; }
  .ranking-nav-button { width: 44px; padding: 0; justify-content: center; }
  .brand img { width: 38px; height: 38px; }
  .demo-shell { width: min(100% - 16px, 820px); min-height: calc(100vh - 132px); padding-top: 10px; }
  .panel { border-radius: 28px; }
  .start-view, .result-view { min-height: 600px; padding: 34px 20px; }
  .portal { transform: scale(.88); margin-block: -6px 8px; }
  .start-view h1, .result-view h1 { font-size: 39px; }
  .start-stats { gap: 12px; }
  .start-stats > span { min-width: 66px; }
  .game-view { padding: 20px 14px; }
  .game-top { gap: 10px; }
  .lives { gap: 3px; }
  .lives span { width: 28px; height: 28px; border-radius: 9px; font-size: 12px; }
  .question-card { padding: 20px 14px; border-radius: 23px; }
  .question-meta { gap: 9px; }
  .question-meta > span:last-child { text-align: right; font-size: 10px; }
  .question-timer { width: 50px; height: 50px; }
  .question-timer > span { width: 44px; height: 44px; }
  .question-card h1 { font-size: 29px; }
  .answer { min-height: 56px; border-radius: 16px; }
  .feedback { padding: 14px; }
  .result-actions { width: 100%; }
  .result-actions > * { width: 100%; }
  .ranking-view { padding: 18px 12px; }
  .ranking-header { grid-template-columns: 42px 1fr auto; gap: 10px; }
  .ranking-back-button { width: 42px; height: 42px; }
  .ranking-header h1 { font-size: 29px; }
  .ranking-header > div:nth-child(2) > span { display: none; }
  .week-chip { padding: 0 10px; }
  .week-chip span { display: none; }
  .player-league-card { padding: 16px 12px; }
  .player-avatar { display: none; }
  .league-shield { width: 45px; height: 50px; }
  .player-league-card strong { font-size: 17px; }
  .player-total strong { font-size: 23px; }
  .league-ladder { padding-inline: 0; }
  .league-ladder span { width: 31px; height: 35px; }
  .podium { min-height: 174px; gap: 6px; }
  .podium-avatar { width: 48px; height: 48px; }
  .ranking-row { grid-template-columns: 30px 32px 1fr auto; padding-inline: 11px; gap: 7px; }
  .ranking-points { font-size: 13px; }
}

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