.game-viewport {
  width: 100%;
  padding-top: 70px;
  min-height: calc(100vh - 70px);
  display: flex;
  flex-direction: column;
}

.horror-section {
  width: 100%;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px 15px;
  box-sizing: border-box;
}

.game-container {
  position: relative;
  width: 100%;
  height: calc(100vh - 140px);
  min-height: 500px;
  background: #000;
  border: 1px solid rgba(145, 63, 240, 0.4);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 10px 50px rgba(0, 0, 0, 0.9), 0 0 30px rgba(124, 58, 237, 0.2);
}

#game3d {
  width: 100%;
  height: 100%;
}

.crosshair {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: rgba(255, 255, 255, 0.4);
  font-family: monospace;
  font-size: 20px;
  pointer-events: none;
  z-index: 5;
}

.hud {
  position: absolute;
  top: 20px;
  left: 20px;
  display: flex;
  gap: 30px;
  z-index: 5;
  pointer-events: none;
}

.hud-item {
  font-family: 'Rajdhani', sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
  color: #c084fc;
  letter-spacing: 2px;
  text-shadow: 0 0 10px rgba(168, 85, 247, 0.6);
}

.hud-item span {
  color: #fff;
}

.static-overlay {
  position: absolute;
  inset: -20%;
  background-size: 160px 160px;
  mix-blend-mode: screen;
  pointer-events: none;
  opacity: 0;
  z-index: 4;
  animation: grain 0.45s steps(5) infinite;
}

@keyframes grain {
  0%   { transform: translate(0, 0); }
  20%  { transform: translate(-6%, 4%); }
  40%  { transform: translate(5%, -7%); }
  60%  { transform: translate(-3%, 8%); }
  80%  { transform: translate(7%, 2%); }
  100% { transform: translate(0, 0); }
}

.overlay-screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(4, 2, 10, 0.88);
  backdrop-filter: blur(6px);
  z-index: 10;
}

.overlay-screen.hidden {
  display: none;
}

.game-title {
  font-family: 'Orbitron', sans-serif;
  font-size: clamp(2rem, 4vw, 3rem);
  color: #fff;
  letter-spacing: 3px;
  margin-bottom: 10px;
  text-shadow: 0 0 20px rgba(168, 85, 247, 0.8);
}

.game-title.over {
  color: #ff3344;
  text-shadow: 0 0 20px rgba(255, 51, 68, 0.8);
}

.game-title.win {
  color: #34d399;
  text-shadow: 0 0 20px rgba(52, 211, 153, 0.8);
}

.game-subtitle {
  font-family: 'Rajdhani', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 2px;
  color: rgba(255, 255, 255, 0.7);
  margin-bottom: 20px;
}

.volume-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 25px;
}

.volume-container label {
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  color: #c084fc;
  letter-spacing: 2px;
}

.volume-container input[type=range] {
  accent-color: #913ff0;
  width: 180px;
  cursor: pointer;
}

.btn {
  border: 1px solid rgba(145, 63, 240, 0.5);
  padding: 14px 32px;
  border-radius: 6px;
  background: linear-gradient(135deg, #7c3aed, #913ff0);
  color: #ffffff;
  font-family: 'Rajdhani', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 0 24px rgba(124, 58, 237, 0.45);
  transition: all 0.25s ease;
}

.btn:hover {
  background: linear-gradient(135deg, #8b31ff, #a855f7);
  box-shadow: 0 0 32px rgba(180, 125, 255, 0.65);
  transform: translateY(-2px);
}

.horror-controls-hint {
  margin: 10px 0 0 0;
  text-align: center;
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 1px;
  color: rgba(255, 255, 255, 0.7);
  text-transform: uppercase;
}

.horror-controls-hint span {
  color: #a855f7;
  font-weight: 700;
}

/* ---------- screen-space effect layers ---------- */
.fx-layer { position: absolute; inset: 0; pointer-events: none; }

#vignette {
  z-index: 3;
  background: radial-gradient(ellipse at center, transparent 35%, rgba(0, 0, 0, 0.85) 100%);
  opacity: 0.6;
}

#chaseTint {
  z-index: 3;
  background: radial-gradient(ellipse at center, transparent 30%, rgba(190, 0, 20, 0.7) 100%);
  opacity: 0;
}

#hideFx {
  z-index: 6;
  opacity: 0;
  transition: opacity 0.25s ease;
  background:
    repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.96) 0 22px, transparent 22px 40px),
    radial-gradient(ellipse at center, transparent 20%, #000 95%);
}

#flashFx { z-index: 7; opacity: 0; background: #fff; }

/* mind slipping */
.game-container.insane #game3d { animation: warp 4s ease-in-out infinite; }
@keyframes warp {
  0%, 100% { filter: none; transform: none; }
  45%      { filter: none; transform: none; }
  50%      { filter: hue-rotate(40deg) saturate(1.6) blur(1px); transform: scale(1.02) skewX(0.6deg); }
  55%      { filter: hue-rotate(-30deg) contrast(1.3); transform: scale(1.01) skewX(-0.5deg); }
  60%      { filter: none; transform: none; }
}

/* ---------- HUD ---------- */
.hud { align-items: center; }
.hud-sanity { display: flex; align-items: center; gap: 10px; }
.bar {
  width: 120px; height: 8px;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(192, 132, 252, 0.5);
  border-radius: 4px; overflow: hidden;
}
#sanityFill {
  width: 100%; height: 100%;
  background: linear-gradient(90deg, #7c3aed, #c084fc);
  transition: width 0.2s linear, background 0.4s;
}
.hud-item.warn, .hud-item.warn span { color: #ff3344; animation: blink 0.6s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.35; } }

#minimapCanvas {
  position: absolute;
  top: 20px; right: 20px;
  width: 150px; height: 150px;
  background: rgba(0, 0, 0, 0.75);
  border: 2px solid rgba(168, 85, 247, 0.6);
  border-radius: 50%;
  z-index: 20;
  pointer-events: none;
  transition: width 0.25s ease, height 0.25s ease, border-radius 0.25s ease;
}
#minimapCanvas.full {
  width: min(360px, 70%); height: auto; aspect-ratio: 1;
  border-radius: 10px;
  top: 50%; right: 50%;
  transform: translate(50%, -50%);
  background: rgba(0, 0, 0, 0.88);
}

#objective {
  position: absolute; top: 52px; left: 20px; z-index: 5;
  font-family: 'Rajdhani', sans-serif; font-weight: 600; font-size: 0.95rem;
  letter-spacing: 2px; color: rgba(255, 255, 255, 0.7);
  text-shadow: 0 0 8px #000;
  pointer-events: none;
}

#hudMessage {
  position: absolute; left: 50%; top: 22%;
  transform: translateX(-50%);
  max-width: 80%; text-align: center;
  font-family: 'Rajdhani', sans-serif; font-weight: 700;
  font-size: clamp(1.1rem, 2.2vw, 1.6rem); letter-spacing: 3px;
  color: #fff; text-shadow: 0 0 14px rgba(168, 85, 247, 0.9), 0 2px 4px #000;
  opacity: 0; transition: opacity 0.4s ease;
  z-index: 8; pointer-events: none;
}
#hudMessage.show { opacity: 1; }
#hudMessage.bad { color: #ff4455; text-shadow: 0 0 14px rgba(255, 40, 60, 0.9), 0 2px 4px #000; }
#hudMessage.good { color: #34d399; text-shadow: 0 0 14px rgba(52, 211, 153, 0.9), 0 2px 4px #000; }

#interactHint {
  position: absolute; left: 50%; top: 58%;
  transform: translateX(-50%);
  font-family: 'Rajdhani', sans-serif; font-weight: 700; letter-spacing: 2px;
  color: #c084fc; text-shadow: 0 0 8px #000;
  opacity: 0; transition: opacity 0.2s; z-index: 8; pointer-events: none;
}
#interactHint.show { opacity: 1; }

.hud-bottom {
  position: absolute; bottom: 18px; left: 50%;
  transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  z-index: 10; pointer-events: none;
}
.stamina-bar {
  width: 290px; height: 6px;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(234, 179, 8, 0.5);
  border-radius: 3px; overflow: hidden;
}
#staminaBarFill { width: 100%; height: 100%; background: #eab308; transition: background 0.2s; }
#staminaBarFill.tired { background: #ef4444; }

.drive-slots { display: flex; gap: 10px; }
.slot {
  width: 46px; height: 46px;
  background: rgba(0, 0, 0, 0.6);
  border: 2px solid rgba(168, 85, 247, 0.35);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.3s ease;
}
.slot.filled {
  border-color: #c084fc;
  background: radial-gradient(circle, rgba(168, 85, 247, 0.6), rgba(0, 0, 0, 0.6));
  box-shadow: 0 0 14px rgba(168, 85, 247, 0.7);
}
.slot.filled::after { content: '\1F4BE'; font-size: 22px; }

/* ---------- jumpscare ---------- */
#jumpscareOverlay {
  position: absolute; inset: 0; z-index: 100;
  display: none; pointer-events: none;
  background-color: #1a0000;
  background-size: contain; background-repeat: no-repeat; background-position: center;
}
#jumpscareOverlay.on { display: block; animation: scare 0.09s linear infinite; }
@keyframes scare {
  0%   { transform: translate(-14px, 8px) scale(1.18); filter: contrast(1.6) saturate(2); }
  25%  { transform: translate(12px, -10px) scale(1.25); }
  50%  { transform: translate(-8px, -12px) scale(1.2); filter: invert(0.15) contrast(1.8); }
  75%  { transform: translate(14px, 10px) scale(1.3); }
  100% { transform: translate(-14px, 8px) scale(1.18); }
}

/* ---------- menus ---------- */
.tips {
  display: flex; flex-direction: column; gap: 4px; margin-bottom: 18px;
  font-family: 'Inter', sans-serif; font-weight: 300; font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.6); text-align: center; max-width: 520px; padding: 0 16px;
}
.difficulty { display: flex; gap: 10px; margin-bottom: 20px; }
.diff-btn {
  font-family: 'Rajdhani', sans-serif; font-weight: 700; letter-spacing: 2px; font-size: 0.85rem;
  padding: 8px 16px; border-radius: 6px; cursor: pointer;
  background: rgba(0, 0, 0, 0.5); color: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(145, 63, 240, 0.35); transition: all 0.2s ease;
}
.diff-btn:hover { color: #fff; border-color: rgba(145, 63, 240, 0.8); }
.diff-btn.active { color: #fff; background: rgba(124, 58, 237, 0.55); border-color: #a855f7; box-shadow: 0 0 14px rgba(124, 58, 237, 0.5); }
.diff-btn[data-diff="nightmare"].active { background: rgba(190, 20, 40, 0.55); border-color: #ff3344; box-shadow: 0 0 14px rgba(255, 51, 68, 0.5); }

.game-stats {
  font-family: 'Rajdhani', sans-serif; font-weight: 600; letter-spacing: 2px;
  color: #c084fc; margin: 0 0 22px; text-align: center; white-space: pre-line;
}
.best-time {
  margin: 14px 0 0; font-family: 'Rajdhani', sans-serif; font-weight: 600;
  letter-spacing: 2px; font-size: 0.85rem; color: rgba(255, 255, 255, 0.45);
}

@media (max-width: 700px) {
  #minimapCanvas { width: 110px; height: 110px; }
  .stamina-bar { width: 200px; }
  .slot { width: 36px; height: 36px; }
  .horror-controls-hint { font-size: 0.7rem; }
}

@media (prefers-reduced-motion: reduce) {
  .static-overlay, .game-container.insane #game3d { animation: none; }
}