:root {
  --bg: #050814;
  --panel: rgba(16, 20, 36, 0.92);
  --line: rgba(255, 255, 255, 0.14);
  --text: #f4f6fb;
  --muted: #9aa3b5;
  --yellow: #f7e14a;
  --yellow-ink: #1a1600;
  --good: #3dd68c;
  --bad: #ff5a6a;
  --accent: #7ec8ff;
  --font: "Figtree", "Segoe UI", sans-serif;
  --display: "Bebas Neue", "Arial Narrow", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  user-select: none;
  touch-action: none;
}

canvas#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.hidden { display: none !important; }

/* ---------- HUD ---------- */

.hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: max(12px, env(safe-area-inset-top)) 16px 0;
  pointer-events: none;
}

.hud-left, .hud-mid, .hud-right {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--line);
  font-weight: 700;
  font-size: 0.92rem;
  backdrop-filter: blur(8px);
}

.pill .lv {
  color: var(--yellow);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
}

.hud-mid .stat {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 7px 10px;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  font-weight: 800;
  min-width: 52px;
  justify-content: center;
}

.stat-ico { font-size: 0.95rem; }

.turbo-wrap {
  min-width: 140px;
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
}

.turbo-label, .turbo-hint {
  display: block;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.turbo-hint { margin-top: 4px; text-align: right; }

.turbo-track {
  margin-top: 4px;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.turbo-bar {
  height: 100%;
  width: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ff8a3d, var(--yellow));
  transition: width 0.1s linear;
}

/* ---------- Toast / Banner ---------- */

.toast {
  position: fixed;
  top: 22%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 15;
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(247, 225, 74, 0.4);
  color: var(--yellow);
  font-weight: 800;
  letter-spacing: 0.02em;
  pointer-events: none;
}

.banner {
  position: fixed;
  inset: 0;
  z-index: 16;
  display: grid;
  place-items: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
  background: radial-gradient(circle at 50% 45%, rgba(10, 14, 28, 0.55), transparent 55%);
}

.banner.show { opacity: 1; }

.banner-title {
  font-family: var(--display);
  font-size: clamp(2.8rem, 8vw, 5rem);
  letter-spacing: 0.04em;
  text-align: center;
  text-transform: uppercase;
  text-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
}

.banner-sub {
  margin-top: 6px;
  text-align: center;
  color: var(--accent);
  font-weight: 700;
  font-size: 1.1rem;
}

/* ---------- Panels ---------- */

.panel {
  position: fixed;
  left: 50%;
  top: 50%;
  bottom: auto;
  transform: translate(-50%, -50%);
  z-index: 18;
  width: min(560px, calc(100% - 24px));
  padding: 18px 18px 16px;
  border-radius: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(12px);
}

.q-label {
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--yellow);
  margin-bottom: 6px;
}

.q-text {
  font-size: 1.25rem;
  font-weight: 800;
  line-height: 1.3;
  margin-bottom: 12px;
}

.q-hint { display: none; }

.choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.choice {
  padding: 14px 12px;
  border-radius: 12px;
  border: 2px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-weight: 800;
  font-size: 1.05rem;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}

.choice:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: rgba(247, 225, 74, 0.45);
}

.choice.good {
  border-color: var(--good);
  background: rgba(61, 214, 140, 0.18);
}

.choice.bad {
  border-color: var(--bad);
  background: rgba(255, 90, 106, 0.16);
}

.q-feedback {
  min-height: 1.2em;
  margin-top: 10px;
  font-weight: 700;
  font-size: 0.95rem;
}

.q-feedback.ok { color: var(--good); }
.q-feedback.bad { color: #ffb0b8; }

.upgrade .up-title {
  font-family: var(--display);
  font-size: 2.2rem;
  letter-spacing: 0.04em;
  text-align: center;
}

.up-sub {
  margin: 0 0 14px;
  text-align: center;
  color: var(--muted);
  font-weight: 600;
}

.up-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.up-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 8px;
  border-radius: 14px;
  border: 2px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease;
}

.up-btn:hover {
  transform: translateY(-2px);
  border-color: rgba(126, 200, 255, 0.55);
}

.up-ico { font-size: 1.6rem; }
.up-name { font-weight: 800; }
.up-desc { font-size: 0.72rem; color: var(--muted); text-align: center; line-height: 1.25; }

/* ---------- Screens ---------- */

.screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    radial-gradient(800px 400px at 70% 20%, rgba(126, 200, 255, 0.18), transparent 55%),
    radial-gradient(600px 300px at 20% 80%, rgba(247, 225, 74, 0.08), transparent 50%),
    rgba(5, 8, 20, 0.55);
  backdrop-filter: blur(2px);
}

.card {
  width: min(440px, 100%);
  padding: 28px 24px 22px;
  border-radius: 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  text-align: center;
}

.kicker {
  margin: 0 0 6px;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--yellow);
}

.title {
  margin: 0 0 10px;
  font-family: var(--display);
  font-size: clamp(2.8rem, 10vw, 3.8rem);
  line-height: 0.95;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.title span { color: var(--accent); }

.tagline {
  margin: 0 0 16px;
  color: #d5dae6;
  line-height: 1.4;
  font-weight: 600;
}

.howto {
  list-style: none;
  margin: 0 0 18px;
  padding: 0;
  text-align: left;
  display: grid;
  gap: 8px;
}

.howto li {
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  font-weight: 600;
  font-size: 0.92rem;
  color: #d8deea;
}

kbd {
  display: inline-block;
  padding: 2px 7px;
  margin: 0 1px;
  border-radius: 5px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.08);
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 800;
}

.big-btn, .small-btn {
  border: 0;
  cursor: pointer;
  font-weight: 800;
  font-family: var(--font);
}

.big-btn {
  width: 100%;
  padding: 14px 18px;
  border-radius: 12px;
  background: var(--yellow);
  color: var(--yellow-ink);
  font-size: 1.15rem;
  box-shadow: 0 8px 24px rgba(247, 225, 74, 0.25);
}

.big-btn:hover { filter: brightness(1.05); }

.small-btn {
  padding: 12px 18px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  border: 1px solid var(--line);
}

.best {
  margin-top: 12px;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.9rem;
}

.over-title {
  font-family: var(--display);
  font-size: 3rem;
  letter-spacing: 0.04em;
}

.over-sub {
  margin: 4px 0 16px;
  color: var(--muted);
  font-weight: 600;
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.stat-box {
  padding: 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
}

.stat-num {
  font-weight: 800;
  font-size: 1.2rem;
}

.stat-label {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.new-best {
  color: var(--yellow);
  font-weight: 800;
  margin-bottom: 6px;
}

.over-buttons {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

/* ---------- Chrome ---------- */

.back-hub {
  position: fixed;
  left: 14px;
  bottom: max(14px, env(safe-area-inset-bottom));
  z-index: 25;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 44px;
  padding: 0 14px 0 8px;
  color: #e9e3ff;
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.95rem;
  text-decoration: none;
  backdrop-filter: blur(6px);
}
.back-hub svg { width: 22px; height: 22px; }
.back-hub:hover { border-color: rgba(255, 255, 255, 0.35); }

.touch {
  display: none;
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: max(64px, calc(env(safe-area-inset-bottom) + 56px));
  z-index: 12;
  pointer-events: none;
  justify-content: space-between;
  align-items: flex-end;
  gap: 8px;
}

.touch .pad {
  pointer-events: auto;
  width: 64px;
  height: 64px;
  border-radius: 16px;
  border: 2px solid var(--line);
  background: rgba(16, 20, 36, 0.55);
  color: var(--text);
  font-size: 1.3rem;
  font-weight: 800;
  backdrop-filter: blur(6px);
}

.touch .turbo-pad {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(247, 225, 74, 0.18);
  border-color: rgba(247, 225, 74, 0.45);
}

.touch .pad-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: auto;
}

.touch .pad.sm {
  width: 56px;
  height: 48px;
  font-size: 1rem;
}

@media (max-width: 900px), (pointer: coarse) {
  .touch { display: flex; }
}

.mute {
  position: fixed;
  right: 14px;
  bottom: max(14px, env(safe-area-inset-bottom));
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  color: #e9e3ff;
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 50%;
  z-index: 25;
  cursor: pointer;
}
.mute svg { width: 26px; height: 26px; }
.mute .slash { display: none; }
.mute.muted .waves { display: none; }
.mute.muted .slash { display: inline; }

@media (max-width: 640px) {
  .hud { flex-wrap: wrap; }
  .hud-mid { order: 3; width: 100%; justify-content: center; }
  .up-grid { grid-template-columns: 1fr; }
  .choices { grid-template-columns: 1fr; }
  .turbo-wrap { min-width: 110px; }
}
