/* =============================================
   LA CARRERA DE TU VIDA — DIANA
   F1-inspired emotional storytelling experience
   ============================================= */

:root {
  --bg-0: #050505;
  --bg-1: #0a0a0a;
  --bg-2: #121214;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.18);
  --fg-0: #ffffff;
  --fg-1: rgba(255, 255, 255, 0.78);
  --fg-2: rgba(255, 255, 255, 0.55);
  --fg-3: rgba(255, 255, 255, 0.32);
  --red: #e10600;
  --red-glow: #ff1a14;
  --red-deep: #8b0300;
  --green: #00ff7a;     /* personal best */
  --purple: #b675ff;    /* overall best */
  --yellow: #ffcb05;
  --carbon: #1a1a1c;

  --font-display: 'Rajdhani', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --font-body: 'Inter', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--bg-0);
  color: var(--fg-0);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  min-height: 100vh;
}

body {
  /* subtle carbon weave */
  background-image:
    radial-gradient(ellipse at top, #14141a 0%, var(--bg-0) 60%),
    repeating-linear-gradient(45deg, transparent 0 4px, rgba(255,255,255,0.012) 4px 5px);
}

button, input { font-family: inherit; }

.mono { font-family: var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase; }
em { font-style: italic; color: var(--red-glow); font-weight: 500; }
strong { color: var(--fg-0); font-weight: 600; }
.accent { color: var(--red-glow); }
.heart { color: var(--red); display: inline-block; transform: translateY(1px); }

/* =========================================================
   SCREENS
   ========================================================= */
.screen {
  position: fixed;
  inset: 0;
  display: none;
  opacity: 0;
  transition: opacity 0.6s ease;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

.screen.active {
  display: block;
  opacity: 1;
  z-index: 2;
}

.screen.leaving {
  opacity: 0;
  pointer-events: none;
  z-index: 1;
}

/* =========================================================
   HUD
   ========================================================= */
.hud {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s ease;
  padding: 14px 20px;
}
.hud.visible { opacity: 1; }

.hud-row {
  display: flex;
  gap: 12px;
  align-items: stretch;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.hud-block {
  background: rgba(10,10,10,0.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.hud-label {
  color: var(--fg-3);
  font-size: 9px;
}

.hud-value {
  color: var(--fg-0);
  font-weight: 700;
  font-size: 13px;
  white-space: nowrap;
}
.hud-value small { color: var(--fg-2); font-weight: 400; font-size: 9px; }

.hud-sectors {
  flex-direction: row;
  align-items: center;
  gap: 10px;
}
.hud-sectors .hud-label { writing-mode: vertical-rl; transform: rotate(180deg); font-size: 8px; }
.sector {
  font-size: 10px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 3px;
  background: rgba(255,255,255,0.04);
  color: var(--fg-3);
  border: 1px solid var(--line);
  min-width: 28px;
  text-align: center;
}
.sector.green { color: #000; background: var(--green); border-color: var(--green); box-shadow: 0 0 12px rgba(0,255,122,0.5); }
.sector.purple { color: #fff; background: var(--purple); border-color: var(--purple); box-shadow: 0 0 12px rgba(182,117,255,0.5); }

@media (max-width: 720px) {
  .hud { padding: 8px 10px; }
  .hud-row { gap: 6px; flex-wrap: wrap; }
  .hud-block { padding: 6px 8px; }
  .hud-label { font-size: 8px; }
  .hud-value { font-size: 11px; }
  .hud-sectors .hud-label { display: none; }
  .sector { font-size: 9px; padding: 3px 6px; min-width: 22px; }
}

/* =========================================================
   SOUND TOGGLE
   ========================================================= */
.sound-toggle {
  position: fixed;
  bottom: 18px;
  right: 18px;
  z-index: 110;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(10,10,10,0.85);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--fg-0);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  font-weight: 600;
  transition: all 0.25s ease;
}
.sound-toggle:hover { border-color: var(--red); color: var(--red-glow); }
.sound-toggle.on { border-color: var(--red); color: var(--red-glow); box-shadow: 0 0 24px rgba(225,6,0,0.35); }
.st-icon svg { width: 16px; height: 16px; display: block; }
.sound-toggle:not(.on) #st-wave { opacity: 0.3; }

/* =========================================================
   LOGIN SCREEN
   ========================================================= */
.screen-login {
  padding: 32px 20px;
  min-height: 100vh;
}
.screen-login.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.grid-floor {
  position: absolute;
  inset: 50% -20% -10% -20%;
  background-image:
    linear-gradient(to right, rgba(225,6,0,0.18) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(225,6,0,0.12) 1px, transparent 1px);
  background-size: 60px 60px;
  transform: perspective(800px) rotateX(60deg);
  transform-origin: top center;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,1), transparent 80%);
  -webkit-mask-image: linear-gradient(to bottom, rgba(0,0,0,1), transparent 80%);
}

.checker {
  position: absolute;
  height: 36px;
  left: 0; right: 0;
  background-image:
    repeating-linear-gradient(90deg, #fff 0 24px, #000 24px 48px),
    repeating-linear-gradient(90deg, #000 0 24px, #fff 24px 48px);
  background-size: 48px 18px, 48px 18px;
  background-position: 0 0, 0 18px;
  background-repeat: repeat-x;
  opacity: 0.18;
}
.checker.top { top: 0; }
.checker.bottom { bottom: 0; }

.login-card {
  position: relative;
  z-index: 1;
  width: min(440px, 100%);
  background: rgba(10, 10, 10, 0.7);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 36px 28px 28px;
  position: relative;
}
.login-card::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(135deg, rgba(225,6,0,0.6), transparent 30%, transparent 70%, rgba(225,6,0,0.4));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

.login-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--fg-2);
  margin-bottom: 22px;
}
.tag-dot {
  width: 8px; height: 8px;
  background: var(--red);
  border-radius: 50%;
  box-shadow: 0 0 12px var(--red);
  animation: pulse 1.5s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}

.login-title { line-height: 1; margin-bottom: 16px; }
.title-overline {
  display: block;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.4em;
  color: var(--fg-2);
  margin-bottom: 6px;
}
.title-name {
  display: block;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(48px, 12vw, 76px);
  letter-spacing: 0.02em;
  background: linear-gradient(180deg, #fff 40%, #888 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 60px rgba(225,6,0,0.4);
}

.login-sub {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 400;
  color: var(--fg-1);
  margin-bottom: 28px;
}

.login-instruction {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--fg-2);
  margin-bottom: 14px;
}

.code-form { display: flex; flex-direction: column; gap: 16px; }

.code-inputs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  max-width: 320px;
}

.code-input {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  width: 100%;
  min-width: 0;
  height: 64px;
  text-align: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 32px;
  color: #fff;
  caret-color: var(--red);
  transition: all 0.2s ease;
  outline: none;
}
.code-input:focus {
  border-color: var(--red);
  background: rgba(225,6,0,0.08);
  box-shadow: 0 0 0 3px rgba(225,6,0,0.2), inset 0 -3px 0 var(--red);
}
.code-input.shake { animation: shake 0.4s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.code-error {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--red-glow);
  letter-spacing: 0.08em;
  min-height: 18px;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: 4px;
  height: 56px;
  padding: 0 28px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: all 0.25s ease;
  box-shadow: 0 8px 24px -10px rgba(225,6,0,0.6), inset 0 -3px 0 rgba(0,0,0,0.3);
}
.btn-primary svg { width: 20px; height: 20px; transition: transform 0.25s ease; }
.btn-primary:hover:not(:disabled) {
  background: var(--red-glow);
  box-shadow: 0 12px 32px -8px rgba(225,6,0,0.8), inset 0 -3px 0 rgba(0,0,0,0.3), 0 0 0 1px rgba(255,255,255,0.1);
}
.btn-primary:hover:not(:disabled) svg { transform: translateX(4px); }
.btn-primary:active:not(:disabled) { transform: translateY(1px); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

.login-foot {
  display: flex;
  justify-content: space-between;
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 9px;
  color: var(--fg-3);
}

/* =========================================================
   STARTING LIGHTS
   ========================================================= */
.screen-lights {
  background: radial-gradient(ellipse at center, #0a0a0c 0%, #000 80%);
}
.screen-lights.active {
  display: flex;
  align-items: center;
  justify-content: center;
}
.lights-stage {
  text-align: center;
  width: 100%;
  padding: 0 16px;
}
.lights-rig {
  display: inline-block;
  background: #0a0a0a;
  border: 1px solid #222;
  border-radius: 12px;
  padding: 22px 30px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.8), inset 0 1px 0 rgba(255,255,255,0.04);
}
.lights-row {
  display: flex;
  gap: 18px;
}
.light-pod {
  background: #050505;
  border: 1px solid #1a1a1a;
  border-radius: 8px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.light {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #220000, #0a0000 70%);
  border: 1px solid #1a1a1a;
  transition: all 0.15s ease;
}
.light.on {
  background: radial-gradient(circle at 35% 30%, #ff5050 0%, #e10600 40%, #6b0200 100%);
  box-shadow: 0 0 24px rgba(225,6,0,0.9), inset 0 0 8px rgba(255,255,255,0.3);
}

.lights-row.mini { gap: 10px; }
.lights-row.mini .light-pod { padding: 6px; gap: 4px; }
.lights-row.mini .light { width: 32px; height: 32px; }

@media (max-width: 540px) {
  .lights-rig { padding: 16px 14px; border-radius: 10px; }
  .lights-row { gap: 8px; }
  .light-pod { padding: 6px; gap: 4px; }
  .light { width: 36px; height: 36px; }
  .lights-row.mini .light { width: 24px; height: 24px; }
  .lights-row.mini { gap: 6px; }
}

.lights-status {
  margin-top: 28px;
  font-size: 12px;
  color: var(--fg-2);
  letter-spacing: 0.2em;
}

.countdown {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(72px, 18vw, 140px);
  line-height: 1;
  margin-top: 18px;
  color: #fff;
  min-height: 1em;
  text-shadow: 0 0 40px rgba(225,6,0,0.6);
}

.go-flash {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--red);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(48px, 14vw, 120px);
  letter-spacing: 0.06em;
  pointer-events: none;
  opacity: 0;
  z-index: 200;
}
.go-flash.flash {
  animation: goflash 0.7s ease forwards;
}
@keyframes goflash {
  0% { opacity: 0; transform: scale(1.4); }
  20% { opacity: 1; transform: scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: scale(1); }
}

/* =========================================================
   LAP SCREENS — shared
   ========================================================= */
.screen-lap {
  padding: 80px 24px 120px;
}

@media (min-width: 720px) {
  .screen-lap { padding: 100px 48px 140px; }
}

.lap-header {
  max-width: 760px;
  margin: 0 auto 48px;
  display: flex;
  gap: 24px;
  align-items: flex-start;
}

.lap-tag {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 0.9;
  flex-shrink: 0;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  padding: 10px 14px;
  background: rgba(225,6,0,0.08);
}
.lap-num {
  font-size: 36px;
  color: var(--red-glow);
  text-shadow: 0 0 20px rgba(225,6,0,0.6);
}
.lap-of {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--fg-3);
  margin-top: 4px;
  letter-spacing: 0.1em;
}

.lap-title-block { flex: 1; min-width: 0; padding-top: 4px; }
.lap-overline {
  font-size: 11px;
  color: var(--fg-2);
  margin-bottom: 8px;
  display: block;
}
.lap-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(28px, 5.5vw, 44px);
  line-height: 1.05;
  letter-spacing: -0.005em;
  color: #fff;
  text-wrap: balance;
}

/* narrative typography */
.lap-narrative {
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
  font-family: var(--font-body);
  font-size: clamp(16px, 2.4vw, 18px);
  line-height: 1.65;
  color: var(--fg-1);
  text-wrap: pretty;
}
.lap-narrative p { opacity: 0; transform: translateY(12px); transition: opacity 0.8s ease, transform 0.8s ease; }
.lap-narrative.in-view p { opacity: 1; transform: none; }
.lap-narrative.in-view p:nth-child(1) { transition-delay: 0.1s; }
.lap-narrative.in-view p:nth-child(2) { transition-delay: 0.3s; }
.lap-narrative.in-view p:nth-child(3) { transition-delay: 0.5s; }
.lap-narrative.in-view p:nth-child(4) { transition-delay: 0.7s; }
.lap-narrative.in-view p:nth-child(5) { transition-delay: 0.9s; }
.lap-narrative.in-view p:nth-child(6) { transition-delay: 1.1s; }
.lap-narrative.in-view p:nth-child(7) { transition-delay: 1.3s; }
.lap-narrative.in-view p:nth-child(n+8) { transition-delay: 1.4s; }

.lap-narrative.intimate {
  font-size: clamp(18px, 2.8vw, 22px);
  line-height: 1.7;
  font-weight: 300;
}
.lap-narrative .accent.big {
  font-family: var(--font-display);
  font-size: clamp(24px, 4vw, 30px);
  font-weight: 600;
  line-height: 1.2;
  color: var(--red-glow);
  margin: 12px 0;
}

.narrative-cards { gap: 28px; }

.memory-card {
  border: 1px solid var(--line-strong);
  border-left: 3px solid var(--red);
  background: linear-gradient(180deg, rgba(255,255,255,0.025), rgba(255,255,255,0.005));
  border-radius: 4px;
  padding: 22px 22px 18px;
  position: relative;
}
.memory-card p + p { margin-top: 10px; }
.mc-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10px;
  color: var(--fg-3);
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.mc-tag {
  background: rgba(225,6,0,0.15);
  color: var(--red-glow);
  padding: 3px 8px;
  border-radius: 2px;
  font-weight: 700;
  letter-spacing: 0.15em;
}

.closing { padding-top: 12px; }

/* =========================================================
   CHALLENGES
   ========================================================= */
.lap-challenge {
  max-width: 640px;
  margin: 56px auto 0;
  padding: 28px 24px;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
}

.challenge-head { margin-bottom: 22px; }
.challenge-tag {
  display: inline-block;
  font-size: 10px;
  color: var(--red-glow);
  letter-spacing: 0.18em;
  margin-bottom: 8px;
}
.challenge-head h3 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(22px, 4vw, 28px);
  margin-bottom: 6px;
}
.challenge-sub {
  font-size: 13px;
  color: var(--fg-2);
}

/* puzzle */
.puzzle-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}
.puzzle-item {
  background: var(--bg-2);
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  padding: 14px 16px;
  display: flex;
  gap: 12px;
  align-items: center;
  cursor: grab;
  transition: all 0.2s ease;
  user-select: none;
  font-size: 14px;
  line-height: 1.4;
  color: var(--fg-1);
}
.puzzle-item:hover { border-color: var(--red); background: rgba(225,6,0,0.05); }
.puzzle-item.dragging { opacity: 0.4; cursor: grabbing; }
.puzzle-item.drag-over { border-color: var(--red-glow); border-style: dashed; }
.puzzle-item.locked-correct {
  border-color: var(--green);
  background: rgba(0,255,122,0.08);
  cursor: default;
}
.puzzle-item.shake-wrong {
  border-color: var(--red);
  animation: shake 0.4s;
}
.puzzle-handle {
  display: flex;
  flex-direction: column;
  gap: 3px;
  color: var(--fg-3);
  font-size: 0;
}
.puzzle-handle::before, .puzzle-handle::after {
  content: '';
  width: 18px;
  height: 2px;
  background: currentColor;
  border-radius: 1px;
}
.puzzle-num {
  font-family: var(--font-mono);
  color: var(--red-glow);
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
  width: 22px;
}
.puzzle-text { flex: 1; }
.puzzle-arrows {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.puzzle-arrow {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--line);
  color: var(--fg-1);
  border-radius: 3px;
  width: 28px;
  height: 22px;
  display: grid;
  place-items: center;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.15s;
}
.puzzle-arrow:hover { background: var(--red); color: #fff; border-color: var(--red); }
.puzzle-arrow:disabled { opacity: 0.25; cursor: not-allowed; }

.puzzle-feedback {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-align: center;
  min-height: 18px;
  color: var(--fg-2);
  margin-bottom: 12px;
  text-transform: uppercase;
}
.puzzle-feedback.success { color: var(--green); }
.puzzle-feedback.error { color: var(--red-glow); }

/* reaction game */
.reaction-rig {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 18px 0 6px;
}
.reaction-readout {
  font-size: 13px;
  color: var(--fg-2);
  letter-spacing: 0.15em;
  min-height: 20px;
  text-align: center;
}
.reaction-readout.good { color: var(--green); }
.reaction-readout.jump { color: var(--red-glow); }
.reaction-actions {
  display: flex;
  gap: 12px;
}

.btn-launch {
  background: linear-gradient(180deg, #fff 0%, #ddd 100%);
  color: #000;
  border: none;
  border-radius: 4px;
  height: 52px;
  padding: 0 28px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 6px 20px -4px rgba(255,255,255,0.2), inset 0 -3px 0 rgba(0,0,0,0.15);
  transition: all 0.2s;
}
.btn-launch:hover:not(:disabled) { box-shadow: 0 8px 28px -4px rgba(255,255,255,0.4), inset 0 -3px 0 rgba(0,0,0,0.15); }
.btn-launch:disabled { background: #2a2a2a; color: var(--fg-3); cursor: not-allowed; box-shadow: none; }
.btn-launch.armed {
  background: var(--red);
  color: #fff;
  animation: armedPulse 1.2s infinite;
  box-shadow: 0 0 30px rgba(225,6,0,0.5), inset 0 -3px 0 rgba(0,0,0,0.3);
}
@keyframes armedPulse {
  0%, 100% { box-shadow: 0 0 24px rgba(225,6,0,0.5); }
  50% { box-shadow: 0 0 40px rgba(225,6,0,0.9); }
}

.btn-launch.big { height: 64px; font-size: 17px; padding: 0 38px; }

.btn-ghost {
  background: transparent;
  color: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  height: 48px;
  padding: 0 22px;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.18em;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.btn-ghost:hover { border-color: var(--red); color: var(--red-glow); }
.btn-ghost svg { width: 14px; height: 14px; }

/* next button */
.btn-next {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin: 60px auto 0;
  background: transparent;
  border: 1px solid var(--red);
  color: #fff;
  border-radius: 4px;
  height: 64px;
  padding: 0 36px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 18px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: all 0.3s;
}
.btn-next::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--red);
  transform: translateX(-101%);
  transition: transform 0.4s ease;
  z-index: -1;
}
.btn-next:hover::before { transform: translateX(0); }
.btn-next .next-arrow {
  font-size: 22px;
  transition: transform 0.3s;
}
.btn-next:hover .next-arrow { transform: translateX(8px); }
.btn-next .mono { font-family: var(--font-display); letter-spacing: 0.16em; text-transform: uppercase; }

.btn-next[hidden] { display: none; }

/* =========================================================
   PRE-FINAL SCREEN
   ========================================================= */
.screen-prefinal {
  text-align: center;
  padding: 24px;
  background: radial-gradient(ellipse at center, #15151a 0%, #000 70%);
}
.screen-prefinal.active {
  display: flex;
  align-items: center;
  justify-content: center;
}
.prefinal-stage { max-width: 640px; }
.prefinal-tag {
  display: inline-block;
  font-size: 11px;
  letter-spacing: 0.25em;
  color: var(--red-glow);
  margin-bottom: 24px;
  padding: 6px 14px;
  border: 1px solid var(--red);
  border-radius: 999px;
}
.prefinal-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(38px, 9vw, 72px);
  line-height: 1.05;
  margin-bottom: 18px;
  letter-spacing: -0.01em;
}
.prefinal-sub {
  font-family: var(--font-display);
  font-size: clamp(20px, 4vw, 28px);
  font-weight: 300;
  color: var(--fg-1);
  margin-bottom: 50px;
}
.prefinal-whisper {
  font-style: italic;
  font-size: 16px;
  color: var(--fg-2);
  margin-bottom: 36px;
  text-wrap: balance;
}

.checker-flag {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 40px;
  background-image:
    repeating-linear-gradient(90deg, #fff 0 24px, #000 24px 48px),
    repeating-linear-gradient(90deg, #000 0 24px, #fff 24px 48px);
  background-size: 48px 20px, 48px 20px;
  background-position: 0 0, 0 20px;
  background-repeat: repeat-x;
  opacity: 0.18;
}

/* =========================================================
   VIDEO SCREEN
   ========================================================= */
.screen-video {
  background: #000;
  padding: 32px 16px 24px;
}
.screen-video.active {
  display: flex;
  align-items: center;
  justify-content: center;
}
.video-frame {
  width: min(960px, 100%);
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
}
.video-tag {
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--red-glow);
  padding: 6px 12px;
  border: 1px solid rgba(225,6,0,0.4);
  border-radius: 999px;
}
.video-wrapper {
  width: 100%;
  aspect-ratio: 16/9;
  background: #0a0a0a;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 30px 80px -20px rgba(225,6,0,0.4), 0 0 0 1px rgba(225,6,0,0.2);
}
.video-wrapper iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

/* =========================================================
   FINISH / PODIUM
   ========================================================= */
.screen-finish {
  text-align: center;
  padding: 32px 20px;
  background: radial-gradient(ellipse at center top, #1a0a0a 0%, #000 60%);
  overflow: hidden;
}
.screen-finish.active {
  display: flex;
  align-items: center;
  justify-content: center;
}
#confetti-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.podium-stage {
  position: relative;
  z-index: 2;
  max-width: 560px;
}
.finish-tag {
  display: inline-block;
  font-size: 11px;
  letter-spacing: 0.3em;
  color: var(--yellow);
  padding: 6px 14px;
  border: 1px solid var(--yellow);
  border-radius: 999px;
  margin-bottom: 32px;
  text-shadow: 0 0 20px rgba(255,203,5,0.4);
}
.trophy {
  margin: 0 auto 30px;
  width: 80px;
  position: relative;
}
.trophy-cup {
  width: 80px;
  height: 70px;
  background: linear-gradient(180deg, #ffe88a 0%, #d4a020 60%, #8b6010 100%);
  border-radius: 12px 12px 50% 50% / 12px 12px 30% 30%;
  position: relative;
  box-shadow: 0 0 40px rgba(255,203,5,0.4), inset 2px 2px 8px rgba(255,255,255,0.4), inset -2px -2px 8px rgba(0,0,0,0.3);
}
.trophy-cup::before, .trophy-cup::after {
  content: '';
  position: absolute;
  top: 8px;
  width: 16px;
  height: 28px;
  border: 4px solid #d4a020;
  border-radius: 50%;
}
.trophy-cup::before { left: -16px; border-right: none; }
.trophy-cup::after { right: -16px; border-left: none; }
.trophy-stem {
  width: 14px;
  height: 18px;
  background: linear-gradient(180deg, #d4a020, #8b6010);
  margin: 0 auto;
}
.trophy-base {
  width: 60px;
  height: 12px;
  background: linear-gradient(180deg, #d4a020, #6a4810);
  margin: 0 auto;
  border-radius: 2px;
}
.finish-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(32px, 7vw, 56px);
  line-height: 1.05;
  margin-bottom: 16px;
  text-wrap: balance;
}
.finish-title span { display: block; color: var(--red-glow); }
.finish-message {
  font-family: var(--font-display);
  font-size: clamp(18px, 3vw, 22px);
  font-weight: 400;
  color: var(--fg-1);
  margin-bottom: 28px;
}
.finish-signoff {
  font-family: var(--font-display);
  font-size: clamp(28px, 5vw, 40px);
  font-weight: 700;
  color: var(--red-glow);
  letter-spacing: 0.02em;
  margin-bottom: 36px;
  text-shadow: 0 0 30px rgba(225,6,0,0.5);
}

/* =========================================================
   ANIMATIONS — entrance per lap
   ========================================================= */
.lap-header { opacity: 0; transform: translateY(-12px); transition: all 0.7s ease; }
.screen.active .lap-header { opacity: 1; transform: none; }

.lap-challenge { opacity: 0; transform: translateY(20px); transition: all 0.7s ease 0.4s; }
.screen.active .lap-challenge { opacity: 1; transform: none; }

.btn-next { opacity: 0; transform: translateY(20px); transition: all 0.5s ease; }
.btn-next:not([hidden]) { opacity: 1; transform: none; }

@media (max-width: 540px) {
  .lap-header { gap: 14px; }
  .lap-tag { padding: 8px 10px; }
  .lap-num { font-size: 28px; }
  .lap-challenge { padding: 22px 16px; }
  .login-card { padding: 28px 22px 22px; }
  .code-input { height: 56px; font-size: 28px; }
  .btn-primary { font-size: 14px; height: 52px; }
  .video-frame { padding: 0; }
}
