:root {
  --bg: #080b12;
  --panel: rgba(18, 23, 35, 0.9);
  --panel-strong: rgba(10, 14, 20, 0.96);
  --line: rgba(192, 214, 250, 0.18);
  --text: #ecf2ff;
  --muted: #aab7d6;
  --danger: #ff6a6a;
  --danger-2: #ff8a65;
  --good: #7cf9d6;
  --gold: #f9d674;
  --shadow: rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background:
    radial-gradient(circle at top, rgba(44, 62, 91, 0.8), transparent 35%),
    linear-gradient(180deg, #070b12 0%, #0d1320 100%);
  color: var(--text);
}

body {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.shell {
  width: min(96vw, 1100px);
  padding: 18px;
}

.hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 14px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 0.7rem;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 3vw, 3rem);
  letter-spacing: 0.04em;
}

.stats {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.stat-box {
  min-width: 110px;
  padding: 0.7rem 1rem;
  border: 1px solid var(--line);
  background: rgba(15, 20, 28, 0.78);
  border-radius: 12px;
  box-shadow: 0 10px 24px var(--shadow);
}

.stat-box span {
  display: block;
  color: var(--muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.stat-box strong {
  font-size: 1.5rem;
}

#flashlightStatus {
  color: var(--muted);
}

#flashlightStatus.active {
  color: var(--gold);
}

#crouchStatus {
  color: var(--muted);
}

#crouchStatus.active {
  color: var(--good);
}

#timer.overtime {
  color: #ff8a65;
  animation: overtime-timer-pulse 0.7s ease-in-out infinite alternate;
}

.game-wrap {
  position: relative;
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.45);
  background: #0b1117;
}

.game-canvas {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #101820;
  cursor: crosshair;
  touch-action: none;
}

.game-canvas canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.crosshair {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 14px;
  height: 14px;
  border: 1px solid rgba(255, 255, 255, 0.82);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.9);
}

.interaction-hint {
  position: absolute;
  left: 50%;
  bottom: 7%;
  min-height: 1.5em;
  padding: 0.4rem 0.7rem;
  color: #fff4d4;
  background: rgba(8, 10, 12, 0.72);
  border-radius: 4px;
  font-size: 0.9rem;
  text-align: center;
  transform: translateX(-50%);
  pointer-events: none;
}

.office-controls {
  position: absolute;
  z-index: 2;
  top: 14px;
  right: 14px;
  display: none;
  width: min(190px, 42%);
  gap: 8px;
  padding: 10px;
  background: rgba(8, 10, 12, 0.88);
  border: 1px solid rgba(236, 226, 203, 0.45);
  border-radius: 5px;
}

.office-controls.active {
  display: grid;
}

.office-controls button {
  padding: 0.65rem 0.75rem;
  border: 1px solid rgba(236, 226, 203, 0.35);
  border-radius: 4px;
  background: #302a27;
  box-shadow: none;
  font-size: 0.82rem;
}

.office-controls button:hover {
  background: #514338;
}

.toolbelt {
  position: absolute;
  z-index: 1;
  bottom: 14px;
  left: 14px;
  pointer-events: none;
}

.torch-slot {
  position: relative;
  display: grid;
  width: 62px;
  height: 62px;
  place-items: center;
  color: #f2ead7;
  background: rgba(12, 14, 17, 0.88);
  border: 1px solid rgba(236, 226, 203, 0.45);
  border-radius: 5px;
  box-shadow: 0 5px 16px rgba(0, 0, 0, 0.5);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.torch-slot > span {
  font-size: 1.9rem;
  line-height: 1;
  filter: grayscale(1) brightness(0.72);
}

.torch-slot kbd {
  position: absolute;
  right: 4px;
  bottom: 3px;
  min-width: 16px;
  padding: 1px 3px;
  color: #e6e2d9;
  background: rgba(0, 0, 0, 0.72);
  border-radius: 2px;
  font: 700 0.62rem/1.2 monospace;
  text-align: center;
}

.torch-slot.active {
  background: rgba(69, 50, 25, 0.9);
  border-color: var(--gold);
  box-shadow: 0 0 20px rgba(249, 214, 116, 0.38);
}

.torch-slot.active > span {
  filter: none;
}

.controls {
  margin: 10px 2px 0;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.5;
}

.overtime-banner {
  position: absolute;
  z-index: 3;
  top: 14px;
  left: 50%;
  display: none;
  padding: 9px 14px;
  color: #fff4ec;
  background: rgba(118, 19, 24, 0.94);
  border: 1px solid rgba(255, 177, 137, 0.75);
  border-radius: 4px;
  box-shadow: 0 0 20px rgba(255, 75, 52, 0.42);
  font-size: 0.76rem;
  font-weight: 900;
  transform: translateX(-50%);
  pointer-events: none;
}

.overtime-banner.active {
  display: block;
  animation: overtime-banner-pulse 0.8s ease-in-out infinite alternate;
}

.overtime-guide {
  position: absolute;
  z-index: 1;
  right: 16px;
  bottom: 16px;
  display: none;
  align-items: center;
  gap: 9px;
  max-width: min(60%, 280px);
  min-height: 48px;
  padding: 8px 11px;
  color: #fff2d2;
  background: rgba(16, 15, 12, 0.9);
  border: 1px solid rgba(255, 204, 105, 0.6);
  border-radius: 4px;
  box-shadow: 0 5px 18px rgba(0, 0, 0, 0.42);
  pointer-events: none;
}

.overtime-guide.active {
  display: flex;
}

.overtime-arrow {
  display: inline-block;
  color: #ffd166;
  font-size: 1.7rem;
  line-height: 1;
}

.overtime-icons {
  color: #ffd166;
  font-size: 1rem;
  white-space: nowrap;
}

.overtime-label {
  font-size: 0.62rem;
  font-weight: 900;
}

@keyframes overtime-timer-pulse {
  from { text-shadow: 0 0 0 rgba(255, 90, 60, 0); }
  to { text-shadow: 0 0 12px rgba(255, 90, 60, 0.9); }
}

@keyframes overtime-banner-pulse {
  from { filter: brightness(0.85); }
  to { filter: brightness(1.2); }
}

.jumpscare {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  color: #fff1ee;
  background: radial-gradient(ellipse at center, rgba(174, 0, 18, 0.34), rgba(30, 0, 4, 0.12) 48%, transparent 75%);
  pointer-events: none;
}

.jumpscare.active {
  display: flex;
  animation: jumpscare-shake 0.075s steps(2, end) infinite;
}

.jumpscare-label {
  padding: 0.2em;
  color: #fff;
  font-size: clamp(2rem, 9vw, 6rem);
  font-weight: 900;
  line-height: 1;
  text-align: center;
  text-shadow: 0 0 18px #f00, 0 0 48px #8f0000, 4px 5px 0 #190004;
  transform: scaleY(1.15);
}

.exit-marker {
  position: absolute;
  z-index: 1;
  top: 14px;
  right: 14px;
  display: none;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  padding: 7px 10px;
  color: #f3ead1;
  background: rgba(8, 10, 12, 0.84);
  border: 1px solid rgba(243, 234, 209, 0.28);
  border-radius: 4px;
  pointer-events: none;
}

.exit-marker.active {
  display: flex;
}

.exit-marker-arrow {
  display: inline-block;
  color: var(--good);
  font-size: 1.5rem;
  line-height: 1;
}

.exit-marker-icons {
  font-size: 1.4rem;
  line-height: 1;
  white-space: nowrap;
}

.exit-marker-label {
  font-size: 0.7rem;
  font-weight: 800;
}

.exit-sticker {
  position: absolute;
  z-index: 1;
  top: 14px;
  left: 18px;
  display: none;
  min-width: 122px;
  padding: 10px 12px 8px;
  color: #18251c;
  background: #d8ffc9;
  border: 2px solid #f3ffe9;
  border-radius: 11px 5px 10px 6px;
  box-shadow: 0 5px 18px rgba(0, 0, 0, 0.5), 0 0 20px rgba(124, 249, 214, 0.34);
  text-align: center;
  transform: rotate(-3deg);
  pointer-events: none;
}

.exit-sticker.active {
  display: grid;
  gap: 3px;
  animation: exit-sticker-pop 0.35s cubic-bezier(0.2, 1.4, 0.5, 1) both;
}

.exit-sticker-icons {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 1.8rem;
  line-height: 1.1;
  white-space: nowrap;
}

.exit-sticker-icons span {
  color: #357147;
  font-size: 1.25rem;
}

.exit-sticker-label {
  font-size: 0.62rem;
  font-weight: 900;
}

@keyframes exit-sticker-pop {
  from { opacity: 0; transform: translateY(-12px) rotate(-8deg) scale(0.7); }
  to { opacity: 1; transform: rotate(-3deg) scale(1); }
}

@keyframes jumpscare-shake {
  0% { transform: translate(7px, -5px) scale(1.02); }
  50% { transform: translate(-6px, 4px) scale(1.045); }
  100% { transform: translate(3px, 6px) scale(1.015); }
}

.overlay {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  background: rgba(6, 8, 12, 0.72);
  backdrop-filter: blur(4px);
}

.overlay.active {
  display: grid;
}

.panel {
  width: min(90%, 480px);
  padding: 28px 24px 22px;
  border: 1px solid var(--line);
  background: rgba(9, 14, 22, 0.92);
  border-radius: 18px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  text-align: center;
}

.label {
  margin: 0 0 8px;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.7rem;
}

.panel h2 {
  margin: 0 0 12px;
  font-size: clamp(1.9rem, 3vw, 2.8rem);
}

.panel p {
  color: var(--muted);
  line-height: 1.6;
  margin: 0 0 18px;
}

button {
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--danger), var(--danger-2));
  color: white;
  font-weight: 700;
  padding: 0.9rem 1.35rem;
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease;
  box-shadow: 0 14px 22px rgba(255, 106, 106, 0.28);
}

button:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

@media (max-width: 720px) {
  .hud {
    flex-direction: column;
    align-items: flex-start;
  }

  .stats {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 5px;
  }

  .stat-box {
    min-width: 0;
    padding: 0.45rem 0.25rem;
    text-align: center;
  }

  .stat-box span {
    font-size: 0.57rem;
    letter-spacing: 0;
    text-transform: none;
  }

  .stat-box strong {
    display: block;
    font-size: 1rem;
    overflow-wrap: anywhere;
  }
}
