:root {
  --bw-orange: #ff6a1a;
  --bw-orange-light: #ff8f4d;
  --bw-orange-deep: #e0530a;
  --bw-black: #1a1a1a;
  --bw-charcoal: #232323;
  --bw-charcoal-light: #2d2d2d;
  --bw-green: #1f9d55;
  --bw-red: #ff4d4d;
  --bw-white: #ffffff;
  --bw-muted: #b8b8b8;
  --sky-top: #7ec8ff;
  --sky-bottom: #cdeeff;
  --track-brown: #b5793f;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overscroll-behavior: none;
  background: var(--bw-black);
  color: var(--bw-white);
  font-family: "Segoe UI", Roboto, system-ui, -apple-system, sans-serif;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
}

.screen {
  display: none;
  width: 100%;
  height: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.screen.active {
  display: flex;
}

.panel {
  background: var(--bw-charcoal);
  border: 1px solid rgba(255, 106, 26, 0.4);
  border-radius: 20px;
  padding: 32px 28px;
  max-width: 420px;
  width: 100%;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
}

.panel-wide {
  max-width: 520px;
}

.brand-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 4px;
}

.brand-mark svg { width: 34px; height: 34px; flex-shrink: 0; }

.brand-wordmark {
  margin: 0;
  font-size: 1.9rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--bw-white);
  text-transform: lowercase;
}

.brand-wordmark .hl { color: var(--bw-orange); }

h1 {
  margin: 0 0 4px;
  font-size: 2rem;
  letter-spacing: 2px;
  color: var(--bw-orange);
}

h2 {
  margin-top: 0;
  color: var(--bw-orange);
}

.subtitle {
  margin: 0 0 16px;
  color: var(--bw-orange-light);
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  font-size: 0.85rem;
}

.blurb {
  color: var(--bw-muted);
  font-size: 0.92rem;
  line-height: 1.4;
}

#email-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
}

input[type="email"] {
  padding: 14px 16px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.15);
  background: var(--bw-black);
  color: var(--bw-white);
  font-size: 1rem;
  outline: none;
}

input[type="email"]:focus {
  border-color: var(--bw-orange);
}

.btn {
  padding: 14px 20px;
  border-radius: 999px;
  border: none;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  letter-spacing: 0.3px;
}

.btn-primary {
  background: var(--bw-orange);
  color: var(--bw-black);
}

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

.btn-ghost {
  background: transparent;
  color: var(--bw-orange-light);
  border: 1.5px solid var(--bw-orange);
  margin-top: 14px;
  border-radius: 999px;
}

.error {
  color: var(--bw-red);
  min-height: 1.2em;
  font-size: 0.85rem;
  margin: 8px 0 0;
}

.instructions {
  text-align: left;
  margin: 20px 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.instr-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  color: #e6e6e6;
}

.key-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  padding: 4px 8px;
  background: var(--bw-black);
  border: 1px solid var(--bw-orange);
  border-radius: 6px;
  color: var(--bw-orange-light);
  font-weight: 700;
  font-size: 0.75rem;
}

/* GAME SCREEN */
#screen-game {
  padding: 0;
  justify-content: flex-start;
  position: relative;
}

.hud {
  display: flex;
  justify-content: space-between;
  width: 100%;
  padding: 10px 16px;
  background: var(--bw-black);
  border-bottom: 2px solid var(--bw-orange);
  z-index: 2;
}

.hud-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-variant-numeric: tabular-nums;
}

.hud-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  color: var(--bw-orange);
  letter-spacing: 1px;
}

#hud-time, #hud-distance {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--bw-white);
}

.countdown {
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 5rem;
  font-weight: 900;
  color: var(--bw-orange);
  text-shadow: 0 4px 12px rgba(0,0,0,0.6);
  z-index: 3;
  pointer-events: none;
}

#game-canvas {
  display: block;
  width: 100%;
  flex: 1 1 auto;
  background: linear-gradient(var(--sky-top), var(--sky-bottom));
  touch-action: none;
}

.controls {
  display: flex;
  gap: 10px;
  padding: 14px;
  background: var(--bw-black);
  border-top: 2px solid var(--bw-orange);
  z-index: 2;
}

.ctrl-btn {
  flex: 1;
  padding: 22px 0;
  border-radius: 16px;
  border: none;
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--bw-black);
  cursor: pointer;
}

.run-btn {
  background: linear-gradient(180deg, #ffffff, #d8d8d8);
  flex: 1.1;
}

.run-btn:active, .run-btn.pressed {
  background: linear-gradient(180deg, var(--bw-orange-light), var(--bw-orange));
  transform: scale(0.96);
}

.jump-btn {
  flex: 1.4;
  background: linear-gradient(180deg, var(--bw-orange-light), var(--bw-orange-deep));
  color: var(--bw-white);
}

.jump-btn:active, .jump-btn.pressed {
  background: linear-gradient(180deg, #ffffff, var(--bw-orange));
  color: var(--bw-black);
  transform: scale(0.96);
}

/* PODIUM */
.podium-stage {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 10px;
  margin: 12px 0 16px;
  min-height: 170px;
}

.podium-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100px;
}

.podium-avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--bw-black);
  margin-bottom: 8px;
  border: 2px solid var(--bw-black);
}

.podium-name {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--bw-white);
  text-align: center;
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.podium-time {
  font-size: 0.75rem;
  color: var(--bw-muted);
  font-variant-numeric: tabular-nums;
  margin-bottom: 8px;
}

.podium-block {
  width: 100%;
  border-radius: 8px 8px 0 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 6px;
  font-size: 1.6rem;
  font-weight: 900;
  color: rgba(0,0,0,0.55);
}

.podium-slot.place-1 .podium-block { height: 130px; background: linear-gradient(180deg, #ffe08a, #d4a017); }
.podium-slot.place-2 .podium-block { height: 92px; background: linear-gradient(180deg, #e7e7e7, #b3b3b3); }
.podium-slot.place-3 .podium-block { height: 66px; background: linear-gradient(180deg, #e0a878, #a9673a); }

.podium-slot.place-1 { order: 2; }
.podium-slot.place-2 { order: 1; }
.podium-slot.place-3 { order: 3; }

.podium-slot.is-you .podium-name { color: var(--bw-orange-light); }

/* RESULTS */
.result-time {
  font-size: 3rem;
  font-weight: 900;
  color: var(--bw-orange);
  margin: 8px 0;
}

.result-rank {
  color: var(--bw-muted);
  font-weight: 600;
}

.results-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 20px;
}

/* LEADERBOARD */
.leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 16px 0;
  max-height: 50vh;
  overflow-y: auto;
}

.lb-row {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  background: var(--bw-black);
  border-radius: 8px;
  font-size: 0.9rem;
}

.lb-row.top1 { border: 1px solid var(--bw-orange); }
.lb-place { font-weight: 800; color: var(--bw-orange); }
.lb-email { text-align: left; color: #e6e6e6; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-time { font-weight: 700; font-variant-numeric: tabular-nums; }
.loading, .empty { color: var(--bw-muted); font-size: 0.9rem; }

@media (min-width: 700px) {
  .controls { max-width: 600px; margin: 0 auto; width: 100%; }
  .hud { max-width: 600px; margin: 0 auto; width: 100%; }
}
