:root {
  --bg: #050506;
  --bg-soft: #0d0d10;
  --panel: rgba(10, 10, 12, 0.82);
  --panel-strong: rgba(10, 10, 12, 0.94);
  --line: rgba(255, 255, 255, 0.08);
  --text: #f2e8dc;
  --muted: #bcae9f;
  --gold: #d4b078;
  --red: #981321;
  --red-hot: #d42032;
  --shadow: 0 26px 60px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  background:
    radial-gradient(circle at top, rgba(152, 19, 33, 0.2), transparent 32%),
    linear-gradient(180deg, #050506 0%, #09090b 50%, #030304 100%);
  color: var(--text);
  font-family: "Space Grotesk", sans-serif;
  overflow: hidden;
}

button {
  border: 0;
  font: inherit;
  cursor: pointer;
}

.app {
  position: relative;
  min-height: 100vh;
  padding: 24px;
  z-index: 2;
}

.noise,
.fog,
.danger-flash {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.noise {
  z-index: 20;
  opacity: 0.15;
  background-image:
    linear-gradient(rgba(255,255,255,0.018), rgba(255,255,255,0.018)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 160 160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='.16'/%3E%3C/svg%3E");
}

.fog {
  z-index: 15;
  opacity: 0.16;
  mix-blend-mode: screen;
}

.fog-a {
  background:
    radial-gradient(circle at 20% 20%, rgba(255,255,255,0.08), transparent 34%),
    radial-gradient(circle at 70% 65%, rgba(255,255,255,0.06), transparent 30%);
  animation: driftA 24s linear infinite;
}

.fog-b {
  background:
    radial-gradient(circle at 78% 18%, rgba(255,255,255,0.06), transparent 30%),
    radial-gradient(circle at 35% 84%, rgba(255,255,255,0.05), transparent 26%);
  animation: driftB 32s linear infinite;
}

.danger-flash {
  z-index: 30;
  opacity: 0;
  background:
    radial-gradient(circle, rgba(255,255,255,0.04), rgba(255,0,0,0.2)),
    rgba(128, 0, 0, 0.08);
  transition: opacity 180ms ease;
}

.danger-flash.active {
  opacity: 1;
}

.app.shake {
  animation: shake 240ms linear;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
}

.topbar h1,
.threat-panel h2,
.legend-card h3 {
  margin: 0;
  font-family: "Cinzel", serif;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.topbar h1 {
  font-size: clamp(2.4rem, 4vw, 4rem);
  text-shadow: 0 0 24px rgba(212, 32, 50, 0.25);
}

.eyebrow,
.stat-card span,
.core-label,
.wheel-label,
.target-meta,
.meter-labels,
.legend-card li {
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.76rem;
}

.topbar-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.stat-card,
.restart-btn,
.ghost-btn,
.wheel-panel,
.threat-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.stat-card {
  padding: 12px 14px;
  border-radius: 16px;
  text-align: center;
}

.stat-card strong {
  display: block;
  margin-top: 6px;
  font-size: 1.1rem;
}

.restart-btn,
.ghost-btn {
  border-radius: 14px;
  padding: 12px 16px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.restart-btn:hover,
.ghost-btn:hover,
.letter-btn:hover {
  transform: translateY(-2px);
}

.arena {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) 360px;
  gap: 22px;
  margin-top: 20px;
  align-items: stretch;
}

.wheel-panel,
.threat-panel {
  position: relative;
  border-radius: 28px;
  padding: 22px;
}

.wheel-header,
.threat-header,
.button-row,
.meter-labels {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.target-meta {
  display: grid;
  gap: 4px;
  justify-items: end;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.78rem;
}

.wheel-stage {
  position: relative;
  display: grid;
  place-items: center;
  margin: 22px auto 0;
  width: min(76vw, 620px);
  aspect-ratio: 1 / 1;
}

.ring-glow {
  position: absolute;
  inset: 12%;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow:
    0 0 0 18px rgba(255, 255, 255, 0.02),
    0 0 60px rgba(148, 19, 33, 0.18) inset;
}

.letter-wheel {
  position: absolute;
  inset: 0;
}

.letter-btn {
  position: absolute;
  left: 50%;
  top: 50%;
  width: clamp(54px, 8vw, 76px);
  height: clamp(54px, 8vw, 76px);
  margin-left: calc(clamp(54px, 8vw, 76px) / -2);
  margin-top: calc(clamp(54px, 8vw, 76px) / -2);
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background:
    radial-gradient(circle at 30% 30%, rgba(255,255,255,0.12), rgba(255,255,255,0.03)),
    rgba(17, 17, 19, 0.9);
  color: var(--text);
  font-size: clamp(1rem, 2vw, 1.3rem);
  font-weight: 700;
  text-transform: uppercase;
  transition:
    transform 180ms ease,
    background 180ms ease,
    border-color 180ms ease,
    box-shadow 180ms ease,
    opacity 180ms ease;
}

.letter-btn.correct {
  background:
    radial-gradient(circle at 30% 30%, rgba(255,255,255,0.16), rgba(43,124,88,0.18)),
    rgba(21, 61, 42, 0.94);
  border-color: rgba(120, 241, 173, 0.35);
  box-shadow: 0 0 24px rgba(43, 124, 88, 0.26);
}

.letter-btn.wrong {
  background:
    radial-gradient(circle at 30% 30%, rgba(255,255,255,0.1), rgba(212,32,50,0.22)),
    rgba(63, 14, 19, 0.96);
  border-color: rgba(255, 110, 110, 0.35);
  opacity: 0.6;
}

.letter-btn.used {
  pointer-events: none;
}

.wheel-core {
  position: relative;
  z-index: 2;
  width: min(46%, 260px);
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 20px;
  background:
    radial-gradient(circle at top, rgba(255,255,255,0.08), transparent 55%),
    rgba(8, 8, 10, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 0 36px rgba(0, 0, 0, 0.42);
}

.core-label {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.74rem;
}

#guessDisplay {
  display: block;
  margin-top: 10px;
  font-size: clamp(1.2rem, 2vw, 1.65rem);
  letter-spacing: 0.22em;
}

.feedback-panel {
  margin-top: 12px;
}

.message {
  min-height: 52px;
  margin: 0;
  color: var(--text);
  line-height: 1.7;
}

.button-row {
  margin-top: 10px;
}

.ghost-btn.hidden {
  display: none;
}

.threat-panel {
  overflow: hidden;
}

.threat-header h2 {
  margin-top: 6px;
  font-size: 1.35rem;
}

.killer-stage {
  position: relative;
  min-height: 420px;
  margin-top: 18px;
  border-radius: 24px;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 90%, rgba(255,255,255,0.03), transparent 36%),
    linear-gradient(180deg, rgba(10,10,12,0.3), rgba(0,0,0,0.88));
}

.killer-floor {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 30%;
  background:
    linear-gradient(180deg, rgba(62, 0, 0, 0), rgba(62, 0, 0, 0.24)),
    radial-gradient(circle at center, rgba(255,255,255,0.03), transparent 55%);
}

.killer-shadow {
  position: absolute;
  left: 50%;
  bottom: 32px;
  width: 140px;
  height: 34px;
  transform: translateX(-50%) scale(1);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0,0,0,0.72), rgba(0,0,0,0));
  filter: blur(8px);
  transition: transform 220ms ease, opacity 220ms ease;
}

.killer-silhouette {
  --killer-scale: 0.78;
  --killer-rise: 0px;
  position: absolute;
  left: 50%;
  bottom: 42px;
  width: 220px;
  height: 320px;
  transform: translateX(-50%) translateY(var(--killer-rise)) scale(var(--killer-scale));
  transform-origin: center bottom;
  transition: transform 260ms ease, filter 260ms ease;
  filter: drop-shadow(0 0 30px rgba(212, 32, 50, 0.12));
}

.killer-head,
.killer-body {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: block;
  background: linear-gradient(180deg, rgba(10,10,10,0.98), rgba(0,0,0,0.98));
}

.killer-head {
  top: 18px;
  width: 78px;
  height: 92px;
  border-radius: 48% 48% 42% 42%;
  box-shadow: 0 0 24px rgba(212, 32, 50, 0.08);
}

.killer-head::before,
.killer-head::after {
  content: "";
  position: absolute;
  top: 34px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 70, 70, 0.68);
  box-shadow: 0 0 10px rgba(255, 70, 70, 0.48);
}

.killer-head::before {
  left: 20px;
}

.killer-head::after {
  right: 20px;
}

.killer-body {
  top: 88px;
  width: 170px;
  height: 220px;
  clip-path: polygon(30% 0%, 70% 0%, 92% 18%, 100% 78%, 86% 100%, 14% 100%, 0% 78%, 8% 18%);
  box-shadow: inset 0 0 34px rgba(255, 255, 255, 0.03);
}

.threat-meter {
  margin-top: 18px;
}

.meter-track {
  height: 14px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.meter-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #5a0e15, #ff6971);
  transition: width 220ms ease;
}

.meter-labels {
  margin-top: 8px;
  font-size: 0.8rem;
}

.legend-card {
  margin-top: 18px;
  padding: 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.legend-card ul {
  margin: 10px 0 0;
  padding-left: 18px;
  line-height: 1.7;
}

body.threat-0 .killer-silhouette { --killer-scale: 0.78; --killer-rise: 28px; }
body.threat-1 .killer-silhouette { --killer-scale: 0.9; --killer-rise: 16px; }
body.threat-2 .killer-silhouette { --killer-scale: 1.02; --killer-rise: 6px; }
body.threat-3 .killer-silhouette { --killer-scale: 1.16; --killer-rise: -6px; }
body.threat-4 .killer-silhouette { --killer-scale: 1.32; --killer-rise: -18px; }
body.threat-5 .killer-silhouette { --killer-scale: 1.5; --killer-rise: -30px; }
body.threat-6 .killer-silhouette { --killer-scale: 1.72; --killer-rise: -50px; }

body.threat-4,
body.threat-5,
body.threat-6 {
  background:
    radial-gradient(circle at top, rgba(180, 20, 30, 0.28), transparent 30%),
    linear-gradient(180deg, #050506 0%, #08080a 45%, #020203 100%);
}

body.threat-5 .wheel-panel,
body.threat-6 .wheel-panel,
body.threat-5 .threat-panel,
body.threat-6 .threat-panel {
  box-shadow: 0 0 0 1px rgba(255, 84, 84, 0.16), 0 26px 60px rgba(86, 0, 0, 0.38);
}

body.win .killer-silhouette {
  opacity: 0.5;
  filter: blur(1px) drop-shadow(0 0 18px rgba(43, 124, 88, 0.18));
}

body.lose .killer-silhouette {
  filter: drop-shadow(0 0 42px rgba(255, 0, 0, 0.28));
}

@keyframes driftA {
  0% { transform: translate3d(-4%, -2%, 0) scale(1); }
  50% { transform: translate3d(5%, 3%, 0) scale(1.06); }
  100% { transform: translate3d(-4%, -2%, 0) scale(1); }
}

@keyframes driftB {
  0% { transform: translate3d(4%, 2%, 0) scale(1.03); }
  50% { transform: translate3d(-5%, -3%, 0) scale(1); }
  100% { transform: translate3d(4%, 2%, 0) scale(1.03); }
}

@keyframes shake {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-4px, 1px); }
  50% { transform: translate(4px, -2px); }
  75% { transform: translate(-2px, 2px); }
  100% { transform: translate(0, 0); }
}

@media (max-width: 1100px) {
  .arena {
    grid-template-columns: 1fr;
  }

  .killer-stage {
    min-height: 320px;
  }
}

@media (max-width: 720px) {
  body {
    overflow-y: auto;
  }

  .app {
    padding: 16px;
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .topbar-actions {
    justify-content: space-between;
  }

  .wheel-stage {
    width: min(94vw, 560px);
  }

  .wheel-core {
    width: 44%;
  }

  .letter-btn {
    width: 58px;
    height: 58px;
    margin-left: -29px;
    margin-top: -29px;
  }
}
