:root {
  --bg-deep: #0e071d;
  --bg-card: rgba(24, 12, 48, 0.92);
  --border-glass: rgba(168, 85, 247, 0.25);
  --border-glass-orange: rgba(255, 107, 0, 0.35);

  --purple-primary: #9333ea;
  --purple-vibrant: #a855f7;
  --purple-glow: rgba(168, 85, 247, 0.35);
  --purple-soft: rgba(147, 51, 234, 0.18);

  --orange-primary: #ff6b00;
  --orange-vibrant: #ff8533;
  --orange-glow: rgba(255, 107, 0, 0.35);
  --orange-soft: rgba(255, 107, 0, 0.16);

  --text-main: #ffffff;
  --text-muted: #b9a9ec;
  --text-dim: #7f71a8;

  --font-display: 'Outfit', sans-serif;
  --font-body: 'Plus Jakarta Sans', sans-serif;
}

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

body {
  background-color: var(--bg-deep);
  color: var(--text-main);
  font-family: var(--font-body);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  position: relative;
  padding-bottom: env(safe-area-inset-bottom, 20px);
}

#ambient-canvas {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 0;
}

.top-nav {
  position: sticky; top: max(8px, env(safe-area-inset-top, 8px)); z-index: 40;
  max-width: 640px; width: calc(100% - 20px);
  margin: 0 auto;
  background: rgba(18, 9, 36, 0.9);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 99px;
  padding: 8px 14px;
  display: flex; align-items: center; justify-content: space-between;
}
.nav-brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: #fff; }
.brand-badge {
  width: 28px; height: 28px;
  background: linear-gradient(135deg, var(--orange-primary) 0%, var(--purple-primary) 100%);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 900; font-size: 14px;
}
.brand-text { font-family: var(--font-display); font-weight: 900; font-size: 17px; }
.brand-text span { color: var(--orange-vibrant); }

.game-badge {
  display: flex; align-items: center; gap: 6px;
  background: var(--purple-soft); border: 1px solid var(--purple-vibrant);
  padding: 3px 10px; border-radius: 99px;
  font-family: var(--font-display); font-weight: 800; font-size: 11px;
  color: #e9d5ff;
}
.glow-dot { width: 6px; height: 6px; background: #a855f7; border-radius: 50%; }
.sound-toggle { cursor: pointer; font-size: 16px; padding: 4px; }

.app-shell {
  position: relative; z-index: 2;
  max-width: 640px; width: 100%;
  margin: 0 auto;
  padding: 14px 12px 60px;
  flex: 1; display: flex; flex-direction: column;
}

.screen-view {
  display: none; flex-direction: column; gap: 14px; width: 100%;
  animation: fadeIn 0.3s ease;
}
.screen-view.active { display: flex; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.hero-box { text-align: center; margin-top: 4px; }
.hero-chip {
  display: inline-block; background: var(--orange-soft);
  border: 1px solid var(--border-glass-orange); color: #ffaa66;
  font-size: 10px; font-weight: 800; letter-spacing: 0.8px;
  padding: 4px 12px; border-radius: 99px; margin-bottom: 6px;
}
.game-title {
  font-family: var(--font-display); font-size: clamp(34px, 8vw, 48px);
  font-weight: 900; letter-spacing: -1.2px; line-height: 1;
}
.game-title span {
  background: linear-gradient(135deg, var(--orange-vibrant) 0%, var(--purple-vibrant) 100%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.game-subtitle {
  color: var(--text-muted); font-size: clamp(13px, 3.5vw, 14px); line-height: 1.4;
  max-width: 480px; margin: 8px auto 0;
}

.rules-card, .question-card, .cert-card {
  background: var(--bg-card);
  backdrop-filter: blur(24px);
  border: 1px solid var(--border-glass);
  border-radius: 20px;
  padding: clamp(14px, 4vw, 20px);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.6);
}

.rules-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0;
}
.rule-box {
  background: rgba(255, 255, 255, 0.04); border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px; padding: 10px 8px; font-size: 12px; font-weight: 700;
  display: flex; align-items: center; gap: 6px;
}

.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  border: none; border-radius: 14px; padding: 13px 18px;
  font-family: var(--font-display); font-weight: 800; font-size: 15px;
  cursor: pointer; text-decoration: none; transition: all 0.2s; min-height: 48px;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: linear-gradient(135deg, var(--orange-primary) 0%, #e05600 100%);
  color: #fff; box-shadow: 0 6px 18px var(--orange-glow);
}
.btn-massive {
  background: linear-gradient(135deg, var(--orange-primary) 0%, var(--purple-primary) 100%);
  color: #fff; font-size: 16px; padding: 15px 20px; border-radius: 16px;
  box-shadow: 0 10px 25px var(--purple-glow); width: 100%; min-height: 52px;
}

/* In-game HUD */
.game-hud {
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(0, 0, 0, 0.4); border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 10px 14px; border-radius: 16px;
}
.level-pill {
  font-family: var(--font-display); font-weight: 900; font-size: 14px; color: #ffaa66;
}
.lives-container { font-size: 18px; letter-spacing: 2px; }

.joker-bar {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
}
.joker-btn {
  background: rgba(255, 255, 255, 0.05); border: 1.5px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px; padding: 8px 4px; text-align: center; color: #fff; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px; transition: all 0.15s;
}
.joker-btn span { font-family: var(--font-display); font-weight: 800; font-size: 13px; color: #d8b4fe; }
.joker-btn small { font-size: 9px; color: #94a3b8; }
.joker-btn:disabled { opacity: 0.25; pointer-events: none; }

.question-card { text-align: center; padding: 20px 14px; }
.diff-badge {
  display: inline-block; background: var(--purple-soft); border: 1px solid var(--purple-vibrant);
  color: #d8b4fe; font-size: 10px; font-weight: 800; padding: 3px 12px; border-radius: 99px; margin-bottom: 10px;
}
.q-title {
  font-family: var(--font-display); font-size: clamp(18px, 4.8vw, 22px); font-weight: 900; line-height: 1.4;
}

.answers-grid {
  display: grid; grid-template-columns: 1fr; gap: 8px;
}
.ans-btn {
  background: rgba(255, 255, 255, 0.05); border: 1.5px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px; padding: 14px 16px; text-align: left; color: #fff; cursor: pointer;
  display: flex; align-items: center; gap: 12px; font-size: clamp(14px, 3.8vw, 16px);
  font-weight: 700; transition: all 0.15s; min-height: 52px;
}
.ans-btn:active { transform: scale(0.98); border-color: var(--orange-vibrant); }
.ans-letter {
  width: 28px; height: 28px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.1); display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 900; font-size: 14px; color: #ffaa66; flex-shrink: 0;
}
.ans-btn.correct { background: rgba(74, 222, 128, 0.25); border-color: #4ade80; color: #4ade80; }
.ans-btn.wrong { background: rgba(248, 113, 113, 0.25); border-color: #f87171; color: #f87171; }

.feedback-banner {
  padding: 12px 14px; border-radius: 14px; text-align: center; font-size: 13px; line-height: 1.4;
}
.feedback-banner.success { background: rgba(74, 222, 128, 0.15); border: 1px solid #4ade80; color: #4ade80; }
.feedback-banner.error { background: rgba(248, 113, 113, 0.15); border: 1px solid #f87171; color: #f87171; }

/* Certificate */
.cert-card { text-align: center; position: relative; overflow: hidden; padding: 24px 16px; }
.cert-watermark {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%) rotate(-25deg);
  font-family: var(--font-display); font-weight: 900; font-size: clamp(32px, 8vw, 56px);
  color: rgba(255, 255, 255, 0.03); pointer-events: none; white-space: nowrap;
}
.cert-logo { font-size: 12px; font-weight: 800; color: #ffaa66; letter-spacing: 1px; margin-bottom: 6px; }
.cert-title { font-family: var(--font-display); font-size: clamp(26px, 6.5vw, 36px); font-weight: 900; }
.cert-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

.iq-score-display { margin: 16px auto; }
.iq-circle {
  width: 120px; height: 120px; border-radius: 50%;
  background: linear-gradient(135deg, var(--purple-primary) 0%, var(--orange-primary) 100%);
  border: 4px solid #fff; box-shadow: 0 0 30px var(--purple-glow);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  margin: 0 auto;
}
.iq-num { font-family: var(--font-display); font-weight: 900; font-size: 38px; color: #fff; line-height: 1; }
.iq-circle small { font-size: 9px; font-weight: 800; color: #ffaa66; letter-spacing: 1px; }

.cert-stats-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 16px 0;
}
.cert-stat-box {
  background: rgba(0, 0, 0, 0.4); border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px; padding: 8px 4px;
}
.cs-val { font-family: var(--font-display); font-weight: 900; font-size: 17px; color: #fff; }
.cs-label { font-size: 9px; color: var(--text-muted); margin-top: 2px; }
