: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;
}

.auth-card, .lobby-header-card, .players-card, .question-banner-card, .input-card, .reveal-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);
}

.section-label {
  display: block; font-size: 11px; font-weight: 800; letter-spacing: 0.8px;
  color: var(--text-muted); text-transform: uppercase; margin-bottom: 8px;
}

.mode-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 12px;
}
.mode-choice-btn {
  background: rgba(255, 255, 255, 0.05); border: 1.5px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px; padding: 10px 4px; text-align: center; color: #fff; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px; transition: all 0.15s;
}
.mode-choice-btn strong { font-size: 12px; font-weight: 800; }
.mode-choice-btn small { font-size: 9px; color: #94a3b8; }
.mode-choice-btn.active {
  border-color: var(--orange-vibrant); background: var(--orange-soft);
  box-shadow: 0 0 12px var(--orange-glow);
}

input[type="text"], input[type="number"] {
  width: 100%; background: rgba(10, 5, 20, 0.85);
  border: 1.5px solid rgba(255, 255, 255, 0.15);
  border-radius: 14px; padding: 12px 16px; font-size: 16px;
  color: #fff; font-family: var(--font-body); font-weight: 600; outline: none;
}
input[type="text"]:focus, input[type="number"]:focus {
  border-color: var(--orange-vibrant); box-shadow: 0 0 14px var(--orange-glow);
}

.action-buttons-stack { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.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-secondary {
  background: rgba(255, 255, 255, 0.08); border: 1px solid rgba(255, 255, 255, 0.15); color: #fff;
}
.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;
}

.or-divider {
  text-align: center; position: relative; margin: 4px 0;
  font-size: 10px; font-weight: 800; color: var(--text-dim); letter-spacing: 0.8px;
}
.join-row { display: grid; grid-template-columns: 1fr 1.1fr; gap: 8px; }
.join-row input { text-align: center; font-family: var(--font-display); font-size: 17px; text-transform: uppercase; }

/* In-game */
.question-banner-card { text-align: center; padding: 18px 14px; }
.round-counter-pill {
  display: inline-block; background: var(--purple-soft); border: 1px solid var(--purple-vibrant);
  color: #d8b4fe; font-size: 11px; font-weight: 800; padding: 3px 12px; border-radius: 99px; margin-bottom: 8px;
}
.question-text {
  font-family: var(--font-display); font-size: clamp(18px, 4.8vw, 24px); font-weight: 900; line-height: 1.35;
}
.unit-badge {
  display: inline-block; background: var(--orange-soft); border: 1px solid var(--orange-vibrant);
  color: #ffaa66; font-size: 12px; font-weight: 800; padding: 3px 12px; border-radius: 99px; margin-top: 10px;
}

.guess-input-row {
  display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; margin-bottom: 12px;
}
.guess-input-row input { font-size: clamp(20px, 5vw, 28px); font-weight: 900; text-align: center; color: #ffaa66; }
.unit-indicator { font-weight: 800; color: #94a3b8; font-size: 14px; }

.duel-status-bar { text-align: center; font-size: 13px; color: var(--text-muted); margin-top: 10px; }

/* Reveal UI */
.actual-value-box {
  text-align: center; background: rgba(0, 0, 0, 0.4); border-radius: 16px; padding: 18px 12px;
  border: 1px solid rgba(255, 255, 255, 0.1); margin-bottom: 14px;
}
.av-label { font-size: 11px; font-weight: 800; color: var(--text-muted); letter-spacing: 0.8px; }
.av-number {
  font-family: var(--font-display); font-size: clamp(32px, 8vw, 44px); font-weight: 900;
  color: #10b981; margin: 4px 0;
}
.av-unit { font-size: 14px; font-weight: 800; color: #6ee7b7; }
.av-fact { font-size: 13px; color: #cbd5e1; margin-top: 10px; line-height: 1.4; }

.results-list { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.result-player-row {
  display: flex; justify-content: space-between; align-items: center;
  background: rgba(255, 255, 255, 0.04); border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px; padding: 12px 14px;
}
.result-player-row.is-winner {
  border-color: #10b981; background: rgba(16, 185, 129, 0.1);
}
.rp-info { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 15px; }
.winner-crown { font-size: 10px; background: #10b981; color: #fff; padding: 2px 6px; border-radius: 4px; }
.rp-stats { text-align: right; font-size: 12px; color: #cbd5e1; }
.rp-guess strong { color: #ffaa66; }

/* Lobby elements */
.room-code-badge {
  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: 14px; margin-bottom: 8px;
}
.code-label { font-size: 11px; font-weight: 800; color: var(--text-muted); }
.code-value { font-family: var(--font-display); font-size: 22px; font-weight: 900; color: #ffaa66; letter-spacing: 2px; }
.btn-copy-code {
  background: var(--purple-soft); border: 1px solid var(--purple-vibrant);
  color: #fff; font-size: 12px; font-weight: 700; padding: 6px 12px; border-radius: 8px; cursor: pointer;
}
.lobby-share-hint { font-size: 12px; color: var(--text-muted); text-align: center; }

.player-list { display: flex; flex-direction: column; gap: 6px; }
.player-pill {
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(255, 255, 255, 0.04); border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 9px 12px; border-radius: 12px; font-size: 14px; font-weight: 700;
}
.player-pill.is-me { border-color: var(--orange-vibrant); background: var(--orange-soft); }
.player-pill.is-bot { border-color: rgba(147, 51, 234, 0.4); background: rgba(147, 51, 234, 0.12); }
.host-badge, .bot-badge {
  font-size: 9px; font-weight: 900; padding: 2px 6px; border-radius: 4px;
}
.host-badge { background: var(--orange-primary); color: #fff; }
.bot-badge { background: var(--purple-primary); color: #fff; }

.bot-quick-actions { display: flex; gap: 6px; }
.btn-chip {
  background: rgba(147, 51, 234, 0.2); border: 1px solid rgba(147, 51, 234, 0.5);
  color: #e2e8f0; font-size: 11px; font-weight: 700; padding: 4px 9px; border-radius: 99px; cursor: pointer;
}
.btn-chip:hover, .btn-chip:active { background: #9333ea; color: #fff; }
.btn-chip-subtle { background: rgba(255,255,255,0.05); border-color: rgba(255,255,255,0.1); }
