: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, .secret-word-card, .hints-history-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;
}

.avatar-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 12px;
}
.avatar-btn {
  background: rgba(255, 255, 255, 0.05); border: 1.5px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px; font-size: 24px; padding: 8px 0; cursor: pointer; transition: all 0.15s;
}
.avatar-btn.selected {
  border-color: var(--orange-vibrant); background: var(--orange-soft);
  box-shadow: 0 0 12px var(--orange-glow); transform: scale(1.05);
}

input[type="text"] {
  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 {
  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; }

/* 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); }

/* Secret Word & In-Game */
.secret-word-card {
  text-align: center; cursor: pointer;
  border: 1.5px solid var(--border-glass-orange);
  background: linear-gradient(135deg, rgba(255, 107, 0, 0.12) 0%, rgba(147, 51, 234, 0.15) 100%);
  padding: 16px; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative; overflow: hidden;
}
.secret-word-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.7), 0 0 20px rgba(255, 107, 0, 0.2);
}
.secret-word-card.is-imposter-card {
  border-color: #f43f5e;
  background: linear-gradient(135deg, rgba(244, 63, 94, 0.18) 0%, rgba(255, 107, 0, 0.15) 100%);
  box-shadow: 0 0 24px rgba(244, 63, 94, 0.25);
}
.secret-word-card.is-detective-card {
  border-color: #10b981;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.15) 0%, rgba(147, 51, 234, 0.15) 100%);
  box-shadow: 0 0 24px rgba(16, 185, 129, 0.2);
}

.role-badge-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin-bottom: 8px;
}
.role-pill {
  font-family: var(--font-display); font-size: 12px; font-weight: 900;
  letter-spacing: 0.8px; padding: 4px 12px; border-radius: 99px;
  text-transform: uppercase;
}
.role-pill.role-imposter {
  background: linear-gradient(135deg, #f43f5e 0%, #e11d48 100%);
  color: #fff; box-shadow: 0 0 12px rgba(244, 63, 94, 0.5);
  animation: pulse 1.5s infinite alternate;
}
.role-pill.role-detective {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #fff; box-shadow: 0 0 12px rgba(16, 185, 129, 0.4);
}
.role-pill.role-hidden {
  background: rgba(255, 255, 255, 0.1); color: #cbd5e1;
}

.visibility-chip {
  font-size: 11px; font-weight: 700; color: #ffaa66;
  background: rgba(0, 0, 0, 0.35); border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 4px 10px; border-radius: 99px;
}

.card-eyebrow { font-size: 11px; font-weight: 800; color: #ffaa66; letter-spacing: 0.6px; margin: 4px 0 2px; }
.secret-word-display {
  font-family: var(--font-display); font-size: clamp(28px, 7vw, 40px); font-weight: 900;
  color: #fff; letter-spacing: 2px; margin: 6px 0;
  text-shadow: 0 0 18px rgba(255, 255, 255, 0.3);
}
.secret-word-display.blurred {
  letter-spacing: 4px; color: #64748b; filter: blur(2px);
}
.imposter-no-word {
  color: #f43f5e;
  text-shadow: 0 0 20px rgba(244, 63, 94, 0.7);
  font-size: clamp(24px, 6vw, 36px);
  display: inline-block;
  letter-spacing: 1px;
}
.word-category-pill {
  display: inline-block; background: rgba(0, 0, 0, 0.4); border: 1px solid rgba(255, 255, 255, 0.15);
  font-size: 12px; font-weight: 700; color: #d8b4fe; padding: 3px 14px; border-radius: 99px; margin-bottom: 6px;
}
.role-mission-desc {
  font-size: 12px; line-height: 1.45; color: #e2e8f0;
  background: rgba(0, 0, 0, 0.35); border-radius: 10px; padding: 8px 12px;
  margin-top: 6px; text-align: left;
}
.role-mission-desc strong { color: #ffaa66; }

.turn-banner {
  display: flex; align-items: center; gap: 12px;
  background: rgba(0, 0, 0, 0.4); border: 1.5px solid rgba(255, 255, 255, 0.1);
  padding: 12px 16px; border-radius: 16px; transition: all 0.25s;
}
.turn-banner.my-turn {
  background: linear-gradient(135deg, rgba(255, 107, 0, 0.22) 0%, rgba(147, 51, 234, 0.2) 100%);
  border-color: var(--orange-vibrant);
  box-shadow: 0 0 20px var(--orange-glow);
  animation: borderGlow 2s infinite alternate;
}
@keyframes borderGlow {
  from { border-color: var(--orange-primary); }
  to { border-color: var(--purple-vibrant); }
}

.pulse-indicator {
  width: 12px; height: 12px; background: #ff6b00; border-radius: 50%;
  box-shadow: 0 0 12px #ff6b00; animation: pulse 1s infinite alternate; flex-shrink: 0;
}
.turn-banner.my-turn .pulse-indicator {
  background: #10b981; box-shadow: 0 0 14px #10b981;
}
.turn-meta { display: flex; flex-direction: column; gap: 2px; }
.turn-text { font-size: 14px; font-weight: 800; color: #fff; }
.turn-subtext { font-size: 11px; font-weight: 600; color: var(--text-muted); }

.hints-feed {
  display: flex; flex-direction: column; gap: 6px; max-height: 190px; overflow-y: auto;
}
.hint-bubble {
  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: 13px;
}
.hint-word { font-family: var(--font-display); font-weight: 800; font-size: 16px; color: #ffaa66; }

/* Host Setup Settings in Lobby */
.lobby-setting-box {
  background: rgba(0, 0, 0, 0.4);
  border: 1.5px solid rgba(255, 107, 0, 0.3);
  border-radius: 16px;
  padding: 14px 16px;
  margin-top: 12px;
  text-align: left;
}
.setting-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.setting-label {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 900;
  color: #ffaa66;
  letter-spacing: 0.8px;
}
.badge-tag {
  font-size: 11px;
  font-weight: 800;
  background: rgba(255, 107, 0, 0.15);
  border: 1px solid rgba(255, 107, 0, 0.4);
  color: #ffaa66;
  padding: 3px 10px;
  border-radius: 99px;
}
.setting-options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.setting-option-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  background: rgba(255, 255, 255, 0.04);
  border: 1.5px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  color: #cbd5e1;
  text-align: left;
  width: 100%;
}
.setting-option-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
}
.setting-option-btn.active {
  background: linear-gradient(135deg, rgba(255, 107, 0, 0.25) 0%, rgba(147, 51, 234, 0.25) 100%);
  border-color: var(--orange-vibrant);
  color: #fff;
  box-shadow: 0 0 16px rgba(255, 107, 0, 0.35);
}
.opt-header-row {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 13px;
  margin-bottom: 4px;
}
.opt-desc {
  font-size: 11px;
  line-height: 1.35;
  color: #94a3b8;
  font-weight: 500;
}
.setting-option-btn.active .opt-desc {
  color: #f1f5f9;
}
.guest-mode-info {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 700;
  color: #e2e8f0;
}

/* Input action bar with spoken option */
.input-action-bar {
  display: flex; flex-direction: column; gap: 8px; margin-top: 4px;
}
.input-text-row {
  display: grid; grid-template-columns: 1fr auto; gap: 8px;
}
.btn-spoken-primary {
  width: 100%;
  padding: 16px 20px;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 0.5px;
  border-radius: 16px;
  background: linear-gradient(135deg, #ff6b00 0%, #9333ea 100%);
  border: 2px solid rgba(255, 255, 255, 0.4);
  color: #fff;
  box-shadow: 0 8px 24px rgba(255, 107, 0, 0.4);
  animation: pulse 1.8s infinite alternate;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: all 0.2s;
}
.btn-spoken-primary:hover, .btn-spoken-primary:active {
  transform: scale(0.98);
  box-shadow: 0 4px 16px rgba(255, 107, 0, 0.6);
}
.btn-spoken-primary .subtext {
  font-size: 11px;
  font-weight: 600;
  opacity: 0.9;
  text-transform: none;
  letter-spacing: 0;
}

.host-turn-bar {
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(0, 0, 0, 0.3); border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 6px 12px; border-radius: 12px; margin-top: 4px;
}
.host-turn-label { font-size: 11px; font-weight: 800; color: var(--text-muted); }

/* Voting Screen */
.voting-summary-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 12px;
}
.vote-hint-card {
  background: rgba(0, 0, 0, 0.4); border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px; padding: 8px; text-align: center;
}
.vh-player { font-size: 11px; font-weight: 700; color: var(--text-muted); }
.vh-word { font-family: var(--font-display); font-size: 15px; font-weight: 900; color: #ffaa66; margin-top: 2px; }

.voting-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.candidate-btn {
  background: rgba(255, 255, 255, 0.05); border: 1.5px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px; padding: 12px 8px; text-align: center; color: #fff; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 4px; transition: all 0.15s;
}
.candidate-btn:hover {
  border-color: var(--orange-vibrant); background: var(--orange-soft); transform: translateY(-1px);
}
.candidate-btn:active { transform: scale(0.97); }
.candidate-btn.disabled-self { opacity: 0.35; pointer-events: none; }
.cand-avatar { font-size: 26px; }
.cand-name { font-weight: 800; font-size: 14px; }
.cand-sub { font-size: 10px; color: #ffaa66; font-weight: 700; }

.voting-status-bar {
  text-align: center; font-size: 12px; color: var(--text-muted); margin-top: 8px;
}

/* Reveal Screen */
.reveal-card { text-align: center; }
.reveal-badge {
  display: inline-block; font-size: 12px; font-weight: 900; letter-spacing: 1px;
  color: #fff; padding: 6px 18px; border-radius: 99px; margin-bottom: 10px;
}
.imposter-spotlight {
  background: rgba(255, 107, 0, 0.15); border: 1.5px solid var(--orange-vibrant);
  border-radius: 16px; padding: 14px 20px; display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--font-display); font-size: 22px; font-weight: 900; color: #ffaa66; margin: 10px 0;
  box-shadow: 0 0 25px var(--orange-glow);
}
.words-comparison-box {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0;
}
.word-box {
  background: rgba(0, 0, 0, 0.4); border-radius: 12px; padding: 10px; border: 1.5px solid rgba(255, 255, 255, 0.1);
}
.word-box.majority { border-color: #10b981; background: rgba(16, 185, 129, 0.08); }
.word-box.imposter { border-color: #f43f5e; background: rgba(244, 63, 94, 0.08); }
.wb-label { font-size: 9px; font-weight: 800; color: var(--text-muted); }
.wb-value { font-family: var(--font-display); font-size: 19px; font-weight: 900; color: #fff; margin-top: 3px; }

/* Votes Breakdown List */
.votes-breakdown-card {
  background: rgba(0, 0, 0, 0.35); border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px; padding: 12px; margin: 12px 0; text-align: left;
}
.votes-breakdown-list { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.vote-breakdown-row {
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(255, 255, 255, 0.03); border: 1px solid rgba(255, 255, 255, 0.06);
  padding: 8px 12px; border-radius: 10px; font-size: 12px; font-weight: 700;
}
.vote-breakdown-row.hit-imposter {
  border-color: rgba(16, 185, 129, 0.35); background: rgba(16, 185, 129, 0.08);
}
.vb-voter, .vb-target { display: flex; align-items: center; gap: 4px; }
.vb-arrow { color: var(--text-dim); font-size: 10px; }
.vb-badge {
  font-size: 10px; font-weight: 900; padding: 2px 8px; border-radius: 6px;
}
.vb-badge.badge-hit { background: #10b981; color: #fff; }
.vb-badge.badge-miss { background: rgba(255, 255, 255, 0.1); color: #cbd5e1; }

.scores-list { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.score-row {
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(255, 255, 255, 0.04); padding: 8px 12px; border-radius: 10px; font-size: 13px; font-weight: 700;
}
.score-val { color: #ffaa66; font-weight: 800; }
