/* ==========================================================================
   EVERY CLICK MAKES HIM SCARIER - Premium Horror Stylesheet
   ========================================================================== */

:root {
  --font-main: 'Outfit', sans-serif;
  --font-horror: 'Creepster', cursive;
  --font-retro: 'VT323', monospace;
  --font-mono: 'Space Grotesk', monospace;

  /* Stage 1 Palette (Playful & Innocent) */
  --bg-primary: #121826;
  --bg-surface: #1e293b;
  --bg-card: rgba(30, 41, 59, 0.7);
  --accent-color: #38bdf8;
  --accent-glow: rgba(56, 189, 248, 0.4);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --border-color: rgba(255, 255, 255, 0.1);
  --creature-halo: rgba(56, 189, 248, 0.25);
  --vignette-strength: 0.15;
  --glitch-amount: 0px;
}

/* Stage Progression Themes */
body.stage-1 {
  --bg-primary: #0b1329;
  --bg-surface: #162447;
  --bg-card: rgba(22, 36, 71, 0.85);
  --accent-color: #38bdf8;
  --accent-glow: rgba(56, 189, 248, 0.4);
  --creature-halo: rgba(56, 189, 248, 0.35);
  --vignette-strength: 0.2;
}

body.stage-2 {
  --bg-primary: #0a0f1d;
  --bg-surface: #121a2f;
  --bg-card: rgba(18, 26, 47, 0.9);
  --accent-color: #e2e8f0;
  --accent-glow: rgba(226, 232, 240, 0.25);
  --creature-halo: rgba(245, 158, 11, 0.25);
  --vignette-strength: 0.45;
}

body.stage-3 {
  --bg-primary: #0a0608;
  --bg-surface: #190e13;
  --bg-card: rgba(25, 14, 19, 0.92);
  --accent-color: #ef4444;
  --accent-glow: rgba(239, 68, 68, 0.4);
  --creature-halo: rgba(239, 68, 68, 0.4);
  --border-color: rgba(239, 68, 68, 0.25);
  --vignette-strength: 0.7;
}

body.stage-4 {
  --bg-primary: #050203;
  --bg-surface: #120507;
  --bg-card: rgba(18, 5, 7, 0.95);
  --accent-color: #dc2626;
  --accent-glow: rgba(220, 38, 38, 0.6);
  --creature-halo: rgba(220, 38, 38, 0.6);
  --border-color: rgba(220, 38, 38, 0.4);
  --vignette-strength: 0.85;
}

body.stage-5 {
  --bg-primary: #000000;
  --bg-surface: #0a0102;
  --bg-card: rgba(10, 1, 2, 0.98);
  --accent-color: #ff0000;
  --accent-glow: rgba(255, 0, 0, 0.8);
  --creature-halo: rgba(255, 0, 0, 0.8);
  --border-color: rgba(255, 0, 0, 0.6);
  --vignette-strength: 0.95;
}

/* Reset and Core Layout */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: var(--font-main);
  transition: background-color 1.2s ease;
}

/* CRT Scanlines and Analog Horror Overlays */
.crt-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
  background: radial-gradient(circle at center, transparent 35%, rgba(0, 0, 0, var(--vignette-strength)) 100%),
              repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.15) 0px, rgba(0, 0, 0, 0.15) 1px, transparent 1px, transparent 2px);
  box-shadow: inset 0 0 100px rgba(0, 0, 0, 0.8);
  transition: all 0.8s ease;
}

.vhs-glitch {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 101;
  opacity: 0;
  background: repeating-linear-gradient(0deg, rgba(255, 0, 0, 0.03), rgba(0, 255, 255, 0.03) 3px, transparent 6px);
  mix-blend-mode: screen;
  transition: opacity 0.5s ease;
}

body.stage-3 .vhs-glitch { opacity: 0.35; animation: vhsFlicker 0.12s infinite; }
body.stage-4 .vhs-glitch { opacity: 0.65; animation: vhsFlicker 0.08s infinite; }
body.stage-5 .vhs-glitch { opacity: 0.9; animation: vhsSevere 0.05s infinite; }

@keyframes vhsFlicker {
  0% { transform: translateY(0); filter: hue-rotate(0deg); }
  50% { transform: translateY(2px) skewX(0.5deg); filter: hue-rotate(90deg); }
  100% { transform: translateY(-1px); filter: hue-rotate(0deg); }
}

@keyframes vhsSevere {
  0% { transform: translate(-2px, 1px) scale(1.002); }
  33% { transform: translate(3px, -2px) skewX(2deg); }
  66% { transform: translate(-3px, 2px) skewX(-2deg); }
  100% { transform: translate(1px, -1px) scale(1); }
}

.flash-overlay {
  position: fixed;
  inset: 0;
  background: #ffffff;
  opacity: 0;
  pointer-events: none;
  z-index: 300;
  transition: opacity 0.05s ease;
}

.crack-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 102;
  opacity: 0;
  background-size: cover;
  background-position: center;
  transition: opacity 0.3s ease;
}

/* Screen Shake Classes */
.shake-micro { animation: shakeMicro 0.08s ease-in-out; }
.shake-medium { animation: shakeMed 0.18s ease-in-out; }
.shake-intense { animation: shakeSevere 0.35s ease-in-out; }

@keyframes shakeMicro {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-3px, 2px); }
  75% { transform: translate(3px, -2px); }
  100% { transform: translate(0, 0); }
}
@keyframes shakeMed {
  0% { transform: translate(0, 0); }
  20% { transform: translate(-6px, 5px) rotate(-0.5deg); }
  50% { transform: translate(7px, -4px) rotate(0.8deg); }
  80% { transform: translate(-4px, 3px); }
  100% { transform: translate(0, 0); }
}
@keyframes shakeSevere {
  0% { transform: translate(0, 0); }
  15% { transform: translate(-14px, 10px) rotate(-2deg); }
  35% { transform: translate(16px, -12px) rotate(2deg); }
  60% { transform: translate(-10px, 8px) rotate(-1deg); }
  85% { transform: translate(8px, -6px) rotate(1deg); }
  100% { transform: translate(0, 0); }
}

/* Modals (Start Warning, Ending, Stats) */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 7, 15, 0.95);
  backdrop-filter: blur(12px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.warning-card {
  max-width: 520px;
  background: #111827;
  border: 1px solid rgba(239, 68, 68, 0.4);
  border-radius: 16px;
  padding: 2.5rem;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8), 0 0 30px rgba(239, 68, 68, 0.2);
  position: relative;
  overflow: hidden;
}

.warning-badge {
  display: inline-block;
  padding: 6px 14px;
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid #ef4444;
  color: #f87171;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 2px;
  border-radius: 9999px;
  margin-bottom: 1.25rem;
}

.warning-title {
  font-family: var(--font-horror);
  font-size: 2.8rem;
  color: #ff4d4d;
  letter-spacing: 2px;
  margin-bottom: 1rem;
  text-shadow: 0 0 15px rgba(255, 77, 77, 0.5);
}

.warning-desc {
  font-size: 1.05rem;
  line-height: 1.6;
  color: #cbd5e1;
  margin-bottom: 1rem;
}

.warning-note {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  color: #94a3b8;
  margin-bottom: 2rem;
  font-style: italic;
}

.btn-start {
  position: relative;
  background: #ef4444;
  color: #ffffff;
  border: none;
  font-family: var(--font-main);
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 1.5px;
  padding: 1rem 2.8rem;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.5);
  transition: all 0.2s ease;
  overflow: hidden;
}

.btn-start:hover {
  transform: translateY(-2px) scale(1.02);
  background: #dc2626;
  box-shadow: 0 0 30px rgba(239, 68, 68, 0.8);
}

.btn-start .btn-glitch-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #b91c1c;
  opacity: 0;
  pointer-events: none;
  font-family: var(--font-horror);
  font-size: 1.4rem;
  transition: opacity 0.15s ease;
}

.btn-start:hover .btn-glitch-text {
  opacity: 0.25;
}

.controls-hint {
  margin-top: 1.5rem;
  font-size: 0.85rem;
  color: #64748b;
}

/* Primary Game Layout */
.game-wrapper {
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: relative;
  z-index: 10;
}

/* Header */
.top-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1.5rem;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-color);
  z-index: 20;
}

.logo-zone {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.status-indicator {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 8px #22c55e;
  transition: all 0.5s ease;
}

body.stage-3 .status-indicator { background: #eab308; box-shadow: 0 0 8px #eab308; }
body.stage-4 .status-indicator { background: #ef4444; box-shadow: 0 0 12px #ef4444; animation: blinkFast 0.5s infinite; }
body.stage-5 .status-indicator { background: #ff0000; box-shadow: 0 0 16px #ff0000; animation: blinkFast 0.2s infinite; }

@keyframes blinkFast {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.2; }
}

.game-title {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 1px;
  color: var(--text-main);
  transition: all 0.5s ease;
}

body.stage-3 .game-title { font-family: var(--font-retro); font-size: 1.3rem; color: #fca5a5; }
body.stage-4 .game-title { font-family: var(--font-horror); font-size: 1.6rem; color: #ef4444; letter-spacing: 2px; }
body.stage-5 .game-title { font-family: var(--font-horror); font-size: 1.8rem; color: #ff0000; text-shadow: 0 0 10px #ff0000; }

.sanity-wrapper {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-width: 240px;
}

.sanity-label {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
}

.sanity-bar-bg {
  flex: 1;
  height: 10px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.sanity-bar-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #ef4444, #eab308, #22c55e);
  transition: width 0.3s ease;
}

.top-actions {
  display: flex;
  gap: 0.5rem;
}

.icon-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  width: 38px;
  height: 38px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: all 0.2s ease;
}

.icon-btn:hover {
  background: var(--accent-color);
  color: #000;
  box-shadow: 0 0 12px var(--accent-glow);
}

/* Layout Grid */
.main-layout {
  flex: 1;
  display: grid;
  grid-template-columns: 310px 1fr 330px;
  gap: 1rem;
  padding: 0.6rem 1.25rem;
  overflow: hidden;
  min-height: 0;
}

/* Sidebars */
.sidebar {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: all 0.5s ease;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1.25rem;
  background: rgba(0, 0, 0, 0.25);
  border-bottom: 1px solid var(--border-color);
}

.panel-tag {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 1.5px;
  color: var(--accent-color);
}

.stage-tag, .currency-tag {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: #cbd5e1;
  background: rgba(255, 255, 255, 0.08);
  padding: 3px 8px;
  border-radius: 6px;
}

/* Left Sidebar: Lore & Log */
.left-sidebar {
  gap: 1rem;
  padding-bottom: 1rem;
}

.lore-box {
  margin: 1rem 1.25rem 0;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.25rem;
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.lore-avatar {
  font-size: 2rem;
  line-height: 1;
}

.lore-text {
  font-size: 0.95rem;
  line-height: 1.5;
  color: #e2e8f0;
  font-style: italic;
  min-height: 48px;
  transition: color 0.3s ease;
}

.milestones-box {
  padding: 0 1.25rem;
}

.section-title {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.objective-card {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 0.9rem;
}

.objective-title {
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 0.35rem;
  color: var(--accent-color);
}

.objective-progress {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.progress-track {
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 99px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--accent-color);
  box-shadow: 0 0 8px var(--accent-glow);
  transition: width 0.2s ease;
}

.terminal-log {
  flex: 1;
  margin: 0 1.25rem;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  padding: 0.8rem;
  font-family: var(--font-retro);
  font-size: 1.05rem;
  line-height: 1.4;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.terminal-log::-webkit-scrollbar {
  width: 4px;
}
.terminal-log::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

.log-entry.normal { color: #94a3b8; }
.log-entry.warning { color: #f59e0b; }
.log-entry.danger { color: #ef4444; text-shadow: 0 0 5px rgba(239, 68, 68, 0.4); }
.log-entry.corrupt { color: #dc2626; font-family: var(--font-horror); font-size: 1.2rem; }

/* Center Stage */
.center-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  position: relative;
  overflow: visible;
  padding-top: 0.25rem;
  gap: 0.4rem;
}

.counter-display {
  text-align: center;
  margin-bottom: 0.25rem;
  z-index: 20;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 0.5rem 2.2rem;
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 240px;
}

.counter-label {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 2.5px;
  color: var(--text-muted);
  margin-bottom: 0.15rem;
  text-transform: uppercase;
}

.counter-number {
  font-family: var(--font-main);
  font-size: clamp(2.4rem, 5.5vh, 3.4rem);
  font-weight: 900;
  letter-spacing: -0.5px;
  line-height: 1.1;
  color: var(--text-main);
  text-shadow: 0 0 25px var(--accent-glow);
  transition: transform 0.08s ease, color 0.3s ease;
}

.counter-number.pop {
  transform: scale(1.08);
}

.cps-display {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  color: var(--accent-color);
  margin-top: 0.15rem;
  font-weight: 600;
}

/* Creature Canvas & Interaction */
.character-container {
  position: relative;
  width: clamp(270px, 42vh, 390px);
  height: clamp(270px, 42vh, 390px);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.halo-effect {
  position: absolute;
  width: 90%;
  height: 90%;
  border-radius: 50%;
  background: radial-gradient(circle, var(--creature-halo) 0%, transparent 70%);
  filter: blur(25px);
  pointer-events: none;
  transition: all 0.8s ease;
}

body.stage-4 .halo-effect,
body.stage-5 .halo-effect {
  animation: pulseBreathing 2s infinite ease-in-out;
}

@keyframes pulseBreathing {
  0%, 100% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.18); opacity: 1; }
}

#creatureCanvas {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  z-index: 5;
  border-radius: 50%;
  transition: transform 0.08s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.character-container:active #creatureCanvas {
  transform: scale(0.94);
}

.click-hitbox {
  position: absolute;
  inset: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  z-index: 15;
  outline: none;
  border-radius: 50%;
}

/* Floating Click Particles (+1, +5, Blood drips) */
.click-particles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 20;
}

.floating-text {
  position: absolute;
  font-family: var(--font-main);
  font-weight: 800;
  font-size: 1.5rem;
  color: var(--accent-color);
  text-shadow: 0 0 8px var(--accent-glow);
  pointer-events: none;
  animation: floatUp 0.85s cubic-bezier(0.165, 0.84, 0.44, 1) forwards;
}

.floating-text.blood {
  color: #ff2222;
  font-family: var(--font-horror);
  font-size: 1.9rem;
  text-shadow: 0 0 12px rgba(255, 0, 0, 0.8);
}

@keyframes floatUp {
  0% { opacity: 1; transform: translate(-50%, -50%) scale(0.8) translateY(0); }
  30% { transform: translate(-50%, -50%) scale(1.3) translateY(-25px); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(0.9) translateY(-60px); }
}

/* Creature Speech Bubble */
.creature-bubble {
  position: relative;
  margin-top: 0.35rem;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid var(--border-color);
  padding: 0.45rem 1.2rem;
  border-radius: 999px;
  font-size: 0.9rem;
  color: #e2e8f0;
  max-width: 380px;
  text-align: center;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  transition: all 0.3s ease;
  z-index: 10;
}

body.stage-4 .creature-bubble {
  font-family: var(--font-retro);
  font-size: 1.2rem;
  color: #f87171;
  border-color: #ef4444;
}

body.stage-5 .creature-bubble {
  font-family: var(--font-horror);
  font-size: 1.4rem;
  color: #ff3333;
  border-color: #ff0000;
  text-shadow: 0 0 8px #ff0000;
}

/* Boss Encounter Bar */
.boss-health-container {
  display: none;
  position: absolute;
  top: -40px;
  left: 50%;
  transform: translateX(-50%);
  width: 420px;
  background: rgba(0, 0, 0, 0.85);
  border: 2px solid #ef4444;
  border-radius: 12px;
  padding: 0.8rem 1rem;
  box-shadow: 0 0 25px rgba(239, 68, 68, 0.7);
  z-index: 30;
  text-align: center;
}

.boss-health-container.active {
  display: block;
  animation: pulseBoss 1.5s infinite;
}

@keyframes pulseBoss {
  0%, 100% { box-shadow: 0 0 20px rgba(239, 68, 68, 0.5); }
  50% { box-shadow: 0 0 35px rgba(239, 68, 68, 0.9); }
}

.boss-label {
  font-family: var(--font-retro);
  font-size: 1.15rem;
  color: #ef4444;
  font-weight: 700;
  letter-spacing: 1px;
  margin-bottom: 0.4rem;
}

.boss-bar-bg {
  height: 14px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.boss-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #b91c1c, #ef4444);
  box-shadow: 0 0 10px #ef4444;
  transition: width 0.15s ease;
}

.boss-timer {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: #fca5a5;
  margin-top: 0.4rem;
}

/* Quick-Time Target Button for Boss / Stage 5 */
.sigil-target {
  position: absolute;
  width: 65px;
  height: 65px;
  border-radius: 50%;
  background: radial-gradient(circle, #ff0000 0%, #7f1d1d 80%);
  border: 2px solid #fff;
  cursor: pointer;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-horror);
  font-size: 1.8rem;
  color: #fff;
  box-shadow: 0 0 20px #ff0000;
  animation: sigilSpawn 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes sigilSpawn {
  0% { transform: scale(0); }
  100% { transform: scale(1); }
}

/* Right Sidebar: Shop & Upgrades */
.right-sidebar {
  display: flex;
  flex-direction: column;
}

.shop-tabs {
  display: flex;
  padding: 0.6rem 0.8rem;
  gap: 0.4rem;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid var(--border-color);
}

.shop-tab {
  flex: 1;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.45rem 0.2rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.shop-tab.active {
  background: var(--bg-surface);
  color: var(--accent-color);
  border-color: var(--border-color);
}

.store-list {
  flex: 1;
  padding: 0.8rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.store-list::-webkit-scrollbar {
  width: 5px;
}
.store-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

/* Store Item Card */
.store-item {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 0.75rem 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.165, 0.84, 0.44, 1);
  position: relative;
  overflow: hidden;
}

.store-item:hover:not(.disabled) {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--accent-color);
  transform: translateX(4px);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.store-item.disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(0.5);
}

.item-icon {
  width: 44px;
  height: 44px;
  background: var(--bg-surface);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  border: 1px solid var(--border-color);
  flex-shrink: 0;
}

.item-details {
  flex: 1;
  min-width: 0;
}

.item-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.2rem;
}

.item-name {
  font-weight: 700;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-main);
}

.item-count {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--accent-color);
  font-weight: 700;
}

.item-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.3;
  margin-bottom: 0.3rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-cost {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 700;
  color: #38bdf8;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

body.stage-3 .item-cost { color: #f87171; }
body.stage-4 .item-cost { color: #ef4444; }

/* Bottom Status Ticker */
.bottom-bar {
  background: rgba(0, 0, 0, 0.8);
  border-top: 1px solid var(--border-color);
  padding: 0.4rem 2rem;
  overflow: hidden;
  white-space: nowrap;
}

.ticker-text {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 2px;
  color: var(--text-muted);
  animation: tickerScroll 25s linear infinite;
}

@keyframes tickerScroll {
  0% { transform: translateX(100vw); }
  100% { transform: translateX(-100%); }
}

/* Jumpscare Screen Overlay */
.jumpscare-overlay {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 600;
  display: none;
  align-items: center;
  justify-content: center;
}

.jumpscare-overlay.active {
  display: flex;
  animation: jumpscareStrobe 0.06s infinite;
}

@keyframes jumpscareStrobe {
  0% { filter: invert(0) contrast(200%); }
  50% { filter: invert(1) contrast(300%); }
  100% { filter: invert(0) contrast(200%); }
}

#jumpscareCanvas {
  width: 90vmin;
  height: 90vmin;
  max-width: 800px;
  max-height: 800px;
}

/* Ending Screen */
.ending-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.95);
  backdrop-filter: blur(15px);
  z-index: 700;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.ending-modal.active {
  display: flex;
  animation: fadeIn 0.8s ease forwards;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.ending-card {
  max-width: 600px;
  width: 100%;
  background: #0a0405;
  border: 2px solid #ef4444;
  border-radius: 16px;
  padding: 3rem 2.5rem;
  text-align: center;
  box-shadow: 0 0 60px rgba(239, 68, 68, 0.5);
  position: relative;
}

.ending-stamp {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  letter-spacing: 3px;
  color: #ef4444;
  border: 2px solid #ef4444;
  padding: 4px 16px;
  display: inline-block;
  transform: rotate(-3deg);
  margin-bottom: 1.5rem;
}

.ending-title {
  font-family: var(--font-horror);
  font-size: 2.8rem;
  color: #ff3333;
  margin-bottom: 1rem;
  letter-spacing: 1.5px;
}

.ending-desc {
  font-size: 1.05rem;
  line-height: 1.6;
  color: #cbd5e1;
  margin-bottom: 2rem;
}

.ending-stats {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  padding: 1.25rem;
  margin-bottom: 2rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  text-align: left;
}

.btn-restart {
  background: #ef4444;
  color: #fff;
  border: none;
  font-family: var(--font-main);
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: 2px;
  padding: 1rem 3rem;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 0 25px rgba(239, 68, 68, 0.6);
  transition: all 0.2s ease;
}

.btn-restart:hover {
  transform: scale(1.05);
  background: #dc2626;
  box-shadow: 0 0 40px rgba(239, 68, 68, 0.9);
}

/* Stats Modal */
.stats-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  z-index: 550;
  display: none;
  align-items: center;
  justify-content: center;
}

.stats-modal.active {
  display: flex;
}

.stats-card {
  width: 500px;
  background: #111827;
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 2rem;
}

.stats-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.stats-header h2 {
  font-family: var(--font-mono);
  font-size: 1.2rem;
  color: var(--accent-color);
}

.stats-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.stat-item {
  background: rgba(255, 255, 255, 0.05);
  padding: 0.9rem;
  border-radius: 8px;
}

.stat-title {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.stat-val {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
}

/* Responsive queries */
@media (max-width: 1100px) {
  .main-layout {
    grid-template-columns: 280px 1fr 280px;
    padding: 1rem;
    gap: 1rem;
  }
  .character-container {
    width: 380px;
    height: 380px;
  }
  #creatureCanvas {
    width: 380px;
    height: 380px;
  }
}

@media (max-width: 860px) {
  .main-layout {
    grid-template-columns: 1fr;
    overflow-y: auto;
  }
  .left-sidebar { display: none; }
  .right-sidebar { min-height: 360px; }
  html, body { overflow: auto; }
}
