/* - - - - - - - - - - - - - - - - - - - - *\
TOKENS — mirrors adamruf.com's dark/neon system (see public/studio/interval/css/styles.css)
\* - - - - - - - - - - - - - - - - - - - - */
:root {
  --bg: #010101;
  --fg: #AEFF00;
  --fg-dim: rgba(174, 255, 0, 0.5);
  --accent-yellow: #FFEE00;
  --accent-orange: #FFAA33;
  /* Matches --sp-ink / --color-heading on adamruf.com -- warm off-white,
     not pure white, since #fff on this near-black background haloes at
     the glyph edges (most visible on LCD subpixel rendering and OLED),
     which reads as less sharp, not more. */
  --white: #F4F4EF;
  --muted: #8a8a8a;
  --border: rgba(255, 255, 255, 0.22);
  --holofoil: linear-gradient(81.86deg, rgba(136, 255, 0, 0.8) 4.89%, rgba(206, 255, 0, 0.8) 78.31%, rgba(238, 255, 0, 0.8) 97.89%);
  --holofoil-hover: linear-gradient(81.86deg, rgb(167, 255, 153) 9.79%, rgb(174, 255, 0) 19.58%, rgb(238, 255, 0) 97.89%);
  /* The actual text-gradient treatment from adamruf.com's homepage (the
     `.highlight` class in src/pages/index.astro) -- green/yellow/orange,
     distinct from --holofoil above (that one matches the Button component's
     narrower fill gradient, not the homepage's text treatment). */
  --holofoil-text: linear-gradient(135deg, #AEFF00 0%, #FFEE00 88%, #FFAA33 100%);
  --btn-shadow: 0px 1px 2px 0px rgba(0, 0, 0, 0.08), 0px 2px 2px 0px rgba(0, 0, 0, 0.04);
  --font-mono: 'Space Mono', 'SF Mono', Menlo, monospace;
  --font-display: 'Oswald', Impact, sans-serif;
  --font-serif: 'Playfair Display', Georgia, serif;
  --control-radius: 0.5rem;
  --tap-min: 3rem;
  color-scheme: dark;
}

* { box-sizing: border-box; }

/* ── Focus ring (applies site-wide on adamruf.com, src/styles/global.css)
   -- ported here since this is a standalone static page outside Astro's
   global stylesheet. Anything without its own :focus-visible override
   (most interactive elements here) falls back to this instead of the
   browser's default blue ring. .btn-primary keeps its own richer variant
   below, matching Button.astro's override of this same global rule. */
@keyframes focus-pulse {
  0%, 100% { outline-color: rgba(174, 255, 0, 0.24); }
  50%       { outline-color: rgba(174, 255, 0, 0.45); }
}
*:focus-visible {
  outline: 4px solid rgba(174, 255, 0, 0.24);
  outline-offset: 0;
  border-radius: 4px;
  animation: focus-pulse 1.8s ease-in-out infinite;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--white);
  overscroll-behavior: none;
}

body {
  font-family: var(--font-mono);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* ---- breadcrumb (mirrors adamruf.com's Breadcrumb.astro) ---- */
.breadcrumb {
  position: fixed;
  top: 2.5rem;
  left: 1.5rem;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 1rem;
  margin: 0;
}
@media (display-mode: standalone) {
  .breadcrumb { display: none; }
}
@media (min-width: 696px) {
  .breadcrumb { left: 2.5rem; }
}
body:has(#app[data-screen="play"]) .breadcrumb,
body:has(#app[data-screen="play"]) .install-pill-anchor { display: none; }
.breadcrumb a { color: #aaa; text-decoration: none; transition: color 0.15s ease; }
.breadcrumb a:hover { color: #fff; }
.breadcrumb__sep { color: #444; }
.breadcrumb__current { color: var(--fg); }
.breadcrumb__nav { position: relative; }
.breadcrumb__nav summary { display: flex; align-items: center; gap: 4px; list-style: none; cursor: pointer; }
.breadcrumb__nav summary::-webkit-details-marker { display: none; }
.breadcrumb__chevron { transition: transform 0.15s ease; }
.breadcrumb__nav[open] .breadcrumb__chevron { transform: rotate(180deg); }
.breadcrumb__menu {
  position: absolute; top: calc(100% + 8px); left: 0;
  display: flex; flex-direction: column; width: max-content; min-width: 100%;
  margin: 0; padding: 6px; list-style: none;
  background: rgba(20, 20, 20, 0.85);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07), 0 8px 24px rgba(0, 0, 0, 0.4);
}
.breadcrumb__menu a { display: block; padding: 6px 10px; border-radius: 6px; color: #ccc; font-size: 0.9375rem; white-space: nowrap; }
.breadcrumb__menu a:hover { color: #fff; background: rgba(255, 255, 255, 0.08); }

/* ---- install pill (mirrors interval) ---- */
.install-pill-anchor { position: fixed; top: calc(2.5rem - 8px); right: 1.5rem; z-index: 10; }
@media (min-width: 696px) { .install-pill-anchor { right: 2.5rem; } }
.icon-btn {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  width: var(--tap-min); height: var(--tap-min);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  border-radius: var(--control-radius);
  color: var(--white);
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.12); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn .icon { width: 20px; height: 20px; }
.icon-btn--primary { background: var(--holofoil); box-shadow: var(--btn-shadow); color: #0A0A0A; border: none; }
.icon-btn--primary:hover { background: var(--holofoil-hover); }

/* Hover/focus-only label -- aria-hidden since the button's own aria-label
   already gives screen readers the accessible name; this is a sighted
   nicety, not a second announcement. */
.icon-tooltip {
  position: absolute; bottom: calc(100% + 8px); left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  background: rgba(20, 20, 20, 0.95);
  border: 1px solid var(--border);
  font-family: var(--font-mono); font-size: 0.75rem; color: #ddd;
  opacity: 0; pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 10;
}
.icon-btn:hover .icon-tooltip, .icon-btn:focus-visible .icon-tooltip { opacity: 1; }
.install-pill-tooltip {
  position: absolute; top: calc(100% + 8px); right: 0; width: max-content; max-width: 220px;
  padding: 8px 12px; font-size: 0.8125rem; color: #ddd;
  background: rgba(20, 20, 20, 0.92); border: 1px solid var(--border); border-radius: 10px;
}

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

#app { position: relative; min-height: 100dvh; }
/* Crossfade between screens instead of an instant hidden-attribute cut —
   showScreen() in app.js adds/removes .screen--fade-out to animate it.
   Plain opacity, not position/display, so it can't disturb the breadcrumb's
   stacking (that's keyed off #app[data-screen], not this transition). */
.screen { min-height: 100dvh; opacity: 1; transition: opacity 0.35s ease; }
.screen[hidden] { display: none !important; }
.screen--fade-out { opacity: 0; }

/* ---- home screen (title + level carousel, one merged screen) ---- */
#screen-home {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  padding: 2rem 1.5rem;
  overflow: hidden;
}
/* Whichever level the carousel is centered on, rendered once as a still
   backdrop — shows the actual game instead of an empty black screen,
   dimmed and blurred enough that the card on top of it stays the legible
   focus. app.js overrides opacity/filter inline for locked levels, scaling
   both further by distance from the unlock frontier. */
#home-board {
  /* render.js sets explicit pixel width/height inline to keep the board's
     own aspect ratio -- inset:0 with a fixed size just pins it to the
     top-left corner instead of centering it, since the fixed width
     overrides the auto-stretch inset would otherwise produce. Centering
     by transform works regardless of the canvas's own size. */
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  opacity: 0.4;
  filter: blur(4px);
  pointer-events: none;
  transition: filter 0.3s ease, opacity 0.3s ease;
}
.home-card { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 0.5rem; text-align: center; max-width: 380px; }
.home-card .btn-primary { width: 100%; }
.carousel { display: flex; align-items: center; justify-content: center; gap: 1rem; margin: 0.5rem 0; }
.carousel-readout { display: flex; flex-direction: column; align-items: center; gap: 0.25rem; min-width: 96px; }
.carousel-numeral { font-family: var(--font-mono); font-weight: 700; font-size: 2rem; color: var(--fg); }
.carousel-best { font-size: 0.8125rem; color: var(--muted); }
.wordmark {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: clamp(2.5rem, 10vw, 3.5rem);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0;
}
.holofoil-text {
  background-image: var(--holofoil-text);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.tagline { color: #ccc; margin: 0.5rem 0 1.5rem; }

/* Matches adamruf.com's shared Button.astro component exactly (gradient,
   shadow, radius, Space Mono label, press-blob) rather than the site's
   display/heading styling — this is the same CTA component, not a
   game-themed reinterpretation of it. */
.btn-primary {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 400;
  padding: 0.75rem 1.5rem;
  min-height: var(--tap-min);
  border: none;
  border-radius: 8px;
  background-color: rgb(167, 245, 0);
  background-image: var(--holofoil);
  box-shadow: var(--btn-shadow);
  color: #0A0A0A;
  cursor: pointer;
  transition: background-color 0.2s ease-in-out, background-image 0.2s ease-in-out, box-shadow 0.2s ease-in-out, transform 0.1s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.btn-primary .btn-icon { position: relative; z-index: 1; width: 20px; height: 20px; flex-shrink: 0; }
.btn-primary:hover { background-color: rgb(174, 255, 0); background-image: var(--holofoil-hover); }
.btn-primary:active { box-shadow: none; transform: scale(0.95); }
.btn-primary:disabled { opacity: 0.6; }
.btn-primary:focus-visible {
  outline: 4px solid rgba(174, 255, 0, 0.24);
  outline-offset: 2px;
  animation: btn-focus-pulse 1.8s ease-in-out infinite;
}
@keyframes btn-focus-pulse {
  0%, 100% { outline-color: rgba(174, 255, 0, 0.24); }
  50% { outline-color: rgba(174, 255, 0, 0.6); }
}
.btn-blob-defs { position: absolute; width: 0; height: 0; }
.btn-bloom {
  position: absolute;
  inset: -25%;
  background: radial-gradient(circle at var(--press-x, 50%) var(--press-y, 50%), rgb(174, 255, 0) 0%, rgb(238, 255, 0) 45%, rgb(162, 255, 198) 75%, rgba(162, 255, 198, 0) 90%);
  opacity: 0;
  transition: opacity 0.15s ease-out;
  pointer-events: none;
}
.btn-primary:active .btn-bloom { opacity: 1; }
.btn-primary .btn-label { position: relative; z-index: 1; }

.perm-msg { color: var(--accent-orange); font-size: 0.875rem; max-width: 320px; margin-top: 0.5rem; }
.title-qr {
  display: flex; flex-direction: column; align-items: center; gap: 0.5rem;
  margin-top: 1.5rem;
}
.title-qr[hidden] { display: none !important; }
/* No fixed width/height here -- app.js sets the displayed size per render
   to an exact integer multiple of the canvas's actual pixel buffer (which
   varies with QR version/URL length). A fixed CSS size forced whatever
   version got picked into a non-integer scale (e.g. 148px buffer squeezed
   into a fixed 132px box), which mangles the module grid with uneven
   resampling -- exactly the kind of corruption that breaks scanning while
   still looking roughly right to the eye. */
#title-qr-canvas {
  border-radius: 8px;
  image-rendering: pixelated;
  /* Experiment: standard dark-on-light polarity (confirmed decodable)
     blended at 50% with whatever's behind it -- which here is the blurred
     Level I backdrop, not a flat color, so the quiet zone won't be
     perfectly uniform. Testing whether that's still scannable in practice. */
  opacity: 0.5;
}

/* ---- feel settings modal (opened from level select) ---- */
.settings {
  position: fixed; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  padding: 1.5rem;
}
.settings[hidden] { display: none !important; }
.settings__backdrop {
  position: absolute; inset: 0;
  background: rgba(1, 1, 1, 0.7);
  cursor: pointer;
}
.settings__card {
  position: relative;
  display: flex; flex-direction: column; gap: 1.75rem;
  width: 90%; max-width: 640px; min-height: 480px;
  max-height: 90vh; overflow-y: auto;
  padding: 2.5rem;
  background: rgba(20, 20, 20, 0.85);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07), 0 8px 24px rgba(0, 0, 0, 0.4);
}
.settings__header { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.settings__heading { margin: 0; font-family: var(--font-serif); font-weight: 400; font-size: 1.5rem; color: var(--white); }
.settings__header-actions { display: flex; align-items: center; gap: 0.25rem; }
.settings__icon-btn .icon { width: 16px; height: 16px; }
.settings__presets { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.preset-btn {
  flex: 1 1 auto;
  font-family: var(--font-mono); font-size: 0.75rem; line-height: 1.4;
  padding: 0.875rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  color: #ccc;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.preset-btn:hover { background: rgba(255, 255, 255, 0.1); border-color: var(--fg); color: #fff; }
.preset-btn__name { font-size: 1rem; font-weight: 700; }
.preset-btn:active { transform: scale(0.97); }
.preset-btn__diff { color: var(--muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.03em; }
.preset-btn--active {
  background: rgba(174, 255, 0, 0.14);
  border-color: var(--fg);
  color: #fff;
}
.preset-btn--active .preset-btn__diff { color: var(--fg); }
.settings__row { display: flex; flex-direction: column; gap: 0.875rem; }
.settings__row--toggle { flex-direction: row; align-items: center; justify-content: space-between; gap: 0.75rem; }
.settings__label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 0.75rem; }
.settings__label {
  font-family: var(--font-serif); font-weight: 400;
  font-size: 1.0625rem; color: #ddd;
}
.settings__val { font-family: var(--font-mono); font-weight: 700; font-size: 0.875rem; color: var(--fg); font-variant-numeric: tabular-nums; }
.settings__range { width: 100%; margin: 0; accent-color: var(--fg); cursor: pointer; touch-action: pan-x; }
.switch { position: relative; display: inline-flex; align-items: center; width: 44px; height: 24px; cursor: pointer; flex-shrink: 0; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch__track {
  position: absolute; inset: 0;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.switch__track::before {
  content: '';
  position: absolute; top: 50%; left: 3px;
  width: 16px; height: 16px;
  background: #ddd;
  border-radius: 50%;
  transform: translateY(-50%);
  transition: transform 0.15s ease, background 0.15s ease;
}
.switch input:checked ~ .switch__track { background: rgba(174, 255, 0, 0.35); border-color: var(--fg); }
.switch input:checked ~ .switch__track::before { background: var(--fg); transform: translateY(-50%) translateX(20px); }
.switch input:focus-visible ~ .switch__track { outline: 2px solid var(--fg); outline-offset: 2px; }

/* ---- play screen ---- */
#screen-play {
  position: fixed; inset: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  touch-action: none;
}
.hud[hidden] { display: none !important; }
.hud {
  display: flex; align-items: center;
  padding: max(0.75rem, env(safe-area-inset-top)) 1rem 0.5rem;
}
.hud-center { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.paused-level-switch { display: flex; align-items: center; gap: 0.5rem; }
.hud-level { font-family: var(--font-mono); font-weight: 700; font-size: 2rem; color: var(--fg); }
.hud-timer { font-family: var(--font-mono); font-weight: 700; font-size: 0.875rem; color: var(--white); }
.hud-delta {
  font-family: var(--font-mono); font-size: 0.8125rem; font-weight: 700;
  padding: 2px 8px; border-radius: 999px;
}
.delta--ahead { color: var(--fg); background: rgba(174, 255, 0, 0.14); }
.delta--behind { color: var(--accent-orange); background: rgba(255, 170, 51, 0.14); }

.board-wrap { position: relative; display: flex; align-items: center; justify-content: center; overflow: hidden; min-height: 0; }
#board { touch-action: none; transition: filter 0.3s ease, opacity 0.3s ease, transform 0.3s ease; }
/* Same treatment as #home-board -- the result card becomes the legible
   focus instead of the board, same as the home card does on the home
   screen's backdrop. */
#board.board--blurred { filter: blur(4px); opacity: 0.4; }
/* Pause only: a slight zoom on top of the blur, cropped by board-wrap's
   overflow:hidden -- reverses the same way on resume. */
#board.board--paused { transform: scale(1.15); }
/* Stretches the reveal to match the 3-2-1's length instead of the usual
   0.3s snap -- set alongside board--blurred/board--paused at the start of
   a fresh countdown, removed once it finishes. */
#board.board--revealing { transition-duration: 3s; }

.overlay[hidden] { display: none !important; }
.overlay {
  position: absolute; inset: 0; z-index: 5;
  display: flex; align-items: center; justify-content: center;
  text-align: center;
  background: rgba(1, 1, 1, 0.55);
  cursor: pointer;
}
.ov-count, .ov-hold, .ov-ready {
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(2.5rem, 14vw, 4rem);
  color: var(--white);
}
.ov-hold, .ov-ready { font-size: 1.5rem; color: #ddd; }
.ov-fell, .ov-rotated {
  font-family: var(--font-display); font-weight: 600; font-size: 1.5rem; color: var(--accent-orange);
}
.ov-sub { font-family: var(--font-mono); font-size: 0.875rem; color: var(--muted); margin-top: 0.5rem; font-weight: 400; }

.paused-panel[hidden] { display: none !important; }
.paused-panel {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  z-index: 6;
  display: flex; flex-direction: column; align-items: center; gap: 1.25rem;
}
.paused-actions { display: flex; align-items: center; gap: 0.75rem; }
.ov-result { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; }
.ov-result__sub { font-size: 0.9375rem; color: var(--muted); }
.ov-result__btns { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.625rem; margin-top: 1rem; max-width: 320px; }

.controls[hidden] { display: none !important; }
.controls {
  display: flex; align-items: center; justify-content: center;
  padding: 0.75rem 1rem max(0.75rem, env(safe-area-inset-bottom));
}

/* ---- Responsive breadcrumb + corner button (mirrors src/components/Breadcrumb.astro) ----
   • 24px line box; the 40px install button at top: calc(2.5rem - 8px) is
     centered on the text line.
   • Never wider than the viewport minus both gutters — and minus the
     button's 40px + 12px gap while it's showing.
   • Ancestors never shrink; the current crumb truncates with an ellipsis.
   • Under 480px the leading "home" crumb is dropped (studio links home). */
.breadcrumb {
  --gutter: 1.5rem;
  --corner: 0px;
  max-width: calc(100% - var(--gutter) * 2 - var(--corner));
  line-height: 24px;
  white-space: nowrap;
}
@media (min-width: 696px) {
  .breadcrumb { --gutter: 2.5rem; }
}
body:has([data-corner-action]:not([hidden])) .breadcrumb { --corner: 52px; }
.breadcrumb > * { flex: none; }
.breadcrumb > .breadcrumb__current,
.breadcrumb > .breadcrumb__nav { flex: 0 1 auto; min-width: 0; }
.breadcrumb__nav summary { min-width: 0; }
.breadcrumb__chevron { flex: none; }
.breadcrumb__label { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 479px) {
  .breadcrumb > :first-child,
  .breadcrumb > :first-child + .breadcrumb__sep { display: none; }
}
.install-pill-anchor .install-pill { width: 2.5rem; height: 2.5rem; }
