:root {
  --bg: #f3ede2;
  --bg-accent: #e7d3b2;
  --panel: rgba(19, 25, 42, 0.92);
  --panel-soft: rgba(255, 250, 240, 0.88);
  --ink: #101423;
  --muted: #58627a;
  --warm: #f2783c;
  --gold: #f6c65b;
  --teal: #1b8f89;
  --cream: #fff8eb;
  --line: rgba(255, 255, 255, 0.16);
  --shadow: 0 22px 70px rgba(16, 20, 35, 0.16);
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 999px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Avenir Next", "Trebuchet MS", "Gill Sans", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(246, 198, 91, 0.35), transparent 28%),
    radial-gradient(circle at top right, rgba(27, 143, 137, 0.18), transparent 28%),
    linear-gradient(180deg, #faf5ec 0%, var(--bg) 48%, #e8d8bd 100%);
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: auto;
  width: 20rem;
  height: 20rem;
  border-radius: 50%;
  filter: blur(10px);
  pointer-events: none;
  opacity: 0.65;
}

body::before {
  top: -5rem;
  right: -6rem;
  background: rgba(242, 120, 60, 0.16);
}

body::after {
  bottom: -7rem;
  left: -4rem;
  background: rgba(27, 143, 137, 0.14);
}

.page-shell {
  width: min(1120px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2rem 0 3rem;
}

.hero {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 1.5rem;
  align-items: stretch;
  margin-bottom: 1.5rem;
}

.hero-copy,
.scoreboard,
.summary-banner,
.game-card {
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.hero-copy {
  padding: 2rem;
  border-radius: var(--radius-lg);
  background:
    linear-gradient(135deg, rgba(19, 25, 42, 0.96), rgba(35, 48, 83, 0.88)),
    linear-gradient(135deg, rgba(255, 255, 255, 0.08), transparent);
  color: var(--cream);
}

.eyebrow,
.game-label,
.stat-label,
.distance-label {
  margin: 0 0 0.45rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.72rem;
}

.hero h1 {
  margin: 0;
  font-family: "Avenir Next Condensed", "Arial Narrow", "Franklin Gothic Medium",
    sans-serif;
  font-size: clamp(3rem, 7vw, 5.6rem);
  line-height: 0.92;
  text-transform: uppercase;
}

.intro {
  margin: 1rem 0 0;
  max-width: 32rem;
  color: rgba(255, 248, 235, 0.8);
  font-size: 1.05rem;
  line-height: 1.55;
}

.scoreboard {
  display: grid;
  gap: 1rem;
  padding: 1.4rem;
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(255, 248, 235, 0.94), rgba(255, 244, 223, 0.84));
  align-content: start;
}

.stat {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  padding: 1rem 1.1rem;
  border-radius: var(--radius-md);
  background: rgba(16, 20, 35, 0.06);
}

.stat-value {
  font-family: "Avenir Next Condensed", "Arial Narrow", sans-serif;
  font-size: 1.5rem;
  letter-spacing: 0.02em;
}

.reset-button {
  border: 0;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--warm), #ec5d4a);
  color: white;
  font: inherit;
  font-weight: 700;
  padding: 0.95rem 1.25rem;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease, filter 180ms ease;
  box-shadow: 0 14px 30px rgba(236, 93, 74, 0.28);
}

.reset-button:hover,
.reset-button:focus-visible {
  transform: translateY(-1px);
  filter: saturate(1.08);
}

.summary-banner {
  margin-bottom: 1.25rem;
  padding: 1rem 1.25rem;
  border-radius: calc(var(--radius-md) + 2px);
  background: rgba(255, 248, 235, 0.78);
  border: 1px solid rgba(16, 20, 35, 0.08);
}

.summary-banner.is-finished {
  background: linear-gradient(135deg, rgba(27, 143, 137, 0.16), rgba(246, 198, 91, 0.24));
}

.summary-copy {
  margin: 0;
  color: var(--ink);
  font-weight: 600;
}

.games-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
}

.game-card {
  padding: 1.35rem;
  border-radius: var(--radius-lg);
  background:
    linear-gradient(180deg, rgba(17, 23, 40, 0.97), rgba(27, 35, 61, 0.92)),
    linear-gradient(135deg, rgba(255, 255, 255, 0.06), transparent);
  color: var(--cream);
  transform: translateY(10px);
  opacity: 0;
  animation: rise-in 540ms cubic-bezier(0.2, 0.9, 0.2, 1) forwards;
}

.game-card:nth-child(2) {
  animation-delay: 70ms;
}

.game-card:nth-child(3) {
  animation-delay: 140ms;
}

.game-card:nth-child(4) {
  animation-delay: 210ms;
}

.game-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: start;
  margin-bottom: 1.1rem;
}

.game-title {
  margin: 0;
  font-size: 1.55rem;
  line-height: 1.1;
  font-family: "Avenir Next Condensed", "Arial Narrow", sans-serif;
  text-transform: uppercase;
}

.distance-pill {
  min-width: 7rem;
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.08);
  text-align: right;
}

.distance-value {
  display: block;
  font-size: 1.05rem;
}

.line-card {
  padding: 1rem;
  border-radius: calc(var(--radius-md) + 4px);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.line-meta,
.tick-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.75rem;
  align-items: center;
}

.line-meta {
  margin-bottom: 0.9rem;
  font-size: 0.88rem;
  color: rgba(255, 248, 235, 0.74);
}

.line-left {
  text-align: left;
}

.line-right {
  text-align: right;
}

.line-center {
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.guess-track {
  position: relative;
  height: 4.2rem;
  border-radius: var(--radius-md);
  cursor: crosshair;
  outline: none;
  user-select: none;
}

.guess-track.is-locked {
  cursor: default;
}

.track-backdrop {
  position: absolute;
  inset: 1.45rem 0.5rem;
  border-radius: var(--radius-sm);
  background:
    linear-gradient(90deg, rgba(27, 143, 137, 0.85), rgba(255, 255, 255, 0.12) 50%, rgba(242, 120, 60, 0.88)),
    rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.track-backdrop::before {
  content: "";
  position: absolute;
  inset: 0.42rem 0.7rem;
  border-radius: var(--radius-sm);
  background-image: repeating-linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.18),
    rgba(255, 255, 255, 0.18) 1px,
    transparent 1px,
    transparent calc(12.5% - 1px)
  );
  opacity: 0.55;
}

.track-midline {
  position: absolute;
  top: 0.6rem;
  bottom: 0.6rem;
  left: 50%;
  width: 2px;
  margin-left: -1px;
  background: rgba(255, 248, 235, 0.68);
}

.marker {
  position: absolute;
  top: 0.4rem;
  bottom: 0.4rem;
  width: 0;
  opacity: 0;
  transform: translateX(-50%);
  transition: left 220ms ease, opacity 200ms ease;
}

.marker::after {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  border-radius: 999px;
}

.marker-preview {
  opacity: 0.7;
}

.marker-preview::after {
  top: 0.55rem;
  width: 14px;
  height: 14px;
  background: rgba(255, 248, 235, 0.88);
  box-shadow: 0 0 0 4px rgba(255, 248, 235, 0.14);
}

.marker-guess::after {
  top: 0.3rem;
  width: 18px;
  height: 18px;
  background: var(--gold);
  box-shadow: 0 0 0 5px rgba(246, 198, 91, 0.18);
}

.marker-actual::after {
  bottom: 0.3rem;
  width: 16px;
  height: 16px;
  background: white;
  border: 4px solid var(--warm);
  box-shadow: 0 0 0 4px rgba(242, 120, 60, 0.16);
}

.guess-track.show-preview .marker-preview,
.guess-track.is-revealed .marker-guess,
.guess-track.is-revealed .marker-actual {
  opacity: 1;
}

.guess-track:focus-visible {
  box-shadow: 0 0 0 3px rgba(246, 198, 91, 0.4);
  border-radius: var(--radius-md);
}

.tick-row {
  margin-top: 0.7rem;
  grid-template-columns: repeat(5, 1fr);
  color: rgba(255, 248, 235, 0.56);
  font-size: 0.78rem;
}

.tick-row span:nth-child(1) {
  text-align: left;
}

.tick-row span:nth-child(3) {
  text-align: center;
}

.tick-row span:nth-child(5) {
  text-align: right;
}

.result-panel {
  margin-top: 1rem;
  padding: 0.95rem 1rem;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.06);
  min-height: 4.9rem;
}

.result-copy {
  margin: 0;
  color: rgba(255, 248, 235, 0.84);
  line-height: 1.45;
}

.game-card.is-complete .result-panel {
  background: rgba(255, 255, 255, 0.1);
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 860px) {
  .hero,
  .games-grid {
    grid-template-columns: 1fr;
  }

  .page-shell {
    width: min(100% - 1rem, 1120px);
    padding-top: 1rem;
  }

  .hero-copy,
  .scoreboard,
  .game-card {
    padding: 1.2rem;
  }
}

@media (max-width: 560px) {
  .line-meta {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .line-left,
  .line-right {
    text-align: center;
  }

  .game-header {
    flex-direction: column;
  }

  .distance-pill {
    width: 100%;
    text-align: left;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
