* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

:root {
  --bg: #0d1226;
  --card: rgba(18, 24, 48, .92);
  --line: rgba(255, 255, 255, .14);
  --txt: #eef2ff;
  --muted: #9aa6d0;
  --acc: #ffcf3f;
  --blue: #3b82f6;
  --green: #22c55e;
  --red: #ef4444;
}

html, body { height: 100%; overflow: hidden; background: var(--bg); color: var(--txt); font-family: "Segoe UI", system-ui, Roboto, Arial, sans-serif; }

canvas#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
canvas#game3d { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; z-index: 0; }

.hidden { display: none !important; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
.hud-top { position: absolute; top: 10px; left: 10px; right: 10px; display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  background: rgba(6, 10, 26, .62); border: 1px solid var(--line);
  padding: 7px 12px; border-radius: 999px; font-size: 13px; font-weight: 700;
  letter-spacing: .5px; backdrop-filter: blur(6px);
}
.pill.alert { color: var(--red); border-color: var(--red); }
.qbar { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); width: min(420px, 74vw); }
.qbar-label { font-size: 12px; font-weight: 700; text-align: center; margin-bottom: 5px; color: #fff; text-shadow: 0 2px 6px #000; }
.qbar-track { height: 12px; background: rgba(6, 10, 26, .7); border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
#qFill { height: 100%; width: 0%; background: linear-gradient(90deg, #38bdf8, var(--acc)); transition: width .12s linear; border-radius: 999px; }
#btnPause { position: absolute; right: 10px; bottom: 16px; pointer-events: auto; }

/* ---------- Screens / cards ---------- */
.screen {
  position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center;
  padding: 18px; background: radial-gradient(1200px 700px at 50% 0%, rgba(59,130,246,.28), transparent 70%),
  linear-gradient(180deg, rgba(6,9,24,.35), rgba(6,9,24,.86));
  overflow: auto;
}
.card {
  width: min(560px, 100%); background: var(--card); border: 1px solid var(--line);
  border-radius: 22px; padding: 26px; box-shadow: 0 30px 70px rgba(0,0,0,.55);
}
.card.wide { width: min(720px, 100%); max-height: 92vh; overflow: auto; }
.card.center { text-align: center; }
h1 { font-size: clamp(30px, 7vw, 46px); letter-spacing: 3px; color: var(--acc); text-shadow: 0 4px 0 rgba(0,0,0,.35); }
h2 { font-size: 24px; margin-bottom: 10px; }
h3 { font-size: 15px; margin: 16px 0 8px; color: var(--muted); }
.subtitle { color: var(--muted); font-size: 14px; margin-top: 10px; line-height: 1.55; }
code { background: rgba(255,255,255,.08); padding: 1px 5px; border-radius: 5px; font-size: 12px; }

.stat-row { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.chip { background: rgba(255,255,255,.07); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: 12px; font-weight: 700; color: var(--muted); }
.chip b { color: var(--acc); }

.field { display: block; margin-top: 16px; font-size: 14px; font-weight: 600; }
.field > span { display: block; margin-bottom: 8px; }
.field small { display: block; color: var(--muted); font-weight: 400; margin-top: 6px; font-size: 12px; }
.field input[type=range] { width: 100%; accent-color: var(--acc); }
.field input.textin {
  width: 100%; background: rgba(0,0,0,.35); color: var(--txt);
  border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
  font-size: 15px; font-weight: 600; font-family: inherit;
}
.field input.textin:focus { outline: none; border-color: var(--acc); }
.field input.textin.inline { width: auto; flex: 1; min-width: 160px; margin: 0; }
#loginError { min-height: 18px; }
.field textarea {
  width: 100%; background: rgba(0,0,0,.35); color: var(--txt); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px; font-size: 13px; font-family: Consolas, monospace; resize: vertical;
}

.seg { display: flex; gap: 8px; }
.seg button {
  flex: 1; padding: 10px; border-radius: 12px; border: 1px solid var(--line);
  background: rgba(255,255,255,.05); color: var(--txt); font-weight: 700; cursor: pointer;
}
.seg button.on { background: var(--blue); border-color: var(--blue); }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.btn {
  border: 1px solid var(--line); background: rgba(255,255,255,.07); color: var(--txt);
  padding: 12px 18px; border-radius: 14px; font-weight: 800; font-size: 14px; cursor: pointer;
  letter-spacing: .5px; transition: transform .08s, filter .15s;
}
.btn:hover { filter: brightness(1.15); }
.btn:active { transform: scale(.97); }
.btn.primary { background: linear-gradient(180deg, #4ade80, #16a34a); border-color: transparent; color: #06210f; }
.btn.ghost { background: transparent; }
.btn.small { padding: 8px 12px; font-size: 12px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.filebtn { display: inline-flex; align-items: center; cursor: pointer; }

.help { margin-top: 18px; font-size: 12.5px; color: var(--muted); line-height: 1.7; background: rgba(255,255,255,.05); padding: 12px 14px; border-radius: 12px; }

/* ---------- Modals ---------- */
.modal {
  position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center;
  padding: 16px; background: rgba(4, 6, 18, .72); backdrop-filter: blur(4px); overflow: auto;
}

/* ---------- Question ---------- */
.qcard { border-top: 5px solid var(--acc); }
.qtop { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.options { display: grid; gap: 10px; margin-top: 16px; }
.opt {
  text-align: left; padding: 14px 16px; border-radius: 14px; border: 2px solid var(--line);
  background: rgba(255,255,255,.06); color: var(--txt); font-size: 15px; font-weight: 600;
  cursor: pointer; display: flex; gap: 12px; align-items: center; transition: .12s;
}
.opt .key { background: rgba(255,255,255,.14); border-radius: 8px; padding: 3px 9px; font-size: 12px; font-weight: 800; }
.opt:hover { border-color: var(--acc); }
.opt.correct { background: rgba(34,197,94,.22); border-color: var(--green); }
.opt.wrong { background: rgba(239,68,68,.2); border-color: var(--red); opacity: .65; }
.opt:disabled { cursor: default; }
.feedback { min-height: 22px; margin-top: 14px; font-weight: 800; font-size: 14px; }
.feedback.bad { color: #ff8a8a; }
.feedback.good { color: #6ee7a0; }
.hint { margin-top: 12px; font-size: 12px; color: var(--muted); text-align: center; }
.shake { animation: shake .35s; }
@keyframes shake { 0%,100%{transform:translateX(0)} 20%{transform:translateX(-9px)} 40%{transform:translateX(9px)} 60%{transform:translateX(-6px)} 80%{transform:translateX(6px)} }

/* ---------- Import / bank ---------- */
.drop {
  margin-top: 14px; border: 2px dashed var(--line); border-radius: 14px; padding: 18px;
  text-align: center; color: var(--muted); font-size: 13px; transition: .15s;
}
.drop.over { border-color: var(--acc); color: var(--acc); background: rgba(255,207,63,.08); }
.result { margin-top: 12px; font-size: 13px; line-height: 1.6; white-space: pre-wrap; }
.result.ok { color: #6ee7a0; }
.result.err { color: #ff8a8a; }
.bank-list-wrap { max-height: 240px; overflow: auto; border: 1px solid var(--line); border-radius: 14px; padding: 6px 12px 12px; margin-top: 6px; }
#bankList { list-style: none; }
#bankList li { padding: 9px 4px; border-bottom: 1px dashed rgba(255,255,255,.1); font-size: 13px; display: flex; gap: 8px; align-items: flex-start; }
#bankList li:last-child { border-bottom: 0; }
#bankList .tag { font-size: 10.5px; background: rgba(59,130,246,.25); border-radius: 6px; padding: 2px 7px; white-space: nowrap; }
#bankList .src { font-size: 10.5px; color: var(--muted); }
#bankList .qline { flex: 1; }

.score-wrap { margin-top: 16px; border: 1px solid var(--line); border-radius: 14px; padding: 4px 14px 10px; background: rgba(255,255,255,.04); }
#scoreList { list-style: none; }
#scoreList li { display: flex; gap: 10px; align-items: baseline; padding: 7px 2px; border-bottom: 1px dashed rgba(255,255,255,.1); font-size: 13.5px; }
#scoreList li:last-child { border-bottom: 0; }
#scoreList li b { color: var(--acc); min-width: 26px; }
#scoreList li .src { color: var(--muted); font-size: 11.5px; margin-left: auto; }

.stats { display: grid; gap: 8px; margin-top: 8px; }
.stats div { display: flex; justify-content: space-between; background: rgba(255,255,255,.05); padding: 10px 14px; border-radius: 10px; font-size: 14px; }
.stats div b { color: var(--acc); }

.toast {
  position: fixed; top: 64px; left: 50%; transform: translateX(-50%); z-index: 40;
  background: rgba(6,10,26,.94); border: 1px solid var(--line); border-radius: 999px;
  padding: 10px 20px; font-weight: 800; font-size: 14px; box-shadow: 0 12px 30px rgba(0,0,0,.5);
}
.toast.good { color: #6ee7a0; border-color: var(--green); }
.toast.bad { color: #ff8a8a; border-color: var(--red); }

@media (max-width: 560px) {
  .card { padding: 18px; }
  .btn { padding: 11px 14px; font-size: 13px; }
  .hud-top { gap: 6px; }
  .pill { font-size: 11px; padding: 6px 9px; }
}
