:root {
  --bg: #09080d;
  --panel: rgba(12, 10, 17, 0.92);
  --panel-2: rgba(25, 20, 34, 0.94);
  --text: #f7f1e8;
  --muted: #b9c3c8;
  --accent: #b9f4ff;
  --accent-2: #d0b16a;
  --danger: #d85f85;
  --app-width: 100vw;
  --app-height: 100dvh;
  --visual-width: 100vw;
  --visual-height: 100dvh;
  --visual-left: 0px;
  --visual-top: 0px;
  --overlay-pad: clamp(4px, 1.6vmin, 14px);
}

@font-face {
  font-family: "UnderdogLocal";
  src: url("assets/fonts/Underdog-Regular.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "CreepsterLocal";
  src: url("assets/fonts/Creepster-Regular.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
  user-drag: none;
}

html,
body {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  touch-action: none;
  -ms-touch-action: none;
}

img,
canvas,
svg {
  -webkit-user-drag: none;
  user-drag: none;
  -webkit-touch-callout: none;
  touch-action: none;
}

button, input { font: inherit; }
input { -webkit-user-select: none; user-select: none; }

.app {
  position: relative;
  width: var(--app-width, 100vw);
  height: var(--app-height, 100dvh);
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 8%, rgba(35, 72, 78, 0.34), transparent 34%),
    radial-gradient(circle at 84% 14%, rgba(79, 54, 89, 0.28), transparent 32%),
    linear-gradient(155deg, #06060a 0%, #151019 52%, #0b0f14 100%);
}

.app::before {
  content: "";
  position: absolute;
  inset: -18%;
  z-index: 0;
  pointer-events: none;
  background: url("assets/ui_horror_panel.webp") center / cover no-repeat;
  opacity: 0.16;
  filter: saturate(0.75) contrast(1.18);
}

.topbar,
.hintbar,
.play-area {
  position: relative;
  z-index: 1;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(96px, 1fr) auto minmax(138px, 1fr);
  grid-template-areas: ". stats tools";
  align-items: center;
  gap: 10px;
  padding: max(8px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left));
  background:
    linear-gradient(90deg, rgba(7, 7, 10, 0.94), rgba(25, 17, 31, 0.96), rgba(8, 10, 13, 0.94)),
    url("assets/ui_horror_strip.webp") center / cover no-repeat;
  border-bottom: 1px solid rgba(208, 177, 106, 0.28);
  box-shadow: 0 12px 38px rgba(0, 0, 0, 0.42), inset 0 -1px 0 rgba(185, 244, 255, 0.1);
}

.hintbar {
  display: flex;
  align-items: center;
  gap: 10px;
  background:
    linear-gradient(90deg, rgba(7, 7, 10, 0.94), rgba(25, 17, 31, 0.96), rgba(8, 10, 13, 0.94)),
    url("assets/ui_horror_strip.webp") center / cover no-repeat;
  box-shadow: 0 12px 38px rgba(0, 0, 0, 0.42), inset 0 -1px 0 rgba(185, 244, 255, 0.1);
}

.hintbar {
  justify-content: center;
  padding: 8px max(12px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  color: var(--muted);
  font-size: clamp(11px, 2vw, 15px);
  text-align: center;
  border-top: 1px solid rgba(208, 177, 106, 0.22);
  border-bottom: 0;
}

.brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 900;
  white-space: nowrap;
  text-shadow: 0 0 16px rgba(185, 244, 255, 0.28);
}

.brand__icon { font-size: clamp(22px, 4vw, 32px); }
.brand__text {
  font-family: "UnderdogLocal", system-ui, sans-serif;
  font-size: clamp(18px, 3.2vw, 28px);
}

html[lang="en"] .brand__text,
html[lang="en"] .panel h1,
html[lang="en"] .level-transition__panel strong {
  font-family: "CreepsterLocal", "UnderdogLocal", system-ui, sans-serif;
  font-weight: 400;
}

.stats {
  grid-area: stats;
  justify-self: center;
  display: flex;
  gap: 10px;
  align-items: center;
  min-width: 0;
}

.tools {
  grid-area: tools;
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 10px;
}

.pill,
.small-btn,
.main-btn {
  border: 1px solid rgba(208, 177, 106, 0.36);
  background:
    linear-gradient(180deg, rgba(45, 37, 55, 0.94), rgba(13, 12, 17, 0.96)),
    url("assets/ui_horror_strip.webp") center / cover no-repeat;
  color: var(--text);
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px rgba(185, 244, 255, 0.06), 0 8px 20px rgba(0, 0, 0, 0.24);
}

.pill {
  position: relative;
  min-width: 134px;
  overflow: hidden;
  padding: 10px 18px;
  font-family: "UnderdogLocal", system-ui, sans-serif;
  font-weight: 900;
  font-size: 16px;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  letter-spacing: 0;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.72), 0 0 14px rgba(185, 244, 255, 0.36);
}

.stats .pill {
  border-color: rgba(185, 244, 255, 0.52);
  background:
    linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.18), transparent) -140% 0 / 80% 100% no-repeat,
    radial-gradient(circle at 18% 18%, rgba(255, 255, 255, 0.28), transparent 34%),
    linear-gradient(135deg, rgba(24, 78, 92, 0.98), rgba(24, 18, 47, 0.98) 54%, rgba(7, 9, 15, 0.98)),
    url("assets/ui_horror_strip.webp") center / cover no-repeat;
  color: #e9fbff;
  box-shadow: 0 0 22px rgba(65, 202, 218, 0.18), inset 0 0 0 1px rgba(255, 255, 255, 0.08), inset 0 -12px 28px rgba(0, 0, 0, 0.26);
  animation: stat-glint 4600ms ease-in-out infinite;
}

.stats .pill:nth-child(2) {
  border-color: rgba(208, 177, 106, 0.66);
  background:
    linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.16), transparent) -140% 0 / 80% 100% no-repeat,
    radial-gradient(circle at 20% 16%, rgba(255, 236, 172, 0.28), transparent 34%),
    linear-gradient(135deg, rgba(84, 38, 68, 0.98), rgba(45, 24, 48, 0.98) 52%, rgba(12, 9, 15, 0.98)),
    url("assets/ui_horror_strip.webp") center / cover no-repeat;
  color: #ffe8c1;
  box-shadow: 0 0 22px rgba(208, 177, 106, 0.2), inset 0 0 0 1px rgba(255, 255, 255, 0.08), inset 0 -12px 28px rgba(0, 0, 0, 0.26);
}

.small-btn {
  position: relative;
  width: clamp(38px, 6vw, 48px);
  height: clamp(38px, 6vw, 48px);
  display: grid;
  place-items: center;
  font-size: clamp(18px, 3vw, 25px);
  cursor: pointer;
}

.small-btn:active,
.main-btn:active { transform: scale(0.97); }

.small-btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.tool-btn--active,
.hint-btn--ad {
  background:
    radial-gradient(circle at 50% 22%, rgba(185, 244, 255, 0.32), transparent 42%),
    linear-gradient(180deg, rgba(38, 62, 70, 0.96), rgba(12, 16, 20, 0.98));
  color: #eaffff;
  border-color: rgba(185, 244, 255, 0.62);
}

.hint-btn__icon {
  font-size: 1.28em;
  line-height: 1;
  filter: drop-shadow(0 0 8px rgba(255, 236, 172, 0.38));
}

.hint-btn--ad .hint-btn__icon {
  transform: translateY(-1px);
}

.hint-btn--ad::after {
  content: "▶";
  position: absolute;
  right: 6px;
  top: 5px;
  width: 14px;
  height: 14px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(216, 95, 133, 0.96);
  color: #fff;
  font-size: 8px;
  line-height: 1;
  box-shadow: 0 0 10px rgba(216, 95, 133, 0.48);
}

.hint-btn__count {
  position: absolute;
  right: -4px;
  bottom: -4px;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #0b1115;
  border: 1px solid rgba(208, 177, 106, 0.72);
  color: var(--accent-2);
  font-size: 11px;
  font-weight: 900;
}

.hint-btn--ad .hint-btn__count {
  min-width: 24px;
  height: 24px;
  padding: 0;
  font-size: 15px;
  line-height: 1;
}

.play-area {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 0;
  padding: 0 10px;
  overflow: hidden;
}

.stage {
  position: relative;
  display: inline-block;
  max-width: calc(100vw - 20px);
  max-height: calc(var(--app-height, 100dvh) - 112px);
  border-radius: clamp(10px, 2vw, 18px);
  overflow: hidden;
  background: #050507;
  border: 2px solid rgba(208, 177, 106, 0.28);
  box-shadow: 0 18px 56px rgba(0, 0, 0, 0.56), 0 0 0 1px rgba(185, 244, 255, 0.05);
  cursor: crosshair;
}

.scene {
  display: block;
  width: auto;
  height: auto;
  max-width: calc(100vw - 20px);
  max-height: calc(var(--app-height, 100dvh) - 112px);
  object-fit: contain;
  pointer-events: none;
  filter: contrast(1.03) saturate(0.96);
}

.stage--level-in .scene {
  animation: scene-in 760ms cubic-bezier(0.18, 0.84, 0.18, 1) both;
}

.markers {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
}

.static-overlay {
  --static-grain: 0.34;
  --static-bands: 0.24;
  --static-glow: 0.2;
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: 0;
  mix-blend-mode: screen;
  background:
    linear-gradient(180deg, transparent 0 81%, rgba(255, 255, 255, 0.08) 82%, rgba(0, 0, 0, 0.22) 86%, transparent 91%),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.11) 0 1px, transparent 1px 4px),
    repeating-linear-gradient(90deg, rgba(185, 244, 255, 0.06) 0 1px, transparent 1px 12px),
    radial-gradient(circle at 50% 54%, transparent 0 11%, rgba(185, 244, 255, var(--static-glow)) 12%, transparent 17%),
    radial-gradient(circle at 48% 46%, rgba(185, 244, 255, calc(var(--static-glow) * 0.86)), transparent 42%);
  filter: contrast(1.18) brightness(1.08);
  transition: opacity 320ms ease;
  animation: static-scan 5200ms linear infinite, static-flicker 2600ms steps(5, end) infinite;
}

.static-overlay::before,
.static-overlay::after {
  content: "";
  position: absolute;
  inset: -12%;
  pointer-events: none;
}

.static-overlay::before {
  opacity: var(--static-grain);
  background:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.16) 0 1px, transparent 1px 7px),
    radial-gradient(circle, rgba(255, 255, 255, 0.44) 0 1px, transparent 1px 100%),
    radial-gradient(circle, rgba(185, 244, 255, 0.28) 0 1px, transparent 1px 100%);
  background-size: auto, 8px 8px, 13px 13px;
  animation: static-noise 150ms steps(2, end) infinite;
}

.static-overlay::after {
  opacity: var(--static-bands);
  background:
    linear-gradient(90deg, transparent 0 22%, rgba(255, 255, 255, 0.36) 24%, transparent 27% 62%, rgba(185, 244, 255, 0.28) 65%, transparent 69%),
    repeating-radial-gradient(circle at 50% 52%, transparent 0 9px, rgba(185, 244, 255, 0.12) 10px 11px, transparent 12px 28px),
    repeating-linear-gradient(180deg, transparent 0 28px, rgba(255, 255, 255, 0.34) 29px 32px, transparent 33px 62px);
  animation: static-ripple 4200ms ease-in-out infinite, static-tear 1900ms steps(4, end) infinite;
}

.static-overlay--active { opacity: 0.28; }
.static-overlay--settled { opacity: 0.31; }
.static-overlay--strong {
  --static-grain: 0.88;
  --static-bands: 0.68;
  --static-glow: 0.34;
  opacity: 0.74;
}

.static-overlay--settling {
  --static-grain: 0.88;
  --static-bands: 0.68;
  --static-glow: 0.34;
  animation:
    static-scan 5200ms linear infinite,
    static-flicker 2600ms steps(5, end) infinite,
    static-fade-to-settled 10000ms ease-out forwards;
}

.static-overlay--settling::before {
  animation:
    static-noise 150ms steps(2, end) infinite,
    static-grain-to-settled 10000ms ease-out forwards;
}

.static-overlay--settling::after {
  animation:
    static-ripple 4200ms ease-in-out infinite,
    static-tear 1900ms steps(4, end) infinite,
    static-bands-to-settled 10000ms ease-out forwards;
}

.magnifier {
  --lens-size: clamp(184px, 28.8vmin, 336px);
  position: absolute;
  left: 0;
  top: 0;
  z-index: 6;
  width: var(--lens-size);
  height: var(--lens-size);
  pointer-events: none;
  opacity: 0;
  transform: translate3d(-9999px, -9999px, 0) scale(0.96);
  transition: opacity 120ms ease, transform 80ms linear;
  will-change: transform, opacity;
}

.magnifier--visible { opacity: 1; }

.magnifier__glass {
  position: absolute;
  inset: 0;
  z-index: 2;
  overflow: hidden;
  border-radius: 50%;
  border: clamp(8px, 1.7vmin, 15px) solid rgba(242, 236, 218, 0.96);
  background-color: #120f16;
  background-repeat: no-repeat;
  filter: brightness(1.86) contrast(1.16) saturate(1.08);
  box-shadow: 0 14px 42px rgba(0, 0, 0, 0.38), 0 0 26px rgba(185, 244, 255, 0.25);
}

.magnifier__glass::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  box-shadow: inset 0 0 0 999px rgba(255, 252, 218, 0.07), inset 0 0 42px rgba(185, 244, 255, 0.24);
}

.magnifier::before {
  content: "";
  position: absolute;
  z-index: 1;
  left: 92%;
  top: 108%;
  width: clamp(34px, 14%, 58px);
  height: clamp(34px, 14%, 58px);
  border-radius: 50%;
  background: radial-gradient(circle at 32% 24%, #fff8dc, #9c8765 55%, #4a392a 100%);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.42), inset 0 0 0 2px rgba(255, 255, 255, 0.24);
  transform: translate(-50%, -50%);
}

.magnifier::after {
  content: "";
  position: absolute;
  z-index: 1;
  left: 72%;
  top: 77%;
  width: 22%;
  height: 58%;
  border-radius: 999px;
  background: linear-gradient(180deg, #ebe3cc, #8a7a62);
  transform: rotate(-42deg);
  transform-origin: 50% 0;
}

.marker,
.specter-burst,
.hint-mark {
  position: absolute;
  translate: -50% -50%;
  pointer-events: none;
}

.marker {
  width: clamp(56px, 7vw, 86px);
  height: clamp(56px, 7vw, 86px);
  border-radius: 50%;
  border: 1px solid rgba(185, 244, 255, 0.86);
  background: radial-gradient(circle, rgba(185, 244, 255, 0.18) 0 13%, transparent 14% 100%);
  box-shadow: 0 0 22px rgba(185, 244, 255, 0.46), inset 0 0 18px rgba(185, 244, 255, 0.18);
  animation: seal-pop 520ms cubic-bezier(0.19, 1, 0.22, 1) both, seal-breathe 2200ms ease-in-out 530ms infinite;
}

.marker::before,
.marker::after {
  content: "";
  position: absolute;
  inset: 16%;
  border-radius: 50%;
}

.marker::before {
  border: 1px dashed rgba(208, 177, 106, 0.88);
  animation: seal-spin 5200ms linear infinite;
}

.marker::after {
  inset: 35%;
  background:
    linear-gradient(90deg, transparent 45%, rgba(255, 255, 255, 0.92) 46% 54%, transparent 55%),
    linear-gradient(0deg, transparent 45%, rgba(255, 255, 255, 0.92) 46% 54%, transparent 55%);
  opacity: 0.72;
}

.specter-burst {
  z-index: 5;
  width: clamp(92px, 12vw, 150px);
  height: clamp(92px, 12vw, 150px);
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(255, 255, 255, 0.62) 0 5%, rgba(185, 244, 255, 0.32) 8% 23%, transparent 35%),
    conic-gradient(from 0deg, transparent, rgba(185, 244, 255, 0.42), transparent, rgba(208, 177, 106, 0.32), transparent);
  filter: blur(0.2px);
  animation: specter-burst 760ms ease-out forwards;
}

.hint-mark {
  width: clamp(70px, 10vw, 120px);
  height: clamp(70px, 10vw, 120px);
  border-radius: 50%;
  border: 2px solid rgba(185, 244, 255, 0.9);
  background:
    radial-gradient(circle, rgba(185, 244, 255, 0.22) 0 9%, transparent 10%),
    repeating-radial-gradient(circle, transparent 0 14px, rgba(185, 244, 255, 0.12) 15px 16px);
  box-shadow: 0 0 28px rgba(185, 244, 255, 0.5), inset 0 0 24px rgba(185, 244, 255, 0.18);
  animation: hint-pulse 1050ms ease-in-out infinite;
}

.hint-mark::before,
.hint-mark::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 72%;
  height: 1px;
  background: rgba(255, 255, 255, 0.82);
  transform: translate(-50%, -50%);
}

.hint-mark::after {
  width: 1px;
  height: 72%;
}

.hitbox-debug {
  position: absolute;
  border: 2px dashed rgba(255, 98, 166, 0.9);
  border-radius: 999px;
  translate: -50% -50%;
  pointer-events: none;
}

.message {
  position: absolute;
  z-index: 9;
  left: 50%;
  top: 50%;
  translate: -50% -50%;
  min-width: min(360px, 74vw);
  padding: 14px 20px;
  border-radius: 12px;
  border: 1px solid rgba(208, 177, 106, 0.36);
  background:
    linear-gradient(180deg, rgba(18, 16, 24, 0.9), rgba(6, 7, 9, 0.92)),
    url("assets/ui_horror_strip.webp") center / cover no-repeat;
  color: var(--text);
  font-family: "UnderdogLocal", system-ui, sans-serif;
  font-size: clamp(18px, 4vw, 32px);
  font-weight: 900;
  line-height: 1.08;
  text-align: center;
  opacity: 0;
  transform: scale(0.96);
  transition: opacity 180ms ease, transform 180ms ease;
  pointer-events: none;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.42);
}

.message--show {
  opacity: 1;
  transform: scale(1);
}

.stage--miss {
  animation: miss-shake 220ms ease-out;
  border-color: rgba(216, 95, 133, 0.7);
}

.level-transition {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 50%, rgba(185, 244, 255, 0.12), transparent 34%),
    linear-gradient(90deg, rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.68), rgba(0, 0, 0, 0.1));
  transition: opacity 320ms ease, visibility 320ms ease;
}

.level-transition--visible {
  opacity: 1;
  visibility: visible;
}

.level-transition__panel {
  min-width: min(420px, 76vw);
  padding: clamp(18px, 4vw, 30px);
  text-align: center;
  border: 1px solid rgba(208, 177, 106, 0.48);
  border-radius: 10px;
  background:
    linear-gradient(180deg, rgba(9, 8, 12, 0.86), rgba(16, 13, 20, 0.94)),
    url("assets/ui_horror_panel.webp") center / cover no-repeat;
  box-shadow: 0 0 44px rgba(185, 244, 255, 0.18), inset 0 0 42px rgba(0, 0, 0, 0.45);
  transform: translateY(12px) scale(0.96);
  transition: transform 420ms cubic-bezier(0.18, 0.84, 0.18, 1);
}

.level-transition--visible .level-transition__panel {
  transform: translateY(0) scale(1);
}

.level-transition__kicker {
  display: block;
  margin-bottom: 8px;
  color: var(--accent-2);
  font-size: clamp(11px, 2vw, 14px);
  font-weight: 900;
  text-transform: uppercase;
}

.level-transition__panel strong {
  display: block;
  font-family: "UnderdogLocal", system-ui, sans-serif;
  font-size: clamp(28px, 6vw, 54px);
  line-height: 1;
  text-shadow: 0 0 22px rgba(185, 244, 255, 0.36);
}

.overlay {
  position: fixed;
  left: var(--visual-left, 0px);
  top: var(--visual-top, 0px);
  width: var(--visual-width, 100vw);
  height: var(--visual-height, 100dvh);
  z-index: 10;
  display: flex;
  align-items: stretch;
  justify-content: center;
  overflow: hidden;
  padding: 0;
  background:
    radial-gradient(circle at 50% 34%, rgba(185, 244, 255, 0.13), transparent 28%),
    rgba(5, 5, 8, 0.96);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 260ms ease, visibility 260ms ease;
}

.overlay__viewport {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding:
    max(var(--overlay-pad), env(safe-area-inset-top))
    max(var(--overlay-pad), env(safe-area-inset-right))
    max(var(--overlay-pad), env(safe-area-inset-bottom))
    max(var(--overlay-pad), env(safe-area-inset-left));
}

.overlay--visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.orientation-overlay {
  position: fixed;
  left: var(--visual-left, 0px);
  top: var(--visual-top, 0px);
  width: var(--visual-width, 100vw);
  height: var(--visual-height, 100dvh);
  z-index: 30;
  display: none;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 38%, rgba(185, 244, 255, 0.14), transparent 34%),
    linear-gradient(180deg, rgba(5, 5, 8, 0.96), rgba(15, 9, 20, 0.98)),
    url("assets/ui_horror_panel.webp") center / cover no-repeat;
  color: var(--text);
  text-align: center;
}

.orientation-overlay__panel {
  width: min(520px, 88vw);
  padding: 26px 24px;
  border: 1px solid rgba(208, 177, 106, 0.52);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(12, 10, 17, 0.88), rgba(6, 7, 10, 0.94)),
    url("assets/ui_horror_strip.webp") center / cover no-repeat;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.62), inset 0 0 42px rgba(185, 244, 255, 0.08);
}

.orientation-overlay__panel strong {
  display: block;
  margin-bottom: 10px;
  font-family: "UnderdogLocal", system-ui, sans-serif;
  font-size: clamp(28px, 8vw, 46px);
  line-height: 1;
  color: #e9fbff;
  text-shadow: 0 0 20px rgba(185, 244, 255, 0.36);
}

.orientation-overlay__panel span {
  display: block;
  color: var(--muted);
  font-size: clamp(15px, 4vw, 20px);
  line-height: 1.35;
}

.panel {
  --panel-fit-scale: 1;
  width: min(560px, calc(var(--visual-width, 100vw) - var(--overlay-pad) * 2));
  max-height: none;
  overflow: visible;
  overscroll-behavior: contain;
  scrollbar-width: none;
  padding: clamp(20px, 4.6vmin, 38px);
  border: 1px solid rgba(208, 177, 106, 0.42);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(9, 8, 12, 0.86), rgba(16, 13, 20, 0.94)),
    url("assets/ui_horror_panel.webp") center / cover no-repeat;
  text-align: center;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.58), inset 0 0 50px rgba(0, 0, 0, 0.42);
  transform: scale(var(--panel-fit-scale));
  transform-origin: center center;
  will-change: transform;
}

.panel::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.panel h1 {
  margin: 8px 0;
  font-family: "UnderdogLocal", system-ui, sans-serif;
  font-size: clamp(30px, 7vw, 54px);
  line-height: 1.03;
}

.panel p {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: clamp(16px, 3vw, 21px);
}

.loader-ghost {
  font-size: clamp(46px, 10vw, 76px);
  animation: float 1800ms ease-in-out infinite;
}

.progress {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.12);
}

.progress__bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  transition: width 160ms ease;
}

.main-btn {
  min-width: 190px;
  padding: 14px 24px;
  cursor: pointer;
  font-weight: 900;
  font-size: clamp(16px, 3vw, 20px);
  color: #081116;
  border-color: rgba(255, 255, 255, 0.18);
  background: linear-gradient(180deg, #d8eff0, #a8d7dc);
}

.panel--settings,
.panel--complete {
  width: min(520px, calc(var(--visual-width, 100vw) - var(--overlay-pad) * 2));
}

.volume-control {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px 14px;
  align-items: center;
  margin: 16px 0;
  padding: 14px 16px;
  border: 1px solid rgba(208, 177, 106, 0.28);
  border-radius: 12px;
  background: rgba(5, 6, 9, 0.48);
  color: var(--text);
  text-align: left;
}

.volume-control span {
  font-weight: 900;
}

.volume-control strong {
  color: var(--accent-2);
  font-variant-numeric: tabular-nums;
}

.volume-control input[type="range"] {
  grid-column: 1 / -1;
  width: 100%;
  min-height: 34px;
  cursor: pointer;
  accent-color: var(--accent-2);
  touch-action: none;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

@keyframes scene-in {
  0% { opacity: 0.35; filter: blur(8px) contrast(1.45) brightness(1.25); transform: scale(1.018); }
  56% { opacity: 1; filter: blur(1.5px) contrast(1.12) brightness(1.06); }
  100% { opacity: 1; filter: contrast(1.03) saturate(0.96); transform: scale(1); }
}

@keyframes static-ripple {
  0%, 100% { opacity: var(--static-bands); }
  45% { opacity: calc(var(--static-bands) * 1.32); }
  72% { opacity: calc(var(--static-bands) * 0.78); }
}

@keyframes static-noise {
  0% { transform: translate3d(-1.5%, -1%, 0); }
  33% { transform: translate3d(1%, 0.8%, 0); }
  66% { transform: translate3d(0.4%, -0.6%, 0); }
  100% { transform: translate3d(-0.8%, 1%, 0); }
}

@keyframes static-scan {
  0% { background-position: 0 0, 0 0, 0 0, 50% 54%, 48% 46%; }
  100% { background-position: 0 140px, 0 96px, 48px 0, 50% 54%, 48% 46%; }
}

@keyframes static-tear {
  0% { transform: translate3d(-0.6%, -1%, 0) skewX(0deg); }
  28% { transform: translate3d(1.2%, 2%, 0) skewX(1.4deg); }
  54% { transform: translate3d(-1.8%, -0.4%, 0) skewX(-1deg); }
  100% { transform: translate3d(0.4%, 1.5%, 0) skewX(0.4deg); }
}

@keyframes static-flicker {
  0%, 100% { filter: contrast(1.18) brightness(1.08); }
  35% { filter: contrast(1.34) brightness(1.2); }
  52% { filter: contrast(1.06) brightness(0.96); }
  71% { filter: contrast(1.42) brightness(1.14); }
}

@keyframes static-fade-to-settled {
  0% { opacity: 0.74; }
  100% { opacity: 0.31; }
}

@keyframes static-grain-to-settled {
  0% { opacity: 0.88; }
  100% { opacity: 0.34; }
}

@keyframes static-bands-to-settled {
  0% { opacity: 0.68; }
  100% { opacity: 0.24; }
}

@keyframes stat-glint {
  0%, 64%, 100% { background-position: -140% 0, center, center, center; }
  82% { background-position: 180% 0, center, center, center; }
}

@keyframes seal-pop {
  0% { opacity: 0; transform: scale(0.32) rotate(-16deg); }
  72% { opacity: 1; transform: scale(1.18) rotate(3deg); }
  100% { opacity: 0.86; transform: scale(1) rotate(0deg); }
}

@keyframes seal-breathe {
  0%, 100% { opacity: 0.78; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.05); }
}

@keyframes seal-spin {
  to { transform: rotate(360deg); }
}

@keyframes specter-burst {
  0% { opacity: 0.98; transform: scale(0.18) rotate(0deg); filter: blur(0); }
  72% { opacity: 0.55; transform: scale(1.08) rotate(80deg); filter: blur(0.6px); }
  100% { opacity: 0; transform: scale(1.38) rotate(130deg); filter: blur(1.6px); }
}

@keyframes hint-pulse {
  0%, 100% { opacity: 0.72; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.08); }
}

@keyframes miss-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  50% { transform: translateX(5px); }
  75% { transform: translateX(-3px); }
}

html.short-viewport {
  --overlay-pad: 4px;
}

html.short-viewport .panel {
  padding: clamp(12px, 4.2vmin, 22px);
}

html.short-viewport .panel h1 {
  margin: 4px 0;
}

html.short-viewport .panel p {
  margin-bottom: 12px;
}

html.short-viewport .loader-ghost {
  font-size: 54px;
}

html.short-viewport .volume-control {
  margin: 8px 0;
  padding: 9px 12px;
  gap: 6px 10px;
}

html.short-viewport .volume-control input[type="range"] {
  min-height: 28px;
}

html.short-viewport .panel--settings .loader-ghost {
  font-size: clamp(28px, 8vmin, 52px);
}

html.short-viewport .panel--settings h1 {
  font-size: clamp(28px, 11vmin, 46px);
}

html.short-viewport .panel--settings .main-btn {
  padding-block: 10px;
}

html.short-viewport .hintbar {
  display: none;
}

html.short-viewport .topbar {
  padding-top: 5px;
  padding-bottom: 5px;
}

html.short-viewport .stage,
html.short-viewport .scene {
  max-height: calc(var(--app-height, 100dvh) - 60px);
}

html.short-viewport .pill {
  padding: 7px 10px;
}

html.short-viewport .magnifier {
  --lens-size: clamp(152px, 36.8vmin, 264px);
}

@media (max-height: 520px) {
  :root {
    --overlay-pad: 4px;
  }

  .panel {
    padding: clamp(12px, 4.2vmin, 22px);
  }

  .panel h1 {
    margin: 4px 0;
  }

  .panel p {
    margin-bottom: 12px;
  }

  .loader-ghost {
    font-size: 54px;
  }

  .volume-control {
    margin: 8px 0;
    padding: 9px 12px;
    gap: 6px 10px;
  }

  .volume-control input[type="range"] {
    min-height: 28px;
  }

  .panel--settings .loader-ghost {
    font-size: clamp(28px, 8vmin, 52px);
  }

  .panel--settings h1 {
    font-size: clamp(28px, 11vmin, 46px);
  }

  .panel--settings .main-btn {
    padding-block: 10px;
  }

  .topbar {
    padding-top: 5px;
    padding-bottom: 5px;
  }

  .hintbar { display: none; }

  .stage,
  .scene {
    max-height: calc(var(--app-height, 100dvh) - 60px);
  }

  .pill { padding: 7px 10px; }

  .magnifier {
    --lens-size: clamp(152px, 36.8vmin, 264px);
  }
}

@media (max-width: 640px) {
  .topbar {
    grid-template-columns: 1fr;
    grid-template-areas:
      "stats"
      "tools";
    justify-items: center;
    gap: 7px;
    padding-bottom: 7px;
  }

  .stats {
    width: 100%;
    justify-content: center;
    gap: 8px;
  }

  .tools {
    justify-self: center;
    gap: 9px;
  }

  .pill {
    min-width: min(136px, 43vw);
    padding: 8px 10px;
    font-size: 14px;
  }

  .small-btn {
    width: 42px;
    height: 42px;
  }
}

@media (max-width: 380px) {
  .stats { gap: 6px; }
  .tools { gap: 7px; }
  .pill {
    min-width: min(124px, 43vw);
    padding: 8px 7px;
    font-size: 12px;
  }
}

@media (orientation: portrait) and (hover: none) and (pointer: coarse) {
  .orientation-overlay {
    display: grid;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}
