/* ============================================
   Expert de Verbier — Redesigned Stylesheet
   Mobile-first, game-focused, clean UX
   ============================================ */

:root {
  --navy: #1a2744;
  --navy-light: #243456;
  --navy-dark: #111c33;
  --snow: #f8f9fa;
  --snow-dim: #e9ecef;
  --glacier: #3b9eff;
  --glacier-dark: #2b7fd4;
  --glacier-light: #6bb5ff;
  --gold: #f5a623;
  --gold-light: #ffc857;
  --success: #2ecc71;
  --danger: #e74c3c;
  --warning: #f39c12;
  --text-primary: #1a2744;
  --text-secondary: #6c757d;
  --text-light: #ffffff;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --shadow-sm: 0 2px 8px rgba(26,39,68,0.06);
  --shadow-md: 0 4px 20px rgba(26,39,68,0.1);
  --shadow-lg: 0 8px 32px rgba(26,39,68,0.16);
  --shadow-xl: 0 16px 48px rgba(26,39,68,0.22);
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-display: 'Space Grotesk', 'DM Sans', sans-serif;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ============================================
   Reset
   ============================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-body);
  background: var(--navy);
  color: var(--text-primary);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--font-display); font-weight: 700; }
h1 { font-size: 1.75rem; line-height: 1.15; }
h2 { font-size: 1.25rem; line-height: 1.3; }
h3 { font-size: 1rem; line-height: 1.4; }

/* ============================================
   Utility classes
   ============================================ */
.hidden { display: none !important; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }

/* ============================================
   Screens
   ============================================ */
.screen {
  display: none;
  min-height: 100dvh;
  padding: 0;
}
.screen.active {
  display: flex;
  flex-direction: column;
  animation: screenIn 0.35s ease both;
}

@keyframes screenIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

@keyframes slideDown {
  from { transform: translateY(-20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes popIn {
  0% { transform: scale(0.5); opacity: 0; }
  70% { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes countUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

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

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-4px); }
  40%, 80% { transform: translateX(4px); }
}

/* ============================================
   Auth Screen
   ============================================ */
.auth-screen {
  background: linear-gradient(160deg, var(--navy) 0%, var(--navy-light) 40%, #1e3a5f 100%);
  justify-content: center;
  align-items: center;
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
}

.auth-screen::before {
  content: '';
  position: absolute;
  top: -40%;
  right: -30%;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(59,158,255,0.08) 0%, transparent 70%);
  pointer-events: none;
}

.auth-card {
  background: rgba(255,255,255,0.97);
  backdrop-filter: blur(20px);
  border-radius: var(--radius-xl);
  padding: 2rem 1.5rem;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-xl);
  position: relative;
  z-index: 1;
}

.auth-logo {
  text-align: center;
  margin-bottom: 1.75rem;
}

.auth-logo-img {
  width: 90px;
  height: 90px;
  border-radius: 20px;
  margin-bottom: 0.75rem;
}

.auth-logo h1 {
  color: var(--navy);
  font-size: 1.5rem;
}

.auth-logo p {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-top: 0.25rem;
}

.auth-powered {
  text-align: center;
  font-size: 0.7rem;
  color: rgba(255,255,255,0.5);
  margin-top: 1.5rem;
}
.auth-powered a {
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  font-weight: 600;
}
.auth-powered a:hover { color: white; }

.auth-subtitle {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
  font-weight: 500;
}

.auth-pitch {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 1.25rem 0;
  padding: 1rem;
  background: var(--snow);
  border-radius: var(--radius-md);
}

.pitch-item {
  font-size: 0.85rem;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-large {
  padding: 1rem;
  font-size: 1.05rem;
}

.auth-divider {
  text-align: center;
  margin: 0.75rem 0;
  position: relative;
  color: var(--text-secondary);
  font-size: 0.8rem;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 40%;
  height: 1px;
  background: var(--snow-dim);
}

.auth-divider::before { left: 0; }
.auth-divider::after { right: 0; }

.auth-account-hint {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 0.5rem;
}

.auth-privacy {
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin-top: 1rem;
  line-height: 1.4;
}

/* Language toggle (auth) */
.lang-toggle {
  display: flex;
  justify-content: center;
  margin-bottom: 1.5rem;
  background: var(--snow-dim);
  border-radius: var(--radius-sm);
  padding: 3px;
}

.lang-toggle button {
  flex: 1;
  padding: 0.45rem 1rem;
  border: none;
  background: none;
  border-radius: 6px;
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-secondary);
  min-height: 36px;
}

.lang-toggle button.active {
  background: white;
  color: var(--navy);
  box-shadow: var(--shadow-sm);
}

/* ============================================
   Form elements
   ============================================ */
.form-group { margin-bottom: 1rem; }

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
}

.form-input {
  width: 100%;
  padding: 0.8rem 1rem;
  border: 2px solid var(--snow-dim);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 1rem;
  transition: var(--transition);
  background: white;
  color: var(--text-primary);
  min-height: 48px;
}

.form-input:focus {
  outline: none;
  border-color: var(--glacier);
  box-shadow: 0 0 0 3px rgba(59,158,255,0.12);
}

.form-input::placeholder { color: #adb5bd; }

.otp-input {
  text-align: center;
  font-size: 1.5rem;
  font-family: var(--font-display);
  letter-spacing: 0.5rem;
  font-weight: 700;
}

/* ============================================
   Buttons
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.8rem 1.5rem;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  min-height: 48px;
  min-width: 48px;
  width: 100%;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

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

.btn-primary {
  background: var(--glacier);
  color: white;
}
.btn-primary:hover { background: var(--glacier-dark); }
.btn-primary:disabled {
  background: var(--snow-dim);
  color: var(--text-secondary);
  cursor: not-allowed;
  transform: none;
}

.btn-outline {
  background: transparent;
  border: 2px solid var(--glacier);
  color: var(--glacier);
}
.btn-outline:hover { background: rgba(59,158,255,0.06); }

.btn-gold {
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  color: var(--navy);
  font-weight: 700;
}

.btn-ghost {
  background: none;
  border: none;
  color: var(--text-secondary);
  width: 100%;
  padding: 0.6rem;
  font-weight: 600;
}

.btn-danger-ghost {
  background: none;
  border: none;
  color: var(--danger);
  width: 100%;
  padding: 0.6rem;
  font-weight: 600;
  font-family: var(--font-body);
  font-size: 0.85rem;
  cursor: pointer;
  margin-top: 1.5rem;
  min-height: 48px;
}

/* Spinner inside buttons */
.spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
}

/* ============================================
   HOME SCREEN
   ============================================ */
.home-screen {
  background: var(--snow);
  padding-bottom: 80px;
}

.home-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem 0;
}

.home-greeting {
  display: flex;
  flex-direction: column;
}

.greeting-text {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.greeting-name {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--navy);
}

.home-top-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Lang pill (home) */
.lang-pill {
  display: flex;
  background: var(--snow-dim);
  border-radius: 6px;
  padding: 2px;
}

.lang-pill button {
  padding: 0.3rem 0.6rem;
  border: none;
  background: none;
  border-radius: 5px;
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-secondary);
  min-height: 28px;
  min-width: 32px;
}

.lang-pill button.active {
  background: white;
  color: var(--navy);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* Title block */
.home-title-block {
  padding: 0.75rem 1.25rem 0;
}

.home-title-block h1 {
  color: var(--navy);
  margin-bottom: 0.75rem;
}

.home-stats-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: white;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.home-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
}

.home-stat-val {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  color: var(--navy);
  line-height: 1.2;
}

.home-stat-lbl {
  font-size: 0.65rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.home-stat-divider {
  width: 1px;
  height: 24px;
  background: var(--snow-dim);
}

/* Install banner */
.install-banner {
  margin: 0.75rem 1.25rem;
  padding: 0.6rem 0.75rem;
  background: linear-gradient(135deg, var(--navy), var(--navy-light, #2a3f6e));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: white;
  font-size: 0.8rem;
  font-weight: 600;
}
.install-text { flex: 1; min-width: 0; }
.install-actions { display: flex; align-items: center; gap: 0.4rem; flex-shrink: 0; }
.install-btn {
  padding: 0.35rem 0.65rem;
  font-size: 0.7rem;
  font-weight: 700;
  background: var(--glacier);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}
.install-close {
  background: none;
  border: none;
  color: rgba(255,255,255,0.5);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
}

/* Guest banner in profile */
.guest-banner {
  background: var(--snow);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin: 1rem 0;
  text-align: center;
}
.guest-banner p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
  line-height: 1.4;
}

/* Section label */
.home-section-label {
  padding: 1.25rem 1.25rem 0.5rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--navy);
}

/* ============================================
   Category Carousel
   ============================================ */
.category-carousel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  padding: 0.25rem 1.25rem 1rem;
}

.cat-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 1.25rem 1rem;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: var(--transition);
  border: 2px solid transparent;
  position: relative;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

.cat-card:active {
  transform: scale(0.97);
  box-shadow: var(--shadow-md);
}

.cat-card.locked {
  opacity: 0.5;
  cursor: not-allowed;
}

.cat-card-icon {
  font-size: 2rem;
  margin-bottom: 0.5rem;
  line-height: 1;
}

.cat-card-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--navy);
  margin-bottom: 0.15rem;
}

.cat-card-level {
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin-bottom: 0.65rem;
}

.cat-card-progress {
  height: 4px;
  background: var(--snow-dim);
  border-radius: 2px;
  overflow: hidden;
}

.cat-card-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--glacier), var(--glacier-light));
  border-radius: 2px;
  transition: width 0.6s ease;
}

.cat-card-play {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-top: 0.75rem;
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--glacier);
}

.cat-card-play svg {
  width: 14px;
  height: 14px;
}

/* ============================================
   Bottom Navigation
   ============================================ */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: white;
  border-top: 1px solid var(--snow-dim);
  display: flex;
  z-index: 9000;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  border: none;
  background: none;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.6rem;
  font-weight: 600;
  color: var(--text-secondary);
  transition: var(--transition);
  -webkit-tap-highlight-color: transparent;
  min-height: 48px;
  padding: 0.25rem;
}

.nav-item .nav-icon {
  font-size: 1.35rem;
  line-height: 1;
}

.nav-item.active {
  color: var(--glacier);
}

/* ============================================
   Level Sheet (Bottom Sheet)
   ============================================ */
.sheet-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(26,39,68,0.45);
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease;
}

.sheet-content {
  position: relative;
  background: white;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: 1rem 1.5rem calc(1.5rem + var(--safe-bottom));
  width: 100%;
  max-width: 480px;
  max-height: 75vh;
  overflow-y: auto;
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 1;
}

.sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--snow-dim);
  border-radius: 2px;
  margin: 0 auto 1rem;
}

.sheet-content h2 {
  margin-bottom: 1rem;
}

/* Level list inside sheet */
.level-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.level-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  background: var(--snow);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
  border: 2px solid transparent;
  -webkit-tap-highlight-color: transparent;
}

.level-row:active:not(.locked) {
  transform: scale(0.98);
  border-color: var(--glacier);
}

.level-row.locked {
  opacity: 0.4;
  cursor: not-allowed;
}

.level-num {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  flex-shrink: 0;
}

.level-num.l1 { background: rgba(46,204,113,0.12); color: var(--success); }
.level-num.l2 { background: rgba(59,158,255,0.12); color: var(--glacier); }
.level-num.l3 { background: rgba(245,166,35,0.12); color: var(--gold); }
.level-num.l4 { background: rgba(231,76,60,0.12); color: var(--danger); }
.level-num.l5 { background: rgba(155,89,182,0.12); color: #9b59b6; }

.level-info { flex: 1; min-width: 0; }

.level-info-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--navy);
}

.level-info-desc {
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin-top: 0.1rem;
}

.level-info-score {
  font-size: 0.75rem;
  color: var(--glacier);
  font-weight: 600;
  margin-top: 0.15rem;
}

.level-row-arrow {
  color: var(--glacier);
  flex-shrink: 0;
}

/* ============================================
   Game Screen
   ============================================ */
.game-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--snow);
}

#game-map {
  position: absolute;
  inset: 0;
  z-index: 1;
}

/* HUD top overlay */
.game-hud-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 0.75rem;
  pointer-events: none;
}

.game-hud-top > * {
  pointer-events: auto;
}

.game-btn-close {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(26,39,68,0.8);
  backdrop-filter: blur(8px);
  border: none;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

.game-hud-center {
  text-align: center;
  flex: 1;
  padding: 0 0.5rem;
}

.game-round-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: rgba(255,255,255,0.8);
  background: rgba(26,39,68,0.5);
  backdrop-filter: blur(8px);
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 10px;
  margin-bottom: 0.3rem;
}

.game-place-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.3rem;
  color: white;
  text-shadow: 0 2px 12px rgba(0,0,0,0.5), 0 0 40px rgba(0,0,0,0.2);
  line-height: 1.2;
}

/* Timer circle */
.game-timer-circle {
  position: relative;
  width: 52px;
  height: 52px;
  flex-shrink: 0;
}

.timer-ring {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.timer-ring-bg {
  fill: none;
  stroke: rgba(255,255,255,0.2);
  stroke-width: 4;
}

.timer-ring-fill {
  fill: none;
  stroke: var(--success);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-dasharray: 163.36;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 1s linear, stroke 0.5s ease;
}

.timer-ring-fill.warning { stroke: var(--warning); }
.timer-ring-fill.danger { stroke: var(--danger); }

.timer-number {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  color: white;
  text-shadow: 0 1px 6px rgba(0,0,0,0.4);
}

.timer-number.pulse {
  animation: pulse 0.5s ease;
}

/* Score pill (top-left, below close button) */
.game-score-pill {
  position: absolute;
  top: 60px;
  left: 0.75rem;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  background: rgba(26,39,68,0.75);
  backdrop-filter: blur(8px);
  padding: 0.3rem 0.6rem;
  border-radius: 12px;
}

.game-score-val {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--gold);
}

.game-score-lbl {
  font-size: 0.65rem;
  color: rgba(255,255,255,0.6);
}

/* Bottom guess area */
.game-bottom {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  padding: 0 1rem calc(1rem + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  pointer-events: none;
}

.game-bottom > * { pointer-events: auto; }

.guess-hint {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--navy);
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(8px);
  padding: 0.35rem 0.85rem;
  border-radius: 20px;
  box-shadow: var(--shadow-sm);
  transition: opacity 0.3s ease;
}

.guess-hint.hidden-soft {
  opacity: 0;
  pointer-events: none;
}

.btn-guess {
  width: 100%;
  max-width: 320px;
  background: var(--glacier);
  color: white;
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  padding: 1rem 2rem;
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(59,158,255,0.4);
  border: none;
  cursor: pointer;
  transition: var(--transition);
  min-height: 56px;
  -webkit-tap-highlight-color: transparent;
  letter-spacing: 0.02em;
}

.btn-guess:active:not(:disabled) { transform: scale(0.97); }

.btn-guess:disabled {
  background: rgba(255,255,255,0.15);
  backdrop-filter: blur(8px);
  color: rgba(255,255,255,0.5);
  box-shadow: none;
  cursor: not-allowed;
}

.btn-guess.ready {
  background: var(--glacier);
  color: white;
  box-shadow: 0 4px 20px rgba(59,158,255,0.4);
  animation: popIn 0.3s ease;
}

/* ============================================
   Round Result Sheet
   ============================================ */
.result-sheet {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1001;
  background: white;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  box-shadow: 0 -4px 32px rgba(0,0,0,0.15);
  animation: slideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.result-sheet-inner {
  padding: 1.5rem 1.5rem calc(1.5rem + var(--safe-bottom));
  text-align: center;
}

.result-emoji {
  font-size: 2.5rem;
  margin-bottom: 0.25rem;
  animation: popIn 0.4s ease 0.1s both;
}

.result-feedback {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
}

.result-feedback.perfect { color: var(--gold); }
.result-feedback.excellent { color: var(--success); }
.result-feedback.good { color: var(--glacier); }
.result-feedback.ok { color: var(--warning); }
.result-feedback.poor { color: var(--danger); }

.result-distance-big {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 2rem;
  color: var(--navy);
  line-height: 1;
}

.result-distance-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}

.result-points-anim {
  display: inline-flex;
  align-items: baseline;
  gap: 0.2rem;
  margin-bottom: 1.25rem;
  animation: countUp 0.5s ease 0.3s both;
}

.result-plus {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--glacier);
}

.result-pts {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.8rem;
  color: var(--glacier);
}

.result-pts-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.btn-next {
  margin-top: 0;
}

/* ============================================
   Level Complete Overlay
   ============================================ */
.complete-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(26,39,68,0.92);
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem;
  animation: fadeIn 0.4s ease;
}

.confetti-canvas {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

.confetti-piece {
  position: absolute;
  width: 8px;
  height: 14px;
  border-radius: 2px;
  top: -20px;
  animation: confettiFall linear forwards;
}

@keyframes confettiFall {
  0% {
    transform: translateY(0) rotate(0deg) scale(1);
    opacity: 1;
  }
  80% { opacity: 1; }
  100% {
    transform: translateY(100vh) rotate(720deg) scale(0.5);
    opacity: 0;
  }
}

.complete-card {
  background: white;
  border-radius: var(--radius-xl);
  padding: 2rem 1.75rem;
  max-width: 340px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-xl);
  position: relative;
  z-index: 1;
  animation: popIn 0.5s ease 0.15s both;
}

.complete-emoji {
  font-size: 3.5rem;
  margin-bottom: 0.5rem;
}

.complete-card h2 {
  margin-bottom: 0.5rem;
  color: var(--navy);
}

.complete-stars {
  font-size: 1.8rem;
  margin-bottom: 0.75rem;
  letter-spacing: 0.25rem;
}

.complete-score-wrap {
  margin-bottom: 1rem;
}

.complete-score-num {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 2.5rem;
  color: var(--glacier);
  line-height: 1;
}

.complete-score-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.unlock-badge {
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  color: var(--navy);
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius-md);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.85rem;
  margin-bottom: 1rem;
  display: inline-block;
  animation: pulse 0.8s ease 0.6s 3;
}

.complete-actions {
  display: flex;
  gap: 0.5rem;
}

.complete-actions .btn {
  flex: 1;
}

/* ============================================
   Screen Header (Leaderboard, Multiplayer)
   ============================================ */
.screen-header {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
  color: white;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.screen-header h2 { color: white; }

.header-back {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  border: none;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

/* ============================================
   Leaderboard Screen
   ============================================ */
.lb-screen {
  background: var(--snow);
}

.lb-body {
  padding: 1.25rem;
  flex: 1;
  overflow-y: auto;
  padding-bottom: 2rem;
}

.lb-podium {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  padding: 1rem 0;
}

.podium-item {
  text-align: center;
  flex: 1;
  max-width: 110px;
}

.podium-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--snow-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  margin: 0 auto 0.4rem;
  font-size: 1.1rem;
  color: var(--navy);
}

.podium-item:nth-child(2) .podium-avatar {
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  color: var(--navy);
  font-size: 1.5rem;
  box-shadow: 0 4px 16px rgba(245,166,35,0.3);
}

.podium-name {
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--navy);
}

.podium-score {
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--glacier);
}

.podium-rank {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 0.2rem;
}

.lb-list { display: flex; flex-direction: column; gap: 0.4rem; }

.lb-row {
  background: white;
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  box-shadow: var(--shadow-sm);
}

.lb-rank {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.85rem;
  width: 28px;
  text-align: center;
  color: var(--text-secondary);
}

.lb-info { flex: 1; min-width: 0; }
.lb-info .lb-name {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--navy);
}
.lb-info .lb-title {
  font-size: 0.65rem;
  color: var(--text-secondary);
}

.lb-score {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--glacier);
}

/* ============================================
   Multiplayer Screen
   ============================================ */
.mp-screen { background: var(--snow); }

.mp-body {
  padding: 1.25rem;
  flex: 1;
  overflow-y: auto;
}

.mp-lobby-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1rem;
}

.qr-card {
  text-align: center;
  padding: 1.5rem;
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.25rem;
}

.qr-wrap canvas { max-width: 180px !important; max-height: 180px !important; }

.room-code-display {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.3rem;
  color: var(--navy);
  margin-top: 0.75rem;
}

.qr-hint {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 0.4rem;
}

.player-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin: 0.75rem 0 1rem;
}

.player-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
  background: white;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.player-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--glacier);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
}

.player-name {
  flex: 1;
  font-weight: 600;
  font-size: 0.9rem;
}

.host-badge {
  font-size: 0.6rem;
  background: var(--gold);
  color: var(--navy);
  padding: 0.12rem 0.45rem;
  border-radius: 8px;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.mp-settings {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

/* Profile actions */
.profile-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.profile-actions .btn { flex: 1; }

/* ============================================
   Toast
   ============================================ */
.toast-container {
  position: fixed;
  top: 0.75rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  width: 90%;
  max-width: 360px;
  pointer-events: none;
}

.toast {
  background: var(--navy);
  color: white;
  padding: 0.7rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: slideDown 0.3s ease, toastOut 0.3s ease 2.7s forwards;
  pointer-events: auto;
  text-align: center;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

@keyframes toastOut {
  to { opacity: 0; transform: translateY(-8px); }
}

/* ============================================
   Loading spinner (standalone)
   ============================================ */
.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(255,255,255,0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}

/* ============================================
   Responsive
   ============================================ */
@media (min-width: 768px) {
  .auth-card { padding: 2.5rem 2rem; }

  .home-screen { max-width: 600px; margin: 0 auto; }

  .category-carousel { grid-template-columns: 1fr 1fr 1fr; }

  .sheet-content { max-width: 480px; }

  .game-place-name { font-size: 1.5rem; }

  .complete-card { max-width: 380px; }

  .bottom-nav { max-width: 600px; left: 50%; transform: translateX(-50%); border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
}

@media (min-width: 1024px) {
  .category-carousel { grid-template-columns: repeat(4, 1fr); }
}

/* QR Scanner */
.join-buttons {
  display: flex;
  gap: 0.5rem;
}
.join-buttons .btn-primary { flex: 1; }
.btn-scan {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
}
#qr-reader {
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-top: 1rem;
}
#qr-reader video { border-radius: var(--radius-md); }
#qr-scanner-container { margin-top: 0.5rem; }
#html5-qr-code-full-region { border: none !important; }
#html5-qr-code-full-region img[alt="Info icon"] { display: none !important; }
