:root {
  --bg: #090b14;
  --bg-card: rgba(20, 24, 42, 0.78);
  --bg-card-solid: #14182a;
  --bg-elevated: rgba(31, 37, 63, 0.85);
  --border: rgba(255, 255, 255, 0.09);
  --border-bright: rgba(139, 92, 246, 0.45);
  --text: #f3f4f8;
  --text-muted: #9ca3af;
  --primary: #7c3aed;
  --primary-2: #ec4899;
  --accent-cyan: #06b6d4;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}

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

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, Inter, sans-serif;
  line-height: 1.45;
  overflow-x: hidden;
}

body.theme-night {
  --bg: #04050a;
  --bg-card: rgba(12, 14, 28, 0.88);
}

.bg-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.25;
  pointer-events: none;
  z-index: 0;
}
.orb-1 {
  width: 280px;
  height: 280px;
  top: -80px;
  left: -60px;
  background: var(--primary);
}
.orb-2 {
  width: 260px;
  height: 260px;
  bottom: -60px;
  right: -60px;
  background: var(--accent-cyan);
}

.app-shell {
  position: relative;
  z-index: 1;
  max-width: 560px;
  margin: 0 auto;
  padding: 14px 14px 92px;
  min-height: 100vh;
}

.center-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 75vh;
  gap: 14px;
  color: var(--text-muted);
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255, 255, 255, 0.14);
  border-top-color: var(--primary-2);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Header & Typography */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 13px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  display: grid;
  place-items: center;
  font-size: 20px;
  box-shadow: 0 6px 18px rgba(124, 58, 237, 0.4);
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand small {
  display: block;
  color: var(--text-muted);
  font-size: 12px;
}

h2 {
  font-size: 18px;
  margin: 0 0 10px;
  font-weight: 700;
}

h3 {
  font-size: 15px;
  margin: 0 0 8px;
  font-weight: 700;
}

.muted {
  color: var(--text-muted);
  font-size: 13px;
}

/* Cards & Surfaces */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}

.card-glow {
  border-color: var(--border-bright);
  background: linear-gradient(160deg, rgba(124, 58, 237, 0.16), rgba(20, 24, 42, 0.88));
}

.hero-card {
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.28), rgba(236, 72, 153, 0.16) 55%, rgba(6, 182, 212, 0.18));
  border: 1px solid rgba(255, 255, 255, 0.14);
}

/* Buttons */
.btn {
  appearance: none;
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.12s ease, opacity 0.15s ease, background 0.15s ease;
  text-decoration: none;
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  border-color: transparent;
  box-shadow: 0 8px 20px rgba(124, 58, 237, 0.35);
}

.btn-success {
  background: linear-gradient(135deg, #059669, #10b981);
  border-color: transparent;
}

.btn-danger {
  background: linear-gradient(135deg, #dc2626, #ef4444);
  border-color: transparent;
}

.btn-warning {
  background: linear-gradient(135deg, #d97706, #f59e0b);
  border-color: transparent;
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.05);
}

.btn-sm {
  padding: 7px 11px;
  font-size: 12px;
  border-radius: 10px;
}

.btn-block {
  width: 100%;
}

.btn-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-row > .btn {
  flex: 1 1 0;
  min-width: 120px;
}

/* Inputs & Selects */
.input, select {
  width: 100%;
  background: rgba(9, 11, 20, 0.72);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 13px;
  color: var(--text);
  font-size: 14px;
  outline: none;
}

.input:focus, select:focus {
  border-color: var(--primary-2);
}

.input-row {
  display: flex;
  gap: 8px;
}

.field {
  margin-bottom: 10px;
}

.field label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 5px;
}

/* Pills & Badges */
.pill-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 12px;
  scrollbar-width: none;
}
.pill-tabs::-webkit-scrollbar { display: none; }

.pill {
  white-space: nowrap;
  padding: 7px 13px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  border: 1px solid transparent;
  cursor: pointer;
}

.pill.active {
  background: rgba(124, 58, 237, 0.25);
  border-color: var(--primary);
  color: #fff;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.badge-new {
  background: linear-gradient(135deg, var(--accent-cyan), var(--primary));
}

.badge-green {
  background: rgba(16, 185, 129, 0.2);
  color: #6ee7b7;
}

.badge-red {
  background: rgba(239, 68, 68, 0.22);
  color: #fca5a5;
}

.badge-amber {
  background: rgba(245, 158, 11, 0.22);
  color: #fcd34d;
}

/* Game Catalog Grid */
.games-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.game-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  overflow: hidden;
}

.game-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--card-accent, var(--primary));
}

.game-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.game-title-wrap {
  display: flex;
  gap: 10px;
  align-items: center;
}

.game-emoji {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  display: grid;
  place-items: center;
  font-size: 24px;
  flex-shrink: 0;
}

.game-meta-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* Room Lobby */
.room-code-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px dashed rgba(255, 255, 255, 0.22);
  cursor: pointer;
}

.room-code-val {
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 0.14em;
  color: #fff;
}

.player-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.player-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 11px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.player-row.dead {
  opacity: 0.45;
  text-decoration: line-through;
}

.player-left {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #6b7280;
  flex-shrink: 0;
}
.dot.online { background: var(--success); box-shadow: 0 0 8px var(--success); }

.player-name {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Role / Secret Peek Card */
.secret-box {
  border-radius: var(--radius);
  padding: 18px 14px;
  text-align: center;
  background: linear-gradient(145deg, rgba(124, 58, 237, 0.22), rgba(15, 23, 42, 0.92));
  border: 1px solid var(--border-bright);
  cursor: pointer;
  user-select: none;
  transition: transform 0.15s ease;
}

.secret-box.spy {
  background: linear-gradient(145deg, rgba(239, 68, 68, 0.26), rgba(15, 23, 42, 0.94));
  border-color: rgba(239, 68, 68, 0.55);
}

.secret-big {
  font-size: 24px;
  font-weight: 900;
  margin: 6px 0;
}

/* Grids for Spy Locations, Stickers, Voting */
.chip-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.loc-chip {
  padding: 9px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  font-size: 13px;
  text-align: center;
  cursor: pointer;
  color: var(--text);
}

.loc-chip.crossed {
  opacity: 0.35;
  text-decoration: line-through;
  background: rgba(239, 68, 68, 0.12);
}

.sticker-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.sticker-card {
  border-radius: 14px;
  padding: 12px;
  background: linear-gradient(150deg, rgba(236, 72, 153, 0.18), rgba(30, 41, 59, 0.85));
  border: 1px solid rgba(236, 72, 153, 0.35);
  text-align: center;
}

.sticker-card.is-me {
  background: linear-gradient(150deg, rgba(124, 58, 237, 0.25), rgba(15, 23, 42, 0.95));
  border-color: var(--primary);
}

.sticker-word {
  margin-top: 6px;
  font-size: 16px;
  font-weight: 800;
  color: #fff;
}

/* Alias Giant Word Card */
.alias-word-card {
  padding: 36px 16px;
  border-radius: 22px;
  text-align: center;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.25), rgba(6, 182, 212, 0.2));
  border: 1px solid rgba(16, 185, 129, 0.5);
  margin: 12px 0;
}

.alias-word-text {
  font-size: 30px;
  font-weight: 900;
  letter-spacing: -0.02em;
}

.timer-pill {
  font-variant-numeric: tabular-nums;
  font-size: 16px;
  font-weight: 800;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
}

/* Bunker trait cards */
.trait-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 7px;
}

.trait-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  font-size: 13px;
}

.trait-item.revealed {
  border-color: rgba(16, 185, 129, 0.45);
  background: rgba(16, 185, 129, 0.09);
}

/* Vote buttons */
.vote-btn {
  width: 100%;
  justify-content: space-between;
  margin-bottom: 7px;
}
.vote-btn.selected {
  border-color: var(--primary-2);
  background: rgba(236, 72, 153, 0.22);
}

/* Progress bars (Most Likely) */
.bar-wrap {
  margin-bottom: 8px;
}
.bar-top {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 3px;
}
.bar-track {
  height: 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--warning), var(--primary-2));
}

/* Sticky bottom bar */
.sticky-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  background: rgba(9, 11, 20, 0.9);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
}

.sticky-inner {
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  gap: 8px;
}

/* Modal & Toast */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 12px;
}

.modal-sheet {
  width: 100%;
  max-width: 540px;
  max-height: 85vh;
  overflow-y: auto;
  background: var(--bg-card-solid);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 18px;
}

.toast-root {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: calc(100% - 28px);
  max-width: 440px;
  pointer-events: none;
}

.toast {
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #fff;
  padding: 11px 14px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
}
.toast.error {
  background: #7f1d1d;
  border-color: #ef4444;
}

/* Toggle switch */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
}

.switch {
  position: relative;
  width: 46px;
  height: 26px;
  flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  cursor: pointer;
  transition: 0.2s;
}
.slider::before {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background: #fff;
  transition: 0.2s;
}
.switch input:checked + .slider {
  background: var(--primary);
}
.switch input:checked + .slider::before {
  transform: translateX(20px);
}
