:root {
  color-scheme: dark;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: #11130f;
  color: #f5f0df;
  letter-spacing: 0;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  background: #050504;
}

body::after {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  content: "";
  box-shadow:
    inset 0 0 120px rgba(0, 0, 0, 0.9),
    inset 0 0 28px rgba(92, 10, 10, 0.28);
  opacity: 0.9;
}

button {
  font: inherit;
}

#game {
  display: block;
  width: 100vw;
  height: 100vh;
  outline: none;
}

.hud {
  position: fixed;
  top: 18px;
  left: 18px;
  z-index: 6;
  width: min(320px, calc(100vw - 36px));
  padding: 14px;
  border: 1px solid rgba(245, 240, 223, 0.18);
  border-radius: 8px;
  background: rgba(17, 19, 15, 0.74);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(12px);
  pointer-events: none;
}

.brand,
.stats {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.brand strong {
  font-size: 16px;
  line-height: 1;
}

.brand span,
.stats span {
  color: #c9d3b6;
  font-size: 12px;
  white-space: nowrap;
}

.bars {
  display: grid;
  gap: 8px;
  margin: 13px 0 11px;
}

.bar {
  display: grid;
  grid-template-columns: 32px 1fr;
  align-items: center;
  gap: 9px;
}

.bar.battery {
  grid-template-columns: 32px 1fr 44px;
}

.bar.hp {
  grid-template-columns: 32px 1fr 34px;
}

.bar span {
  color: #f0c46a;
  font-size: 11px;
  font-weight: 700;
}

.bar i {
  display: block;
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background:
    linear-gradient(90deg, #f05d4d, #f0c46a) left center / var(--value, 100%) 100%
      no-repeat,
    rgba(245, 240, 223, 0.12);
  transition: background-size 120ms linear;
}

#staminaBar {
  background:
    linear-gradient(90deg, #4ecdc4, #9ec768) left center / var(--value, 100%) 100%
      no-repeat,
    rgba(245, 240, 223, 0.12);
}

#sanityBar {
  background:
    linear-gradient(90deg, #9a6df0, #f0c46a) left center / var(--value, 100%) 100%
      no-repeat,
    rgba(245, 240, 223, 0.12);
}

#batteryBar {
  background:
    linear-gradient(90deg, #f0c46a, #fff6ad) left center / var(--value, 100%) 100%
      no-repeat,
    rgba(245, 240, 223, 0.12);
  box-shadow: 0 0 12px rgba(240, 196, 106, 0.18);
}

#batteryText {
  color: #fff3b8;
  font-size: 11px;
  font-weight: 800;
  text-align: right;
}

#hpText {
  color: #ffe0d8;
  font-size: 11px;
  font-weight: 800;
  text-align: right;
}

#damageLayer {
  position: fixed;
  inset: 0;
  z-index: 36;
  pointer-events: none;
}

.screen-damage-pop {
  position: absolute;
  left: 50%;
  top: 44%;
  color: #ff6d5d;
  font-size: 24px;
  font-weight: 900;
  text-shadow:
    0 0 8px rgba(255, 62, 46, 0.55),
    0 2px 12px rgba(0, 0, 0, 0.8);
  transform: translate(-50%, -50%);
  animation: screen-damage-rise 860ms ease-out forwards;
}

@keyframes screen-damage-rise {
  from {
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.94);
  }
  to {
    opacity: 0;
    transform: translate(-50%, -96px) scale(1.18);
  }
}

.hotbar {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 8;
  display: flex;
  gap: 10px;
  transform: translateX(-50%);
  pointer-events: none;
}

.hotbar-slot {
  position: relative;
  display: grid;
  place-items: center;
  width: 74px;
  height: 74px;
  border: 1px solid rgba(245, 240, 223, 0.18);
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 42%, rgba(240, 196, 106, 0.12), transparent 58%),
    rgba(8, 9, 8, 0.76);
  box-shadow:
    0 14px 32px rgba(0, 0, 0, 0.42),
    inset 0 0 18px rgba(255, 255, 255, 0.045);
  overflow: hidden;
}

.hotbar-slot.active {
  border-color: rgba(240, 196, 106, 0.86);
  box-shadow:
    0 0 24px rgba(240, 196, 106, 0.36),
    0 14px 32px rgba(0, 0, 0, 0.42),
    inset 0 0 18px rgba(240, 196, 106, 0.18);
}

.hotbar-slot span {
  position: absolute;
  top: 6px;
  left: 7px;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border: 1px solid rgba(255, 247, 220, 0.28);
  border-radius: 5px;
  color: #fff7dc;
  background: rgba(0, 0, 0, 0.42);
  font-size: 11px;
  font-weight: 900;
}

.hotbar-slot img {
  display: block;
  max-width: 86%;
  max-height: 86%;
  object-fit: contain;
  filter: drop-shadow(0 0 12px rgba(78, 205, 196, 0.28));
}

.hotbar-slot[data-item="sword"] img {
  width: 82%;
  height: 82%;
  border-radius: 6px;
}

.hotbar-slot[data-item="flashlight"] img {
  width: 78%;
  height: 78%;
  background: transparent;
  filter:
    drop-shadow(0 0 10px rgba(255, 246, 173, 0.48))
    drop-shadow(0 0 20px rgba(78, 205, 196, 0.22));
}

#minimap {
  position: fixed;
  right: 18px;
  top: 18px;
  z-index: 6;
  width: min(180px, calc(45vw - 18px));
  height: min(180px, calc(45vw - 18px));
  border: 1px solid rgba(245, 240, 223, 0.18);
  border-radius: 8px;
  background: rgba(17, 19, 15, 0.74);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(12px);
}

#jumpscareOverlay {
  position: fixed;
  top: 50%;
  left: 50%;
  width: min(88vw, 760px);
  height: auto;
  max-height: 88vh;
  object-fit: contain;
  opacity: 0;
  transform: translate(-50%, -50%) scale(1.08);
  filter: contrast(1.18) saturate(0.85);
  pointer-events: none;
  z-index: 40;
  transition:
    opacity 80ms linear,
    transform 700ms ease-out;
}

#jumpscareOverlay.visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

#flashbangOverlay {
  position: fixed;
  inset: 0;
  z-index: 42;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 1), rgba(255, 255, 236, 0.86) 38%, rgba(232, 238, 255, 0.5) 100%);
  opacity: 0;
  transition: opacity 2800ms ease-out;
}

#flashbangOverlay.visible {
  opacity: 0.96;
  transition: opacity 50ms linear;
}

#sanityOverlay {
  position: fixed;
  inset: 0;
  z-index: 12;
  pointer-events: none;
  opacity: var(--sanity-opacity, 0);
  background:
    radial-gradient(circle at 50% 50%, transparent 22%, rgba(0, 0, 0, 0.46) 62%, rgba(0, 0, 0, 0.88) 100%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 7px);
  mix-blend-mode: multiply;
  transition: opacity 180ms linear;
}

#whisperLayer {
  position: fixed;
  left: 50%;
  bottom: 82px;
  z-index: 34;
  width: min(620px, calc(100vw - 40px));
  transform: translateX(-50%);
  color: rgba(244, 214, 179, 0.72);
  font-size: clamp(13px, 2.8vw, 18px);
  font-style: italic;
  text-align: center;
  text-shadow: 0 0 18px rgba(0, 0, 0, 0.9);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 360ms ease,
    transform 360ms ease;
}

#whisperLayer.visible {
  opacity: 1;
  transform: translate(-50%, -6px);
}

#cluePanel {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 33;
  display: grid;
  width: min(390px, calc(100vw - 36px));
  gap: 8px;
  padding: 14px 16px;
  border: 1px solid rgba(240, 196, 106, 0.22);
  border-radius: 8px;
  color: #f5e2b8;
  background: rgba(16, 9, 7, 0.88);
  box-shadow:
    0 18px 42px rgba(0, 0, 0, 0.36),
    inset 0 0 24px rgba(93, 21, 15, 0.22);
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

#cluePanel.visible {
  opacity: 1;
  transform: translateY(0);
}

#clueKind {
  color: #bfa374;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

#clueTitle {
  color: #fff1c9;
  font-size: 16px;
}

#clueText {
  margin: 0;
  color: #d5c5aa;
  font-size: 13px;
  line-height: 1.42;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 35;
  max-width: min(520px, calc(100vw - 36px));
  transform: translateX(-50%);
  padding: 10px 14px;
  border: 1px solid rgba(245, 240, 223, 0.16);
  border-radius: 8px;
  color: #fff7dc;
  background: rgba(60, 66, 47, 0.84);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.26);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translate(-50%, -4px);
}

.boot {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-content: center;
  gap: 16px;
  justify-items: center;
  background:
    linear-gradient(180deg, rgba(13, 5, 5, 0.9), rgba(4, 5, 4, 0.84)),
    rgba(17, 19, 15, 0.86);
  backdrop-filter: blur(8px);
  transition: opacity 180ms ease;
}

.boot.hidden {
  opacity: 0;
  pointer-events: none;
}

.boot-mark {
  color: #f5e2b8;
  font-size: clamp(30px, 9vw, 76px);
  font-weight: 900;
  line-height: 0.95;
  text-align: center;
}

.warning-panel {
  display: grid;
  width: min(420px, calc(100vw - 48px));
  gap: 6px;
  padding: 12px 14px;
  border: 1px solid rgba(240, 93, 77, 0.34);
  border-radius: 8px;
  color: #f4d6b3;
  background: rgba(26, 8, 8, 0.72);
  box-shadow: inset 0 0 22px rgba(0, 0, 0, 0.34);
}

.warning-panel strong {
  color: #f0c46a;
  font-size: 12px;
  text-transform: uppercase;
}

.warning-panel span {
  color: #d9c3a6;
  font-size: 13px;
  line-height: 1.35;
}

.entry {
  display: grid;
  width: min(320px, calc(100vw - 48px));
  gap: 10px;
}

.entry label {
  color: #c9d3b6;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

#usernameInput {
  width: 100%;
  min-height: 44px;
  border: 1px solid rgba(245, 240, 223, 0.22);
  border-radius: 8px;
  padding: 0 12px;
  color: #fff7dc;
  background: rgba(17, 19, 15, 0.76);
  outline: none;
}

#usernameInput:focus {
  border-color: rgba(78, 205, 196, 0.72);
}

#enterButton {
  width: 100%;
  min-height: 44px;
  border: 1px solid rgba(245, 240, 223, 0.32);
  border-radius: 8px;
  color: #15170f;
  background: #f0c46a;
  cursor: pointer;
  font-weight: 800;
}

#enterButton:disabled {
  cursor: wait;
  opacity: 0.55;
}

.crystal-viewer-link {
  min-width: min(320px, calc(100vw - 48px));
  min-height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(240, 93, 77, 0.38);
  border-radius: 8px;
  color: #fff1c9;
  background: rgba(26, 8, 8, 0.68);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.crystal-viewer-link:focus-visible {
  outline: 2px solid rgba(78, 205, 196, 0.82);
  outline-offset: 2px;
}

#bootStatus {
  color: #c9d3b6;
  font-size: 13px;
}

@media (max-width: 720px) {
  .hud {
    top: 12px;
    left: 12px;
    width: calc(100vw - 24px);
    padding: 12px;
  }

  #minimap {
    top: auto;
    right: 12px;
    bottom: 12px;
    width: 132px;
    height: 132px;
  }

  #cluePanel {
    right: 12px;
    bottom: 154px;
  }

  .hotbar {
    bottom: 12px;
  }

  .hotbar-slot {
    width: 60px;
    height: 60px;
  }
}
