:root {
  /* Arcade Toy Future — docs/VISUAL_PLAN.md */
  --bg: #1a1440;
  --panel: #2a2460;
  --neon: #ffd84d;
  --cyan: #3de7ff;
  --text: #fff8f0;
  --muted: #c4b5fd;
  --danger: #ff3b6b;
  --ok: #4ade80;
  --font-ui: "DM Sans", "Outfit", system-ui, sans-serif;
  --font-arcade: "Press Start 2P", monospace;
}

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

html, body {
  min-height: 100%;
  background:
    radial-gradient(ellipse 95% 55% at 50% -12%, #4c1d95 0%, transparent 58%),
    radial-gradient(ellipse 45% 35% at 100% 100%, #db2777 0%, transparent 52%),
    radial-gradient(ellipse 40% 30% at 0% 80%, #0e7490 0%, transparent 50%),
    var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
}

body {
  display: flex;
  justify-content: center;
  padding: 8px 10px 16px;
  min-height: 100vh;
}

#app {
  width: min(100%, 1100px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

/* ── Top HUD ── */
.top-hud {
  display: grid;
  grid-template-columns: 1fr 1.2fr 1fr;
  gap: 8px;
  align-items: start;
  padding: 4px 2px;
}

.hud-block {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.hud-block.center { align-items: center; text-align: center; }
.hud-block.right { align-items: flex-end; text-align: right; }

.label {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--muted);
  text-transform: uppercase;
}

.value {
  font-family: var(--font-ui);
  font-size: 22px;
  font-weight: 700;
  color: var(--neon);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 16px rgba(255, 200, 61, 0.35);
}

.value.cyan {
  color: var(--cyan);
  text-shadow: 0 0 14px rgba(38, 217, 255, 0.35);
  font-size: 20px;
}

.power-meter-wrap {
  width: min(100%, 200px);
  margin-top: 6px;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}

.power-meter-wrap.active {
  opacity: 1;
  transform: none;
}

.power-track {
  height: 6px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  border: 1px solid rgba(38, 217, 255, 0.25);
}

.power-fill {
  height: 100%;
  width: 100%;
  transform-origin: left center;
  transform: scaleX(1);
  background: linear-gradient(90deg, #22d3ee, #a5f3fc);
  box-shadow: 0 0 10px rgba(38, 217, 255, 0.6);
  transition: transform 0.08s linear;
}

.power-meter-wrap.warn .power-fill {
  background: linear-gradient(90deg, #fbbf24, #fff);
  animation: pulse-warn 0.5s ease-in-out infinite alternate;
}

@keyframes pulse-warn {
  from { filter: brightness(1); }
  to { filter: brightness(1.35); }
}

@media (prefers-reduced-motion: reduce) {
  .power-meter-wrap.warn .power-fill { animation: none; }
}

.power-label {
  display: block;
  margin-top: 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--cyan);
}

.title-strip {
  text-align: center;
  padding: 2px 0 4px;
}

.title-strip h1 {
  font-family: var(--font-arcade);
  font-size: clamp(12px, 3vw, 16px);
  color: var(--neon);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-shadow: 0 0 12px rgba(255, 200, 61, 0.5);
}

.badge-3d {
  font-size: 0.55em;
  color: #041018;
  background: linear-gradient(180deg, #7ef9ff, #26d9ff);
  padding: 4px 8px;
  border-radius: 6px;
  text-shadow: none;
}

.tagline {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

/* ── Stage ── */
.stage-wrap {
  position: relative;
  border-radius: 14px;
  padding: 7px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: linear-gradient(165deg, #3b2a80 0%, #2a1f6e 45%, #1a1440 100%);
  box-shadow:
    0 0 0 2px rgba(255, 216, 77, 0.35),
    0 0 0 4px rgba(61, 231, 255, 0.2),
    0 0 48px rgba(244, 114, 182, 0.18),
    0 18px 48px rgba(20, 10, 50, 0.55);
}

.viewport {
  width: 100%;
  /* Maze is 28×31 — keep it upright and large */
  aspect-ratio: 28 / 31;
  flex: 1 1 auto;
  min-height: min(78vh, 860px);
  max-height: 88vh;
  height: min(88vh, 920px);
  border-radius: 8px;
  overflow: hidden;
  background: #2a1f6e;
}

.combo-toast {
  position: absolute;
  left: 50%;
  top: 18%;
  transform: translate(-50%, -10px);
  font-family: var(--font-arcade);
  font-size: 12px;
  color: var(--cyan);
  text-shadow: 0 0 12px rgba(38, 217, 255, 0.7);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s, transform 0.15s;
  z-index: 4;
}

.combo-toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ── Overlay ── */
.overlay {
  position: absolute;
  inset: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(26, 20, 64, 0.78);
  backdrop-filter: blur(8px);
  border-radius: 8px;
  z-index: 5;
}

.overlay.hidden {
  display: none !important;
}

.overlay-card {
  width: min(94%, 400px);
  padding: 22px 18px 18px;
  border-radius: 16px;
  background: linear-gradient(165deg, #3b2a80, #2a2460 55%, #1a1440);
  border: 2px solid rgba(255, 216, 77, 0.4);
  box-shadow:
    0 0 0 1px rgba(61, 231, 255, 0.25),
    0 12px 40px rgba(20, 10, 50, 0.55);
  text-align: center;
}

.overlay-card h2 {
  font-family: var(--font-arcade);
  font-size: 14px;
  color: var(--neon);
  margin-bottom: 12px;
  line-height: 1.5;
}

.overlay-card p {
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-line;
  margin-bottom: 12px;
  color: var(--text);
}

.controls {
  list-style: none;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 12px;
  line-height: 1.8;
}

kbd {
  display: inline-block;
  min-width: 1.35em;
  padding: 2px 5px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.07);
  font-size: 11px;
  color: var(--cyan);
  font-family: var(--font-ui);
}

.cast {
  display: grid;
  gap: 5px;
  text-align: left;
  font-size: 12px;
  color: var(--muted);
  margin: 0 auto 14px;
  max-width: 280px;
}

.cast-item { display: flex; align-items: center; gap: 8px; }

.bird-swatch {
  width: 12px;
  height: 12px;
  border-radius: 50% 50% 40% 40%;
  box-shadow: 0 0 8px currentColor;
}
.bird-swatch.scarlet { background: #ff2d55; color: #ff2d55; }
.bird-swatch.rose { background: #ff4dc8; color: #ff4dc8; }
.bird-swatch.sky { background: #22d3ee; color: #22d3ee; }
.bird-swatch.amber { background: #fbbf24; color: #fbbf24; }

.overlay-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

.btn-primary,
#start-btn {
  font-family: var(--font-arcade);
  font-size: 11px;
  padding: 14px 22px;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  color: #1a1200;
  background: linear-gradient(180deg, #ffe566, #f0b400);
  box-shadow: 0 6px 0 #a67800, 0 10px 24px rgba(240, 180, 0, 0.3);
  min-width: 180px;
}

.btn-secondary {
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 700;
  padding: 10px 18px;
  border-radius: 999px;
  cursor: pointer;
  color: var(--cyan);
  background: rgba(38, 217, 255, 0.08);
  border: 1px solid rgba(38, 217, 255, 0.3);
  min-width: 160px;
}

.btn-primary:active,
#start-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 #a67800; }

/* ── Footer ── */
.footer-hud {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  padding: 2px 4px 0;
}

.lives { display: flex; gap: 6px; min-height: 18px; }

.life-icon {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #ffe566, #f0b400 55%, #c98a00);
  box-shadow: 0 0 10px rgba(255, 200, 61, 0.5);
}

.level-info {
  font-family: var(--font-arcade);
  font-size: 10px;
  color: var(--cyan);
}

.hint-col { text-align: right; }
.hint {
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.fps {
  font-size: 10px;
  color: rgba(139, 147, 184, 0.55);
  margin-top: 2px;
}

.diag {
  font-size: 10px;
  color: rgba(139, 147, 184, 0.4);
  text-align: center;
  font-family: ui-monospace, monospace;
}

/* Zoom controls */
.zoom-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 4px 8px 2px;
  user-select: none;
}

.zoom-bar input[type="range"] {
  width: min(220px, 40vw);
  accent-color: #3de7ff;
  cursor: pointer;
}

.zoom-bar button {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 2px solid rgba(255, 216, 77, 0.45);
  background: linear-gradient(180deg, #3b2a80, #2a2460);
  color: #ffd84d;
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.25);
}

.zoom-bar button:active {
  transform: scale(0.95);
}

.zoom-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--cyan);
  min-width: 52px;
}

.zoom-hint {
  font-size: 11px;
  color: var(--muted);
}

.buff-strip {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  min-height: 0;
}

.buff {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.15);
}
.buff.turbo { color: #00ff88; background: rgba(0, 255, 136, 0.12); border-color: rgba(0, 255, 136, 0.35); }
.buff.mult { color: #ffd700; background: rgba(255, 215, 0, 0.12); border-color: rgba(255, 215, 0, 0.35); }
.buff.shield { color: #60a5fa; background: rgba(96, 165, 250, 0.12); border-color: rgba(96, 165, 250, 0.35); }
.buff.freeze { color: #a5f3fc; background: rgba(165, 243, 252, 0.12); border-color: rgba(165, 243, 252, 0.35); }

/* Pad */
#coinman-pad {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  user-select: none;
}
#coinman-pad .pad-row { display: flex; gap: 8px; justify-content: center; }
#coinman-pad button {
  font-family: var(--font-ui);
  font-size: 18px;
  min-width: 52px;
  min-height: 48px;
  border-radius: 12px;
  border: 1px solid rgba(38, 217, 255, 0.28);
  background: linear-gradient(180deg, #1a2450, #101830);
  color: var(--neon);
  cursor: pointer;
}
#coinman-pad #pad-start {
  font-size: 13px;
  font-weight: 700;
  min-width: 168px;
  color: var(--cyan);
  padding: 12px 16px;
}
#coinman-pad button:active { transform: scale(0.96); }

@media (max-width: 480px) {
  .tagline { display: none; }
  .value { font-size: 18px; }
  .viewport {
    min-height: 62vh;
    height: 70vh;
    max-height: 78vh;
  }
  #app { width: 100%; }
}

@media (min-width: 900px) {
  .viewport {
    min-height: 80vh;
    height: min(86vh, 960px);
  }
}
