/* style.css — page chrome for Pounce.
   The game itself draws into <canvas id="game"> via Canvas 2D. Internal
   resolution is locked at 800 × 480 (5 : 3 landscape); the canvas is then
   scaled to the viewport via CSS while preserving aspect ratio. Inspired by
   cat-ski's bezel pattern, adapted for landscape so the game fills as much
   horizontal real-estate as the viewport allows. */

@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=VT323&display=swap');

:root {
  /* Page chrome: deep nighttime backdrop so the sunset palette inside the
     canvas glows by contrast. Accent stays warm gold (matches the cat-food
     can + magic-fish highlights inside the game). */
  --bg-1:    #0a0712;
  --bg-2:    #181028;
  --bg-3:    #2a1f44;
  --panel:   #1a1227;
  --panel-2: #0d0a18;
  --bezel:   #3a2a55;
  --ink:     #f0e9e0;
  --ink-dim: #b0a89c;
  --ink-soft:#c69c6d;     /* warm dusty rose, used for bezel links */
  --accent:  #ffd166;     /* sunset gold */
  --accent-2:#84e36b;     /* shooter-state green tint */
  --accent-3:#ff8b6b;     /* warning / panic warm */
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--bg-2);
  color: var(--ink);
  font-family: 'VT323', ui-monospace, Menlo, Consolas, monospace;
  /* dvh = dynamic viewport height; resizes with the browser chrome on mobile */
  min-height: 100dvh;
  width: 100%;
}

body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  gap: 10px;
  background:
    radial-gradient(ellipse at 50% 0%, var(--bg-3) 0%, var(--bg-2) 60%, var(--bg-1) 100%);
  /* Don't paint anything if the canvas is bigger than the viewport — the
     overflow we want is on the inner .screen-wrap only. */
  overflow-x: hidden;
}

/* ----- Frame: the rounded chrome that wraps the whole app -----
   The width formula reserves vertical room for the bezel-title +
   controls hint INSIDE the frame, plus the bottom .frame-controls element
   that sits OUTSIDE it (≈210 px of total chrome). Both frames share the
   same width via the --frame-width variable so they line up. */
:root {
  --frame-width: min(95vw, calc((100dvh - 210px) * 5 / 3 + 24px), 1612px);
}
.frame {
  position: relative;
  padding: 12px 12px 14px;
  border-radius: 8px;
  background: linear-gradient(var(--panel), var(--panel-2));
  box-shadow:
    0 0 0 2px var(--bezel),
    0 0 0 4px #000,
    0 24px 48px rgba(0,0,0,0.55),
    inset 0 0 32px rgba(0,0,0,0.55);
  width: var(--frame-width);
  max-width: 100%;
}

/* ----- Bottom audio-controls frame ----- */
.frame-controls {
  /* Same chrome treatment as the main frame, but smaller and not full-height. */
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 22px;
  /* Slightly softer shadow than the main frame so it reads as the smaller
     of the two stacked elements. */
  box-shadow:
    0 0 0 2px var(--bezel),
    0 0 0 4px #000,
    0 12px 24px rgba(0,0,0,0.45),
    inset 0 0 16px rgba(0,0,0,0.45);
}
.frame-controls .bezel-button {
  font-size: 10px;
  letter-spacing: 2px;
  padding: 6px 10px;
}
.game-controls-label {
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  letter-spacing: 3px;
  color: var(--ink-soft);
  text-shadow: 0 0 6px rgba(122, 167, 199, 0.55);
  margin-right: 6px;
}

/* Each audio-row is a button + its volume slider as one inline group. */
.audio-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

/* Retro-styled range slider. WebKit + Firefox both supported via vendor
   pseudo-elements — keep both. Track is dim, thumb is the accent gold. */
.audio-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 90px;
  height: 16px;
  background: transparent;
  cursor: pointer;
  outline: none;
  margin: 0;
  padding: 0;
}
.audio-slider::-webkit-slider-runnable-track {
  height: 4px;
  background: var(--bg-3);
  border: 1px solid var(--bezel);
  border-radius: 2px;
}
.audio-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  background: var(--accent);
  border: 1px solid #000;
  border-radius: 50%;
  margin-top: -5px;     /* (track-h - thumb-h) / 2, ish */
  cursor: pointer;
  box-shadow: 0 0 4px rgba(255, 209, 102, 0.6);
}
.audio-slider::-moz-range-track {
  height: 4px;
  background: var(--bg-3);
  border: 1px solid var(--bezel);
  border-radius: 2px;
}
.audio-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  background: var(--accent);
  border: 1px solid #000;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 4px rgba(255, 209, 102, 0.6);
}
.audio-slider:focus::-webkit-slider-thumb { background: var(--accent-2); }
.audio-slider:focus::-moz-range-thumb     { background: var(--accent-2); }

/* ----- Top bezel: HOME / README on left, brand center, sister-projects right ----- */
.bezel-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-family: 'Press Start 2P', monospace;
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--ink-soft);
  margin-bottom: 10px;
  padding: 0 4px;
  text-shadow: 0 0 6px rgba(122, 167, 199, 0.55);
}
.bezel-center { flex: 1; text-align: center; color: var(--accent); }
.bezel-left, .bezel-right {
  display: flex;
  align-items: center;
  gap: 10px;
}
.bezel-title .dot {
  color: var(--accent);
  animation: blink 1.2s steps(2, end) infinite;
}
@keyframes blink { 50% { opacity: 0; } }
.bezel-link {
  font-size: 8px;
  letter-spacing: 2px;
  color: var(--ink-soft);
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 4px 2px;
  text-shadow: none;
  transition: color 120ms;
}
.bezel-link:hover  { color: var(--accent-2); }
.bezel-link:active { color: var(--accent); }

/* Buttons rendered with bezel-link styling so the music toggle blends in
   visually with the surrounding HOME / README / SOURCE anchor tags. */
.bezel-button {
  background: transparent;
  border: 0;
  font-family: inherit;
  cursor: pointer;
}
.bezel-button[aria-pressed="false"] { color: #6a6573; text-decoration: line-through; }

/* ----- Leaderboard strip: thin board between the bezel and the canvas ----- */
.leaderboard {
  display: flex;
  justify-content: center;
  gap: 28px;
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  letter-spacing: 1.5px;
  color: var(--ink-soft);
  margin: 0 0 8px;
  padding: 6px 8px;
  border-top: 1px solid rgba(140, 110, 70, 0.25);
  border-bottom: 1px solid rgba(140, 110, 70, 0.25);
  flex-wrap: wrap;
}
.lb-row {
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
  min-width: 130px;
}
.lb-rank  { color: var(--accent-2); min-width: 18px; }
.lb-name  { color: var(--ink);      min-width: 50px; letter-spacing: 2px; }
.lb-score { color: var(--ink-dim);  min-width: 38px; text-align: right; margin-left: auto; }
.lb-empty { opacity: 0.45; }
@media (max-width: 540px) {
  .leaderboard { gap: 12px; font-size: 8px; padding: 5px 4px; }
  .lb-row { gap: 6px; min-width: 0; }
  .lb-name  { min-width: 38px; letter-spacing: 1.5px; }
  .lb-score { min-width: 30px; }
}

/* ----- Name-entry overlay (high-score prompt) ----- */
.lb-entry {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(15, 12, 28, 0.95);
  border: 2px solid var(--accent);
  padding: 16px 24px 14px;
  z-index: 10;
  text-align: center;
  font-family: 'Press Start 2P', monospace;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
}
.lb-entry.hidden { display: none; }
.lb-entry-title {
  color: var(--accent);
  font-size: 14px;
  margin-bottom: 12px;
  letter-spacing: 3px;
  text-shadow: 0 0 8px rgba(255, 209, 102, 0.4);
}
.lb-entry-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.lb-name-input {
  font-family: inherit;
  font-size: 14px;
  letter-spacing: 4px;
  width: 140px;
  padding: 8px 10px;
  background: var(--bg-2);
  color: var(--ink);
  border: 2px solid var(--ink-dim);
  text-align: center;
  text-transform: uppercase;
  outline: none;
  caret-color: var(--accent);
}
.lb-name-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(255, 209, 102, 0.3);
}
.lb-submit {
  font-family: inherit;
  font-size: 10px;
  padding: 8px 12px;
  background: var(--accent);
  color: var(--bg-2);
  border: 2px solid var(--accent);
  cursor: pointer;
  letter-spacing: 2px;
  box-shadow: 2px 2px 0 #000;
}
.lb-submit:active {
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 #000;
}
.lb-entry-hint {
  margin-top: 10px;
  font-size: 8px;
  color: var(--ink-dim);
  letter-spacing: 1.5px;
}

/* ----- Screen wrap: holds the canvas at the right aspect ratio ----- */
.screen-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 5 / 3;
  border-radius: 4px;
  overflow: hidden;
  background: #6ec5ff;
  box-shadow:
    inset 0 0 0 2px #000,
    inset 0 0 24px rgba(0, 0, 0, 0.4);
}

canvas#game {
  display: block;
  width: 100%;
  height: 100%;
  /* Crisp scaling for pixel art when the CSS size > internal resolution. */
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  cursor: crosshair;
  outline: none;
  background: #6ec5ff;
}

/* ----- Below-frame controls hint ----- */
.controls {
  margin-top: 10px;
  padding: 0 4px;
  font-size: 18px;
  color: var(--ink-dim);
  letter-spacing: 1px;
  text-align: center;
}
.controls strong { color: var(--ink); }
.controls a { color: var(--ink-soft); text-decoration: underline; text-underline-offset: 2px; }
.controls a:hover { color: var(--accent-2); }

@media (max-width: 700px) {
  body { padding: 8px; }
  .frame { padding: 8px; border-radius: 6px; }
  .bezel-title { font-size: 9px; letter-spacing: 1px; gap: 6px; }
  .bezel-link  { font-size: 7px; }
  .controls    { font-size: 14px; }
}
