:root {
  --bg: #030406;
  --surface: #0e1117;
  --surface-border: #1e2633;
  --text: #f0f4f8;
  --text-dim: #7f8c9d;
  --accent: #ff2a4b; /* Blood red for outbreak & killer */
  --accent-blue: #00e5ff; /* Survivor cyan */
  --accent-yellow: #ffb703; /* Search / Fuse electricity */
}

* { box-sizing: border-box; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; user-select: none; }
body { margin: 0; background: var(--bg); color: var(--text); overflow: hidden; height: 100vh; }

.topbar {
  position: absolute; top: 0; left: 0; width: 100%; height: 48px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px; background: rgba(8, 10, 14, 0.85); z-index: 100;
  border-bottom: 1px solid var(--surface-border); backdrop-filter: blur(8px);
}
.brand { font-weight: 900; font-size: 1.1rem; letter-spacing: 0.5px; }
.brand-sub { color: var(--accent); }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.room-tag {
  background: rgba(0, 229, 255, 0.12); color: var(--accent-blue);
  border: 1px solid rgba(0, 229, 255, 0.3); padding: 4px 10px;
  border-radius: 6px; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.5px;
  text-transform: uppercase;
}
.icon-btn { background: none; border: none; color: #fff; font-size: 1.3rem; cursor: pointer; }

.screen { position: absolute; inset: 0; display: none; padding-top: 48px; }
.screen.show { display: flex; flex-direction: column; align-items: center; justify-content: center; }

/* Menu */
.menu-card {
  background: var(--surface); padding: 36px 42px; border-radius: 14px;
  max-width: 720px; width: 92%; text-align: center;
  border: 1px solid var(--surface-border); box-shadow: 0 20px 60px rgba(0,0,0,0.9);
}
.menu-badge {
  display: inline-block; padding: 4px 12px; background: rgba(255, 42, 75, 0.15);
  border: 1px solid rgba(255, 42, 75, 0.35); border-radius: 20px;
  font-size: 0.75rem; font-weight: 800; letter-spacing: 1px; color: var(--accent);
  margin-bottom: 14px; text-transform: uppercase;
}
.menu-title { font-size: 2.8rem; margin: 0 0 10px; font-weight: 900; letter-spacing: -0.5px; }
.accent { color: var(--accent); }
.menu-sub { color: var(--text-dim); line-height: 1.5; font-size: 0.95rem; margin-bottom: 24px; }

.mode-select-box { margin-bottom: 20px; }
.btn-glow {
  box-shadow: 0 0 24px rgba(255, 42, 75, 0.4);
  font-size: 1.15rem; padding: 16px 36px;
}
.btn-glow:hover {
  box-shadow: 0 0 36px rgba(255, 42, 75, 0.6);
  transform: translateY(-2px);
}

.multiplayer-box {
  display: flex; align-items: center; justify-content: space-between;
  background: #131722; padding: 16px 20px; border-radius: 10px;
  border: 1px solid var(--surface-border); margin-bottom: 24px;
}
.mp-col { flex: 1; display: flex; justify-content: center; }
.mp-divider { font-weight: 800; color: #48546a; padding: 0 16px; font-size: 0.8rem; }
.join-row { display: flex; gap: 8px; width: 100%; }
.join-row input {
  background: #090c12; border: 1px solid var(--surface-border); color: #fff;
  padding: 10px 14px; border-radius: 6px; font-size: 1rem;
  text-transform: uppercase; width: 130px; text-align: center; font-weight: 700;
}

.solo-divider { text-align: center; margin: 20px 0; position: relative; }
.solo-divider::before { content:""; position:absolute; left:0; top:50%; width:100%; height:1px; background:var(--surface-border); z-index:1; }
.solo-divider span { background: var(--surface); position: relative; z-index: 2; padding: 0 12px; color: #64748b; font-weight: 700; font-size: 0.8rem; letter-spacing: 0.5px; }

.controls-guide {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  background: #090c12; padding: 14px 18px; border-radius: 8px;
  font-size: 0.85rem; color: var(--text-dim); text-align: left;
}
.controls-guide strong { color: #fff; }

.btn {
  padding: 12px 24px; border: none; border-radius: 8px; font-weight: 700;
  cursor: pointer; transition: 0.2s transform, 0.2s background, 0.2s box-shadow;
  font-size: 0.95rem; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #e01d3c; }
.btn-secondary { background: #20293a; color: #fff; border: 1px solid #334155; }
.btn-secondary:hover { background: #2a374d; }
.btn-full { width: 100%; }
.btn-large { font-size: 1.05rem; padding: 14px 28px; }

/* Lobby */
.lobby-card {
  background: var(--surface); padding: 36px; border-radius: 14px;
  width: 440px; text-align: center; border: 1px solid var(--surface-border);
}
.player-list { margin: 20px 0; display: flex; flex-direction: column; gap: 8px; max-height: 220px; overflow-y: auto; }
.player-row {
  background: #131722; padding: 12px 16px; border-radius: 8px;
  display: flex; justify-content: space-between; align-items: center;
  border: 1px solid var(--surface-border); font-size: 0.9rem; font-weight: 600;
}
.text-dim { color: var(--text-dim); font-size: 0.85rem; }

/* ==================== GAME HUD ==================== */
.game-hud { position: absolute; inset: 0; pointer-events: none; z-index: 50; overflow: hidden; }

.hud-top-panel {
  position: absolute; top: 60px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}

.hud-objective-box {
  background: rgba(8, 10, 14, 0.85); padding: 8px 24px; border-radius: 30px;
  border: 1px solid rgba(0, 229, 255, 0.4); color: var(--accent-blue);
  font-weight: 800; font-size: 1.05rem; letter-spacing: 0.5px;
  display: flex; align-items: center; gap: 8px; box-shadow: 0 4px 20px rgba(0,0,0,0.6);
}

.hud-gate-status {
  background: rgba(8, 10, 14, 0.8); padding: 4px 16px; border-radius: 20px;
  border: 1px solid rgba(255, 183, 3, 0.35); color: var(--accent-yellow);
  font-size: 0.8rem; font-weight: 700; letter-spacing: 0.5px;
}

/* Outbreak Flashing Alarm */
.outbreak-banner {
  position: absolute; top: 120px; left: 50%; transform: translateX(-50%);
  background: rgba(255, 0, 40, 0.9); color: #fff; padding: 12px 32px;
  border-radius: 10px; text-align: center; border: 2px solid #fff;
  box-shadow: 0 0 40px rgba(255, 0, 40, 0.8);
  display: none; animation: pulse-outbreak 0.8s infinite alternate;
}
.outbreak-title { font-size: 1.4rem; font-weight: 900; letter-spacing: 1px; }
.outbreak-sub { font-size: 0.85rem; font-weight: 700; margin-top: 2px; }

@keyframes pulse-outbreak {
  0% { transform: translateX(-50%) scale(0.96); opacity: 0.9; }
  100% { transform: translateX(-50%) scale(1.04); opacity: 1; }
}

/* Interaction Prompt */
.interaction-prompt {
  position: absolute; bottom: 22%; left: 50%; transform: translateX(-50%);
  background: rgba(8, 10, 14, 0.9); padding: 8px 18px; border-radius: 8px;
  border: 1px solid #fff; color: #fff; font-weight: 800; font-size: 0.95rem;
  display: none; align-items: center; gap: 8px; box-shadow: 0 4px 20px rgba(0,0,0,0.8);
}
.key-pill {
  background: #fff; color: #000; padding: 2px 8px; border-radius: 4px; font-weight: 900;
}

/* Search Progress Bar */
.search-progress-box {
  position: absolute; bottom: 28%; left: 50%; transform: translateX(-50%);
  width: 220px; text-align: center; display: none;
}
.search-label { font-size: 0.75rem; font-weight: 800; color: var(--accent-yellow); margin-bottom: 6px; letter-spacing: 0.5px; }
.search-bar-track {
  width: 100%; height: 8px; background: rgba(0,0,0,0.8);
  border: 1px solid var(--accent-yellow); border-radius: 4px; overflow: hidden;
}
.search-bar-fill {
  width: 0%; height: 100%; background: var(--accent-yellow);
  box-shadow: 0 0 10px var(--accent-yellow);
}

/* Locker Hiding Overlay */
.hiding-overlay {
  position: absolute; inset: 0; background: rgba(0,0,0,0.7);
  display: none; pointer-events: none; z-index: 40;
}
.hiding-slats {
  position: absolute; inset: 0;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,0.85) 0px, rgba(0,0,0,0.85) 16px, transparent 16px, transparent 24px);
}
.hiding-notice {
  position: absolute; bottom: 15%; left: 50%; transform: translateX(-50%);
  background: rgba(0, 229, 255, 0.2); border: 1px solid var(--accent-blue);
  color: var(--accent-blue); padding: 8px 20px; border-radius: 20px;
  font-weight: 800; font-size: 0.9rem;
}

/* Inventory Dock */
.inventory-dock {
  position: absolute; bottom: 24px; left: 24px;
  display: flex; gap: 12px;
}
.inv-slot {
  background: rgba(8, 10, 14, 0.85); border: 1px solid var(--surface-border);
  padding: 8px 14px; border-radius: 8px; display: flex; align-items: center; gap: 8px;
  font-weight: 800; font-size: 0.9rem;
}
.inv-icon { font-size: 1.2rem; }
.inv-count { color: #fff; }

/* Killer Dash Bar */
.hud-charge-bar {
  position: absolute; bottom: 24px; right: 24px;
  background: rgba(8, 10, 14, 0.85); padding: 8px 14px; border-radius: 8px;
  border: 1px solid rgba(255, 42, 75, 0.4); width: 180px;
}
.hud-charge-label { font-size: 0.7rem; font-weight: 800; color: var(--accent); margin-bottom: 4px; }
.hud-charge-track { width: 100%; height: 6px; background: rgba(0,0,0,0.8); border-radius: 3px; overflow: hidden; }
.hud-charge-fill { width: 100%; height: 100%; background: var(--accent); }

/* Red Alert Screen Filter */
.red-alert-overlay {
  position: absolute; inset: 0; pointer-events: none; z-index: 30;
  /* A radial-gradient vignette rather than an inset box-shadow. The shadow was
     animated from an 80px to a 160px blur radius across the whole viewport,
     forever — and box-shadow blur is rasterized on the CPU every frame, on top
     of an already GPU-bound WebGL scene. The gradient is painted once into its
     own compositor layer and only its opacity animates, which is free. */
  background: radial-gradient(ellipse at center,
              rgba(255, 0, 40, 0) 45%,
              rgba(255, 0, 40, 0.55) 85%,
              rgba(255, 0, 40, 0.9) 100%);
  opacity: 0; transition: opacity 0.5s ease-in-out;
  will-change: opacity;
}
.red-alert-active {
  opacity: 1;
  animation: strobe-red 1.2s infinite ease-in-out;
}
@keyframes strobe-red {
  0%, 100% { opacity: 0.5; }
  50%      { opacity: 1; }
}

/* Overlays */
.full-overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; background: rgba(0,0,0,0.88);
  z-index: 100; backdrop-filter: blur(8px);
}
.overlay-card {
  background: var(--surface); padding: 40px 48px; border-radius: 16px;
  text-align: center; border: 1px solid var(--surface-border); max-width: 500px;
}
.skull-icon, .trophy-icon { font-size: 3.5rem; margin-bottom: 12px; }
.text-red { color: var(--accent); }
.text-cyan { color: var(--accent-blue); }

#gameCanvas { display: block; width: 100%; height: 100%; background: #000; }

/* Map Selector Pills */
.map-select-row {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  margin-bottom: 20px;
}
.map-label { font-size: 0.8rem; font-weight: 800; color: var(--text-dim); letter-spacing: 0.5px; }
.map-pills { display: flex; gap: 6px; background: #090c12; padding: 4px; border-radius: 8px; border: 1px solid var(--surface-border); }
.map-pill {
  background: none; border: none; color: var(--text-dim); padding: 6px 12px;
  border-radius: 6px; font-weight: 800; font-size: 0.75rem; cursor: pointer; transition: 0.2s;
}
.map-pill.active { background: var(--accent-blue); color: #000; box-shadow: 0 0 10px rgba(0, 229, 255, 0.4); }

.hud-sub-stats {
  display: flex; gap: 8px; align-items: center;
}

.hud-hunt-timer {
  background: rgba(255, 0, 40, 0.85); padding: 4px 16px; border-radius: 20px;
  border: 1px solid #fff; color: #fff; font-size: 0.8rem; font-weight: 900; letter-spacing: 0.5px;
  box-shadow: 0 0 16px rgba(255, 0, 40, 0.8);
  animation: timer-pulse 1s infinite alternate;
}

@keyframes timer-pulse {
  0% { transform: scale(0.98); }
  100% { transform: scale(1.03); }
}

/* ===========================================================================
   OPTIONAL DR. YEET ACCOUNT
   =========================================================================== */
.arcade-acct { margin: 10px 0 6px; text-align: center; }
.acct-signed-in { display: flex; gap: 12px; align-items: center; justify-content: center; flex-wrap: wrap; }
.acct-signed-in[hidden], .acct-signed-out[hidden] { display: none; }
.acct-who { font-size: 0.85rem; color: #cfe3ef; }
.acct-who strong { color: #7CFFB2; }
.acct-opt { opacity: 0.6; font-size: 0.78em; }
.link-btn { background: none; border: none; cursor: pointer; color: #8fd8ff; font: inherit; font-size: 0.85rem; text-decoration: underline; }

.acct-modal { position: fixed; inset: 0; z-index: 400; display: flex; align-items: center; justify-content: center;
  background: rgba(3,6,9,0.88); backdrop-filter: blur(6px); }
.acct-modal[hidden] { display: none; }
.acct-card { position: relative; width: min(440px, 92vw); text-align: left; padding: 28px 30px;
  border-radius: 18px; border: 1px solid rgba(255,255,255,0.12); background: rgba(12,18,24,0.98);
  box-shadow: 0 24px 70px rgba(0,0,0,0.85); }
.acct-close { position: absolute; top: 12px; right: 14px; background: none; border: none;
  color: rgba(255,255,255,0.6); font-size: 1.1rem; cursor: pointer; }
.acct-title { margin: 0 0 8px; letter-spacing: 1px; font-size: 1.05rem; }
.acct-blurb { font-size: 0.84rem; color: rgba(255,255,255,0.7); line-height: 1.45; margin: 0 0 10px; }
.acct-warn { font-size: 0.78rem; color: #ffca7a; background: rgba(255,190,90,0.1);
  border: 1px solid rgba(255,190,90,0.3); border-radius: 10px; padding: 8px 11px; margin: 0 0 16px; line-height: 1.4; }
.acct-field { display: block; margin-bottom: 12px; }
.acct-field span { display: block; font-size: 0.74rem; letter-spacing: 0.6px; color: rgba(255,255,255,0.6); margin-bottom: 4px; }
.acct-field input { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.05); color: #eaf4ff; font-size: 0.92rem; }
.acct-actions { display: flex; gap: 10px; margin-top: 6px; }
.acct-actions .btn { flex: 1; }
.acct-error { color: #ff8f8f; font-size: 0.8rem; min-height: 1em; margin: 10px 0 0; }

/* --- Minimap -------------------------------------------------------------- */
/* With the lights genuinely out you navigate by memory, so the map has to tell
   you the two things memory is worst at: which rooms you have already searched,
   and which way you are facing. */
.minimap {
  position: fixed; top: 74px; right: 18px; z-index: 60;
  width: 190px; border-radius: 12px; overflow: hidden;
  background: rgba(6, 9, 15, 0.82);
  border: 1px solid rgba(120, 200, 255, 0.22);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  pointer-events: none;
}
.minimap canvas { display: block; width: 190px; height: 190px; }
.minimap-legend {
  padding: 5px 9px; font-size: 11px; letter-spacing: 0.6px;
  font-family: "Manrope", system-ui, sans-serif; font-weight: 800;
  color: #9fd8ff; background: rgba(0, 0, 0, 0.45);
  text-align: center; text-transform: uppercase;
}
@media (max-width: 820px) {
  .minimap { width: 128px; top: 62px; right: 10px; }
  .minimap canvas { width: 128px; height: 128px; }
}

/* --- Flashlight HUD ------------------------------------------------------------ */
.flashlight-hud {
  position: fixed; top: 74px; left: 18px; z-index: 60;
  display: flex; align-items: center; gap: 8px;
  padding: 7px 12px; border-radius: 999px;
  background: rgba(6, 9, 15, 0.8);
  border: 1px solid rgba(255, 220, 160, 0.24);
  font-family: "Manrope", system-ui, sans-serif;
  pointer-events: none;
}
.flashlight-icon { font-size: 15px; filter: drop-shadow(0 0 6px rgba(255, 220, 150, 0.55)); }
.flashlight-icon.out { filter: none; opacity: 0.35; }
.flashlight-bar {
  width: 82px; height: 5px; border-radius: 3px; overflow: hidden;
  background: rgba(255, 255, 255, 0.14);
}
.flashlight-fill {
  height: 100%; width: 100%; border-radius: 3px;
  background: linear-gradient(90deg, #ffd9a0, #ffb347);
}
.flashlight-fill.low { background: linear-gradient(90deg, #ff8a4d, #ff4d5e); }
.flashlight-mode {
  font-size: 10px; font-weight: 800; letter-spacing: 1px;
  color: #ffd9a0; min-width: 34px; text-align: center;
}
@media (max-width: 820px) { .flashlight-hud { top: 62px; left: 10px; padding: 5px 9px; } }

/* ---------------------------------------------------------------------------
   LOCKER JUMPSCARE
   A survivor sitting in the dark has their door ripped open by Patient Zero.
   Front-loaded on purpose: full white-red on the very first frame, then a fast
   decay. A scare that fades IN is not a scare.
   --------------------------------------------------------------------------- */
.locker-scare {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
}
.locker-scare span {
  font: 900 clamp(38px, 11vw, 130px)/1 system-ui, sans-serif;
  letter-spacing: 0.06em;
  color: #fff;
  text-shadow: 0 0 26px rgba(255, 0, 40, 0.95), 0 0 70px rgba(255, 0, 0, 0.6);
}
.locker-scare.firing { animation: locker-scare-flash 0.72s steps(1, end) 1 both; }
.locker-scare.firing span { animation: locker-scare-text 0.72s ease-out 1 both; }

@keyframes locker-scare-flash {
  0%   { opacity: 1; background: radial-gradient(circle at 50% 50%, rgba(255,255,255,0.92), rgba(180,0,10,0.96) 60%, #2a0004 100%); }
  14%  { opacity: 1; background: radial-gradient(circle at 50% 50%, rgba(255,60,60,0.5), rgba(90,0,6,0.9) 70%, #120002 100%); }
  28%  { opacity: 1; background: radial-gradient(circle at 50% 50%, rgba(255,255,255,0.8), rgba(150,0,10,0.9) 60%, #1a0003 100%); }
  55%  { opacity: 0.75; background: radial-gradient(circle at 50% 50%, rgba(120,0,10,0.5), rgba(20,0,2,0.85) 75%, #0a0001 100%); }
  100% { opacity: 0; background: transparent; }
}
@keyframes locker-scare-text {
  0%   { transform: scale(1.9); opacity: 1; }
  22%  { transform: scale(1.02); opacity: 1; }
  60%  { transform: scale(1.08); opacity: 0.8; }
  100% { transform: scale(1.3); opacity: 0; }
}

/* The camera takes the hit too, or the flash reads as a UI effect rather than
   something that happened to you in the room. */
.scare-shake { animation: scare-shake 0.62s cubic-bezier(.36,.07,.19,.97) both; }
@keyframes scare-shake {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  8%   { transform: translate(-14px, 9px) rotate(-1.1deg); }
  19%  { transform: translate(12px, -11px) rotate(0.9deg); }
  31%  { transform: translate(-10px, -7px) rotate(-0.7deg); }
  46%  { transform: translate(8px, 8px) rotate(0.5deg); }
  63%  { transform: translate(-5px, -4px) rotate(-0.3deg); }
  81%  { transform: translate(3px, 2px) rotate(0.15deg); }
}
