:root {
  --bg: #10142d;
  --panel: rgba(21, 26, 58, 0.92);
  --panel2: rgba(255, 255, 255, 0.09);
  --line: rgba(255, 255, 255, 0.16);
  --text: #fff8ec;
  --muted: #cbd2ee;
  --pink: #ff386f;
  --blue: #28c8ff;
  --green: #8cff2d;
  --gold: #ffd13d;
  --shadow: 0 28px 70px rgba(0, 0, 0, 0.42);
  --safeBottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  background: #0d1026;
  color: var(--text);
  overflow-x: hidden;
}
button, input, select { font: inherit; }
button { border: 0; cursor: pointer; touch-action: manipulation; }
.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(circle at 14% 18%, rgba(255, 56, 111, .33), transparent 28%),
    radial-gradient(circle at 86% 12%, rgba(40, 200, 255, .28), transparent 26%),
    radial-gradient(circle at 50% 100%, rgba(255, 209, 61, .20), transparent 30%),
    linear-gradient(135deg, #10142d, #1b2457 55%, #120b24);
}
.bg::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: .35;
  background-image: linear-gradient(90deg, rgba(255,255,255,.09) 1px, transparent 1px), linear-gradient(rgba(255,255,255,.07) 1px, transparent 1px);
  background-size: 44px 44px;
}
.app { width: min(1320px, calc(100vw - 32px)); margin: 22px auto 52px; }
.hidden { display: none !important; }
.screen { display: none; }
.screen.active { display: block; }
.topbar { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; margin-bottom: 22px; }
.brand { display: flex; align-items: center; gap: 13px; justify-self: center; }
.brandLogo { width: 54px; height: 54px; display: grid; place-items: center; border-radius: 18px; background: linear-gradient(135deg, var(--pink), #ff9b1f); font-size: 34px; font-weight: 1000; box-shadow: 0 18px 40px rgba(255, 56, 111, .32); }
.brand strong { display: block; font-size: 24px; letter-spacing: .5px; text-transform: uppercase; }
.brand small { display: block; color: var(--muted); margin-top: 2px; }
.topActions { display: flex; gap: 10px; justify-self: end; align-items: center; }
.btn, .scorePill { border-radius: 18px; padding: 12px 16px; font-weight: 950; }
.btnGhost, .scorePill { border: 1px solid var(--line); background: rgba(255,255,255,.10); color: #fff; backdrop-filter: blur(12px); white-space: nowrap; }
.btnPrimary { width: 100%; background: linear-gradient(180deg, var(--pink), #d9154a); color: #fff; box-shadow: 0 12px 0 #8f0d35, 0 18px 38px rgba(255,56,111,.28); text-transform: uppercase; font-size: 20px; }
.btn:active, .characterCard:active, .choice:active { transform: translateY(2px); }
.heroBlock { text-align: center; margin: 10px auto 24px; }
.label { display: inline-block; margin: 0 0 10px; padding: 8px 13px; border-radius: 999px; background: rgba(255,209,61,.14); color: var(--gold); font-size: 13px; font-weight: 950; text-transform: uppercase; letter-spacing: .7px; }
.heroBlock h1 { margin: 0; font-size: clamp(44px, 7vw, 96px); line-height: .9; text-transform: uppercase; letter-spacing: 1px; text-shadow: 0 8px 0 rgba(0,0,0,.28); }
.heroBlock p:last-child { color: var(--muted); font-size: 20px; max-width: 820px; margin: 16px auto 0; }
.characterGrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.characterCard {
  position: relative;
  min-height: 570px;
  padding: 18px;
  border-radius: 32px;
  background: linear-gradient(180deg, rgba(255,255,255,.11), rgba(0,0,0,.17)), var(--panel);
  border: 2px solid var(--line);
  color: var(--text);
  box-shadow: var(--shadow);
  overflow: hidden;
  text-align: left;
  transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease;
}
.characterCard::before { content: ""; position: absolute; inset: 0; background: radial-gradient(circle at 50% 22%, rgba(255,255,255,.16), transparent 36%); opacity: .8; }
.characterCard > * { position: relative; z-index: 1; }
.characterCard:hover, .characterCard:focus-visible { border-color: var(--accent); transform: translateY(-5px); outline: none; }
.characterCard.selected { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(255,255,255,.10), 0 0 0 8px var(--accent), var(--shadow); }
.characterCard.selected::after { content: "Gekozen"; position: absolute; top: 16px; right: 16px; z-index: 2; padding: 8px 12px; border-radius: 999px; background: #fff; color: #101327; font-weight: 1000; text-transform: uppercase; font-size: 12px; }
.difficulty { display: inline-block; padding: 8px 12px; border-radius: 999px; background: var(--accent); color: #101327; font-weight: 1000; text-transform: uppercase; }
.characterCard img { display: block; width: 100%; height: 330px; object-fit: contain; object-position: center bottom; margin: 8px 0 0; filter: drop-shadow(0 22px 24px rgba(0,0,0,.62)); pointer-events: none; }
.characterCard strong { display: block; margin: -2px 0 8px; padding: 13px 10px; border-radius: 15px; background: linear-gradient(#8a4b20, #5c2c12); border: 2px solid #d98a42; box-shadow: 0 8px 0 #2b1208; font-size: clamp(25px, 2.4vw, 31px); line-height: 1; text-align: center; text-transform: uppercase; }
.stars { display: block; color: var(--gold); font-size: 27px; letter-spacing: 2px; margin: 10px 0 8px; }
.characterCard small { display: block; color: #fff; font-size: 16px; line-height: 1.45; min-height: 48px; }
.chooseLabel { display: block; margin-top: 16px; padding: 16px 18px; border-radius: 20px; background: linear-gradient(180deg, var(--accent), rgba(255,255,255,.25)); color: #101327; font-size: 19px; font-weight: 1000; text-align: center; text-transform: uppercase; box-shadow: 0 10px 0 rgba(0,0,0,.42); }
.settingsPanel { position: sticky; bottom: 12px; z-index: 5; margin-top: 22px; display: grid; grid-template-columns: 1fr 1fr 1fr .9fr; gap: 14px; align-items: stretch; padding: 15px; border: 1px solid var(--line); border-radius: 28px; background: rgba(8,11,30,.92); backdrop-filter: blur(16px); box-shadow: 0 20px 70px rgba(0,0,0,.42); }
.selectedBox, .field { display: grid; align-content: center; gap: 7px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 18px; background: var(--panel2); }
.selectedBox span, .field span { color: var(--gold); font-size: 12px; font-weight: 950; text-transform: uppercase; letter-spacing: .4px; }
.selectedBox strong { font-size: 18px; }
input, select { width: 100%; min-height: 48px; padding: 12px 13px; border-radius: 16px; border: 1px solid var(--line); background: rgba(255,255,255,.13); color: #fff; font-weight: 850; }
input[type="range"] { min-height: 32px; padding: 0; accent-color: var(--pink); }
option { color: #101327; }
.startBtn { align-self: stretch; }
.gameLayout { display: grid; grid-template-columns: 320px 1fr; gap: 22px; }
.playerPanel, .questionPanel, .resultPanel { border: 1px solid var(--line); border-radius: 32px; padding: 22px; background: linear-gradient(180deg, rgba(255,255,255,.10), rgba(0,0,0,.16)), var(--panel); box-shadow: var(--shadow); }
.playerPanel img { width: 100%; height: 260px; object-fit: contain; object-position: center bottom; filter: drop-shadow(0 20px 22px rgba(0,0,0,.62)); }
.playerPanel h2 { margin: 0 0 7px; font-size: 31px; line-height: 1; text-transform: uppercase; }
.levelPill, .modePill { display: inline-flex; padding: 8px 12px; border-radius: 999px; color: #101327; font-weight: 1000; text-transform: uppercase; }
.modePill { background: rgba(255,56,111,.22); color: #ff9bb3; }
.hud { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.hud div { display: grid; gap: 3px; padding: 13px; border-radius: 18px; background: var(--panel2); }
.hud span { color: var(--muted); font-size: 13px; font-weight: 850; }
.hud b { color: var(--gold); font-size: 27px; }
.progress { height: 13px; margin: 22px 0 8px; border-radius: 999px; background: rgba(255,255,255,.12); overflow: hidden; }
.progress i { display: block; width: 0; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--green), var(--gold), var(--pink)); transition: width .25s ease; }
.questionPanel { min-height: 560px; display: flex; flex-direction: column; }
.questionTop { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.feedback { min-height: 30px; font-size: 20px; font-weight: 1000; }
.feedback.ok { color: var(--green); }
.feedback.bad { color: #ff7893; }
.questionPanel h2 { margin: 32px 0; font-size: clamp(30px, 4.4vw, 56px); line-height: 1.05; }
.answerArea { display: grid; gap: 13px; margin-top: auto; }
.choice { width: 100%; padding: 19px; border: 2px solid var(--line); border-radius: 22px; background: rgba(255,255,255,.10); color: #fff; text-align: left; font-size: 21px; font-weight: 900; transition: transform .14s ease, border-color .14s ease, background .14s ease; }
.choice:hover, .choice:focus-visible { border-color: var(--blue); background: rgba(40,200,255,.14); transform: translateX(4px); outline: none; }
.choice.correct { border-color: var(--green); background: rgba(140,255,45,.18); }
.choice.wrong { border-color: var(--pink); background: rgba(255,56,111,.18); }
.textAnswer { width: 100%; padding: 20px; border-radius: 22px; font-size: 24px; }
.questionActions { margin-top: 18px; }
.resultPanel { max-width: 720px; margin: 80px auto; text-align: center; }
.resultPanel h1 { margin: 0 0 12px; font-size: clamp(42px, 7vw, 62px); }
.resultPanel p { color: var(--muted); font-size: 20px; }
.finalScore { margin: 24px 0; color: var(--gold); font-size: clamp(70px, 14vw, 88px); font-weight: 1000; }
.finalScore small { display: block; color: var(--muted); font-size: 18px; }
@media (max-width: 1120px) {
  .settingsPanel { grid-template-columns: 1fr 1fr; }
  .startBtn { grid-column: 1 / -1; }
  .gameLayout { grid-template-columns: 280px 1fr; }
  .characterCard { min-height: 545px; }
}
@media (max-width: 820px) {
  .app { width: min(100vw - 18px, 720px); margin-top: 10px; padding-bottom: calc(18px + var(--safeBottom)); }
  .topbar { grid-template-columns: 1fr auto; gap: 10px; margin-bottom: 14px; }
  #backBtn { grid-column: 1 / -1; width: fit-content; }
  .brand { justify-self: start; }
  .brandLogo { width: 46px; height: 46px; border-radius: 15px; font-size: 29px; }
  .brand strong { font-size: 18px; }
  .brand small { font-size: 12px; }
  .topActions { gap: 8px; }
  .btn, .scorePill { padding: 10px 11px; border-radius: 15px; font-size: 14px; }
  .heroBlock { text-align: left; margin-bottom: 14px; }
  .heroBlock h1 { font-size: clamp(42px, 15vw, 60px); }
  .heroBlock p:last-child { margin-top: 10px; font-size: 16px; }
  .characterGrid { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(282px, 86vw); grid-template-columns: none; gap: 16px; overflow-x: auto; padding: 7px 4px 17px; scroll-snap-type: x mandatory; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; }
  .characterCard { min-height: auto; padding: 14px; border-radius: 26px; scroll-snap-align: start; }
  .characterCard:hover { transform: none; }
  .characterCard img { height: 250px; }
  .characterCard strong { font-size: 24px; }
  .settingsPanel { position: static; grid-template-columns: 1fr; padding: 13px; border-radius: 24px; gap: 12px; }
  .btnPrimary, .chooseLabel { font-size: 18px; }
  .gameLayout { grid-template-columns: 1fr; gap: 14px; }
  .playerPanel { position: sticky; top: 8px; z-index: 4; display: grid; grid-template-columns: 92px 1fr; gap: 12px; align-items: center; padding: 14px; border-radius: 24px; backdrop-filter: blur(16px); }
  .playerPanel img { grid-row: span 3; height: 110px; }
  .playerPanel h2 { font-size: 22px; }
  .hud { margin-top: 0; }
  .hud div { padding: 10px; border-radius: 15px; }
  .hud b { font-size: 22px; }
  .progress, #progressText { grid-column: 1 / -1; }
  .progress { margin: 4px 0 0; }
  .questionPanel { min-height: auto; padding: 17px; border-radius: 24px; }
  .questionPanel h2 { margin: 22px 0; font-size: clamp(28px, 9vw, 42px); }
  .feedback { font-size: 17px; }
  .choice { padding: 17px; border-radius: 18px; font-size: 18px; }
  .textAnswer { padding: 17px; font-size: 20px; }
  .resultPanel { margin: 30px auto; padding: 22px; border-radius: 24px; }
}
@media (max-width: 420px) {
  .app { width: calc(100vw - 12px); }
  .brand small { display: none; }
  .characterGrid { grid-auto-columns: minmax(270px, 88vw); }
  .characterCard img { height: 230px; }
  .topActions { justify-content: flex-end; }
  .playerPanel { grid-template-columns: 84px 1fr; }
}
.feedback.explain {
  display: block;
  width: 100%;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid rgba(255, 56, 111, .35);
  background: rgba(255, 56, 111, .12);
  font-size: 16px;
  line-height: 1.45;
  font-weight: 750;
}
.smallMuted { color: var(--muted); margin: 0 0 14px; }
.leaderboardBox {
  margin: 24px 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255,255,255,.08);
  text-align: left;
}
.leaderboardBox h2 { margin: 0 0 8px; }
.scoreSubmit { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; }
.scoreSubmit .btnPrimary { width: auto; font-size: 15px; padding: 14px 16px; }
.leaderboardList { margin: 16px 0 0; padding-left: 24px; }
.leaderboardList li { margin: 8px 0; color: var(--text); }
.leaderboardList span { display: block; color: var(--muted); font-size: 14px; }
@media (max-width: 820px) {
  .scoreSubmit { grid-template-columns: 1fr; }
  .scoreSubmit .btnPrimary { width: 100%; }
  .feedback.explain { font-size: 15px; }
}
