/* =============================================
   WHO'S ON MY CARD? — Stadium Curator Theme
   Design System: "The Stadium Curator"
   Fonts: Space Grotesk (headings) + Manrope (body)
   ============================================= */

/* ===== BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: 'Manrope', sans-serif;
  background: #0b1326;
  color: #dae2fd;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; border: none; outline: none; }
input, select { font-family: inherit; outline: none; border: none; }
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: #131b2e; }
::-webkit-scrollbar-thumb { background: #4edea3; border-radius: 2px; }

/* ===== SCREEN SYSTEM ===== */
.screen { display: none; min-height: 100vh; width: 100%; flex-direction: column; }
.screen.active { display: flex; }

/* ===== GLASS EFFECTS ===== */
.glass-card {
  background: rgba(45, 52, 73, 0.4);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 0.5px solid rgba(255,255,255,0.08);
}
.glass-effect {
  background: rgba(45, 52, 73, 0.6);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

/* ===== GRADIENT BUTTONS ===== */
.btn-primary-gradient {
  background: linear-gradient(135deg, #4edea3, #009365);
  color: #003824;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: all 0.2s;
  box-shadow: 0 8px 24px rgba(78,222,163,0.2);
}
.btn-primary-gradient:hover { transform: translateY(-2px); box-shadow: 0 12px 32px rgba(78,222,163,0.3); }
.btn-primary-gradient:active { transform: scale(0.97); }

.btn-gold-gradient {
  background: linear-gradient(135deg, #e9c349, #b8952e);
  color: #241a00;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-style: italic;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: all 0.2s;
  box-shadow: 0 8px 24px rgba(233,195,73,0.2);
}
.btn-gold-gradient:hover { transform: translateY(-2px); box-shadow: 0 12px 32px rgba(233,195,73,0.3); }
.btn-gold-gradient:active { transform: scale(0.97); }

.btn-glass {
  background: rgba(45, 52, 73, 0.4);
  backdrop-filter: blur(20px);
  color: #dae2fd;
  border-top: 0.5px solid rgba(255,255,255,0.05);
  transition: all 0.2s;
}
.btn-glass:hover { background: rgba(45, 52, 73, 0.6); }

/* ===== TRADING CARD ===== */
.trading-card {
  position: relative;
  aspect-ratio: 3/4;
  border-radius: 0.5rem;
  overflow: hidden;
  transition: transform 0.3s, box-shadow 0.3s;
}
.trading-card:hover {
  transform: scale(1.03);
  box-shadow: 0 32px 64px -12px rgba(0,0,0,0.6), 0 0 32px 0 rgba(78,222,163,0.08);
}
.trading-card .card-bg {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, #222a3d 0%, #131b2e 100%);
}
.trading-card .card-rating {
  position: absolute; top: 8px; right: 8px;
  background: rgba(78,222,163,0.15);
  border: 1px solid rgba(78,222,163,0.3);
  color: #4edea3;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 0.85rem;
  padding: 2px 8px;
  border-radius: 0.25rem;
}
.trading-card .card-initials {
  width: 80px; height: 80px;
  border-radius: 50%;
  background: #171f33;
  border: 2px solid #4edea3;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700; font-size: 1.5rem;
  color: #4edea3;
}
.trading-card.locked { filter: grayscale(1) brightness(0.4); }
.trading-card.legendary { border: 1px solid rgba(233,195,73,0.4); }
.trading-card.epic { border: 1px solid rgba(139,92,246,0.4); }
.trading-card.rare { border: 1px solid rgba(78,222,163,0.3); }
.trading-card.common { border: 1px solid rgba(144,144,151,0.2); }

/* ===== MYSTERY CARD ===== */
.mystery-card {
  position: relative;
  aspect-ratio: 3/4;
  border-radius: 0.5rem;
  background: #131b2e;
  border: 2px dashed rgba(78,222,163,0.3);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.mystery-card .mystery-icon {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 4rem; font-weight: 900;
  color: rgba(78,222,163,0.2);
  text-shadow: 0 0 40px rgba(78,222,163,0.15);
}
.mystery-card::after {
  content: 'IDENTITY ENCRYPTED';
  position: absolute; bottom: 12px;
  font-family: 'Manrope', sans-serif;
  font-size: 0.55rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 2px;
  color: rgba(198,198,205,0.4);
}

/* Card flip */
.card-flip { perspective: 1000px; }
.card-flip .card-inner { position: relative; width: 100%; height: 100%; transition: transform 0.8s; transform-style: preserve-3d; }
.card-flip.revealed .card-inner { transform: rotateY(180deg); }
.card-flip .card-front, .card-flip .card-back {
  position: absolute; width: 100%; height: 100%;
  backface-visibility: hidden; border-radius: 0.5rem;
}
.card-flip .card-back { transform: rotateY(180deg); }

/* ===== CHAT BUBBLES ===== */
.chat-container { display: flex; flex-direction: column; gap: 8px; overflow-y: auto; padding: 8px 0; }
.chat-bubble {
  max-width: 80%;
  padding: 10px 16px;
  border-radius: 0.5rem;
  font-size: 0.85rem;
  line-height: 1.4;
  animation: bubbleIn 0.3s ease-out;
}
.chat-bubble.mine {
  align-self: flex-end;
  background: #222a3d;
  border-bottom-right-radius: 0.125rem;
  color: #dae2fd;
}
.chat-bubble.theirs {
  align-self: flex-start;
  background: #131b2e;
  border-bottom-left-radius: 0.125rem;
  color: #c6c6cd;
}
.chat-bubble .answer-badge {
  display: inline-block;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700; font-size: 0.7rem;
  text-transform: uppercase;
  margin-top: 4px;
}
.chat-bubble .answer-badge.yes { color: #4edea3; }
.chat-bubble .answer-badge.no { color: #ffb4ab; }
.chat-bubble .answer-badge.pending { color: #e9c349; }
.chat-bubble .player-name {
  font-size: 0.65rem;
  color: #909097;
  margin-bottom: 2px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Custom question answer buttons (shown to opponent) */
.custom-q-actions {
  display: flex; gap: 8px; margin-top: 8px;
}
.custom-q-actions button {
  padding: 6px 20px; border-radius: 0.375rem;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600; font-size: 0.8rem;
  transition: all 0.15s;
}
.custom-q-actions .btn-yes { background: rgba(78,222,163,0.15); color: #4edea3; }
.custom-q-actions .btn-yes:hover { background: rgba(78,222,163,0.25); }
.custom-q-actions .btn-no { background: rgba(255,180,171,0.15); color: #ffb4ab; }
.custom-q-actions .btn-no:hover { background: rgba(255,180,171,0.25); }

/* ===== TURN TIMER ===== */
.turn-timer {
  position: relative;
  width: 48px; height: 48px;
}
.turn-timer svg { transform: rotate(-90deg); }
.turn-timer .timer-track { fill: none; stroke: #222a3d; stroke-width: 3; }
.turn-timer .timer-progress { fill: none; stroke: #e9c349; stroke-width: 3; stroke-linecap: round; transition: stroke-dashoffset 1s linear; }
.turn-timer .timer-progress.urgent { stroke: #ffb4ab; }
.turn-timer .timer-text {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700; font-size: 0.85rem;
  color: #e9c349;
}
.turn-timer .timer-text.urgent { color: #ffb4ab; }

/* ===== CATEGORY CHIPS ===== */
.category-chips { display: flex; gap: 6px; overflow-x: auto; padding: 4px 0; scrollbar-width: none; }
.category-chips::-webkit-scrollbar { display: none; }
.category-chip {
  padding: 6px 14px;
  background: #171f33;
  color: #c6c6cd;
  border-radius: 0.375rem;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  transition: all 0.2s;
  display: flex; align-items: center; gap: 4px;
}
.category-chip:hover { background: #222a3d; color: #dae2fd; }
.category-chip.active { background: rgba(78,222,163,0.1); color: #4edea3; }

/* ===== PREDEFINED QUESTION SELECTOR ===== */
.q-selector {
  display: flex; flex-direction: column; gap: 4px;
  max-height: 200px; overflow-y: auto;
  padding: 4px;
  background: #131b2e;
  border-radius: 0.5rem;
}
.q-selector-item {
  padding: 10px 14px;
  background: #171f33;
  border-radius: 0.375rem;
  color: #dae2fd;
  font-size: 0.8rem;
  text-align: left;
  transition: all 0.15s;
}
.q-selector-item:hover { background: #222a3d; }
.q-selector-item.used { opacity: 0.35; pointer-events: none; }

/* ===== BOTTOM NAV ===== */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: #131b2e;
  display: flex; justify-content: space-around;
  padding: 8px 0 max(8px, env(safe-area-inset-bottom));
  z-index: 50;
  box-shadow: 0 -8px 32px rgba(11,19,38,0.5);
}
.bottom-nav .nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 16px;
  border-radius: 0.5rem;
  color: #909097;
  font-size: 0.6rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.5px;
  transition: all 0.2s;
  background: transparent;
}
.bottom-nav .nav-item .nav-icon { font-size: 1.25rem; }
.bottom-nav .nav-item.active {
  color: #4edea3;
  background: linear-gradient(180deg, rgba(78,222,163,0.12) 0%, rgba(78,222,163,0.04) 100%);
}

/* ===== TOP APP BAR ===== */
.top-bar {
  position: sticky; top: 0; z-index: 40;
  background: rgba(11,19,38,0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 10px 16px;
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: 0 4px 20px rgba(78,222,163,0.05);
}
.top-bar .logo-text {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700; font-style: italic;
  font-size: 0.9rem;
  color: #4edea3;
}
.top-bar .coins-badge {
  display: flex; align-items: center; gap: 4px;
  background: #171f33;
  padding: 4px 12px;
  border-radius: 0.375rem;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700; font-size: 0.8rem;
  color: #e9c349;
}

/* ===== TOAST ===== */
.toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
  background: #222a3d; color: #dae2fd;
  padding: 12px 24px; border-radius: 0.5rem;
  font-size: 0.85rem; font-weight: 600;
  z-index: 300;
  animation: slideDown 0.3s ease-out;
  pointer-events: none;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.toast.success { border-left: 3px solid #4edea3; }
.toast.error { border-left: 3px solid #ffb4ab; }

/* ===== LOBBY PLAYER CARD ===== */
.lobby-player-card {
  background: #171f33;
  border-radius: 0.5rem;
  padding: 20px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  transition: all 0.3s;
}
.lobby-player-card .player-avatar {
  width: 64px; height: 64px;
  border-radius: 0.5rem;
  background: #222a3d;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
  border: 2px solid #4edea3;
}
.lobby-player-card.searching {
  border: 2px dashed #45464d;
  background: #131b2e;
}
.lobby-player-card.searching .player-avatar {
  border: 2px dashed #45464d;
  color: #45464d;
}

/* ===== VS BADGE ===== */
.vs-badge {
  width: 48px; height: 48px;
  background: rgba(233,195,73,0.1);
  border: 1px solid rgba(233,195,73,0.3);
  border-radius: 0.5rem;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700; font-size: 0.9rem;
  color: #e9c349;
}

/* ===== ROOM CODE ===== */
.room-code {
  font-family: 'Space Grotesk', monospace;
  font-size: 2rem; font-weight: 900;
  letter-spacing: 6px;
  color: #4edea3;
  background: #060e20;
  padding: 12px 24px;
  border-radius: 0.5rem;
  border: 1px dashed rgba(78,222,163,0.2);
  user-select: all; cursor: pointer;
}

/* ===== STATS GRID ===== */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.stat-card {
  background: #131b2e;
  border-radius: 0.5rem;
  padding: 16px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  border-top: 0.5px solid rgba(255,255,255,0.05);
}
.stat-card .stat-icon { font-size: 1.5rem; color: #4edea3; }
.stat-card .stat-value {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700; font-size: 1.8rem;
  color: #dae2fd;
}
.stat-card .stat-label {
  font-size: 0.65rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 1px;
  color: #909097;
}

/* ===== MATCH HISTORY ===== */
.match-entry {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  background: #131b2e;
  border-radius: 0.5rem;
  transition: background 0.15s;
}
.match-entry:hover { background: #171f33; }
.match-entry .result-badge {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700; font-size: 0.7rem;
  padding: 2px 8px; border-radius: 0.25rem;
}
.match-entry .result-badge.win { background: rgba(78,222,163,0.15); color: #4edea3; }
.match-entry .result-badge.loss { background: rgba(255,180,171,0.15); color: #ffb4ab; }

/* ===== TOGGLE SWITCH ===== */
.toggle-switch {
  position: relative;
  width: 48px; height: 26px;
  background: #222a3d;
  border-radius: 13px;
  cursor: pointer;
  transition: background 0.2s;
}
.toggle-switch.on { background: #4edea3; }
.toggle-switch::after {
  content: '';
  position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px;
  background: #dae2fd;
  border-radius: 50%;
  transition: transform 0.2s;
}
.toggle-switch.on::after { transform: translateX(22px); background: #003824; }

/* ===== PROGRESS BAR ===== */
.progress-bar {
  height: 6px;
  background: #131b2e;
  border-radius: 3px;
  overflow: hidden;
}
.progress-bar .fill {
  height: 100%;
  background: linear-gradient(90deg, #4edea3, #009365);
  border-radius: 3px;
  transition: width 0.5s;
}

/* ===== SPLASH SCREEN ===== */
.splash-bg {
  background: linear-gradient(180deg, #0b1326 0%, #060e20 50%, #0b1326 100%);
  position: relative;
  overflow: hidden;
}
.splash-bg::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 50% 30%, rgba(78,222,163,0.06) 0%, transparent 60%);
}

/* ===== SECTION ACCENT BAR ===== */
.section-accent {
  display: flex; align-items: center; gap: 8px;
}
.section-accent::before {
  content: '';
  width: 3px; height: 1.2em;
  background: #e9c349;
  border-radius: 2px;
}

/* ===== ANIMATIONS ===== */
@keyframes bubbleIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideDown { from { opacity: 0; transform: translate(-50%, -20px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideUp { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
@keyframes shimmer {
  0% { background-position: -200% center; }
  100% { background-position: 200% center; }
}
@keyframes cardReveal {
  0% { transform: perspective(1000px) rotateY(0deg); }
  100% { transform: perspective(1000px) rotateY(180deg); }
}
@keyframes confettiFall {
  0% { transform: translateY(-10vh) rotate(0deg); opacity: 1; }
  100% { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}
@keyframes glow {
  0%, 100% { box-shadow: 0 0 8px rgba(78,222,163,0.2); }
  50% { box-shadow: 0 0 24px rgba(78,222,163,0.4); }
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes countUp { from { opacity: 0; transform: scale(0.5); } to { opacity: 1; transform: scale(1); } }

/* Utility animations */
.animate-fade-in { animation: fadeIn 0.4s ease-out; }
.animate-slide-up { animation: slideUp 0.4s ease-out; }
.animate-pulse { animation: pulse 2s ease-in-out infinite; }
.animate-glow { animation: glow 2s ease-in-out infinite; }
.animate-spin { animation: spin 1s linear infinite; }

/* ===== CONFETTI ===== */
.confetti-container { position: fixed; inset: 0; pointer-events: none; z-index: 200; overflow: hidden; }
.confetti-piece {
  position: absolute; width: 10px; height: 10px; top: -10px;
  animation: confettiFall 3s linear forwards;
}

/* ===== MODAL OVERLAY ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(6,14,32,0.85);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: none; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-overlay.active { display: flex; }

/* ===== RESPONSIVE ===== */
@media (max-width: 640px) {
  .room-code { font-size: 1.5rem; letter-spacing: 4px; }
}

/* Body padding for bottom nav */
.has-bottom-nav { padding-bottom: 72px; }
