/* ============================================
   AquaParty Mobile — Liquid Arcade Theme
   ============================================ */

/* === CSS VARIABLES === */
:root {
  --blue-rotoplas: #0066B3;
  --cyan: #00BCD4;
  --aqua: #00E5FF;
  --green-pipe: #4CAF50;
  --green-pipe-dark: #2E7D32;
  --green-glow: #66BB6A;
  --gold: #FFD700;
  --green-success: #4CAF50;
  --red: #FF5252;
  --orange: #FF9800;
  --bg-dark: #0A1628;
  --bg-mid: #1A3A5C;
  --white: #FFFFFF;
  --overlay: rgba(0,0,0,0.6);
  --font: 'Space Grotesk', 'Segoe UI', system-ui, sans-serif;
  --safe-top: max(12px, env(safe-area-inset-top));
  --safe-bottom: max(16px, env(safe-area-inset-bottom));
}

/* === RESET === */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--bg-dark);
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  font-family: var(--font);
  color: var(--white);
}

/* === CONTAINERS === */
#scene-container {
  position: fixed; top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 10;
}

#phaser-container {
  position: fixed; top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 5;
  display: none;
}
#phaser-container.active { display: block; }
#phaser-container canvas { width: 100% !important; height: 100% !important; }

/* === LOADING SCREEN === */
#loading {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--bg-dark), var(--bg-mid));
  z-index: 9999; transition: opacity 0.5s;
}
#loading.fade-out { opacity: 0; pointer-events: none; }
#loading h1 {
  font-size: 42px; letter-spacing: 6px; margin-bottom: 8px; font-weight: 700;
  background: linear-gradient(135deg, var(--cyan), var(--gold));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
#loading .subtitle {
  color: rgba(255,255,255,0.6); font-size: 14px; letter-spacing: 3px;
  text-transform: uppercase; margin-bottom: 24px;
}
.spinner {
  width: 40px; height: 40px; border: 3px solid rgba(0,188,212,0.2);
  border-top-color: var(--cyan); border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* === SCENE BASE === */
.scene {
  position: absolute; top: 0; left: 0;
  width: 100%; height: 100%;
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, var(--bg-dark), var(--bg-mid));
  overflow: hidden;
}

/* === ANIMATED BACKGROUND (bubbles) === */
.scene-bg {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  pointer-events: none; overflow: hidden;
}
.bubble {
  position: absolute; bottom: -20px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, rgba(0,229,255,0.3), rgba(0,188,212,0.1));
  animation: bubbleRise linear infinite;
}
@keyframes bubbleRise {
  0% { transform: translateY(0) scale(1); opacity: 0.6; }
  50% { opacity: 0.8; }
  100% { transform: translateY(-110vh) scale(0.3); opacity: 0; }
}

/* === TYPOGRAPHY === */
.title-xl {
  font-size: 28px; font-weight: 700; text-align: center;
  background: linear-gradient(135deg, var(--cyan), var(--gold));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: none;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}
.title-lg {
  font-size: 22px; font-weight: 700; text-align: center; color: var(--white);
  text-shadow: 0 2px 8px rgba(0,0,0,0.5);
}
.title-md {
  font-size: 18px; font-weight: 600; text-align: center; color: var(--cyan);
  text-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
.text-subtle {
  font-size: 14px; color: rgba(255,255,255,0.5); text-align: center;
  letter-spacing: 1px; text-transform: uppercase;
}

/* === CARDS === */
.card {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(0,188,212,0.2);
  border-radius: 16px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 16px;
}
.card-glow {
  box-shadow: 0 0 20px rgba(0,188,212,0.3), inset 0 0 20px rgba(0,188,212,0.05);
}

/* === BUTTONS === */
.btn-primary {
  width: 100%; max-width: 340px; padding: 18px 24px;
  border: none; border-radius: 14px; font-size: 20px; font-weight: 700;
  background: linear-gradient(135deg, var(--blue-rotoplas), var(--cyan));
  color: var(--white);
  text-transform: uppercase; letter-spacing: 2px; cursor: pointer;
  font-family: var(--font); transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 4px 20px rgba(0,102,179,0.4);
}
.btn-primary:active { transform: scale(0.96); }
.btn-primary:disabled { opacity: 0.4; pointer-events: none; }
.btn-primary:not(:disabled) { animation: btnPulse 2s ease-in-out infinite; }
@keyframes btnPulse {
  0%, 100% { box-shadow: 0 4px 20px rgba(0,102,179,0.4); }
  50% { box-shadow: 0 8px 40px rgba(0,188,212,0.6); }
}

.btn-success {
  padding: 18px 48px; border: none; border-radius: 14px;
  font-size: 18px; font-weight: 700;
  background: linear-gradient(135deg, var(--green-success), #8BC34A);
  color: var(--white);
  text-transform: uppercase; letter-spacing: 2px; cursor: pointer;
  font-family: var(--font);
  box-shadow: 0 4px 20px rgba(76,175,80,0.4);
}
.btn-success:active { transform: scale(0.96); }

/* === INPUTS === */
.input-field {
  width: 100%; max-width: 340px; padding: 16px 18px;
  border: 2px solid rgba(0,188,212,0.3); border-radius: 12px;
  background: rgba(10,22,40,0.8); color: var(--white);
  font-size: 18px; text-align: center; outline: none;
  font-family: var(--font); transition: border-color 0.2s, box-shadow 0.2s;
}
.input-field:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 20px rgba(0,188,212,0.2);
}
.input-field::placeholder { color: rgba(255,255,255,0.3); }

/* === CHARACTER CARDS === */
.char-grid {
  display: flex; gap: 10px; padding: 0 16px;
  overflow-x: auto; scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.char-grid::-webkit-scrollbar { display: none; }
.char-card {
  flex: 0 0 auto; width: 100px; scroll-snap-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 12px 8px; border-radius: 14px; cursor: pointer;
  background: rgba(255,255,255,0.05);
  border: 2px solid transparent;
  transition: all 0.3s ease;
}
.char-card:active { transform: scale(0.95); }
.char-card.selected {
  border-color: var(--cyan);
  background: rgba(0,188,212,0.15);
  box-shadow: 0 0 20px rgba(0,188,212,0.3);
  transform: scale(1.05);
}
.char-emoji { font-size: 36px; line-height: 1; }
.char-name { font-size: 11px; font-weight: 600; color: var(--cyan); text-align: center; }
.char-power { font-size: 9px; color: rgba(255,255,255,0.4); text-align: center; line-height: 1.2; }

/* === TRIVIA BUTTONS === */
.trivia-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 12px; padding: 0 16px; width: 100%;
}
.trivia-btn {
  padding: 20px 12px; border: none; border-radius: 16px;
  font-size: 18px; font-weight: 700; color: var(--white);
  cursor: pointer; font-family: var(--font);
  transition: all 0.2s ease;
  box-shadow: 0 4px 15px rgba(0,0,0,0.3);
  display: flex; align-items: center; justify-content: center;
  min-height: 70px; text-align: center; line-height: 1.2;
  position: relative; overflow: hidden;
}
.trivia-btn::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.1) 0%, transparent 50%);
  border-radius: 16px;
}
.trivia-btn:active { transform: scale(0.95); }
.trivia-btn.opt-a { background: linear-gradient(135deg, #1565C0, #1976D2); }
.trivia-btn.opt-b { background: linear-gradient(135deg, #C62828, #E53935); }
.trivia-btn.opt-c { background: linear-gradient(135deg, #2E7D32, #43A047); }
.trivia-btn.opt-d { background: linear-gradient(135deg, #E65100, #F57C00); }
.trivia-btn.correct {
  background: linear-gradient(135deg, #2E7D32, #4CAF50) !important;
  animation: correctPulse 0.5s ease;
}
.trivia-btn.wrong {
  background: linear-gradient(135deg, #B71C1C, #D32F2F) !important;
  animation: shake 0.5s ease;
}
.trivia-btn.locked {
  opacity: 0.4; pointer-events: none;
}
.trivia-btn.selected-lock {
  box-shadow: 0 0 25px rgba(0,188,212,0.5);
  border: 2px solid var(--cyan);
}

/* Trivia animations */
@keyframes popIn {
  0% { transform: scale(0); opacity: 0; }
  70% { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes correctPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.08); }
  100% { transform: scale(1); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}

/* === TIMER BAR === */
.timer-bar-container {
  width: 100%; max-width: 340px; height: 6px;
  background: rgba(255,255,255,0.1); border-radius: 3px;
  overflow: hidden; margin: 0 auto;
}
.timer-bar {
  height: 100%; border-radius: 3px;
  background: linear-gradient(90deg, var(--cyan), var(--aqua));
  transition: width 1s linear;
}
.timer-bar.danger {
  background: linear-gradient(90deg, var(--red), var(--orange));
  animation: timerPulse 0.5s ease infinite;
}
@keyframes timerPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* === TIMER TEXT === */
.timer-text {
  font-size: 24px; font-weight: 700; color: var(--cyan);
  font-family: var(--font); text-align: center;
}
.timer-text.danger { color: var(--red); animation: timerPulse 0.5s ease infinite; }

/* === SCORE DISPLAY === */
.score-text {
  font-size: 20px; font-weight: 600; color: var(--gold);
  text-shadow: 0 2px 8px rgba(0,0,0,0.5);
}
.score-fly {
  position: absolute; font-size: 24px; font-weight: 700;
  color: var(--gold); pointer-events: none;
  animation: scoreFly 1s ease-out forwards;
}
@keyframes scoreFly {
  0% { transform: translateY(0) scale(1); opacity: 1; }
  100% { transform: translateY(-60px) scale(1.5); opacity: 0; }
}

/* === GAUGE (Estimate) === */
.gauge-container {
  width: 80px; height: 300px; max-height: 50vh;
  border-radius: 12px; border: 3px solid rgba(0,188,212,0.4);
  background: rgba(0,0,0,0.3); position: relative;
  overflow: hidden;
}
.gauge-fill {
  position: absolute; bottom: 0; left: 0; width: 100%;
  background: linear-gradient(0deg, var(--blue-rotoplas), var(--cyan));
  border-radius: 0 0 9px 9px;
  transition: height 0.1s ease-out;
}
.gauge-wave {
  position: absolute; top: -8px; left: -10%; width: 120%;
  height: 16px; pointer-events: none;
  background: radial-gradient(ellipse at 50% 100%, rgba(0,229,255,0.4), transparent);
  animation: waveMove 2s ease-in-out infinite;
}
@keyframes waveMove {
  0%, 100% { transform: translateX(-5%); }
  50% { transform: translateX(5%); }
}
.gauge-value {
  font-size: 32px; font-weight: 700; color: var(--white);
  text-shadow: 0 2px 10px rgba(0,0,0,0.5);
}
.gauge-markers {
  position: absolute; top: 0; right: -40px; width: 35px; height: 100%;
  display: flex; flex-direction: column; justify-content: space-between;
}
.gauge-marker {
  font-size: 10px; color: rgba(255,255,255,0.4); text-align: left;
}

/* === SCORE SCENE === */
.score-bar-row {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 16px; width: 100%;
}
.score-bar-name {
  font-size: 14px; font-weight: 600; width: 80px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.score-bar-track {
  flex: 1; height: 28px; background: rgba(255,255,255,0.08);
  border-radius: 14px; overflow: hidden; position: relative;
}
.score-bar-fill {
  height: 100%; border-radius: 14px;
  transition: width 1.5s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex; align-items: center; justify-content: flex-end;
  padding-right: 8px; font-size: 12px; font-weight: 700;
}
.score-bar-emoji { font-size: 24px; }
.score-position-change {
  font-size: 12px; font-weight: 600; width: 30px; text-align: center;
}
.score-position-change.up { color: var(--green-success); }
.score-position-change.down { color: var(--red); }

/* === CONFETTI === */
.confetti {
  position: fixed; top: -10px;
  width: 8px; height: 14px; border-radius: 2px;
  animation: confettiFall linear forwards;
  z-index: 1000; pointer-events: none;
}
@keyframes confettiFall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}

/* === INTRO SCENE === */
.intro-number {
  font-size: 120px; font-weight: 700; color: var(--white);
  text-shadow: 0 0 40px rgba(0,188,212,0.5);
  animation: introNumberPop 0.8s ease;
}
@keyframes introNumberPop {
  0% { transform: scale(3); opacity: 0; }
  60% { transform: scale(0.9); opacity: 1; }
  100% { transform: scale(1); }
}
.intro-title {
  font-size: 28px; font-weight: 700; text-align: center;
  background: linear-gradient(135deg, var(--gold), var(--orange));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: slideInUp 0.6s ease;
}
@keyframes slideInUp {
  0% { transform: translateY(30px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}

/* === WAITING DOTS ANIMATION === */
.dots::after {
  content: '';
  animation: dots 1.5s steps(4, end) infinite;
}
@keyframes dots {
  0% { content: ''; }
  25% { content: '.'; }
  50% { content: '..'; }
  75% { content: '...'; }
}

/* === FLOATING ANIMATION === */
.float { animation: float 3s ease-in-out infinite; }
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

/* === HUD === */
.game-hud {
  position: absolute; top: 0; left: 0; width: 100%;
  padding: 8px 16px; padding-top: var(--safe-top);
  display: flex; justify-content: space-between; align-items: center;
  background: linear-gradient(to bottom, rgba(10,22,40,0.85), transparent);
  z-index: 20; pointer-events: none;
}

/* === LOCK ICON === */
.lock-icon {
  display: inline-block; margin-left: 8px;
  animation: lockIn 0.3s ease;
}
@keyframes lockIn {
  0% { transform: scale(0) rotate(-180deg); }
  100% { transform: scale(1) rotate(0deg); }
}

/* === UTILITY === */
.hidden { display: none !important; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-col { display: flex; flex-direction: column; }
.gap-sm { gap: 8px; }
.gap-md { gap: 16px; }
.gap-lg { gap: 24px; }
.p-md { padding: 16px; }
.mt-auto { margin-top: auto; }
.mx-auto { margin-left: auto; margin-right: auto; }
.w-full { width: 100%; }
.text-center { text-align: center; }
