:root {
  --bg: #17110d;
  --ink: #f6e9d4;
  --muted: #c9b294;
  --orange: #e8792b;
  --gold: #f2b544;
  --teal: #3aa7a3;
  --red: #b8362c;
  --purple: #7c4dbd;
  --cream: #fbf3e4;
  --wood-1: #e0b072;
  --wood-2: #d4a062;
  --wood-seam: #b98447;
  --card: rgba(30, 20, 14, 0.9);
  --gutter: 30px;
  --lane-w: 860px;
  --header-h: 72px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 12px); }

body {
  margin: 0;
  color: var(--ink);
  font-family: "Karla", system-ui, sans-serif;
  font-size: 18px;
  line-height: 1.6;
  overflow-x: hidden;
  /* Retro art deco wallpaper either side of the lane */
  background:
    linear-gradient(90deg, transparent calc(50% - var(--lane-w) / 2 - 150px), rgba(8, 12, 12, 0.88) calc(50% - var(--lane-w) / 2 - 40px), rgba(8, 12, 12, 0.88) calc(50% + var(--lane-w) / 2 + 40px), transparent calc(50% + var(--lane-w) / 2 + 150px)),
    radial-gradient(ellipse 70% 50% at 50% -5%, rgba(242, 181, 68, 0.28), transparent 70%),
    repeating-conic-gradient(from -90deg at 50% -10%, rgba(242, 181, 68, 0.07) 0 4deg, transparent 4deg 12deg),
    linear-gradient(rgba(9, 20, 21, 0.62), rgba(9, 20, 21, 0.62)),
    url("deco.svg") 0 0 / 80px 40px;
  background-attachment: fixed;
  background-color: var(--bg);
}

a { color: var(--gold); }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- Score monitor ---------- */
.scoreboard {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: var(--header-h);
  padding: 8px 20px;
  background: linear-gradient(#10243a, #0a1726);
  border-bottom: 4px solid var(--orange);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.5);
}
.logo {
  font-family: "Bungee", sans-serif;
  color: var(--gold);
  text-decoration: none;
  white-space: nowrap;
}
.scorecard {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(9, 1fr) 1.4fr;
  max-width: 640px;
  margin: 0 auto;
  border: 2px solid #8fb3d9;
  background: #f4f7fb;
  color: #0a1726;
}
.scorecard a {
  position: relative;
  display: grid;
  grid-template-rows: 14px 18px 22px;
  text-decoration: none;
  color: inherit;
  border-right: 2px solid #8fb3d9;
  font-size: 0.7rem;
  line-height: 1;
}
.scorecard a:last-child { border-right: none; }
.scorecard .num { text-align: center; padding-top: 2px; background: #d7e4f2; font-weight: 700; }
.scorecard .mark {
  justify-self: end;
  width: 20px;
  border-left: 1.5px solid #8fb3d9;
  border-bottom: 1.5px solid #8fb3d9;
  text-align: center;
  font: 700 0.85rem "Bungee", sans-serif;
  line-height: 18px;
  color: var(--red);
}
.scorecard .run { text-align: center; font: 700 0.85rem "Karla", sans-serif; align-self: center; }
.scorecard a.current { background: #fff3c4; }
.scorecard a.current .num { background: var(--gold); }
.scorecard a:hover .num { background: var(--orange); color: #fff; }
.total {
  display: grid;
  text-align: center;
  font-family: "Bungee", sans-serif;
  color: var(--gold);
  line-height: 1.1;
  min-width: 56px;
}
.total small { font: 700 0.7rem "Karla", sans-serif; color: #8fb3d9; text-transform: uppercase; letter-spacing: 0.1em; }
.total b { font-weight: 400; font-size: 1.5rem; }

/* ---------- The lane ---------- */
.lane {
  position: relative;
  max-width: calc(var(--lane-w) + var(--gutter) * 2);
  margin: 0 auto;
  padding: 0 calc(var(--gutter) + 20px) 0;
  /* 39 boards of maple and pine */
  background:
    linear-gradient(90deg, transparent var(--gutter), rgba(255, 255, 255, 0.12) calc(50% - 1px), transparent calc(100% - var(--gutter))),
    repeating-linear-gradient(90deg, var(--wood-1) 0 20px, var(--wood-seam) 20px 21px, var(--wood-2) 21px 41px, var(--wood-seam) 41px 42px);
  background-clip: content-box, padding-box;
  /* Gutters */
  border-left: var(--gutter) solid #26201c;
  border-right: var(--gutter) solid #26201c;
  box-shadow:
    inset 8px 0 10px -6px rgba(0, 0, 0, 0.6),
    inset -8px 0 10px -6px rgba(0, 0, 0, 0.6),
    -6px 0 0 #2a1d14, -8px 0 0 #c9a24d, -12px 0 0 #2a1d14, -13px 0 0 #c9a24d,
    6px 0 0 #2a1d14, 8px 0 0 #c9a24d, 12px 0 0 #2a1d14, 13px 0 0 #c9a24d;
}
/* Gutter channels */
.lane::before,
.lane::after {
  content: "";
  position: absolute;
  top: 0; bottom: 0;
  width: var(--gutter);
  background: linear-gradient(90deg, #120e0b, #3b332e 50%, #120e0b);
  border-radius: 0 0 14px 14px;
}
.lane::before { left: calc(var(--gutter) * -1); }
.lane::after { right: calc(var(--gutter) * -1); }

/* The approach */
.approach {
  text-align: center;
  padding: 64px 0 36px;
  color: #2a1a10;
}
.eyebrow { color: #6b3b17; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; margin: 0; }
.approach h1 {
  font-family: "Bungee Shade", "Bungee", sans-serif;
  font-weight: 400;
  font-size: clamp(2.6rem, 9vw, 5.6rem);
  line-height: 1;
  margin: 16px 0;
  color: var(--red);
  text-shadow: 4px 4px 0 #2a1a10;
}
.approach h1 span { color: var(--orange); display: block; }
.lede { max-width: 560px; margin: 0 auto 28px; font-size: 1.15rem; font-weight: 700; }

.approach-dots, .range-dots, .arrows { display: flex; justify-content: center; }
.approach-dots { gap: 48px; margin-top: 44px; }
.approach-dots i, .range-dots i {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: #2a1a10;
  opacity: 0.7;
}
.range-dots { gap: 34px; margin: 10px 0; }
.range-dots i { width: 8px; height: 8px; }

.foul-line {
  position: relative;
  height: 10px;
  margin: 20px calc((var(--gutter) * -1) + -20px) 28px;
  background: #1a1a1a;
  border-top: 2px solid var(--red);
  border-bottom: 2px solid var(--red);
}
.foul-line span {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  padding: 2px 12px;
  background: var(--red);
  color: var(--cream);
  font: 700 0.75rem "Karla", sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  white-space: nowrap;
  border-radius: 4px;
}

/* Target arrows: seven of them, in a shallow V */
.arrows { gap: 7%; margin: 8px 0 18px; }
.arrows i {
  width: 0; height: 0;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-top: 36px solid #2a1a10;
  opacity: 0.75;
}
.arrows i:nth-child(1), .arrows i:nth-child(7) { transform: translateY(-24px); }
.arrows i:nth-child(2), .arrows i:nth-child(6) { transform: translateY(-16px); }
.arrows i:nth-child(3), .arrows i:nth-child(5) { transform: translateY(-8px); }

.btn {
  display: inline-block;
  font: 700 1rem "Karla", sans-serif;
  padding: 12px 22px;
  border-radius: 999px;
  border: 2px solid var(--orange);
  background: var(--orange);
  color: var(--bg);
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.15s, background 0.15s;
}
.btn:hover { transform: translateY(-2px) rotate(-1deg); background: var(--gold); border-color: var(--gold); }

/* ---------- Frames ---------- */
.frame {
  position: relative;
  background: var(--card);
  border-radius: 16px;
  padding: 30px clamp(18px, 4vw, 40px);
  margin: 0 0 40px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(242, 181, 68, 0.25);
}
.frame-tag {
  position: absolute;
  top: -14px; left: 24px;
  margin: 0;
  padding: 2px 12px;
  background: var(--gold);
  color: #2a1a10;
  font: 400 0.8rem "Bungee", sans-serif;
  border-radius: 6px;
}
.frame h2 {
  font-family: "Bungee", sans-serif;
  font-weight: 400;
  color: var(--orange);
  font-size: clamp(1.5rem, 4vw, 2.1rem);
  margin: 6px 0 8px;
}
.sub { color: var(--muted); margin-top: 0; }

.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 24px; }
.pull {
  margin: 20px 0 0;
  padding: 16px 22px;
  border-left: 6px solid var(--teal);
  background: rgba(58, 167, 163, 0.12);
  font-size: 1.15rem;
  font-style: italic;
  border-radius: 0 12px 12px 0;
}

.precepts { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; counter-reset: p; }
.precepts[start="6"] { counter-reset: p 5; }
.precepts li {
  counter-increment: p;
  position: relative;
  padding: 12px 16px 12px 64px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 12px;
}
.precepts li::before {
  content: counter(p);
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--gold); color: var(--bg);
  font-family: "Bungee", sans-serif;
}
.precepts strong { color: var(--gold); }

.rules { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.rules li { padding: 10px 14px 10px 44px; background: rgba(0, 0, 0, 0.25); border-radius: 10px; position: relative; }
.rules li::before { content: "⚠"; position: absolute; left: 14px; color: var(--gold); }
.rules b { color: var(--gold); }

/* Oracle & shoe rental forms */
.oracle-form { display: flex; gap: 10px; flex-wrap: wrap; }
.oracle-form input {
  flex: 1 1 220px;
  min-width: 0;
  font: inherit;
  padding: 12px 18px;
  border-radius: 999px;
  border: 2px solid var(--muted);
  background: var(--cream);
  color: var(--bg);
}
.oracle-form input:focus { outline: 3px solid var(--teal); border-color: var(--teal); }
.ball-wrap { display: flex; align-items: center; gap: 28px; margin-top: 24px; flex-wrap: wrap; justify-content: center; }
.ball {
  position: relative;
  width: 130px; height: 130px;
  flex: none;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #9a6be0, var(--purple) 45%, #2e1752 100%);
  box-shadow: var(--shadow), inset -10px -14px 24px rgba(0, 0, 0, 0.4);
}
.ball .hole { position: absolute; width: 17px; height: 17px; border-radius: 50%; background: #120a1f; }
.ball .hole:nth-child(1) { top: 32px; left: 44px; }
.ball .hole:nth-child(2) { top: 32px; left: 70px; }
.ball .hole:nth-child(3) { top: 62px; left: 56px; width: 21px; height: 21px; }
.ball.rolling { animation: roll 0.9s ease-in-out; }
@keyframes roll {
  25% { transform: translateX(-12px) rotate(-90deg); }
  50% { transform: translateX(12px) rotate(180deg); }
  75% { transform: translateX(-6px) rotate(300deg); }
  100% { transform: rotate(360deg); }
}
.oracle-answer { flex: 1 1 260px; font-size: 1.3rem; font-weight: 700; color: var(--cream); min-height: 3em; margin: 0; }

.ticket {
  margin-top: 20px;
  display: flex;
  gap: 18px;
  align-items: center;
  padding: 18px 22px;
  background: var(--cream);
  color: #2a1a10;
  border-radius: 8px;
  border: 2px dashed var(--red);
}
.ticket .shoe { font-size: 2.6rem; }
.ticket h3 { margin: 0; font-family: "Bungee", sans-serif; font-weight: 400; color: var(--red); }
.ticket p { margin: 0; }

/* Quiz */
.quiz fieldset { border: none; padding: 0; margin: 0 0 20px; min-width: 0; }
.quiz legend { font-weight: 700; color: var(--gold); margin-bottom: 8px; }
.quiz label {
  display: block;
  padding: 10px 14px;
  margin: 6px 0;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.25);
  cursor: pointer;
  border: 2px solid transparent;
}
.quiz label:hover { border-color: var(--muted); }
.quiz input { accent-color: var(--orange); margin-right: 10px; }
.quiz label:has(input:checked) { border-color: var(--orange); background: rgba(232, 121, 43, 0.15); }
.quiz-result { margin-top: 20px; padding: 20px; border-radius: 14px; background: var(--cream); color: var(--bg); }
.quiz-result h3 { font-family: "Bungee", sans-serif; font-weight: 400; margin: 0 0 6px; color: var(--red); }
.quiz-result p { margin: 0; }

/* League cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.card {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 14px;
  padding: 20px;
  border-top: 5px solid var(--teal);
  transition: transform 0.2s;
}
.card:nth-child(3n+2) { border-top-color: var(--orange); }
.card:nth-child(3n) { border-top-color: var(--purple); }
.card:hover { transform: translateY(-4px) rotate(-0.6deg); }
.card .emoji { font-size: 2rem; }
.card h3 { font-family: "Bungee", sans-serif; font-weight: 400; margin: 6px 0; color: var(--gold); }
.card p { margin: 0; color: var(--muted); font-size: 0.96rem; }

/* Bar */
.recipe { display: flex; gap: 32px; align-items: center; flex-wrap: wrap; }
.recipe ul { flex: 1 1 240px; margin: 0; padding-left: 20px; }
.recipe li { margin: 6px 0; }
.recipe b { color: var(--gold); }
.glass {
  position: relative;
  width: 110px; height: 120px;
  flex: none;
  margin: 0 auto;
  border: 4px solid rgba(255, 255, 255, 0.6);
  border-top: none;
  border-radius: 0 0 18px 18px;
  overflow: hidden;
}
.glass .kahlua { position: absolute; inset: 40% 0 0; background: #4a2b18; }
.glass .cream {
  position: absolute; inset: 22% 0 50%;
  background: var(--cream);
  z-index: 1;
  animation: swirl 5s ease-in-out infinite;
  border-radius: 40% 60% 50% 50% / 30% 30% 70% 70%;
}
@keyframes swirl { 50% { transform: translateY(14px) scaleX(1.1); border-radius: 60% 40% 50% 50%; } }
.fineprint { color: var(--muted); font-size: 0.9rem; margin: 20px 0 0; }

/* ---------- Frame 1: the bowling game ---------- */
.game { display: grid; gap: 14px; }
.game-canvas {
  display: block;
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  border-radius: 12px;
  box-shadow: var(--shadow), 0 0 0 3px #c9a24d, 0 0 0 6px #2a1d14;
  touch-action: none;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}
.game-canvas:active { cursor: grabbing; }
.game-canvas:focus-visible { outline: 3px solid var(--teal); outline-offset: 6px; }
.game-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  font-weight: 700;
}
.game-controls label { display: flex; gap: 8px; color: var(--gold); }
.game-controls output { color: var(--muted); min-width: 9.5em; font-weight: 400; }
.game-controls input[type="range"] { accent-color: var(--orange); width: 160px; }
.btn-small { padding: 6px 14px; font-size: 0.9rem; }
.game-card-wrap { overflow-x: auto; }
.game-card {
  margin: 0 auto;
  border-collapse: collapse;
  background: #f4f7fb;
  color: #0a1726;
  font-size: 0.85rem;
  min-width: 100%;
  table-layout: fixed;
}
.game-card th { background: #d7e4f2; font-weight: 700; padding: 2px 0; border: 1.5px solid #8fb3d9; }
.game-card td { border: 1.5px solid #8fb3d9; padding: 0; text-align: center; vertical-align: top; height: 46px; }
.game-card th:last-child { width: 14%; }
.game-card .cur { background: #fff3c4; }
.game-card th.cur { background: var(--gold); }
.game-card .boxes { display: flex; justify-content: flex-end; }
.game-card .boxes span {
  width: 18px; height: 18px;
  border-left: 1px solid #8fb3d9;
  border-bottom: 1px solid #8fb3d9;
  font: 700 0.75rem/18px "Karla", sans-serif;
  color: var(--red);
}
.game-card b { display: block; font-size: 0.95rem; padding-top: 2px; }
.game-msg { text-align: center; font-weight: 700; font-size: 1.1rem; margin: 0; min-height: 1.6em; }

/* ---------- End of the lane ---------- */
.pin-rack { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 0 0; }
.pin-rack div { display: flex; gap: 10px; }
.pin-rack i {
  width: 22px; height: 34px;
  background: var(--cream);
  border-radius: 50% 50% 40% 40% / 60% 60% 40% 40%;
  box-shadow: inset 0 9px 0 -5px var(--red), 0 4px 6px rgba(0, 0, 0, 0.3);
}
.lane-end { text-align: center; color: #2a1a10; font-weight: 700; margin: 14px 0 0; padding-bottom: 30px; }
.lane-end a { color: var(--red); }

/* ---------- Masking unit / footer ---------- */
.masking {
  max-width: calc(var(--lane-w) + var(--gutter) * 4);
  margin: 0 auto 0;
  text-align: center;
  padding: 36px 24px 48px;
  color: var(--muted);
  font-size: 0.9rem;
  background:
    radial-gradient(circle at 15% 50%, rgba(232, 121, 43, 0.25), transparent 30%),
    radial-gradient(circle at 85% 50%, rgba(58, 167, 163, 0.25), transparent 30%),
    linear-gradient(#0a1726, #10243a);
  border-top: 6px solid var(--orange);
  border-radius: 0 0 24px 24px;
}
.stranger { font-style: italic; color: var(--ink); font-size: 1.05rem; }

/* ---------- Mini lane tracker ---------- */
.minilane { display: none; }
@media (min-width: 1240px) {
  .minilane {
    display: block;
    position: fixed;
    right: 28px;
    top: calc(var(--header-h) + 40px);
    bottom: 40px;
    width: 46px;
    z-index: 5;
  }
  .minilane-track {
    position: relative;
    height: 100%;
    border-radius: 6px;
    background: repeating-linear-gradient(90deg, var(--wood-1) 0 4px, var(--wood-2) 4px 8px);
    border-left: 6px solid #26201c;
    border-right: 6px solid #26201c;
    box-shadow: var(--shadow);
  }
  .minilane-pins {
    position: absolute;
    bottom: 8px; left: 0; right: 0;
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-template-rows: repeat(4, 7px);
    gap: 2px 0;
    justify-items: center;
  }
  .minilane-pins i { width: 5px; height: 6px; border-radius: 50%; background: var(--cream); }
  /* 1-2-3-4 triangle, head pin nearest the bowler */
  .minilane-pins i:nth-child(1) { grid-area: 1 / 4; }
  .minilane-pins i:nth-child(2) { grid-area: 2 / 3; }
  .minilane-pins i:nth-child(3) { grid-area: 2 / 5; }
  .minilane-pins i:nth-child(4) { grid-area: 3 / 2; }
  .minilane-pins i:nth-child(5) { grid-area: 3 / 4; }
  .minilane-pins i:nth-child(6) { grid-area: 3 / 6; }
  .minilane-pins i:nth-child(7) { grid-area: 4 / 1; }
  .minilane-pins i:nth-child(8) { grid-area: 4 / 3; }
  .minilane-pins i:nth-child(9) { grid-area: 4 / 5; }
  .minilane-pins i:nth-child(10) { grid-area: 4 / 7; }
  .minilane-ball {
    position: absolute;
    left: 50%;
    top: 4px;
    width: 16px; height: 16px;
    margin-left: -8px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, #9a6be0, var(--purple) 50%, #2e1752);
  }
}

/* Toast for a perfect game */
.toast {
  position: fixed;
  left: 50%; bottom: 24px;
  transform: translateX(-50%);
  z-index: 30;
  padding: 14px 22px;
  background: var(--gold);
  color: #2a1a10;
  font: 400 1.1rem "Bungee", sans-serif;
  border-radius: 12px;
  box-shadow: var(--shadow);
  animation: pop 0.4s ease-out;
  text-align: center;
  max-width: calc(100% - 32px);
}
@keyframes pop { from { transform: translate(-50%, 30px); opacity: 0; } }

@media (max-width: 640px) {
  :root { --gutter: 12px; --header-h: 64px; }
  body { font-size: 17px; }
  .scoreboard { padding: 6px 8px; gap: 8px; }
  .logo span { display: none; }
  .scorecard { grid-template-columns: repeat(10, 1fr); }
  .scorecard a { grid-template-rows: 12px 16px 20px; font-size: 0.6rem; }
  .scorecard .mark { width: 14px; font-size: 0.7rem; line-height: 16px; }
  .scorecard .run { font-size: 0.7rem; }
  .total b { font-size: 1.2rem; }
  .total { min-width: 40px; }
  .lane { padding: 0 12px; }
  .foul-line { margin-left: -12px; margin-right: -12px; }
  .approach { padding-top: 40px; }
  .approach-dots { gap: 28px; }
  .range-dots { gap: 18px; }
  .frame-tag { left: 16px; }
}

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

@media (max-width: 640px) {
  .game-card { font-size: 0.7rem; }
  .game-card td { height: 38px; }
  .game-card .boxes span { width: 11px; height: 13px; font-size: 0.6rem; line-height: 13px; }
  .game-card b { font-size: 0.75rem; }
  .game-controls input[type="range"] { width: 130px; }
}
