:root {
  --bg-deep: #1a0850;
  --bg-mid: #2d1080;
  --sega-blue: #4488ff;
  --sega-cyan: #00e8ff;
  --sega-magenta: #ff6b9d;
  --sega-yellow: #ffe600;
  --sega-red: #ff4466;
  --sega-lime: #7fff00;
  --sega-orange: #ff9933;
  --panel-bg: #12083a;
  --panel-border: #ff6b9d;
  --panel-accent: #7fff00;
  --text: #f0f0ff;
  --text-dim: #c8b8ff;
  --pixel-shadow: 4px 4px 0 #000;
  --font-pixel: "Press Start 2P", monospace;
  --layout-max: 640px;
  --layout-pad: 16px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  overflow-x: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-pixel);
  font-size: 11px;
  line-height: 1.8;
  color: var(--text);
  background-color: var(--bg-deep);
  overflow-x: hidden;
}

/* CRT overlay */
.crt {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.12) 0px,
    rgba(0, 0, 0, 0.12) 1px,
    transparent 1px,
    transparent 3px
  );
  opacity: 0.35;
}

.crt::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.55) 100%);
}

/* Animated starfield */
.stars {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 0;
  background-image:
    radial-gradient(1px 1px at 10% 20%, var(--sega-cyan) 50%, transparent 50%),
    radial-gradient(1px 1px at 30% 60%, #fff 50%, transparent 50%),
    radial-gradient(1px 1px at 70% 15%, var(--sega-magenta) 50%, transparent 50%),
    radial-gradient(1px 1px at 85% 75%, var(--sega-yellow) 50%, transparent 50%),
    radial-gradient(1px 1px at 50% 90%, #fff 50%, transparent 50%),
    radial-gradient(2px 2px at 15% 85%, var(--sega-cyan) 50%, transparent 50%),
    radial-gradient(1px 1px at 92% 40%, #fff 50%, transparent 50%),
    radial-gradient(1px 1px at 45% 35%, var(--sega-magenta) 50%, transparent 50%);
  animation: twinkle 4s ease-in-out infinite alternate;
}

@keyframes twinkle {
  from { opacity: 0.5; }
  to { opacity: 1; }
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
  z-index: 10000;
}

.skip-link:focus {
  left: 16px;
  top: 16px;
  padding: 12px 16px;
  background: var(--sega-yellow);
  color: #000;
  text-decoration: none;
  box-shadow: var(--pixel-shadow);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* Hero */
.hero {
  position: relative;
  z-index: 1;
  text-align: center;
  width: min(var(--layout-max), 100%);
  padding: 40px var(--layout-pad) 28px;
  margin: 0 auto;
}

.hero__title {
  margin: 0 0 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.hero__title-line {
  display: block;
  font-size: clamp(20px, 6vw, 36px);
  text-shadow:
    3px 3px 0 var(--sega-magenta),
    6px 6px 0 #000;
  letter-spacing: 0.08em;
}

.hero__title-line--cyan {
  color: var(--sega-cyan);
}

.hero__title-line--magenta {
  color: var(--sega-magenta);
}

.hero__title-arrow {
  font-size: 14px;
  color: var(--sega-yellow);
  animation: bounce 1s ease-in-out infinite;
}

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

.hero__subtitle {
  margin: 0 0 28px;
  font-size: 10px;
  color: var(--sega-yellow);
  letter-spacing: 0.12em;
}

.blink {
  animation: blink 1.2s step-start infinite;
}

.blink-slow {
  animation: blink 2.4s step-start infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

.hero__stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  width: 100%;
  text-align: center;
}

.stat__label {
  display: block;
  font-size: 7px;
  color: var(--sega-cyan);
  margin-bottom: 6px;
}

.stat__value {
  display: block;
  font-size: 8px;
  color: var(--sega-yellow);
}

/* Panels */
main {
  position: relative;
  z-index: 1;
  width: min(var(--layout-max), 100%);
  margin: 0 auto;
  padding: 0 var(--layout-pad) 120px;
  padding-bottom: calc(120px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.panel {
  background: var(--panel-bg);
  border: 4px solid var(--panel-border);
  box-shadow:
    var(--pixel-shadow),
    inset 0 0 0 2px rgba(255, 255, 255, 0.06);
  padding: 24px 20px;
  position: relative;
}

.panel::before {
  content: "";
  position: absolute;
  top: 6px;
  left: 6px;
  right: 6px;
  height: 3px;
  background: var(--panel-accent);
  opacity: 1;
}

.section__title {
  margin: 0 0 16px;
  font-size: 11px;
  color: var(--sega-cyan);
  text-shadow: 2px 2px 0 #000;
  display: flex;
  align-items: center;
  gap: 8px;
}

.pixel-icon {
  font-style: normal;
}

.story p {
  margin: 0 0 12px;
  color: var(--text);
  font-size: 10px;
  line-height: 2;
}

.story__punchline {
  color: var(--sega-magenta) !important;
  font-size: 9px !important;
}

/* Location */
.location {
  font-style: normal;
}

.location__city {
  margin: 0 0 4px;
  font-size: 10px;
  color: var(--sega-yellow);
}

.location__address {
  margin: 0 0 20px;
  font-size: 9px;
  color: var(--text-dim);
}

/* Rules */
.rules {
  margin: 0;
  padding: 0;
  list-style: none;
}

.rules li {
  font-size: 9px;
  padding: 10px 0;
  border-bottom: 2px dashed rgba(90, 60, 255, 0.4);
  line-height: 2;
}

.rules li:last-child {
  border-bottom: none;
}

/* Form */
.form-intro,
.wishlist-intro {
  margin: 0 0 20px;
  font-size: 9px;
  color: var(--text-dim);
  line-height: 2;
}

.form__row {
  margin-bottom: 20px;
}

.form__row--inline {
  max-width: 200px;
}

.form__label {
  display: block;
  margin-bottom: 8px;
  font-size: 8px;
  color: var(--sega-cyan);
}

.form__input {
  width: 100%;
  padding: 14px 12px;
  font-family: var(--font-pixel);
  font-size: 10px;
  color: var(--text);
  background: #0a0420;
  border: 3px solid var(--sega-blue);
  box-shadow: inset 2px 2px 0 rgba(0, 0, 0, 0.5);
  outline: none;
  transition: border-color 0.15s;
}

.form__input:focus {
  border-color: var(--sega-yellow);
}

.form__input--letter {
  text-align: center;
  text-transform: uppercase;
  font-size: 16px;
  letter-spacing: 0.2em;
}

.form__hint {
  margin: 8px 0 0;
  font-size: 7px;
  color: var(--text-dim);
}

.counter {
  display: flex;
  align-items: center;
  gap: 8px;
}

.counter__btn {
  width: 44px;
  height: 44px;
  font-family: var(--font-pixel);
  font-size: 16px;
  color: var(--sega-yellow);
  background: var(--sega-blue);
  border: 3px solid #000;
  box-shadow: var(--pixel-shadow);
  cursor: pointer;
  flex-shrink: 0;
}

.counter__btn:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 #000;
}

.counter__input {
  text-align: center;
  flex: 1;
  -moz-appearance: textfield;
}

.counter__input::-webkit-outer-spin-button,
.counter__input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.form__checks {
  border: none;
  margin: 0 0 24px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.pixel-checkbox {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
  font-size: 8px;
  line-height: 1.9;
}

.pixel-checkbox input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.checkbox__box {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  margin-top: 2px;
  background: #0a0420;
  border: 3px solid var(--sega-magenta);
  box-shadow: inset 2px 2px 0 rgba(0, 0, 0, 0.5);
  position: relative;
}

.pixel-checkbox input:checked + .checkbox__box {
  background: var(--sega-magenta);
  border-color: var(--sega-yellow);
}

.pixel-checkbox input:checked + .checkbox__box::after {
  content: "✓";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: #000;
  font-weight: bold;
}

.pixel-checkbox input:focus-visible + .checkbox__box {
  outline: 2px solid var(--sega-yellow);
  outline-offset: 2px;
}

.checkbox__sub {
  display: block;
  color: var(--text-dim);
  font-size: 7px;
  margin-top: 4px;
}

.checkbox__text {
  word-break: break-word;
}

.form-status {
  min-height: 24px;
  margin-bottom: 16px;
  font-size: 8px;
  line-height: 1.8;
}

.form-status--error {
  color: var(--sega-red);
}

.form-status--success {
  color: var(--sega-cyan);
}

.form-status--loading {
  color: var(--sega-yellow);
}

.hidden {
  display: none !important;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 14px 20px;
  font-family: var(--font-pixel);
  font-size: 9px;
  text-decoration: none;
  text-align: center;
  border: 3px solid #000;
  box-shadow: var(--pixel-shadow);
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
}

.btn:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 #000;
}

.btn--primary {
  width: 100%;
  color: #000;
  background: var(--sega-yellow);
  border-color: #000;
}

.btn--primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn--secondary {
  color: var(--sega-cyan);
  background: var(--sega-blue);
}

.btn--wishlist {
  width: 100%;
  color: #000;
  background: var(--sega-magenta);
}

.btn--submit .btn__text {
  letter-spacing: 0.1em;
}

/* Footer */
.footer {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 32px 20px 110px;
}

.footer__text {
  margin: 0 0 8px;
  font-size: 8px;
  color: var(--sega-magenta);
}

.footer__credit {
  margin: 0;
  font-size: 7px;
  color: var(--text-dim);
}

/* Responsive */
@media (max-width: 768px) {
  body {
    font-size: 10px;
  }

  .hero__title-line {
    font-size: clamp(18px, 7vw, 28px);
  }

  .hero__stats {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .stat {
    padding: 6px 0;
    border-bottom: 2px dashed rgba(255, 107, 157, 0.25);
  }

  .stat:last-child {
    border-bottom: none;
  }

  .section__title {
    font-size: 10px;
    flex-wrap: wrap;
  }

  .btn {
    width: 100%;
    max-width: 100%;
  }

  .btn--secondary {
    display: block;
  }
}

@media (max-width: 480px) {
  .hero {
    padding: 28px 12px 20px;
  }

  .hero__subtitle {
    font-size: 8px;
    letter-spacing: 0.08em;
  }

  .panel {
    padding: 18px 14px;
    border-width: 3px;
  }

  main {
    padding-left: 12px;
    padding-right: 12px;
    gap: 18px;
  }

  .form__row--inline {
    max-width: none;
  }

  .form__input,
  .form__label,
  .pixel-checkbox {
    font-size: 8px;
  }

  .form__input--letter {
    font-size: 14px;
  }

  .counter__btn {
    width: 48px;
    height: 48px;
  }

  .story p,
  .rules li,
  .form-intro,
  .wishlist-intro {
    font-size: 8px;
    line-height: 1.9;
  }

  .cyclist-track {
    height: 72px;
  }

  .cyclist__img {
    width: 100px;
  }

  .cyclist {
    width: 100px;
    bottom: 14px;
  }

  .cake-scene__img {
    width: min(200px, 86vw);
  }

  .footer {
    padding-bottom: calc(100px + env(safe-area-inset-bottom, 0px));
  }
}

@media (max-width: 360px) {
  .hero__title-line {
    font-size: 16px;
  }

  .hero__title-arrow {
    font-size: 10px;
  }

  .checkbox__text {
    font-size: 7px;
  }
}

@media (min-width: 769px) {
  .hero__stats {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  .blink,
  .blink-slow,
  .hero__title-arrow,
  .stars,
  .cyclist,
  .cyclist__img,
  .flame {
    animation: none !important;
  }

  .cyclist-track {
    display: none;
  }
}

/* ── Birthday cake + flames ── */
.cake-scene {
  position: relative;
  display: inline-block;
  margin: 0 auto 20px;
  padding: 0;
  background: transparent;
  border: none;
  box-shadow: none;
}

.cake-scene__img {
  display: block;
  width: min(260px, 78vw);
  height: auto;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  filter: drop-shadow(0 6px 0 rgba(0, 0, 0, 0.45));
}

.flame {
  position: absolute;
  width: 8px;
  height: 12px;
  background: var(--sega-orange);
  box-shadow:
    0 -3px 0 var(--sega-yellow),
    0 -6px 0 #ffcc00;
  animation: flicker 0.25s steps(3) infinite alternate;
  transform-origin: bottom center;
  pointer-events: none;
}

.flame--1 { top: 54%; left: 34.5%; animation-delay: 0s; }
.flame--2 { top: 52%; left: 42%; animation-delay: 0.08s; }
.flame--3 { top: 51%; left: 49.5%; animation-delay: 0.04s; }
.flame--4 { top: 52%; left: 57%; animation-delay: 0.12s; }
.flame--5 { top: 54%; left: 64.5%; animation-delay: 0.06s; }

@keyframes flicker {
  0% {
    transform: scaleY(1) scaleX(1);
    opacity: 1;
    background: var(--sega-orange);
  }
  33% {
    transform: scaleY(1.3) scaleX(0.8);
    opacity: 0.85;
    background: #ffcc00;
  }
  66% {
    transform: scaleY(0.85) scaleX(1.1);
    opacity: 1;
    background: var(--sega-red);
  }
  100% {
    transform: scaleY(1.15) scaleX(0.9);
    opacity: 0.9;
    background: var(--sega-yellow);
  }
}

/* ── Cyclist pedaling across screen ── */
.cyclist-track {
  pointer-events: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 96px;
  z-index: 4;
  overflow: hidden;
}

.road {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 28px;
  background: #2a1458;
  border-top: 4px solid var(--sega-lime);
  box-shadow: 0 -4px 0 rgba(0, 0, 0, 0.35);
}

.road::after {
  content: "";
  position: absolute;
  top: 10px;
  left: 0;
  right: 0;
  height: 4px;
  background: repeating-linear-gradient(
    90deg,
    var(--sega-yellow) 0 16px,
    transparent 16px 32px
  );
  opacity: 0.55;
}

.cyclist {
  position: absolute;
  bottom: 18px;
  left: -160px;
  width: 140px;
  height: 90px;
  animation: ride-across 16s linear infinite;
  will-change: left;
}

.cyclist__img {
  display: block;
  width: 140px;
  height: auto;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  animation: pedal-bob 0.32s steps(4) infinite;
  filter: drop-shadow(2px 4px 0 rgba(0, 0, 0, 0.5));
  will-change: transform;
}

@keyframes ride-across {
  0% { left: -160px; }
  100% { left: calc(100vw + 20px); }
}

@keyframes pedal-bob {
  0% { transform: translateY(0) rotate(0deg); }
  25% { transform: translateY(-4px) rotate(-1deg); }
  50% { transform: translateY(0) rotate(0deg); }
  75% { transform: translateY(3px) rotate(1deg); }
  100% { transform: translateY(0) rotate(0deg); }
}
