@import url("https://fonts.googleapis.com/css2?family=Bebas+Neue&family=Cinzel:wght@700;800&display=swap");

:root {
  --bg: #050607;
  --text: #e9e7e1;
  --accent: #9c1a1a;
  --safe: #74d68a;
}

* {
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  touch-action: none;
}

canvas {
  display: block;
  touch-action: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

#ui {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

#topbar {
  position: absolute;
  top: 12px;
  left: 12px;
  display: grid;
  gap: 4px;
  text-shadow: 0 1px 4px #000;
  font-size: 14px;
  display: none;
}

#crosshair {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 22px;
  opacity: 0.8;
  display: none;
}

#hint {
  position: absolute;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 14px;
  letter-spacing: 0.04em;
  text-shadow: 0 1px 4px #000;
  display: none;
}

#vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, transparent 34%, rgba(0, 0, 0, 0.78) 100%);
  mix-blend-mode: multiply;
  opacity: 0.5;
}

.overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  z-index: 20;
}

.overlay.show {
  display: flex;
}

.panel {
  width: min(360px, 92vw);
  background: rgba(10, 10, 12, 0.92);
  border: 1px solid #2b2f36;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.68);
  padding: 24px;
  text-align: center;
}

.panel h1, .panel h2 {
  margin: 0 0 14px;
  letter-spacing: 0.12em;
}

.panel p {
  margin: 8px 0;
  color: #d4d0c8;
}

.panel .help {
  color: #aaa;
  font-size: 12px;
}

.panel select, .panel button {
  width: 100%;
  margin-top: 10px;
  padding: 10px;
  background: #111;
  color: var(--text);
  border: 1px solid #555;
}

.panel button {
  cursor: pointer;
  border-color: #f0f0f0;
  background: linear-gradient(#f7f7f7, #cfcfcf);
  color: #050507;
  font-weight: 700;
}

#resultOverlay.death-minimal .panel {
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 0;
}

#resultOverlay.death-minimal #resultText {
  display: none;
}

#resultOverlay.win-minimal {
  background: transparent;
}

#resultOverlay.win-minimal .panel {
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 0;
}

#resultOverlay.win-minimal #resultText {
  display: none;
}

#resultOverlay.win-minimal #resultTitle,
#resultOverlay.win-minimal #restartBtn {
  font-family: "Bebas Neue", "Impact", "Arial Narrow", sans-serif;
  font-weight: 400;
  letter-spacing: 0.14em;
}

#resultOverlay.win-minimal #restartBtn {
  width: auto;
  min-width: 140px;
  padding: 8px 14px;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  box-shadow: none;
  border: 0;
  outline: none;
  background: transparent;
  color: #000000;
  font-size: 28px;
  text-shadow: 0 0 12px rgba(255, 255, 255, 0.36);
}

#resultOverlay.win-minimal #restartBtn:active,
#resultOverlay.win-minimal #restartBtn:focus,
#resultOverlay.win-minimal #restartBtn:focus-visible {
  background: transparent;
  box-shadow: none;
  outline: none;
}

#resultOverlay.death-minimal #resultTitle {
  font-family: "Bebas Neue", "Impact", "Arial Narrow", sans-serif;
  font-weight: 400;
  letter-spacing: 0.14em;
}

#resultOverlay.death-minimal #restartBtn {
  width: auto;
  min-width: 170px;
  padding: 8px 18px;
  appearance: none;
  box-shadow: none;
  border: 0;
  outline: none;
  background: transparent;
  color: #ffffff;
  font-family: "Bebas Neue", "Impact", "Arial Narrow", sans-serif;
  font-size: 28px;
  font-weight: 400;
  letter-spacing: 0.14em;
  text-shadow: 0 0 12px rgba(255, 255, 255, 0.36);
}

#startOverlay {
  background:
    radial-gradient(ellipse at 50% 64%, rgba(255, 60, 60, 0.28) 0%, rgba(186, 0, 0, 0.62) 42%, rgba(56, 0, 0, 0.94) 100%),
    linear-gradient(180deg, #ff0d0d 0%, #a90000 46%, #310000 100%);
  overflow: hidden;
}

#startOverlay::before {
  content: "";
  position: absolute;
  inset: -18%;
  background:
    linear-gradient(to right, rgba(0, 0, 0, 0.48) 0%, rgba(0, 0, 0, 0.08) 16%, rgba(0, 0, 0, 0.08) 84%, rgba(0, 0, 0, 0.48) 100%),
    radial-gradient(ellipse at 50% 78%, rgba(255, 255, 255, 0.28) 0%, rgba(255, 255, 255, 0.07) 26%, rgba(255, 255, 255, 0) 48%);
  transform-origin: center;
  filter: blur(0.6px) saturate(1.14) contrast(1.1);
  pointer-events: none;
  animation: ohagiDepthWarp 6.4s cubic-bezier(0.2, 0.06, 0.62, 0.94) infinite;
}

#startOverlay::after {
  content: "";
  position: absolute;
  inset: -18%;
  background:
    repeating-linear-gradient(
      0deg,
      rgba(0, 0, 0, 0.12) 0px,
      rgba(0, 0, 0, 0.12) 2px,
      rgba(255, 255, 255, 0.04) 2px,
      rgba(255, 255, 255, 0.04) 4px
    );
  mix-blend-mode: multiply;
  opacity: 0.32;
  pointer-events: none;
  animation: ohagiFilmJitter 0.42s steps(2, end) infinite;
}

#startOverlay .panel {
  width: min(520px, 94vw);
  min-height: 74vh;
  margin-top: 2vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 34vh;
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 5vh 0 0;
  z-index: 2;
}

#startOverlay .panel h1 {
  margin: 7vh 0 0;
  font-family: "Bebas Neue", "Impact", "Arial Narrow", sans-serif;
  font-weight: 400;
  color: #fff;
  font-size: clamp(52px, 14vw, 112px);
  letter-spacing: 0.2em;
  text-shadow: 0 0 22px rgba(255, 255, 255, 0.24);
  animation: ohagiTitlePulse 6.2s ease-in-out infinite;
}

#startOverlay #startBtn {
  width: auto;
  min-width: 160px;
  margin-top: -15vh;
  padding: 12px 30px;
  position: relative;
  border: 0;
  background: transparent;
  color: #fff;
  font-family: "Bebas Neue", "Impact", "Arial Narrow", sans-serif;
  font-size: 28px;
  font-weight: 400;
  letter-spacing: 0.16em;
  text-transform: none;
  text-shadow: 0 0 14px rgba(255, 255, 255, 0.42);
  isolation: isolate;
  animation: ohagiPlayBase 6.8s linear infinite;
}

#startOverlay #startBtn::before,
#startOverlay #startBtn::after {
  content: attr(data-text);
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 100%;
  text-align: center;
  pointer-events: none;
  opacity: 0;
}

#startOverlay #startBtn::before {
  color: rgba(255, 78, 78, 0.78);
  mix-blend-mode: screen;
  animation: ohagiPlaySliceA 6.8s steps(1, end) infinite;
}

#startOverlay #startBtn::after {
  color: rgba(214, 241, 255, 0.72);
  mix-blend-mode: screen;
  animation: ohagiPlaySliceB 6.8s steps(1, end) infinite;
}

#startOverlay #startBtn:hover {
  color: #ffe5e5;
}

@keyframes ohagiDepthWarp {
  0% { transform: scale(1.1) skewX(0deg) skewY(0deg); }
  20% { transform: scale(1.14) skewX(0.85deg) skewY(-0.5deg); }
  42% { transform: scale(1.12) skewX(-0.95deg) skewY(0.65deg); }
  66% { transform: scale(1.16) skewX(0.7deg) skewY(-0.7deg); }
  100% { transform: scale(1.1) skewX(-0.6deg) skewY(0.45deg); }
}

@keyframes ohagiFilmJitter {
  0% { transform: translate(0, 0); opacity: 0.2; }
  25% { transform: translate(-0.4%, 0.2%); opacity: 0.3; }
  50% { transform: translate(0.5%, -0.3%); opacity: 0.24; }
  75% { transform: translate(-0.2%, 0.35%); opacity: 0.32; }
  100% { transform: translate(0, 0); opacity: 0.22; }
}

@keyframes ohagiTitlePulse {
  0% {
    transform: translateY(0) scale(1);
    filter: blur(0px) contrast(1);
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.22);
  }
  35% {
    transform: translateY(-0.5px) scale(1.01);
    filter: blur(0.2px) contrast(1.06);
    text-shadow: -0.5px 0 rgba(255, 20, 20, 0.28), 0.5px 0 rgba(255, 255, 255, 0.26), 0 0 26px rgba(255, 255, 255, 0.24);
  }
  60% {
    transform: translateY(0.3px) scale(0.998);
    filter: blur(0.12px) contrast(1.03);
    text-shadow: 0.5px 0 rgba(255, 30, 30, 0.22), -0.5px 0 rgba(255, 255, 255, 0.2), 0 0 22px rgba(255, 255, 255, 0.22);
  }
  100% {
    transform: translateY(0) scale(1);
    filter: blur(0px) contrast(1);
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.22);
  }
}

@keyframes ohagiPlayBase {
  0% {
    transform: translateX(0) scaleX(1);
    filter: blur(0px);
  }
  83% {
    transform: translateX(0) scaleX(1);
    filter: blur(0px);
  }
  84% {
    transform: translateX(0.9px) scaleX(1.02);
    filter: blur(0.4px);
  }
  86% {
    transform: translateX(-1.3px) scaleX(0.97);
    filter: blur(0.15px);
  }
  88% {
    transform: translateX(0.4px) scaleX(1.01);
    filter: blur(0.28px);
  }
  90% {
    transform: translateX(-0.7px) scaleX(0.985);
    filter: blur(0px);
  }
  100% {
    transform: translateX(0) scaleX(1);
    filter: blur(0px);
  }
}

@keyframes ohagiPlaySliceA {
  0%, 83% {
    opacity: 0;
    clip-path: inset(0 0 100% 0);
    transform: translate(-50%, -50%) translateX(0) scaleX(1);
  }
  84% {
    opacity: 0.85;
    clip-path: inset(6% 0 68% 0);
    transform: translate(-50%, -50%) translateX(2px) scaleX(1.05);
  }
  85% {
    opacity: 0.68;
    clip-path: inset(44% 0 26% 0);
    transform: translate(-50%, -50%) translateX(-2.6px) scaleX(0.92);
  }
  86% {
    opacity: 0;
    clip-path: inset(0 0 100% 0);
    transform: translate(-50%, -50%) translateX(0) scaleX(1);
  }
  89% {
    opacity: 0.75;
    clip-path: inset(72% 0 8% 0);
    transform: translate(-50%, -50%) translateX(1.6px) scaleX(1.04);
  }
  90%,
  100% {
    opacity: 0;
    clip-path: inset(0 0 100% 0);
    transform: translate(-50%, -50%) translateX(0) scaleX(1);
  }
}

@keyframes ohagiPlaySliceB {
  0%, 84% {
    opacity: 0;
    clip-path: inset(0 0 100% 0);
    transform: translate(-50%, -50%) translateX(0) scaleX(1);
  }
  85% {
    opacity: 0.78;
    clip-path: inset(22% 0 52% 0);
    transform: translate(-50%, -50%) translateX(-2.1px) scaleX(1.07);
  }
  87% {
    opacity: 0.64;
    clip-path: inset(58% 0 18% 0);
    transform: translate(-50%, -50%) translateX(1.9px) scaleX(0.93);
  }
  88% {
    opacity: 0;
    clip-path: inset(0 0 100% 0);
    transform: translate(-50%, -50%) translateX(0) scaleX(1);
  }
  92% {
    opacity: 0.7;
    clip-path: inset(8% 0 70% 0);
    transform: translate(-50%, -50%) translateX(-1.4px) scaleX(1.03);
  }
  93%,
  100% {
    opacity: 0;
    clip-path: inset(0 0 100% 0);
    transform: translate(-50%, -50%) translateX(0) scaleX(1);
  }
}



#mobileControls {
  position: fixed;
  inset: 0;
  pointer-events: auto;
  z-index: 15;
  touch-action: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.vstick {
  position: absolute;
  left: -999px;
  top: -999px;
  width: 92px;
  height: 92px;
  border: 0;
  background: rgba(18, 18, 18, 0.22);
  pointer-events: none;
  touch-action: none;
  opacity: 0;
  transition: opacity 0.06s linear;
}

#moveStick {
  width: 90px;
  height: 90px;
  border: 1px solid rgba(214, 224, 236, 0.58);
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 28%, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0) 38%),
    radial-gradient(circle at 50% 62%, rgba(14, 18, 24, 0.86), rgba(3, 4, 7, 0.78));
  box-shadow:
    0 0 14px rgba(225, 235, 245, 0.14),
    inset 0 0 12px rgba(255, 255, 255, 0.1),
    inset 0 -8px 10px rgba(0, 0, 0, 0.35);
}

#lookStick {
  border-color: transparent;
  background: transparent;
}

#lookStick .knob {
  background: transparent;
}

.vstick.show {
  opacity: 1;
}

.vstick .knob {
  position: absolute;
  left: 30px;
  top: 30px;
  width: 30px;
  height: 30px;
  background: rgba(220, 220, 220, 0.45);
}

#moveStick .knob {
  width: 22px;
  height: 22px;
  left: 34px;
  top: 34px;
  border-radius: 50%;
  background: linear-gradient(145deg, rgba(244, 248, 255, 0.92), rgba(126, 138, 152, 0.92));
  box-shadow:
    0 0 10px rgba(232, 240, 255, 0.32),
    inset 0 0 4px rgba(255, 255, 255, 0.35);
}

@media (min-width: 1025px) {
  #mobileControls {
    display: none;
  }
}
