/* hjkl.li — minimal terminal-dark theme. Background matches the canvas so the
 * cell grid blends into the page (the game emits no background color itself).
 */
:root {
  --bg: #0e1014;
  --fg: #dce0e8;
  --muted: #6b7080;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  /* The canvas owns the whole viewport — never let the page scroll. */
  overflow: hidden;
  /* Stop iOS Safari rubber-banding / pull-to-refresh from fighting the game. */
  overscroll-behavior: none;
  background: var(--bg);
  color: var(--fg);
  font-family: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono",
    Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 13px;
}

#wrap {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0;
  gap: 0;
}

/* Loading overlay: shown while the wasm module is being fetched and
   compiled. Hidden by JS once the game loop starts. */
#loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 5;
  background: var(--bg);
  color: var(--muted);
  font-size: 14px;
  transition: opacity 0.6s ease;
}
#loading.done {
  opacity: 0;
  pointer-events: none;
}
.spinner {
  width: 28px;
  height: 28px;
  border: 2px solid #3a3f4d;
  border-top-color: var(--fg);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

#game {
  background: var(--bg);
  max-width: none;
  height: auto;
  outline: none;
  border-radius: 0;
  box-shadow: none;
  image-rendering: pixelated;
  display: block;
}

/* CRT wrapper: subtle curvature, scanlines, and bloom sit on top of the
   canvas. The border-radius + inner shadow simulate a convex tube face.
   touch-action:none hands all gestures on the screen to the game's pointer
   handlers — no pinch-zoom or double-tap-zoom mid-rally. */
#crt {
  position: relative;
  display: inline-block;
  line-height: 0;
  border-radius: 18px;
  overflow: hidden;
  touch-action: none;
  box-shadow:
    inset 0 0 60px rgba(0, 0, 0, 0.4),
    0 0 40px rgba(0, 0, 0, 0.6);
}

/* Fullscreen targets the CRT wrapper itself (the terminal area), not the
   page. The UA stylesheet stretches :fullscreen elements to the viewport, so
   center the canvas inside it and drop the tube-face chrome — the game fills
   the screen while the hint bar and status line stay outside. The scanline /
   bloom / vignette overlays span the whole screen, which reads even more
   CRT-like at full size. */
#crt:fullscreen,
#crt:-webkit-full-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  border-radius: 0;
  box-shadow: none;
  background: var(--bg);
}

/* CRT scanlines: every other pixel row is dimmed, mimicking the shadow-mask
   of a 15kHz CRT.  More visible than before but still subtle enough to not
   overpower the image. */
#crt::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 1px,
    rgba(0, 0, 0, 0.15) 1px,
    rgba(0, 0, 0, 0.15) 2px
  );
  z-index: 1;
}

/* Phosphor bloom: a warm white glow at the centre that fades toward the
   edges, mimicking the way a CRT phosphor screen glows brighter in the
   middle. */
#crt-bloom {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(
    ellipse at center,
    rgba(255, 255, 240, 0.06) 0%,
    transparent 70%
  );
  z-index: 2;
}

/* CRT vignette: darker corners simulating the light falloff of a curved
   CRT tube face and the natural brightness roll-off toward the edges. */
#crt-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(
    ellipse at center,
    transparent 50%,
    rgba(0, 0, 0, 0.55) 100%
  );
  z-index: 3;
}

/* High-score name entry: small modal over the canvas, shown at the end of a
   record run. Hidden until JS adds .show. */
#name-dlg {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(14, 16, 20, 0.85);
}
#name-dlg.show { display: flex; }
#name-dlg form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 20px 24px;
  background: #161a21;
  border: 1px solid #3a3f4d;
  border-radius: 8px;
}
#name-dlg label { color: var(--fg); font-size: 13px; }
#name-dlg input {
  font: inherit;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid #3a3f4d;
  border-radius: 4px;
  padding: 6px 8px;
  outline: none;
}
#name-dlg input:focus { border-color: #5a6175; }
#name-dlg .row { display: flex; gap: 8px; justify-content: flex-end; }
#name-dlg button {
  font: inherit;
  font-size: 12px;
  color: var(--muted);
  background: #161a21;
  border: 1px solid #3a3f4d;
  border-radius: 4px;
  padding: 4px 12px;
  cursor: pointer;
}
#name-dlg button:hover { color: var(--fg); border-color: #5a6175; }

/* Subtle warm-up flicker: a random-ish opacity pulse that mimics the
   slight instability of an old CRT electron gun.  Only visible on the
   glow layers, so it never erases game content. */
@keyframes crt-flicker {
  0%   { opacity: 0.97; }
  5%   { opacity: 1.0; }
  10%  { opacity: 0.96; }
  15%  { opacity: 1.0; }
  20%  { opacity: 0.98; }
  50%  { opacity: 1.0; }
  80%  { opacity: 0.97; }
  90%  { opacity: 1.0; }
  100% { opacity: 0.99; }
}
#crt-bloom,
#crt-vignette,
#crt::after {
  animation: crt-flicker 0.15s infinite steps(10);
}

#hint {
  /* Float over the bottom of the game so it doesn't steal layout space, and
   * fade out after a few seconds of inactivity (the .dim class is toggled in
   * JS on pointer/keyboard activity). Restores instantly on any input.
   * env() keeps it clear of the home-indicator bar on notched phones. */
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
  font-size: 13px;
  color: var(--muted);
  max-width: 90vw;
  justify-content: center;
  padding: 6px 14px;
  background: rgba(14, 16, 20, 0.72);
  border-radius: 8px;
  backdrop-filter: blur(4px);
  transition: opacity 0.4s ease;
  opacity: 1;
  pointer-events: auto;
}
#hint.dim { opacity: 0; pointer-events: none; }
#hint .sep { opacity: 0.5; }
#hint a { color: var(--muted); text-decoration: none; }
#hint a:hover { color: var(--fg); }
#hint code { color: var(--fg); }
#hint button {
  font: inherit;
  font-size: 12px;
  color: var(--muted);
  background: #161a21;
  border: 1px solid #3a3f4d;
  border-radius: 4px;
  padding: 1px 8px;
  cursor: pointer;
}
#hint button:hover { color: var(--fg); border-color: #5a6175; }

kbd {
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid #3a3f4d;
  border-bottom-width: 2px;
  border-radius: 4px;
  background: #161a21;
  color: var(--fg);
  font-size: 12px;
  line-height: 1.4;
}

#status {
  font-size: 12px;
  color: var(--muted);
  min-height: 1em;
}
