/* ============================================================
   March Madness Bracket Delusion Scorer
   Dark theme | Basketball-inspired | Mobile-first
   ============================================================ */

:root {
  --bg-primary: #0a0e1a;
  --bg-secondary: #111827;
  --bg-card: #1a2035;
  --bg-elevated: #1f2a45;
  --orange: #ff6b2b;
  --orange-glow: rgba(255, 107, 43, 0.25);
  --orange-dim: rgba(255, 107, 43, 0.12);
  --white: #f0f2f5;
  --white-muted: rgba(240, 242, 245, 0.65);
  --white-dim: rgba(240, 242, 245, 0.35);
  --navy: #0f172a;
  --navy-light: #1e293b;
  --accent-green: #22c55e;
  --accent-red: #ef4444;
  --accent-purple: #a855f7;
  --font-sans: 'Space Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ---- Reset ---- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--white);
  line-height: 1.5;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

/* ---- App Container ---- */
#app {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/* ---- Screens ---- */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transform: translateX(30px);
  transition:
    opacity var(--transition-slow),
    transform var(--transition-slow),
    visibility 0s linear var(--transition-slow);
  will-change: opacity, transform;
}

.screen.active {
  opacity: 1;
  visibility: visible;
  transform: translateX(0);
  transition:
    opacity var(--transition-slow),
    transform var(--transition-slow),
    visibility 0s linear 0s;
}

.screen.exit-left {
  opacity: 0;
  visibility: hidden;
  transform: translateX(-30px);
}

/* ============================================================
   SCREEN 1: INTRO
   ============================================================ */
.intro-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 24px calc(24px + var(--safe-bottom));
  text-align: center;
  gap: 6px;
}

.intro-icon {
  margin-bottom: 8px;
}

.basketball-bounce {
  display: inline-block;
  font-size: 56px;
  animation: bounce 2s ease-in-out infinite;
  filter: drop-shadow(0 4px 20px var(--orange-glow));
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}

.intro-title {
  font-size: clamp(28px, 7vw, 38px);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--white) 0%, var(--orange) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.intro-tagline {
  font-size: 16px;
  color: var(--white-muted);
  font-weight: 400;
  margin-top: 4px;
}

/* Decorative bracket lines */
.intro-decoration {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
}

.bracket-line {
  width: 50px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--orange));
  border-radius: 1px;
}

.bracket-line.right {
  background: linear-gradient(90deg, var(--orange), transparent);
}

.bracket-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--orange);
  box-shadow: 0 0 12px var(--orange-glow);
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 36px;
  font-size: 16px;
  font-weight: 600;
  color: var(--white);
  background: linear-gradient(135deg, var(--orange) 0%, #e85d20 100%);
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 24px var(--orange-glow), inset 0 1px 0 rgba(255,255,255,0.15);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  position: relative;
  overflow: hidden;
  margin-top: 8px;
}

.btn-primary::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.12), transparent);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.btn-primary:active {
  transform: scale(0.97);
  box-shadow: 0 2px 12px var(--orange-glow);
}

.btn-primary:active::after {
  opacity: 1;
}

.intro-footer {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--white-dim);
  margin-top: 10px;
  letter-spacing: 0.02em;
}

/* ============================================================
   SCREEN 2: QUIZ
   ============================================================ */
.quiz-header {
  padding: 16px 20px 0;
  flex-shrink: 0;
}

.progress-container {
  width: 100%;
}

.progress-text {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}

#progress-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--white-muted);
}

#progress-label #q-current {
  color: var(--orange);
  font-weight: 700;
  font-family: var(--font-mono);
}

#progress-pct {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--white-dim);
}

.progress-track {
  width: 100%;
  height: 4px;
  background: var(--bg-elevated);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--orange), #ff8f5a);
  border-radius: 2px;
  transition: width var(--transition-slow);
}

.quiz-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 24px 20px calc(24px + var(--safe-bottom));
  gap: 20px;
}

.quiz-question-text {
  font-size: clamp(18px, 4.5vw, 22px);
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -0.01em;
  color: var(--white);
  text-align: center;
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.option-btn {
  width: 100%;
  padding: 14px 16px;
  font-size: 15px;
  font-weight: 500;
  color: var(--white);
  background: var(--bg-card);
  border: 1.5px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-md);
  text-align: left;
  transition:
    background var(--transition-fast),
    border-color var(--transition-fast),
    transform var(--transition-fast),
    box-shadow var(--transition-fast);
  position: relative;
  overflow: hidden;
}

.option-btn::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--orange);
  transform: scaleY(0);
  transition: transform var(--transition-fast);
  border-radius: 0 2px 2px 0;
}

.option-btn:active {
  transform: scale(0.98);
}

.option-btn:hover {
  background: var(--bg-elevated);
  border-color: rgba(255, 107, 43, 0.2);
}

.option-btn.selected {
  background: var(--bg-elevated);
  border-color: var(--orange);
  box-shadow: 0 0 20px var(--orange-glow);
}

.option-btn.selected::before {
  transform: scaleY(1);
}

/* Fade transition for question changes */
.quiz-body.fade-out {
  opacity: 0;
  transform: translateX(20px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.quiz-body.fade-in {
  opacity: 1;
  transform: translateX(0);
  transition: opacity 220ms ease, transform 220ms ease;
}

/* ============================================================
   SCREEN 3: RESULTS
   ============================================================ */
.results-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px 24px calc(20px + var(--safe-bottom));
  gap: 16px;
  text-align: center;
}

.meter-container {
  position: relative;
  flex-shrink: 0;
}

.meter-ring {
  position: relative;
  width: clamp(160px, 40vw, 200px);
  height: clamp(160px, 40vw, 200px);
}

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

.meter-track {
  fill: none;
  stroke: var(--bg-elevated);
  stroke-width: 10;
}

.meter-fill {
  fill: none;
  stroke: var(--orange);
  stroke-width: 10;
  stroke-linecap: round;
  stroke-dasharray: 534;
  stroke-dashoffset: 534;
  transition: stroke-dashoffset 1.8s cubic-bezier(0.4, 0, 0.2, 1);
  filter: drop-shadow(0 0 8px var(--orange-glow));
}

.meter-value {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.score-num {
  font-family: var(--font-mono);
  font-size: clamp(40px, 10vw, 56px);
  font-weight: 700;
  line-height: 1;
  color: var(--white);
}

.score-label {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--white-dim);
  margin-top: 2px;
}

.result-tier {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.result-emoji {
  font-size: 32px;
  line-height: 1;
}

.result-title {
  font-size: clamp(20px, 5vw, 26px);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--orange);
}

.result-desc {
  font-size: 14px;
  color: var(--white-muted);
  max-width: 280px;
  line-height: 1.5;
}

.result-stat {
  padding: 10px 16px;
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-md);
  max-width: 320px;
}

.stat-text {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--white-muted);
  line-height: 1.6;
}

.stat-text strong {
  color: var(--orange);
  font-weight: 600;
}

.result-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 300px;
  margin-top: 4px;
}

.btn-share {
  width: 100%;
}

.btn-secondary {
  width: 100%;
  padding: 12px 24px;
  font-size: 15px;
  font-weight: 600;
  color: var(--white-muted);
  background: var(--bg-card);
  border: 1.5px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-lg);
  transition: background var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
}

.btn-secondary:active {
  transform: scale(0.97);
  background: var(--bg-elevated);
}

.btn-secondary:hover {
  border-color: rgba(255, 255, 255, 0.15);
}

/* ============================================================
   UTILITY & MEDIA
   ============================================================ */

/* Subtle background pattern */
#app::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(255, 107, 43, 0.06) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 100%, rgba(168, 85, 247, 0.04) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

.screen {
  z-index: 1;
}

/* Larger phones / small tablets */
@media (min-height: 700px) {
  .intro-content {
    gap: 10px;
  }

  .results-content {
    gap: 20px;
  }
}

/* Very short screens */
@media (max-height: 580px) {
  .basketball-bounce {
    font-size: 40px;
  }

  .intro-title {
    font-size: 24px;
  }

  .meter-ring {
    width: 130px;
    height: 130px;
  }

  .results-content {
    gap: 10px;
    padding-top: 12px;
  }

  .result-stat {
    padding: 8px 12px;
  }

  .score-num {
    font-size: 36px;
  }
}

/* Animations */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-in {
  animation: fadeInUp 400ms cubic-bezier(0.4, 0, 0.2, 1) both;
}

.animate-in:nth-child(1) { animation-delay: 0ms; }
.animate-in:nth-child(2) { animation-delay: 80ms; }
.animate-in:nth-child(3) { animation-delay: 160ms; }
.animate-in:nth-child(4) { animation-delay: 240ms; }
.animate-in:nth-child(5) { animation-delay: 320ms; }

/* Score count-up glow */
@keyframes scoreGlow {
  0%, 100% { text-shadow: none; }
  50% { text-shadow: 0 0 30px var(--orange-glow); }
}

.score-counting {
  animation: scoreGlow 1.8s ease-in-out;
}
