:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #7fc7ef;
  color: #fffdf4;
}

* {
  box-sizing: border-box;
}

html,
body,
#game-shell {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  min-width: 320px;
  background:
    linear-gradient(180deg, #7fc7ef 0%, #c6ecff 46%, #f8f2c9 100%);
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

#hud {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  left: max(14px, env(safe-area-inset-left));
  z-index: 3;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-width: min(520px, calc(100vw - 28px));
  pointer-events: none;
}

#hud span {
  min-width: 86px;
  padding: 8px 11px;
  border: 1px solid rgba(255, 255, 255, 0.38);
  border-radius: 8px;
  background: rgba(28, 54, 66, 0.52);
  box-shadow: 0 8px 22px rgba(30, 49, 58, 0.2);
  color: #fffbe7;
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
  white-space: nowrap;
}

#world {
  min-width: 166px;
}

#toast {
  position: fixed;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  z-index: 4;
  max-width: min(360px, calc(100vw - 32px));
  padding: 10px 14px;
  border-radius: 8px;
  background: rgba(22, 49, 53, 0.72);
  box-shadow: 0 12px 28px rgba(25, 46, 50, 0.22);
  color: #fffde8;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.25;
  opacity: 0;
  pointer-events: none;
  text-align: center;
  transform: translate(-50%, 14px);
  transition: opacity 180ms ease, transform 180ms ease;
}

#toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

#jumpscare {
  position: fixed;
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  background: #000;
  pointer-events: none;
}

#jumpscare[hidden] {
  display: none;
}

#jumpscare img {
  width: min(92vw, 900px);
  height: min(90vh, 1100px);
  object-fit: contain;
}

#static-overlay {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: 0.24;
  background:
    repeating-linear-gradient(
      180deg,
      rgba(240, 255, 255, 0.18) 0,
      rgba(240, 255, 255, 0.18) 1px,
      rgba(0, 0, 0, 0) 3px,
      rgba(0, 0, 0, 0) 7px
    ),
    repeating-linear-gradient(
      90deg,
      rgba(255, 80, 216, 0.08) 0,
      rgba(255, 80, 216, 0.08) 2px,
      rgba(0, 255, 255, 0.06) 3px,
      rgba(0, 0, 0, 0) 9px
    );
  mix-blend-mode: screen;
  animation: static-jitter 240ms steps(2) infinite;
}

#static-overlay[hidden] {
  display: none;
}

@keyframes static-jitter {
  0% {
    transform: translateY(0);
    opacity: 0.18;
  }

  50% {
    transform: translateY(-2px);
    opacity: 0.28;
  }

  100% {
    transform: translateY(1px);
    opacity: 0.22;
  }
}

#finish-panel {
  position: fixed;
  inset: 50% auto auto 50%;
  z-index: 5;
  width: min(330px, calc(100vw - 32px));
  padding: 24px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 8px;
  background: rgba(17, 43, 49, 0.82);
  box-shadow: 0 22px 60px rgba(21, 39, 45, 0.35);
  text-align: center;
  transform: translate(-50%, -50%);
  backdrop-filter: blur(14px);
}

#finish-panel h1 {
  margin: 0 0 8px;
  color: #fff6c7;
  font-size: 34px;
  line-height: 1;
}

#finish-panel p {
  margin: 0 0 18px;
  color: #cceeff;
  font-size: 18px;
  font-weight: 800;
}

#startup-error {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 6;
  width: min(420px, calc(100vw - 32px));
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 8px;
  background: rgba(28, 54, 66, 0.84);
  box-shadow: 0 18px 48px rgba(25, 46, 50, 0.28);
  color: #fffde8;
  font-size: 16px;
  font-weight: 850;
  line-height: 1.35;
  text-align: center;
  transform: translate(-50%, -50%);
}

#restart {
  width: 100%;
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: #ffd267;
  color: #173238;
  cursor: pointer;
  font: inherit;
  font-size: 15px;
  font-weight: 900;
}

#restart:focus-visible {
  outline: 3px solid #ffffff;
  outline-offset: 3px;
}

@media (max-width: 540px) {
  #hud {
    right: max(14px, env(safe-area-inset-right));
  }

  #hud span {
    flex: 1 1 96px;
    min-width: 0;
    text-align: center;
  }

  #finish-panel h1 {
    font-size: 30px;
  }
}
