/* ------------------------------------------------------------------ */
/* Design tokens                                                         */
/* ------------------------------------------------------------------ */
:root {
  --bg:         #07070f;
  --surface-1:  #0e0e1a;
  --surface-2:  #141424;
  --surface-3:  #1a1a2e;
  --surface-4:  #202038;

  --fg:         #eeedf8;
  --muted:      rgba(238,237,248,0.52);
  --subtle:     rgba(238,237,248,0.30);
  --faint:      rgba(238,237,248,0.09);

  --border:     rgba(255,255,255,0.055);
  --border-hi:  rgba(255,255,255,0.13);

  --accent:     #fff8e7;
  --accent-glow:rgba(255,248,231,0.16);

  --red:        #ff0000;
  --red-dark:   #8b0000;

  --radius-sm:  6px;
  --radius-md:  10px;
  --radius-lg:  14px;
  --radius-xl:  20px;
  --radius-full:9999px;
}

/* ------------------------------------------------------------------ */
/* Reset                                                                 */
/* ------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%; height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display",
               "Segoe UI", system-ui, sans-serif;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ------------------------------------------------------------------ */
/* ====== GAME PAGE ======                                              */
/* ------------------------------------------------------------------ */
#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* HUD bar */
#hud {
  position: fixed;
  top: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.hud-panel {
  background: rgba(10,10,20,0.75);
  backdrop-filter: blur(12px) saturate(1.4);
  -webkit-backdrop-filter: blur(12px) saturate(1.4);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 6px 12px;
  font-size: 11.5px;
  line-height: 1.6;
}

.hud-label {
  color: var(--subtle);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 500;
}
.hud-value { color: var(--fg); font-weight: 600; font-size: 12px; }

/* health glow */
#healthPanel.lowHealth {
  border-color: rgba(220,38,38,0.65);
  animation: lowHealthPulse 1.1s ease-in-out infinite;
}
@keyframes lowHealthPulse {
  0%,100% { box-shadow: 0 0 8px 1px rgba(220,38,38,0.3); }
  50%      { box-shadow: 0 0 16px 4px rgba(220,38,38,0.65); }
}

/* urgent timer */
.urgentTimer { color: #f87171 !important; }

/* Pause button in HUD */
.pause-btn {
  pointer-events: all;
  margin-left: auto;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10,10,20,0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius-md);
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  transition: color 150ms, border-color 150ms, background 150ms;
}
.pause-btn:hover {
  color: var(--fg);
  border-color: rgba(255,255,255,0.22);
  background: var(--surface-2);
}

/* Bottom-left control hint */
#controlHint {
  position: fixed;
  bottom: 12px;
  left: 12px;
  color: var(--subtle);
  font-size: 11px;
  line-height: 2.1;
  background: rgba(10,10,20,0.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 5px 12px;
  pointer-events: none;
  max-width: 56vw;
}
#controlHint kbd {
  background: var(--surface-3);
  border: 1px solid var(--border-hi);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--muted);
  font-size: 10px;
}

/* Bottom-right breach */
#breachPanel {
  position: fixed;
  bottom: 12px;
  right: 12px;
  pointer-events: none;
}

/* ------------------------------------------------------------------ */
/* Overlay base                                                          */
/* ------------------------------------------------------------------ */
.overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 60;
  backdrop-filter: grayscale(0.75) brightness(0.5);
  -webkit-backdrop-filter: grayscale(0.75) brightness(0.5);
  background: rgba(0,0,0,0.28);
}
.overlay.visible { display: flex; }

.overlay-content {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 38px 44px;
  background: rgba(12,12,22,0.92);
  backdrop-filter: blur(20px) saturate(1.5);
  -webkit-backdrop-filter: blur(20px) saturate(1.5);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius-xl);
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.04),
    0 24px 60px rgba(0,0,0,0.65);
  min-width: 300px;
  text-align: center;
}

/* ------------------------------------------------------------------ */
/* Death screen                                                          */
/* ------------------------------------------------------------------ */
#deathGlow {
  position: absolute;
  top: 50%; left: 50%;
  width: 55vmin; height: 55vmin;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle,
    rgba(120,0,0,0.5)  0%,
    rgba(80,0,0,0.16)  45%,
    rgba(40,0,0,0)     70%);
  pointer-events: none;
  z-index: -1;
}

/* "You Died" — same font family as "You Won!" so they're consistent.
   Narrow via scaleX so it looks intentionally compressed, not just small. */
#deathTitle {
  font-size: 56px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
  display: inline-block;
  transform: scaleX(0.68);
  transform-origin: center;
  color: var(--red);
  text-shadow:
    0 0 10px rgba(139,0,0,1),
    0 0 28px rgba(139,0,0,0.8),
    0 0 60px rgba(139,0,0,0.5);
}

.death-sub {
  color: var(--muted);
  font-size: 12.5px;
  margin-top: -6px;
}

/* ------------------------------------------------------------------ */
/* Win screen                                                            */
/* ------------------------------------------------------------------ */
#winTitle {
  font-size: 44px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
  background: linear-gradient(135deg, #fff8e7 0%, #ffe8a0 55%, #ffc840 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: none;
  filter: drop-shadow(0 0 20px rgba(255,200,80,0.35));
}
#winSummary {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

/* ------------------------------------------------------------------ */
/* Overlay buttons                                                       */
/* ------------------------------------------------------------------ */
.overlay-btns {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

.btn-primary {
  padding: 10px 26px;
  background: var(--fg);
  color: #07070f;
  border: none;
  border-radius: var(--radius-full);
  font-size: 13.5px;
  font-weight: 650;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: opacity 140ms, transform 140ms;
  position: relative;
  overflow: hidden;
}
.btn-primary::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.15) 0%, transparent 55%);
  pointer-events: none;
}
.btn-primary:hover { opacity: 0.88; transform: scale(1.03); }
.btn-primary:active { transform: scale(0.97); }

.btn-ghost {
  padding: 10px 26px;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius-full);
  font-size: 13.5px;
  cursor: pointer;
  transition: background 140ms, color 140ms, border-color 140ms;
}
.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--fg);
  border-color: rgba(255,255,255,0.22);
}
