/* Cami's Lanes: cosmic bowling under blacklight. The lane is the picture; the page
   round it is the dark of the hall, with the overhead score monitor as the one
   bright thing in the chrome. Righteous is mid-century bowling-alley signage;
   Outfit is a calm geometric sans for reading. */

:root {
  --uv-night: #0b0718;
  --uv-deep: #150d2c;
  --uv-panel: #1d1240;
  --uv-line: #3a2a6e;
  --violet: #8f63ff;
  --cyan: #3ff3ff;
  --pink: #ff4fb0;
  --pin: #f6f2ff;
  --stripe: #ff2e4d;
  --text: #efeaff;
  --text-soft: #b4a9dc;

  --display: "Righteous", "Arial Rounded MT Bold", sans-serif;
  --body: "Outfit", system-ui, sans-serif;

  --gutter: clamp(0.75rem, 2.5vw, 1.5rem);
}

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

html { color-scheme: dark; }

body {
  margin: 0;
  background: var(--uv-night);
  color: var(--text);
  font: 400 1.0625rem/1.55 var(--body);
  overflow-x: hidden;
}

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

/* the playing screen fills the viewport (or the arcade's frame) exactly */
.hall {
  height: 100vh;
  height: 100svh;
  min-height: 30rem;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  background:
    radial-gradient(60rem 26rem at 50% 0%, rgba(143, 99, 255, 0.18), transparent 70%),
    var(--uv-night);
}

/* ---- top bar */

.top {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  padding: 0.5rem var(--gutter) 0.4rem;
}

.back {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--text-soft);
  font-weight: 600;
  text-underline-offset: 3px;
}
.back::before { content: "‹"; margin-right: 0.35em; font-size: 1.3em; line-height: 1; }
.back:hover { color: var(--text); }

h1 {
  margin: 0;
  font: 400 clamp(1.5rem, 3.2vw, 2.1rem)/1 var(--display);
  color: var(--pin);
  text-shadow: 0 0 0.5em rgba(255, 79, 176, 0.55), 0 0 0.12em rgba(255, 79, 176, 0.9);
}

.lane-tag {
  margin: 0;
  padding: 0.1rem 0.7rem;
  border: 2px solid var(--cyan);
  border-radius: 999px;
  color: var(--cyan);
  font: 400 1rem/1.6 var(--display);
  box-shadow: 0 0 0.6rem rgba(63, 243, 255, 0.35), inset 0 0 0.5rem rgba(63, 243, 255, 0.2);
}

.best {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  margin: 0 0 0 auto;
  color: var(--text-soft);
}
.best dd { margin: 0; color: var(--text); font: 400 1.25rem/1 var(--display); }

/* ---- the overhead score monitor */

.monitor {
  padding: 0 var(--gutter) 0.5rem;
}

.sheet {
  width: 100%;
  max-width: 54rem;
  margin: 0 auto;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
  background: linear-gradient(180deg, #23154d, #170e34);
  border: 2px solid var(--uv-line);
  border-radius: 10px;
  box-shadow: 0 0 1.4rem rgba(143, 99, 255, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  overflow: hidden;
  font-variant-numeric: tabular-nums;
}

.sheet th,
.sheet td {
  padding: 0;
  text-align: center;
  border-right: 1px solid var(--uv-line);
}
.sheet th:last-child,
.sheet td.total { border-right: 0; }

.sheet th {
  font: 600 1rem/1.5 var(--body);
  color: var(--text-soft);
  background: rgba(0, 0, 0, 0.18);
  border-bottom: 1px solid var(--uv-line);
}
.sheet th.tenth { width: 13%; }
.sheet th.total-head { width: 13%; }

/* the ball marks sit in little boxes along the top right of each frame, like a real sheet */
.marks td {
  height: 1.75rem;
  vertical-align: top;
}
.marks .balls {
  display: flex;
  justify-content: flex-end;
  height: 100%;
}
.marks .ball {
  flex: 0 0 auto;
  min-width: 1.3em;
  padding: 0 0.15em;
  font: 600 1rem/1.75rem var(--body);
  color: var(--pin);
}
.marks .ball + .ball { border-left: 1px solid var(--uv-line); }
.marks .ball:last-child { border-bottom: 1px solid var(--uv-line); }
.marks .ball.x { color: var(--pink); text-shadow: 0 0 0.4em rgba(255, 79, 176, 0.8); }
.marks .ball.slash { color: var(--cyan); text-shadow: 0 0 0.4em rgba(63, 243, 255, 0.8); }

.runs td {
  height: 1.75rem;
  font: 400 1.125rem/1.75rem var(--display);
  color: var(--text);
}

.sheet td.total {
  font: 400 clamp(1.4rem, 3vw, 1.9rem)/1 var(--display);
  color: var(--pin);
  text-shadow: 0 0 0.5em rgba(143, 99, 255, 0.9);
  vertical-align: middle;
}

/* the frame being bowled */
.sheet .now { background: rgba(63, 243, 255, 0.12); }
.sheet th.now { color: var(--cyan); }

/* ---- the lane */

.stage {
  position: relative;
  min-height: 0;
  overflow: hidden;
  background: #07040d;
}

.stage canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
  outline: none;
}
.stage canvas:active { cursor: grabbing; }
.stage canvas:focus-visible { box-shadow: inset 0 0 0 3px var(--cyan); }

.up-next {
  position: absolute;
  top: 0.6rem;
  left: var(--gutter);
  margin: 0;
  font: 400 1.25rem/1.2 var(--display);
  color: var(--pin);
  text-shadow: 0 0 0.6em rgba(11, 7, 24, 0.9);
  pointer-events: none;
}
.up-next .ball-no {
  display: block;
  font: 600 1rem/1.3 var(--body);
  color: var(--text-soft);
}

.curve {
  position: absolute;
  top: 0.6rem;
  right: var(--gutter);
  margin: 0;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  background: rgba(11, 7, 24, 0.7);
  color: var(--cyan);
  font-weight: 600;
  pointer-events: none;
}

.meter {
  position: absolute;
  right: var(--gutter);
  bottom: 1rem;
  width: 1.1rem;
  height: min(40%, 12rem);
  border: 2px solid var(--pin);
  border-radius: 999px;
  overflow: hidden;
  background: rgba(11, 7, 24, 0.75);
  pointer-events: none;
}
.meter span {
  position: absolute;
  inset: auto 0 0;
  height: 0;
  background: linear-gradient(0deg, var(--cyan), var(--violet) 55%, var(--pink));
}

/* neon lettering over the lane for strikes and spares */
.cheer {
  position: absolute;
  inset: 34% 0 auto;
  margin: 0;
  text-align: center;
  font: 400 clamp(3rem, 12vw, 7rem)/1 var(--display);
  color: #fff4fb;
  text-shadow:
    0 0 0.06em #fff,
    0 0 0.18em var(--pink),
    0 0 0.45em var(--pink),
    0 0 0.9em rgba(143, 99, 255, 0.9);
  opacity: 0;
  pointer-events: none;
}
.cheer.spare {
  color: #f0feff;
  text-shadow:
    0 0 0.06em #fff,
    0 0 0.18em var(--cyan),
    0 0 0.45em var(--cyan),
    0 0 0.9em rgba(143, 99, 255, 0.9);
}
.cheer.show { animation: cheer 1.7s ease-out both; }

@keyframes cheer {
  0% { opacity: 0; transform: scale(0.82); }
  14% { opacity: 1; transform: scale(1.04); }
  24% { transform: scale(1); }
  70% { opacity: 1; }
  100% { opacity: 0; transform: scale(1); }
}

.nogl {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 2rem var(--gutter);
  text-align: center;
}
.nogl[hidden] { display: none; }
.nogl p { max-width: 30rem; margin: 0; font-size: 1.125rem; }

/* ---- under the lane */

.deck {
  display: flex;
  align-items: center;
  gap: 0.75rem 1rem;
  padding: 0.6rem var(--gutter) max(0.6rem, env(safe-area-inset-bottom));
  border-top: 1px solid var(--uv-line);
  background: var(--uv-deep);
}

.hint {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  max-width: 44rem;
  font-size: 1.0625rem;
  line-height: 1.4;
}
.hint strong { font-weight: 700; color: var(--pin); }

.buttons {
  display: flex;
  gap: 0.6rem;
  flex: 0 0 auto;
}

button {
  min-height: 44px;
  padding: 0.4rem 1.1rem;
  border-radius: 999px;
  font: 600 1rem/1 var(--body);
  cursor: pointer;
}

.toggle {
  border: 2px solid var(--uv-line);
  background: transparent;
  color: var(--text-soft);
}
.toggle::before {
  content: "";
  display: inline-block;
  width: 0.7em;
  height: 0.7em;
  margin-right: 0.5em;
  border-radius: 50%;
  border: 2px solid currentColor;
  vertical-align: -0.05em;
}
.toggle[aria-pressed="true"] {
  border-color: var(--pink);
  color: var(--pin);
}
.toggle[aria-pressed="true"]::before {
  background: var(--pink);
  border-color: var(--pink);
  box-shadow: 0 0 0.5em var(--pink);
}

.again {
  border: 2px solid var(--cyan);
  background: var(--cyan);
  color: var(--uv-night);
}
.again:hover { background: #8ff8ff; }
.again.ready { box-shadow: 0 0 0 4px rgba(63, 243, 255, 0.3), 0 0 1.2rem rgba(63, 243, 255, 0.6); }

a:focus-visible,
button:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 3px;
}

/* ---- notes, below the playing screen */

.notes {
  max-width: 44rem;
  margin: 0 auto;
  padding: 1.75rem var(--gutter) 2.5rem;
  color: var(--text-soft);
}
.notes p { margin: 0 0 1rem; }
.notes strong { color: var(--text); }

/* ---- smaller screens */

@media (max-width: 40rem) {
  .top { gap: 0.1rem 0.75rem; padding-top: 0.25rem; padding-bottom: 0.25rem; }
  .back { min-height: 44px; }
  h1 { font-size: 1.45rem; }
  .lane-tag { font-size: 1rem; padding: 0 0.6rem; }
  .monitor { padding-left: 0.5rem; padding-right: 0.5rem; }
  .sheet th.tenth { width: 15%; }
  .sheet th.total-head { width: 15%; }
  .marks .ball { min-width: 0; padding: 0 0.1em; font-size: 1rem; }
  .runs td { font-size: 1rem; }
  .deck { flex-wrap: wrap; }
  .hint { flex-basis: 100%; }
  .buttons { width: 100%; }
  .buttons button { flex: 1 1 0; }
}

@media (prefers-reduced-motion: reduce) {
  .cheer.show { animation: cheer-still 1.7s linear both; }
  @keyframes cheer-still {
    0%, 100% { opacity: 0; }
    10%, 75% { opacity: 1; }
  }
}
