:root {
  --bg: #141a24;
  --accent: #ffb347;
  --glass-bg: rgba(11, 14, 20, 0.72);
  --glass-border: rgba(255, 255, 255, 0.12);
  --text: #eef2f6;
  --text-dim: rgba(238, 242, 246, 0.68);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
}

#game {
  position: relative;
  width: 100vw;
  height: 100dvh;
  height: 100vh;
  background: var(--bg);
}

#scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0; /* explicit, not relied-upon "auto" — keeps the canvas unambiguously below the HUD
                 (z-index:20) and every overlay (z-index:30) in every embedding context. */
}

#flash {
  position: absolute;
  inset: 0;
  background: #ff2b2b;
  opacity: 0;
  pointer-events: none;
  z-index: 40;
}

.glass {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  backdrop-filter: blur(6px);
}

#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 20;
}

#readouts {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: 12px;
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 8px 14px;
  font-size: 12.5px;
  letter-spacing: 0.04em;
  max-width: calc(100vw - 76px);
  flex-wrap: wrap;
}
#readouts .label { color: var(--text-dim); font-size: 10.5px; }
#readouts strong { font-size: 15px; font-variant-numeric: tabular-nums; color: var(--accent); }
#readouts .divider { width: 1px; height: 14px; background: var(--glass-border); margin: 0 3px; }

#pause-button {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: 12px;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  color: var(--text);
  font-size: 16px;
  pointer-events: auto;
  cursor: pointer;
  z-index: 25;
}

#desktop-hint {
  position: absolute;
  bottom: max(12px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  /* visible (flex) default: ui/Hud.js's constructor sets style.display = '' for the desktop-capable
     case (clearing to this stylesheet default) and 'none' explicitly otherwise — see the "NOTE ON
     DISPLAY TOGGLING" comment further down for the same convention applied to overlays/cues. */
  display: flex;
  gap: 14px;
  padding: 8px 16px;
  font-size: 11.5px;
  color: var(--text-dim);
  white-space: nowrap;
}
#desktop-hint b { color: var(--accent); }

/* NOTE ON DISPLAY TOGGLING: ui/Hud.js shows an element by clearing its inline style
   (`el.style.display = ''`), which falls back to whatever THIS stylesheet says, and hides it with
   `el.style.display = 'none'`. That means every element below that Hud show/hide()s must default
   to a VISIBLE display value here — main.js is responsible for calling the matching hide*() (or,
   for #level-toast which has no wrapper, setting el.style.display = 'none' directly via hud.el)
   during its synchronous init so nothing flashes visible before the real start state is applied. */
#ftue-cue {
  position: absolute;
  bottom: max(64px, calc(env(safe-area-inset-bottom) + 64px));
  left: 50%;
  transform: translateX(-50%);
  font-size: 12.5px;
  color: var(--text-dim);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  padding: 6px 12px;
  display: flex; /* visible default — main.js calls hud.showFtueCue(false) at init */
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
#ftue-cue .hand { display: inline-block; animation: ftue-tap 1.1s ease-in-out infinite; }
@keyframes ftue-tap {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-4px) scale(0.92); }
}

#level-toast {
  position: absolute;
  top: 64px;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 18px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  display: flex; /* visible default — main.js hides it directly at init (Hud has no hideToast()) */
  pointer-events: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex; /* visible default — main.js calls hud.hidePause()/hud.hideFail() at init so only
                    #start-overlay (via hud.showStart()) is actually showing on first paint */
  align-items: center;
  justify-content: center;
  background: rgba(4, 5, 8, 0.76);
  z-index: 30;
}

.card {
  width: min(440px, 90vw);
  max-height: 88vh;
  overflow-y: auto;
  padding: 26px 24px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(22, 27, 35, 0.96), rgba(14, 18, 24, 0.96));
  border: 1px solid var(--glass-border);
  text-align: center;
}
.card.compact { padding: 20px; }
.eyebrow { margin: 0 0 4px; font-size: 11px; letter-spacing: 0.12em; color: var(--accent); }
.card h1 { margin: 0 0 10px; font-size: 26px; }
.card h2 { margin: 0 0 10px; font-size: 20px; }
.objective { color: var(--text-dim); font-size: 13.5px; line-height: 1.5; margin: 0 0 16px; }
.controls-grid { display: grid; gap: 8px; text-align: left; margin-bottom: 18px; }
.controls-grid div { display: flex; justify-content: space-between; gap: 12px; font-size: 12.5px; }
.controls-grid b { color: var(--accent); white-space: nowrap; }
.controls-grid span:last-child { color: var(--text-dim); text-align: right; }
.actions { display: flex; justify-content: center; }
#play-button, #retry-button {
  padding: 12px 26px;
  border-radius: 999px;
  border: none;
  background: var(--accent);
  color: #1a1000;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.04em;
  cursor: pointer;
}
.hint { margin: 14px 0 0; font-size: 11.5px; color: var(--text-dim); }
#fail-overlay p { color: var(--text-dim); font-size: 13px; }
#fail-overlay strong { color: var(--text); font-size: 16px; }

@media (max-width: 480px) {
  #desktop-hint { display: none !important; }
  #readouts { font-size: 11px; }
}
