:root {
  --bg-0: #070b14;
  --bg-1: #0c1323;
  --panel: rgba(7, 13, 26, 0.78);
  --panel-strong: rgba(8, 16, 32, 0.95);
  --line: rgba(95, 249, 255, 0.26);
  --line-strong: rgba(95, 249, 255, 0.62);
  --text: #dffcff;
  --muted: #95b4be;
  --accent: #5ff9ff;
  --accent-hot: #00d1ff;
  --danger: #ff476f;
  --warn: #ffc658;
  --success: #37ffa4;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Rajdhani", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 20% 20%, #11203d, transparent 45%),
    radial-gradient(circle at 80% 0%, #172443, transparent 42%),
    linear-gradient(170deg, var(--bg-0), #04070f 48%, #0d1a2b 120%);
}

body {
  position: relative;
  overflow-x: hidden;
}

.ambient-grid,
.scanlines,
#fx-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

#fx-canvas {
  z-index: 1;
}

.ambient-grid {
  z-index: 0;
  background-image: linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 34px 34px;
  opacity: 0.24;
  transform: perspective(900px) rotateX(55deg) translateY(36vh) scale(1.6);
  transform-origin: center;
  filter: drop-shadow(0 -20px 45px rgba(0, 176, 255, 0.2));
}

.scanlines {
  z-index: 2;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.022) 0,
    rgba(255, 255, 255, 0.022) 1px,
    transparent 2px,
    transparent 4px
  );
  mix-blend-mode: soft-light;
}

.app-shell {
  position: relative;
  z-index: 3;
  width: min(1100px, 92vw);
  margin: 2.2rem auto;
  display: grid;
  gap: 1.1rem;
}

.hud,
.stage,
.footer-bar {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow), inset 0 0 0 1px rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(8px);
}

.hud {
  padding: 1rem 1.15rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
}

.brand-prefix {
  display: inline-block;
  color: var(--accent);
  letter-spacing: 0.22em;
  font-size: 0.74rem;
}

.hud h1 {
  margin: 0.2rem 0 0;
  font-family: "Orbitron", sans-serif;
  font-size: clamp(1.02rem, 2.5vw, 1.55rem);
  letter-spacing: 0.06em;
}

.hud-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(82px, 1fr));
  gap: 0.45rem;
  min-width: min(100%, 460px);
}

.stat-box {
  border: 1px solid rgba(95, 249, 255, 0.4);
  background: rgba(0, 0, 0, 0.25);
  border-radius: 9px;
  padding: 0.45rem 0.55rem;
}

.stat-label {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.stat-box strong {
  font-family: "Orbitron", sans-serif;
  font-size: 1rem;
}

.stage {
  min-height: min(78vh, 720px);
  display: grid;
  place-items: center;
  padding: 1.4rem;
}

.card {
  width: min(860px, 100%);
  border: 1px solid var(--line-strong);
  background: var(--panel-strong);
  border-radius: 14px;
  padding: clamp(1rem, 3vw, 2rem);
  position: relative;
  overflow: hidden;
  animation: enter 0.42s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

.card::before {
  content: "";
  position: absolute;
  inset: 0;
  border: 1px solid rgba(255, 255, 255, 0.03);
  pointer-events: none;
}

.eyebrow {
  margin: 0;
  font-size: 0.76rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
}

.card h2 {
  margin: 0.2rem 0 0.7rem;
  font-family: "Orbitron", sans-serif;
  line-height: 1.25;
  font-size: clamp(1.2rem, 3.2vw, 2rem);
}

.card p {
  font-size: clamp(1rem, 1.9vw, 1.14rem);
  color: #d4eff2;
  margin: 0.6rem 0;
}

.field {
  display: grid;
  gap: 0.4rem;
  margin-top: 1rem;
}

.field span {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.78rem;
  color: var(--muted);
}

input {
  border: 1px solid rgba(95, 249, 255, 0.65);
  background: rgba(4, 10, 20, 0.9);
  color: var(--text);
  padding: 0.7rem 0.8rem;
  font-size: 1rem;
  border-radius: 8px;
  outline: none;
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(95, 249, 255, 0.2);
}

.primary-btn,
.choice-btn,
#mute-toggle {
  border: 1px solid rgba(95, 249, 255, 0.65);
  color: var(--text);
  background: linear-gradient(180deg, rgba(15, 31, 52, 0.94), rgba(8, 17, 33, 0.95));
  padding: 0.72rem 1rem;
  border-radius: 9px;
  cursor: pointer;
  font-family: "Orbitron", sans-serif;
  letter-spacing: 0.06em;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.primary-btn:hover,
.choice-btn:hover,
#mute-toggle:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 12px 26px rgba(0, 191, 255, 0.2);
}

.card-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.chip {
  border: 1px solid rgba(255, 198, 88, 0.7);
  background: rgba(255, 198, 88, 0.12);
  color: #ffd989;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.83rem;
}

.choices {
  margin-top: 0.9rem;
  display: grid;
  gap: 0.66rem;
}

.choice-btn {
  width: 100%;
  text-align: left;
  font-family: "Rajdhani", sans-serif;
  font-size: 1.03rem;
  letter-spacing: 0.02em;
  padding: 0.78rem 0.86rem;
}

.choice-btn:active {
  transform: translateY(0);
}

.feedback-card[data-state="correct"] {
  border-color: rgba(55, 255, 164, 0.72);
}

.feedback-card[data-state="wrong"] {
  border-color: rgba(255, 71, 111, 0.72);
}

.score-recap {
  margin-top: 0.6rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.score-pill {
  border-radius: 999px;
  border: 1px solid rgba(95, 249, 255, 0.45);
  background: rgba(95, 249, 255, 0.09);
  padding: 0.24rem 0.58rem;
  font-size: 0.86rem;
}

.rank-reveal {
  margin: 1.2rem 0 1rem;
  border: 1px solid rgba(95, 249, 255, 0.48);
  background: linear-gradient(120deg, rgba(0, 209, 255, 0.14), rgba(255, 198, 88, 0.1));
  border-radius: 12px;
  padding: 1rem;
  display: grid;
  gap: 0.33rem;
}

.rank-reveal span {
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  font-size: 0.78rem;
}

.rank-reveal strong {
  font-family: "Orbitron", sans-serif;
  font-size: clamp(1.2rem, 3vw, 1.8rem);
  color: #f2ffe8;
  text-shadow: 0 0 16px rgba(81, 255, 160, 0.5);
}

.rank-reveal.reveal strong {
  animation: reveal 1.2s ease forwards;
}

.roadmap h3 {
  margin: 0.8rem 0 0.45rem;
  font-family: "Orbitron", sans-serif;
  font-size: 1rem;
}

.roadmap ul {
  margin: 0;
  padding-left: 1.2rem;
}

.roadmap li {
  margin: 0.3rem 0;
  color: #c6ebf1;
}

.leaderboard {
  margin-top: 1rem;
  border: 1px solid rgba(95, 249, 255, 0.35);
  border-radius: 12px;
  padding: 0.9rem;
  background: rgba(2, 10, 21, 0.65);
}

.leaderboard-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: baseline;
  justify-content: space-between;
}

.leaderboard h3 {
  margin: 0;
  font-family: "Orbitron", sans-serif;
  font-size: 1rem;
}

#player-placement,
#leaderboard-status {
  margin: 0.35rem 0;
  color: var(--muted);
  font-size: 0.95rem;
}

#submit-score-btn {
  margin-top: 0.3rem;
}

#submit-score-btn[disabled] {
  opacity: 0.7;
  cursor: not-allowed;
}

#leaderboard-list {
  margin: 0.5rem 0 0;
  padding-left: 1.25rem;
  display: grid;
  gap: 0.4rem;
}

#leaderboard-list li {
  color: #d7f7ff;
  font-size: 0.98rem;
}

.footer-bar {
  padding: 0.65rem 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.footer-bar p {
  margin: 0;
  color: var(--muted);
  letter-spacing: 0.03em;
}

#mute-toggle {
  font-family: "Rajdhani", sans-serif;
  font-weight: 700;
}

@keyframes enter {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.988);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes reveal {
  0% {
    opacity: 0;
    letter-spacing: 0.35em;
    filter: blur(7px);
  }
  35% {
    opacity: 0.5;
  }
  100% {
    opacity: 1;
    letter-spacing: 0.03em;
    filter: blur(0);
  }
}

@media (max-width: 780px) {
  .app-shell {
    margin: 1rem auto;
  }

  .stage {
    min-height: 68vh;
    padding: 0.8rem;
  }

  .hud-stats {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }

  .footer-bar {
    flex-direction: column;
    align-items: stretch;
  }
}
