/* ============================================================
   深夜 00:01 / Quiet Kitchen — v2.0 Director's Cut Noir Studio UI
   3:00 AM Phosphor-Green CRT + Brushed Hardware Bezel Aesthetic
   ============================================================ */

:root {
  --bg-void: #020405;
  --bg-panel: rgba(8, 13, 16, 0.94);
  --bg-card: rgba(11, 18, 22, 0.88);
  --border-subtle: rgba(57, 255, 136, 0.16);
  --border-strong: rgba(57, 255, 136, 0.48);
  --led-green: #39ff88;
  --led-green-soft: rgba(57, 255, 136, 0.22);
  --fridge-cyan: #8ce7ff;
  --warn-amber: #ffb830;
  --danger-red: #ff2a4b;
  --text-main: #e8f5ee;
  --text-muted: #7b968a;
  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Helvetica Neue", sans-serif;
  --font-mono: "SF Mono", "JetBrains Mono", "Menlo", "Consolas", monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-void);
  color: var(--text-main);
  font-family: var(--font-sans);
  touch-action: none;
}

#app {
  position: relative;
  width: 100vw;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: #020405;
  overflow: hidden;
}

.hidden {
  display: none !important;
}

/* ================= ATMOSPHERIC POST-PROCESSING ================= */

.crt-scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 42;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.016) 0px,
    rgba(255, 255, 255, 0.016) 1px,
    transparent 1px,
    transparent 3px
  );
  opacity: 0.55;
}

.film-grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 41;
  opacity: 0.035;
  background-image: radial-gradient(rgba(255,255,255,0.6) 1px, transparent 0);
  background-size: 4px 4px;
}

.vignette-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 40;
  background: radial-gradient(circle at 50% 46%, transparent 42%, rgba(0, 0, 0, 0.82) 100%);
}

.flash-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 55;
  opacity: 0;
  transition: opacity 0.14s ease-out;
}

.flash-overlay.hallway-flash {
  background: linear-gradient(to bottom, rgba(255, 232, 158, 0.6) 0%, rgba(255, 42, 75, 0.36) 52%, rgba(0, 0, 0, 0.85) 100%);
  opacity: 1;
}

.flash-overlay.thunder-flash {
  background: radial-gradient(circle at 50% 10%, rgba(160, 225, 255, 0.35), rgba(140, 210, 255, 0.04));
  opacity: 1;
}

.shake-screen {
  animation: screenShake 0.44s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes screenShake {
  0%, 100% { transform: translate(0, 0); }
  12% { transform: translate(-9px, -5px); }
  25% { transform: translate(9px, 6px); }
  38% { transform: translate(-7px, 4px); }
  52% { transform: translate(6px, -4px); }
  68% { transform: translate(-4px, 2px); }
  84% { transform: translate(3px, -2px); }
}

/* ================= TOP STUDIO HUD ================= */

.top-hud {
  position: relative;
  z-index: 22;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  background: linear-gradient(to bottom, rgba(3, 6, 8, 0.96), rgba(4, 8, 10, 0.72));
  border-bottom: 1px solid rgba(57, 255, 136, 0.14);
  backdrop-filter: blur(10px);
}

.hud-left {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.stage-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.stage-time-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.led-mini {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--led-green);
  text-shadow: 0 0 10px rgba(57, 255, 136, 0.75);
  letter-spacing: 0.08em;
}

.stage-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.1em;
}

.mode-tag {
  font-family: var(--font-mono);
  font-size: 9px;
  padding: 1px 6px;
  border-radius: 3px;
  background: rgba(255, 42, 75, 0.2);
  border: 1px solid rgba(255, 42, 75, 0.6);
  color: #ff7a8e;
  letter-spacing: 0.08em;
}

.stage-title {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Hallway Sleep Sensor */
.hud-center {
  display: flex;
  justify-content: center;
}

.sleep-sensor {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px;
  background: linear-gradient(180deg, rgba(11, 18, 22, 0.92), rgba(6, 10, 13, 0.92));
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  min-width: 196px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 6px 18px rgba(0, 0, 0, 0.45);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.sleep-sensor.warn {
  border-color: rgba(255, 184, 48, 0.6);
  box-shadow: 0 0 16px rgba(255, 184, 48, 0.22);
}

.sleep-sensor.danger {
  border-color: rgba(255, 42, 75, 0.85);
  box-shadow: 0 0 22px rgba(255, 42, 75, 0.4);
}

.door-frame {
  width: 15px;
  height: 22px;
  border: 1.5px solid #475d55;
  border-radius: 2px;
  background: #030607;
  position: relative;
  overflow: hidden;
}

.door-light-crack {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 0%;
  background: linear-gradient(to left, #fff0ba, #ffb830);
  box-shadow: 0 0 10px #ffb830;
  transition: width 0.14s ease;
}

.sleep-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sleep-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  gap: 8px;
}

.sleep-status {
  color: var(--text-main);
  font-weight: 600;
}

.wake-pct {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
}

.wake-bar-track {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  overflow: hidden;
}

.wake-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--led-green);
  border-radius: 2px;
  transition: width 0.12s linear, background-color 0.2s;
}

.hud-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.speedrun-timer {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--warn-amber);
  padding: 4px 9px;
  background: rgba(255, 184, 48, 0.1);
  border: 1px solid rgba(255, 184, 48, 0.32);
  border-radius: 6px;
}

.icon-btn, .text-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  min-width: 32px;
  padding: 0 9px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  background: rgba(13, 21, 25, 0.78);
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 11px;
  transition: all 0.16s ease;
}

.icon-btn:hover, .text-btn:hover {
  border-color: var(--border-strong);
  color: var(--text-main);
}

.icon-btn.active {
  color: var(--led-green);
  border-color: rgba(57, 255, 136, 0.38);
}

.icon-btn.mic-live {
  color: var(--danger-red);
  border-color: rgba(255, 42, 75, 0.7);
  box-shadow: 0 0 14px rgba(255, 42, 75, 0.4);
}

/* ================= STAGE CANVAS & FLOATING BANNERS ================= */

.stage-wrapper {
  position: relative;
  flex: 1;
  width: 100%;
  min-height: 0;
  overflow: hidden;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

/* Dynamic Wildcard Event Banner */
.event-banner {
  position: absolute;
  top: 56px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 18;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  pointer-events: none;
  backdrop-filter: blur(8px);
  animation: slideDownFade 0.24s ease-out;
}

.event-banner.mask {
  background: rgba(14, 42, 54, 0.9);
  border: 1px solid rgba(140, 231, 255, 0.65);
  color: #c2f4ff;
  box-shadow: 0 0 22px rgba(140, 231, 255, 0.25);
}

.event-banner.alert {
  background: rgba(58, 22, 14, 0.92);
  border: 1px solid rgba(255, 184, 48, 0.7);
  color: #ffe09e;
  box-shadow: 0 0 22px rgba(255, 184, 48, 0.28);
}

.event-mod {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.4);
}

@keyframes slideDownFade {
  from { opacity: 0; transform: translate(-50%, -8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.stage-hint-bar {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 16;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 15px;
  border-radius: 999px;
  background: rgba(5, 10, 12, 0.86);
  border: 1px solid rgba(57, 255, 136, 0.28);
  backdrop-filter: blur(10px);
  font-size: 12.5px;
  color: #dff5e9;
  max-width: calc(100vw - 28px);
  text-align: center;
  pointer-events: none;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.55);
}

.hint-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--led-green);
  box-shadow: 0 0 8px var(--led-green);
  flex-shrink: 0;
}

.stage-progress-pill {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 16;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 15px;
  border-radius: 999px;
  background: rgba(5, 10, 12, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  pointer-events: none;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
}

.progress-track {
  width: 130px;
  height: 5px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #1fc76d, var(--led-green));
  box-shadow: 0 0 10px rgba(57, 255, 136, 0.65);
  transition: width 0.08s linear;
}

#stage-progress-val {
  color: var(--led-green);
  min-width: 34px;
  text-align: right;
}

/* ================= BOTTOM dB OSCILLOSCOPE & VU BAR ================= */

.meter-dock {
  position: relative;
  z-index: 26;
  height: 106px;
  padding: 8px 18px 10px;
  background: linear-gradient(to top, #020405 0%, rgba(5, 10, 12, 0.97) 100%);
  border-top: 1px solid rgba(57, 255, 136, 0.2);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.meter-dock.danger-border {
  border-top-color: rgba(255, 42, 75, 0.88);
  box-shadow: 0 -8px 32px rgba(255, 42, 75, 0.3);
}

.meter-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.meter-readout {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.meter-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--text-muted);
}

.db-value {
  font-family: var(--font-mono);
  font-size: 23px;
  font-weight: 800;
  color: var(--led-green);
  text-shadow: 0 0 12px rgba(57, 255, 136, 0.55);
  min-width: 60px;
}

.db-value.warn {
  color: var(--warn-amber);
  text-shadow: 0 0 12px rgba(255, 184, 48, 0.65);
}

.db-value.danger {
  color: var(--danger-red);
  text-shadow: 0 0 16px rgba(255, 42, 75, 0.9);
}

.db-unit {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

/* Studio Segmented VU LED Strip */
.vu-segments {
  display: flex;
  align-items: center;
  gap: 3px;
  margin-left: 8px;
  align-self: center;
}

.vu-seg {
  width: 6px;
  height: 13px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.07);
  transition: background-color 0.05s, box-shadow 0.05s;
}

.vu-seg.lit-green {
  background: #39ff88;
  box-shadow: 0 0 6px rgba(57, 255, 136, 0.7);
}

.vu-seg.lit-amber {
  background: #ffb830;
  box-shadow: 0 0 6px rgba(255, 184, 48, 0.75);
}

.vu-seg.lit-red {
  background: #ff2a4b;
  box-shadow: 0 0 8px rgba(255, 42, 75, 0.9);
}

.meter-stats {
  display: flex;
  align-items: center;
  gap: 12px;
}

.stat-chip {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
}

.stat-chip strong {
  color: var(--text-main);
  font-weight: 700;
}

.danger-chip strong {
  color: #ff6e84;
}

.danger-chip.masked strong {
  color: #8ce7ff;
}

.waveform-container {
  flex: 1;
  width: 100%;
  min-height: 0;
  border-radius: 6px;
  background: rgba(2, 6, 8, 0.95);
  border: 1px solid rgba(57, 255, 136, 0.14);
  overflow: hidden;
  position: relative;
}

#meter-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* ================= OVERLAY SCREENS & TITLE ================= */

.overlay-screen {
  position: fixed;
  inset: 0;
  z-index: 36;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(2, 4, 5, 0.76);
  backdrop-filter: blur(8px);
}

.overlay-screen.active {
  display: flex;
  animation: fadeIn 0.24s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Title Screen floats gracefully over the LIVE animated dark kitchen canvas! */
#screen-title {
  justify-content: space-between;
  background: radial-gradient(circle at 50% 42%, rgba(6, 14, 12, 0.45) 0%, rgba(2, 4, 5, 0.86) 72%);
  backdrop-filter: blur(2px);
  padding-bottom: 122px;
}

.title-top-bar {
  width: 100%;
  max-width: 960px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.ambient-tag {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  color: #8aa599;
}

.ver-pill {
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(57, 255, 136, 0.14);
  border: 1px solid rgba(57, 255, 136, 0.35);
  color: var(--led-green);
  font-size: 9.5px;
  font-weight: 700;
}

.rec-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--led-green);
  box-shadow: 0 0 10px var(--led-green);
  animation: blinkSlow 1.8s infinite;
}

@keyframes blinkSlow {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}

.title-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.title-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  max-width: 580px;
  width: 100%;
  margin: auto 0;
}

/* Brushed Metal Microwave LED Bezel */
.microwave-hero-bezel {
  background: linear-gradient(160deg, #0c1413 0%, #050908 60%, #0a1210 100%);
  border: 2px solid #1c3329;
  border-radius: 16px;
  padding: 16px 36px 13px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    inset 0 0 28px rgba(0, 0, 0, 0.95),
    0 0 54px rgba(57, 255, 136, 0.18),
    0 18px 42px rgba(0, 0, 0, 0.85);
  margin-bottom: 20px;
  position: relative;
}

.bezel-rivet {
  position: absolute;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #233b31;
  box-shadow: inset 0 1px 1px rgba(0,0,0,0.9);
}
.bezel-rivet.tl { top: 8px; left: 8px; }
.bezel-rivet.tr { top: 8px; right: 8px; }
.bezel-rivet.bl { bottom: 8px; left: 8px; }
.bezel-rivet.br { bottom: 8px; right: 8px; }

.led-screen-glass {
  position: relative;
  padding: 6px 14px;
  border-radius: 8px;
  background: #020504;
  border: 1px solid rgba(57, 255, 136, 0.18);
  box-shadow: inset 0 0 18px rgba(0, 0, 0, 0.95);
}

.led-ghost-bg {
  position: absolute;
  inset: 6px 14px;
  font-family: var(--font-mono);
  font-size: clamp(54px, 10.5vw, 84px);
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.1em;
  color: rgba(57, 255, 136, 0.06);
  pointer-events: none;
}

.led-display-hero {
  position: relative;
  font-family: var(--font-mono);
  font-size: clamp(54px, 10.5vw, 84px);
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.1em;
  color: var(--led-green);
  text-shadow:
    0 0 12px rgba(57, 255, 136, 0.92),
    0 0 34px rgba(57, 255, 136, 0.45),
    0 0 64px rgba(57, 255, 136, 0.2);
}

.led-display-hero.danger-tick {
  color: var(--danger-red);
  text-shadow:
    0 0 14px rgba(255, 42, 75, 0.95),
    0 0 38px rgba(255, 42, 75, 0.58);
}

.led-sub-indicators {
  display: flex;
  justify-content: center;
  gap: 18px;
  margin-top: 9px;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.2em;
}

.led-ind { color: #20372d; }
.led-ind.active { color: var(--led-green); text-shadow: 0 0 8px rgba(57, 255, 136, 0.65); }
.led-ind.warn { color: var(--warn-amber); text-shadow: 0 0 8px rgba(255, 184, 48, 0.65); }

.game-title {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 10px;
}

.title-main {
  font-size: clamp(30px, 5vw, 42px);
  font-weight: 800;
  letter-spacing: 0.06em;
  color: #f4fbf7;
  text-shadow: 0 4px 20px rgba(0, 0, 0, 0.8);
}

.title-sub {
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.34em;
  color: var(--led-green);
  opacity: 0.9;
}

.game-tagline {
  font-size: 14px;
  line-height: 1.6;
  color: #a4bdb1;
  margin-bottom: 22px;
  max-width: 460px;
}

.title-actions {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.primary-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  width: 100%;
  padding: 14px 22px;
  border-radius: 12px;
  border: 1px solid rgba(57, 255, 136, 0.72);
  background: linear-gradient(135deg, rgba(24, 92, 56, 0.94), rgba(12, 48, 30, 0.96));
  color: #f0fff6;
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.04em;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16);
  transition: transform 0.14s ease, box-shadow 0.2s ease, background 0.2s;
}

.primary-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 32px rgba(57, 255, 136, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.22);
  background: linear-gradient(135deg, rgba(31, 114, 70, 0.98), rgba(16, 62, 39, 0.98));
}

.primary-btn:active { transform: translateY(1px); }

.primary-btn .btn-sub {
  font-size: 11px;
  font-weight: 400;
  color: #a0f0c4;
}

.primary-btn.danger-btn {
  border-color: rgba(255, 42, 75, 0.85);
  background: linear-gradient(135deg, rgba(148, 18, 40, 0.94), rgba(84, 10, 22, 0.98));
}

.primary-btn.danger-btn:hover {
  box-shadow: 0 0 30px rgba(255, 42, 75, 0.48);
}

.pulse-glow {
  box-shadow: 0 0 24px rgba(57, 255, 136, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.secondary-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.secondary-actions.four-cols {
  grid-template-columns: repeat(4, 1fr);
}

.secondary-btn {
  padding: 11px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  background: rgba(12, 20, 24, 0.88);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.16s ease;
}

.secondary-btn:hover {
  border-color: rgba(57, 255, 136, 0.5);
  background: rgba(18, 32, 28, 0.94);
  transform: translateY(-1px);
}

.daily-btn {
  border-color: rgba(140, 231, 255, 0.32);
  color: #a8eeff;
}

.daily-btn:hover {
  border-color: rgba(140, 231, 255, 0.78);
  background: rgba(14, 34, 44, 0.94);
}

.hardcore-btn {
  border-color: rgba(255, 75, 100, 0.36);
  color: #ff98a8;
}

.hardcore-btn:hover {
  border-color: rgba(255, 42, 75, 0.8);
  background: rgba(54, 12, 20, 0.94);
}

.ghost-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(10, 16, 20, 0.72);
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.ghost-btn:hover {
  color: var(--text-main);
  border-color: rgba(57, 255, 136, 0.4);
}

.mini-pill {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(57, 255, 136, 0.15);
  color: var(--led-green);
}

.audio-tip {
  margin-top: 15px;
  font-size: 11.5px;
  color: #678377;
}

/* ================= MODAL PANELS ================= */

.modal-panel {
  width: 100%;
  max-width: 560px;
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.9), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.wide-panel {
  max-width: 860px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 18px;
}

.panel-header h2 { font-size: 20px; font-weight: 800; }
.panel-sub { font-size: 12.5px; color: var(--text-muted); margin-top: 3px; }

.close-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.close-btn:hover { color: var(--text-main); border-color: var(--border-strong); }

/* Chapters in Stage Select */
.stage-chapters {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.chapter-heading {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--led-green);
  margin-bottom: 8px;
  padding-bottom: 5px;
  border-bottom: 1px solid rgba(57, 255, 136, 0.16);
}

.stage-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(185px, 1fr));
  gap: 10px;
}

.stage-card {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 13px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: var(--bg-card);
  cursor: pointer;
  text-align: left;
  transition: all 0.16s ease;
}

.stage-card:hover {
  border-color: rgba(57, 255, 136, 0.58);
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.55);
}

.stage-card.boss-card {
  border-color: rgba(57, 255, 136, 0.38);
  background: linear-gradient(155deg, rgba(12, 32, 24, 0.96), rgba(8, 12, 15, 0.96));
}

.stage-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--led-green);
}

.stage-rank-pill {
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(57, 255, 136, 0.16);
  font-weight: 700;
}

.stage-rank-pill.none {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
}

.stage-card-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
}

.stage-card-desc {
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--text-muted);
}

.stage-card-best {
  margin-top: auto;
  padding-top: 6px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: #6d8c7e;
}

/* Feast Tray Grid */
.tray-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  gap: 10px;
}

.tray-item {
  padding: 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(8, 13, 16, 0.72);
  text-align: center;
  opacity: 0.45;
}

.tray-item.collected {
  opacity: 1;
  border-color: rgba(57, 255, 136, 0.42);
  background: linear-gradient(160deg, rgba(14, 30, 24, 0.92), rgba(9, 14, 17, 0.92));
}

.tray-emoji {
  font-size: 30px;
  margin-bottom: 6px;
  filter: grayscale(1);
}

.tray-item.collected .tray-emoji {
  filter: none;
}

.tray-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
}

.tray-item.collected .tray-name {
  color: var(--led-green);
}

.tray-meta {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Achievements Grid */
.ach-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}

.ach-card {
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(8, 13, 16, 0.72);
  opacity: 0.48;
}

.ach-card.unlocked {
  opacity: 1;
  border-color: rgba(57, 255, 136, 0.44);
  background: rgba(12, 28, 22, 0.88);
}

.ach-title { font-size: 13.5px; font-weight: 700; color: var(--text-main); margin-bottom: 4px; }
.ach-card.unlocked .ach-title { color: var(--led-green); }
.ach-desc { font-size: 11.5px; color: var(--text-muted); line-height: 1.45; }

/* ================= RESULT & DEATH REPORT PANELS ================= */

.result-panel { text-align: center; }

.result-stamp {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 10px;
}

.clear-stamp {
  color: var(--led-green);
  border: 2px solid var(--led-green);
  background: rgba(57, 255, 136, 0.12);
  box-shadow: 0 0 28px rgba(57, 255, 136, 0.34);
}

.result-kicker {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  color: var(--led-green);
  margin-bottom: 6px;
}

.result-headline { font-size: 24px; font-weight: 800; margin-bottom: 8px; }
.result-quote { font-size: 13.5px; color: #9ab2a6; line-height: 1.6; margin-bottom: 20px; }

.result-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 18px;
}

.metric-box {
  padding: 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.09);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.metric-box span { font-size: 11px; color: var(--text-muted); }
.metric-box strong { font-family: var(--font-mono); font-size: 15px; color: var(--text-main); }

.new-ach-banner {
  margin-bottom: 16px;
  padding: 9px 12px;
  border-radius: 8px;
  background: rgba(57, 255, 136, 0.12);
  border: 1px solid rgba(57, 255, 136, 0.45);
  color: var(--led-green);
  font-size: 12.5px;
  font-weight: 600;
}

.fail-panel {
  border-color: rgba(255, 42, 75, 0.58);
  box-shadow: 0 0 65px rgba(255, 42, 75, 0.24), 0 28px 80px rgba(0, 0, 0, 0.92);
}

.fail-alert-bar {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(255, 42, 75, 0.16);
  border: 1px solid rgba(255, 42, 75, 0.55);
  color: #ff7b8e;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  margin-bottom: 14px;
}

.alert-blink { color: var(--danger-red); animation: blinkSlow 0.65s infinite; }

.fail-timestamp-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.fail-time-badge {
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 4px 10px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.07);
  color: #ffd89b;
}

.fail-db-badge {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 800;
  padding: 4px 12px;
  border-radius: 6px;
  background: rgba(255, 42, 75, 0.24);
  color: #ff4765;
  border: 1px solid rgba(255, 42, 75, 0.55);
}

.fail-headline {
  font-size: clamp(20px, 3.6vw, 25px);
  font-weight: 800;
  line-height: 1.4;
  color: #fff2f4;
  margin-bottom: 10px;
  text-shadow: 0 0 22px rgba(255, 42, 75, 0.38);
}

.fail-subtext {
  font-size: 13.5px;
  color: #b49aa0;
  line-height: 1.6;
  margin-bottom: 16px;
}

.fail-waveform-box {
  width: 100%;
  border-radius: 8px;
  background: #060405;
  border: 1px solid rgba(255, 42, 75, 0.3);
  padding: 6px;
  margin-bottom: 18px;
}

#fail-wave-canvas { display: block; width: 100%; height: 64px; }

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.modal-action-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.toast {
  position: fixed;
  bottom: 118px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  padding: 9px 16px;
  border-radius: 999px;
  background: rgba(14, 32, 24, 0.96);
  border: 1px solid rgba(57, 255, 136, 0.55);
  color: var(--led-green);
  font-size: 12.5px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.75);
}

@media (max-width: 640px) {
  .top-hud { padding: 8px 10px; gap: 6px; }
  .sleep-sensor { min-width: 132px; padding: 4px 8px; }
  .vu-segments { display: none; }
  .secondary-actions.four-cols { grid-template-columns: repeat(2, 1fr); }
  .meter-dock { height: 96px; padding: 6px 12px 8px; }
  .db-value { font-size: 19px; }
}
