/* Podciep - The Game | Main Stylesheet */

/* === CSS Variables === */
:root {
  /* Dark Silesian atmosphere - base/neutral */
  --bg-dark: #0a0a0f;
  --bg-medium: #12121a;
  --bg-light: #1a1a25;

  /* Fog colors */
  --fog-light: rgba(180, 180, 195, 0.15);
  --fog-dark: rgba(60, 60, 80, 0.2);

  /* Text colors */
  --text-primary: #d4d4dc;
  --text-secondary: #8a8a9a;
  --text-muted: #5a5a6a;

  /* Accent - cold, eerie blue */
  --accent: #6a7fa8;
  --accent-hover: #8a9fc8;
  --accent-glow: rgba(106, 127, 168, 0.3);

  /* Danger/warning - muted red */
  --danger: #8a4a4a;

  /* Typography */
  --font-narrative: 'Cormorant Garamond', Georgia, serif;
  --font-ui: 'Inter', -apple-system, sans-serif;

  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 2rem;
  --space-xl: 3rem;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-medium: 300ms ease;
  --transition-slow: 600ms ease;

  /* Vignette */
  --vignette-opacity: 0.4;
  --vignette-color: rgba(0, 0, 0, var(--vignette-opacity));
}

/* === MOOD THEMES === */

/* Eerie - unsettling blue */
[data-mood="eerie"] {
  --bg-dark: #080a10;
  --bg-medium: #0e1218;
  --bg-light: #151a24;
  --text-primary: #c8d0e0;
  --text-secondary: #7888a0;
  --accent: #5878a8;
  --accent-hover: #7898c8;
  --accent-glow: rgba(88, 120, 168, 0.4);
  --vignette-opacity: 0.5;
}

/* Dark - oppressive darkness */
[data-mood="dark"] {
  --bg-dark: #050508;
  --bg-medium: #0a0a10;
  --bg-light: #101015;
  --text-primary: #a0a0a8;
  --text-secondary: #606068;
  --accent: #484858;
  --accent-hover: #606078;
  --accent-glow: rgba(72, 72, 88, 0.3);
  --vignette-opacity: 0.7;
}

/* Memory - warm sepia nostalgia */
[data-mood="memory"] {
  --bg-dark: #0f0d0a;
  --bg-medium: #181510;
  --bg-light: #201c16;
  --text-primary: #dcd4c8;
  --text-secondary: #a09888;
  --accent: #a08868;
  --accent-hover: #c0a888;
  --accent-glow: rgba(160, 136, 104, 0.3);
  --vignette-opacity: 0.35;
}

/* Cold - icy winter */
[data-mood="cold"] {
  --bg-dark: #080a0f;
  --bg-medium: #101520;
  --bg-light: #182030;
  --text-primary: #d8e0ec;
  --text-secondary: #90a0b8;
  --accent: #6090c0;
  --accent-hover: #80b0e0;
  --accent-glow: rgba(96, 144, 192, 0.4);
  --vignette-opacity: 0.45;
}

/* Suffocating - thick yellowish */
[data-mood="suffocating"] {
  --bg-dark: #0c0a08;
  --bg-medium: #141210;
  --bg-light: #1c1a16;
  --text-primary: #d8d0c0;
  --text-secondary: #989080;
  --accent: #908060;
  --accent-hover: #b0a080;
  --accent-glow: rgba(144, 128, 96, 0.35);
  --vignette-opacity: 0.65;
}

/* Supernatural - greenish purple */
[data-mood="supernatural"] {
  --bg-dark: #08080c;
  --bg-medium: #101218;
  --bg-light: #181c24;
  --text-primary: #d0d8dc;
  --text-secondary: #8898a0;
  --accent: #6888a0;
  --accent-hover: #88a8c0;
  --accent-glow: rgba(104, 136, 160, 0.4);
  --vignette-opacity: 0.5;
}

/* Industrial - Silesian smog */
[data-mood="industrial"] {
  --bg-dark: #0a0908;
  --bg-medium: #121110;
  --bg-light: #1a1918;
  --text-primary: #d0ccc8;
  --text-secondary: #908880;
  --accent: #807870;
  --accent-hover: #a09890;
  --accent-glow: rgba(128, 120, 112, 0.3);
  --vignette-opacity: 0.55;
}

/* Dread - red-tinged horror */
[data-mood="dread"] {
  --bg-dark: #0c0808;
  --bg-medium: #141010;
  --bg-light: #1c1418;
  --text-primary: #dcd0d0;
  --text-secondary: #a08888;
  --accent: #a06868;
  --accent-hover: #c08888;
  --accent-glow: rgba(160, 104, 104, 0.4);
  --vignette-opacity: 0.6;
}

/* Ethereal - dreamlike white */
[data-mood="ethereal"] {
  --bg-dark: #0c0c10;
  --bg-medium: #161620;
  --bg-light: #20202c;
  --text-primary: #e8e8f0;
  --text-secondary: #a0a0b0;
  --accent: #9898b8;
  --accent-hover: #b8b8d8;
  --accent-glow: rgba(152, 152, 184, 0.35);
  --vignette-opacity: 0.25;
}

/* Stairwell - claustrophobic */
[data-mood="stairwell"] {
  --bg-dark: #060608;
  --bg-medium: #0c0c10;
  --bg-light: #121216;
  --text-primary: #b8b8c0;
  --text-secondary: #686878;
  --accent: #505060;
  --accent-hover: #707080;
  --accent-glow: rgba(80, 80, 96, 0.3);
  --vignette-opacity: 0.75;
}

/* Childhood - soft golden */
[data-mood="childhood"] {
  --bg-dark: #0e0c0a;
  --bg-medium: #161412;
  --bg-light: #1e1c1a;
  --text-primary: #e0dcd4;
  --text-secondary: #a8a090;
  --accent: #b0a080;
  --accent-hover: #d0c0a0;
  --accent-glow: rgba(176, 160, 128, 0.3);
  --vignette-opacity: 0.3;
}

/* === Reset & Base === */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* Fix for mobile viewport height */
  height: 100%;
  height: -webkit-fill-available;
}

body {
  font-family: var(--font-ui);
  background: var(--bg-dark);
  color: var(--text-primary);
  min-height: 100vh;
  min-height: -webkit-fill-available;
  min-height: 100dvh;
  overflow: hidden;
  transition: background-color 1.5s ease, color 1.5s ease;
}

/* === Game Container === */
#game-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: linear-gradient(
    180deg,
    var(--bg-dark) 0%,
    var(--bg-medium) 50%,
    var(--bg-dark) 100%
  );
  transition: background 1.5s ease;
}

/* Vignette overlay */
#game-container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(
    ellipse at center,
    transparent 0%,
    transparent 40%,
    rgba(0, 0, 0, var(--vignette-opacity)) 100%
  );
  z-index: 150;
  pointer-events: none;
  transition: background 1.5s ease;
}

/* === Scene Background Image === */
.scene-background-image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0;
  transition: opacity 1.2s ease;
  z-index: 0;
}

.scene-background-image.visible {
  opacity: 0.4;
}

/* Strong vignette over background image */
.scene-background-image::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(
    ellipse at center,
    transparent 0%,
    transparent 20%,
    rgba(10, 10, 15, 0.5) 50%,
    rgba(10, 10, 15, 0.85) 80%,
    rgba(10, 10, 15, 0.95) 100%
  );
  pointer-events: none;
}

/* === Canvas Layer (Fog) === */
#fog-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 100;
  pointer-events: none;
}

/* === UI Layer === */
#ui-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 150;
  display: flex;
  flex-direction: column;
  pointer-events: none;
  overflow: hidden;
}

#ui-layer > * {
  pointer-events: auto;
}

/* === Header === */
#game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-md) var(--space-lg);
  background: linear-gradient(180deg, rgba(10, 10, 15, 0.7) 0%, transparent 100%);
  gap: var(--space-md);
}

/* === Header Buttons === */
#header-buttons {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.header-icon-btn {
  background: transparent;
  border: 1px solid var(--text-muted);
  color: var(--text-secondary);
  font-size: 1.25rem;
  padding: var(--space-sm) var(--space-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  border-radius: 4px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.header-icon-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.header-icon-btn svg {
  width: 1.25em;
  height: 1.25em;
}

.item-count {
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--accent);
  color: var(--bg-dark);
  font-size: 0.65rem;
  font-weight: 600;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

.item-count.hidden {
  display: none;
}

/* === Inventory Overlay === */
#inventory-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 10, 15, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 260;
  opacity: 1;
  transition: opacity var(--transition-medium);
}

#inventory-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

#inventory-box {
  background: linear-gradient(
    135deg,
    rgba(18, 18, 26, 0.95) 0%,
    rgba(26, 26, 37, 0.9) 100%
  );
  border: 1px solid rgba(100, 100, 120, 0.2);
  border-radius: 12px;
  padding: var(--space-lg);
  min-width: 350px;
  max-width: 500px;
  max-height: 80vh;
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.5),
    0 0 60px rgba(74, 96, 128, 0.1);
  animation: confirmAppear 0.3s ease-out;
}

#inventory-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid rgba(100, 100, 120, 0.15);
}

#inventory-header h2 {
  font-family: var(--font-narrative);
  font-size: 1.5rem;
  font-weight: 400;
  color: var(--text-primary);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin: 0;
}

#inventory-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.75rem;
  cursor: pointer;
  transition: color var(--transition-fast);
  line-height: 1;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#inventory-close:hover {
  color: var(--text-primary);
}

#inventory-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

#inventory-empty {
  text-align: center;
  color: var(--text-muted);
  font-family: var(--font-narrative);
  font-style: italic;
  padding: var(--space-xl) 0;
}

#inventory-empty.hidden {
  display: none;
}

/* Inventory Grid Items */
.inventory-grid-item {
  width: 70px;
  height: 70px;
  background: linear-gradient(135deg, rgba(26, 26, 37, 0.8) 0%, rgba(18, 18, 26, 0.9) 100%);
  border: 1px solid rgba(90, 90, 106, 0.4);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-medium);
  position: relative;
  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.inventory-grid-item::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 8px;
  background: radial-gradient(ellipse at 30% 20%, rgba(255, 255, 255, 0.08) 0%, transparent 60%);
  pointer-events: none;
}

.inventory-grid-item:hover {
  border-color: var(--accent);
  background: linear-gradient(135deg, rgba(40, 45, 60, 0.9) 0%, rgba(26, 30, 42, 0.95) 100%);
  transform: scale(1.05);
  box-shadow:
    0 6px 20px rgba(106, 127, 168, 0.3),
    0 2px 8px rgba(0, 0, 0, 0.5);
}

.inventory-grid-item.selected {
  border-color: var(--accent);
  box-shadow:
    0 0 15px rgba(106, 127, 168, 0.4),
    0 2px 8px rgba(0, 0, 0, 0.5);
}

.inventory-grid-item .item-icon {
  width: 40px;
  height: 40px;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
}

.inventory-grid-item:hover .item-icon {
  filter: drop-shadow(0 2px 4px rgba(106, 127, 168, 0.4)) brightness(1.1);
}

/* Item Details */
#item-details {
  margin-top: var(--space-md);
  padding-top: var(--space-md);
  border-top: 1px solid rgba(100, 100, 120, 0.15);
}

#item-details.hidden {
  display: none;
}

#item-detail-name {
  font-family: var(--font-narrative);
  font-size: 1.15rem;
  color: var(--text-primary);
  margin-bottom: var(--space-xs);
}

#item-detail-description {
  font-family: var(--font-ui);
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Item pickup animation */
@keyframes itemPickup {
  0% {
    transform: scale(0) rotate(-180deg);
    opacity: 0;
  }
  50% {
    transform: scale(1.3) rotate(10deg);
  }
  100% {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
}

.inventory-grid-item.new {
  animation: itemPickup 0.5s ease-out forwards;
}

/* === Pickup Notification === */
#pickup-notification {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  background: linear-gradient(135deg, rgba(30, 35, 50, 0.95) 0%, rgba(20, 22, 35, 0.98) 100%);
  border: 1px solid rgba(106, 127, 168, 0.4);
  border-radius: 12px;
  box-shadow:
    0 0 40px rgba(106, 127, 168, 0.3),
    0 0 80px rgba(106, 127, 168, 0.15),
    0 8px 32px rgba(0, 0, 0, 0.5);
  z-index: 1000;
  pointer-events: none;
  opacity: 0;
  animation: pickupNotificationIn 0.4s ease-out forwards;
}

#pickup-notification.hidden {
  display: none;
}

#pickup-notification.fade-out {
  animation: pickupNotificationOut 0.5s ease-in forwards;
}

#pickup-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: pickupIconPulse 0.6s ease-out;
}

#pickup-icon .item-icon {
  width: 48px;
  height: 48px;
  filter: drop-shadow(0 0 8px rgba(106, 127, 168, 0.6));
}

#pickup-text {
  font-family: var(--font-narrative);
  font-size: 1.2rem;
  color: var(--text-primary);
  text-shadow: 0 0 10px rgba(106, 127, 168, 0.5);
}

@keyframes pickupNotificationIn {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.8);
  }
  100% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

@keyframes pickupNotificationOut {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -60%) scale(0.9);
  }
}

@keyframes pickupIconPulse {
  0% {
    transform: scale(0);
  }
  50% {
    transform: scale(1.3);
  }
  100% {
    transform: scale(1);
  }
}

#scene-title {
  font-family: var(--font-narrative);
  font-size: 1.5rem;
  font-weight: 400;
  color: var(--text-secondary);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}


/* === Scene Container === */
#scene-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: var(--space-lg);
  padding-bottom: var(--space-md);
  pointer-events: none;
  overflow: hidden;
  min-height: 0; /* Allow flex item to shrink */
}

#scene-text {
  font-family: var(--font-narrative);
  font-size: 1.4rem;
  line-height: 1.8;
  color: var(--text-primary);
  max-width: 700px;
  margin: 0 auto;
  text-align: center;
  background: rgba(10, 10, 15, 0.3);
  padding: var(--space-xl) var(--space-lg);
  border-radius: 8px;
  pointer-events: auto;
  position: relative;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(100, 100, 120, 0.1);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
  /* Scrollable text area */
  overflow-y: auto;
  max-height: 100%;
  -webkit-overflow-scrolling: touch;
}

#scene-text:empty {
  display: none;
}

#scene-text p {
  margin-bottom: var(--space-md);
}

#scene-text p:last-child {
  margin-bottom: 0;
}

/* Custom scrollbar for scene text */
#scene-text::-webkit-scrollbar {
  width: 6px;
}

#scene-text::-webkit-scrollbar-track {
  background: transparent;
}

#scene-text::-webkit-scrollbar-thumb {
  background: rgba(100, 100, 120, 0.3);
  border-radius: 3px;
}

#scene-text::-webkit-scrollbar-thumb:hover {
  background: rgba(100, 100, 120, 0.5);
}

/* Typewriter effect */
#scene-text.typewriter {
  overflow: hidden;
}

#scene-text .typewriter-cursor {
  display: inline-block;
  width: 2px;
  height: 1.2em;
  background: var(--accent);
  margin-left: 2px;
  animation: blink 1s step-end infinite;
  vertical-align: text-bottom;
}

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

/* === Choices Container === */
#choices-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  padding-bottom: var(--space-lg);
  background: linear-gradient(0deg, rgba(10, 10, 15, 0.95) 0%, rgba(10, 10, 15, 0.8) 70%, rgba(10, 10, 15, 0) 100%);
  position: relative;
  flex-shrink: 0; /* Never shrink - always visible */
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.choice-btn {
  font-family: var(--font-ui);
  font-size: 1rem;
  color: var(--text-secondary);
  background: rgba(26, 26, 37, 0.7);
  border: 1px solid rgba(90, 90, 106, 0.4);
  padding: var(--space-md) var(--space-lg);
  min-width: 300px;
  max-width: 500px;
  cursor: pointer;
  transition: all var(--transition-medium);
  border-radius: 4px;
  text-align: center;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.choice-btn:hover {
  background: rgba(106, 127, 168, 0.15);
  border-color: var(--accent);
  color: var(--text-primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 20px var(--accent-glow);
}

.choice-btn:active {
  transform: translateY(0);
}

.choice-btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* === Scene Transition Overlay === */
.transition-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-dark);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
}

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

/* Scene text transition styles */
#scene-text {
  transition: opacity 0.4s ease-out, transform 0.4s ease-out;
}

#scene-title {
  transition: opacity 0.3s ease-out;
}

#choices-container {
  transition: opacity 0.4s ease-out;
}

/* Choice buttons entrance animation */
.choice-btn {
  opacity: 0;
  transform: translateY(10px);
  animation: choiceAppear 0.4s ease-out forwards;
}

.choice-btn:nth-child(1) { animation-delay: 0.1s; }
.choice-btn:nth-child(2) { animation-delay: 0.2s; }
.choice-btn:nth-child(3) { animation-delay: 0.3s; }
.choice-btn:nth-child(4) { animation-delay: 0.4s; }

@keyframes choiceAppear {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* === Dialogue Overlay === */
#dialogue-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 10, 15, 0.8);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  opacity: 1;
  transition: opacity var(--transition-medium);
}

#dialogue-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

#dialogue-box {
  background: var(--bg-medium);
  border: 1px solid var(--text-muted);
  border-radius: 8px;
  padding: var(--space-lg);
  max-width: 600px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

#dialogue-speaker {
  font-family: var(--font-ui);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: var(--space-sm);
}

#dialogue-text {
  font-family: var(--font-narrative);
  font-size: 1.25rem;
  line-height: 1.7;
  color: var(--text-primary);
  margin-bottom: var(--space-lg);
}

#dialogue-responses {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.dialogue-response-btn {
  font-family: var(--font-ui);
  font-size: 0.95rem;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid var(--text-muted);
  padding: var(--space-sm) var(--space-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  border-radius: 4px;
  text-align: left;
}

.dialogue-response-btn:hover {
  background: rgba(106, 127, 168, 0.1);
  border-color: var(--accent);
  color: var(--text-primary);
}

/* === Menu Overlay === */
#menu-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 10, 15, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 250;
  opacity: 1;
  transition: opacity var(--transition-medium);
}

#menu-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

#menu-box {
  text-align: center;
  background: rgba(18, 18, 26, 0.6);
  padding: var(--space-xl);
  border-radius: 12px;
  border: 1px solid rgba(100, 100, 120, 0.15);
}

#menu-box h2 {
  font-family: var(--font-narrative);
  font-size: 2rem;
  font-weight: 400;
  color: var(--text-primary);
  margin-bottom: var(--space-lg);
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

#menu-box button {
  display: block;
  width: 200px;
  margin: var(--space-sm) auto;
  font-family: var(--font-ui);
  font-size: 1rem;
  color: var(--text-secondary);
  background: rgba(26, 26, 37, 0.4);
  border: 1px solid rgba(90, 90, 106, 0.3);
  padding: var(--space-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  border-radius: 4px;
}

#menu-box button:hover {
  border-color: var(--accent);
  color: var(--text-primary);
  background: rgba(106, 127, 168, 0.1);
}

/* === Audio Controls === */
#audio-controls {
  margin-top: var(--space-lg);
  padding-top: var(--space-md);
  border-top: 1px solid var(--text-muted);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  justify-content: center;
}

#audio-controls label {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

#volume-slider {
  width: 100px;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--bg-light);
  border-radius: 2px;
  cursor: pointer;
}

#volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  transition: background var(--transition-fast);
}

#volume-slider::-webkit-slider-thumb:hover {
  background: var(--accent-hover);
}

#volume-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: var(--accent);
  border: none;
  border-radius: 50%;
  cursor: pointer;
}

#btn-mute {
  width: auto !important;
  min-width: 40px;
  padding: var(--space-sm) !important;
  font-size: 1.2rem;
  margin: 0 !important;
}

/* === Music Controls === */
#music-controls {
  margin-top: var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  justify-content: center;
}

#music-controls label {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

#music-volume-slider {
  width: 100px;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--bg-light);
  border-radius: 2px;
  cursor: pointer;
}

#music-volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  transition: background var(--transition-fast);
}

#music-volume-slider::-webkit-slider-thumb:hover {
  background: var(--accent-hover);
}

#music-volume-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: var(--accent);
  border: none;
  border-radius: 50%;
  cursor: pointer;
}

#btn-music-toggle {
  width: auto !important;
  min-width: 40px;
  padding: var(--space-sm) !important;
  font-size: 1.2rem;
  margin: 0 !important;
  position: relative;
}

#btn-music-toggle.muted {
  opacity: 0.6;
}

#btn-music-toggle.muted::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 15%;
  width: 70%;
  height: 2px;
  background: currentColor;
  transform: rotate(-45deg);
  transform-origin: center;
}

/* === Confirm Popup === */
#confirm-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 10, 15, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 350;
  opacity: 1;
  transition: opacity var(--transition-medium);
}

#confirm-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

#confirm-box {
  text-align: center;
  background: linear-gradient(
    135deg,
    rgba(18, 18, 26, 0.9) 0%,
    rgba(26, 26, 37, 0.85) 100%
  );
  padding: var(--space-xl) var(--space-xl) var(--space-lg);
  border-radius: 8px;
  border: 1px solid rgba(100, 100, 120, 0.2);
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.5),
    0 0 60px rgba(74, 96, 128, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.03);
  max-width: 400px;
  margin: var(--space-md);
  animation: confirmAppear 0.3s ease-out;
}

@keyframes confirmAppear {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(-10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

#confirm-message {
  font-family: var(--font-narrative);
  font-size: 1.15rem;
  color: var(--text-primary);
  line-height: 1.6;
  margin-bottom: var(--space-lg);
  letter-spacing: 0.02em;
}

#confirm-buttons {
  display: flex;
  gap: var(--space-md);
  justify-content: center;
}

#confirm-buttons button {
  font-family: var(--font-ui);
  font-size: 0.95rem;
  color: var(--text-secondary);
  background: rgba(26, 26, 37, 0.6);
  border: 1px solid rgba(90, 90, 106, 0.35);
  padding: var(--space-sm) var(--space-lg);
  min-width: 100px;
  cursor: pointer;
  transition: all var(--transition-fast);
  border-radius: 4px;
}

#confirm-buttons button:hover {
  border-color: var(--accent);
  color: var(--text-primary);
  background: rgba(74, 96, 128, 0.15);
}

#btn-confirm-yes {
  border-color: rgba(106, 127, 168, 0.4) !important;
}

#btn-confirm-yes:hover {
  border-color: var(--accent) !important;
  box-shadow: 0 0 12px rgba(106, 127, 168, 0.2);
}

/* === Alert Popup === */
#alert-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 10, 15, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 350;
  opacity: 1;
  transition: opacity var(--transition-medium);
}

#alert-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

#alert-box {
  text-align: center;
  background: linear-gradient(
    135deg,
    rgba(18, 18, 26, 0.9) 0%,
    rgba(26, 26, 37, 0.85) 100%
  );
  padding: var(--space-xl) var(--space-xl) var(--space-lg);
  border-radius: 8px;
  border: 1px solid rgba(100, 100, 120, 0.2);
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.5),
    0 0 60px rgba(74, 96, 128, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.03);
  max-width: 400px;
  margin: var(--space-md);
  animation: confirmAppear 0.3s ease-out;
}

#alert-message {
  font-family: var(--font-narrative);
  font-size: 1.15rem;
  color: var(--text-primary);
  line-height: 1.6;
  margin-bottom: var(--space-lg);
  letter-spacing: 0.02em;
}

#btn-alert-ok {
  font-family: var(--font-ui);
  font-size: 0.95rem;
  color: var(--text-secondary);
  background: rgba(26, 26, 37, 0.6);
  border: 1px solid rgba(106, 127, 168, 0.4);
  padding: var(--space-sm) var(--space-lg);
  min-width: 100px;
  cursor: pointer;
  transition: all var(--transition-fast);
  border-radius: 4px;
}

#btn-alert-ok:hover {
  border-color: var(--accent);
  color: var(--text-primary);
  background: rgba(74, 96, 128, 0.15);
  box-shadow: 0 0 12px rgba(106, 127, 168, 0.2);
}

/* === Title Screen === */
#title-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: transparent;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 300;
  opacity: 1;
  transition: opacity 1s ease;
}

/* Background image layer - same opacity as scene backgrounds */
#title-screen::before {
  content: '';
  position: absolute;
  top: -5%;
  left: -5%;
  width: 110%;
  height: 110%;
  background: url('../assets/images/main_screen.webp') center/cover no-repeat;
  z-index: -2;
  opacity: 0;
  animation: fadeInBackground 2s ease-out 0.5s forwards, slowPanZoom 25s ease-in-out 2.5s infinite alternate, shakeAmbient 4s ease-in-out infinite;
}

@keyframes slowPanZoom {
  0% {
    transform: scale(1) translate(0, 0);
  }
  100% {
    transform: scale(1.08) translate(-1.5%, -1%);
  }
}

/* Shake effect */
@keyframes shake {
  0%, 100% { transform: translate(0, 0); }
  10% { transform: translate(-2px, -1px); }
  20% { transform: translate(2px, 1px); }
  30% { transform: translate(-1px, 2px); }
  40% { transform: translate(1px, -1px); }
  50% { transform: translate(-2px, 1px); }
  60% { transform: translate(2px, -2px); }
  70% { transform: translate(-1px, -1px); }
  80% { transform: translate(1px, 2px); }
  90% { transform: translate(-2px, -2px); }
}

.shake {
  animation: shake 0.5s ease-in-out;
}

.shake-subtle {
  animation: shake 0.8s ease-in-out;
  --shake-intensity: 0.5;
}

.shake-intense {
  animation: shake 0.3s ease-in-out;
}

/* Continuous subtle shake for atmosphere */
.shake-ambient {
  animation: shakeAmbient 4s ease-in-out infinite;
}

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

/* Blur to sharp effect */
.blur-to-sharp {
  animation: blurToSharp 1.5s ease-out forwards;
}

@keyframes blurToSharp {
  0% {
    filter: blur(8px);
    opacity: 0.3;
  }
  50% {
    filter: blur(3px);
    opacity: 0.7;
  }
  100% {
    filter: blur(0);
    opacity: 1;
  }
}

@keyframes fadeInBackground {
  to {
    opacity: 0.4;
  }
}

#title-screen.hidden::before {
  animation: fadeOutBackground 1s ease forwards;
}

@keyframes fadeOutBackground {
  from {
    opacity: 0.4;
  }
  to {
    opacity: 0;
  }
}

/* Vignette overlay - same as scene backgrounds */
#title-screen::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(
    ellipse at center,
    transparent 0%,
    transparent 20%,
    rgba(10, 10, 15, 0.5) 50%,
    rgba(10, 10, 15, 0.85) 80%,
    rgba(10, 10, 15, 0.95) 100%
  );
  z-index: -1;
  pointer-events: none;
}

#title-screen.hidden {
  opacity: 0;
  pointer-events: none;
}

/* Hide header buttons when on title screen */
#header-buttons {
  transition: opacity var(--transition-medium);
}

#header-buttons.hidden-on-title {
  opacity: 0;
  pointer-events: none;
}

#title-content {
  text-align: center;
}

.game-chapter {
  font-family: var(--font-narrative);
  font-size: 1.25rem;
  font-weight: 400;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.25em;
  margin-top: var(--space-lg);
  margin-bottom: var(--space-xl);
  text-shadow: 0 0 20px var(--accent-glow), 0 2px 10px rgba(0, 0, 0, 0.8);
}

#game-footer {
  position: fixed;
  bottom: var(--space-sm);
  left: var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  font-family: var(--font-ui);
  font-size: 0.7rem;
  color: var(--text-secondary);
  opacity: 0.6;
  z-index: 350;
  pointer-events: auto;
  letter-spacing: 0.02em;
}

/* Hide main footer on mobile during game (shown in menu instead) */
@media (max-width: 768px) {
  #game-footer.game-active {
    display: none;
  }

  /* Center footer on mobile */
  #game-footer {
    left: 0;
    right: 0;
    justify-content: center;
  }
}

#game-footer a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

#game-footer a:hover {
  color: var(--accent);
}

#game-footer .deploy-time {
  color: var(--text-muted);
  opacity: 0.8;
}

/* Menu footer styling */
#menu-footer {
  margin-top: var(--space-lg);
  padding-top: var(--space-md);
  border-top: 1px solid rgba(100, 100, 120, 0.15);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
  font-family: var(--font-ui);
  font-size: 0.75rem;
  color: var(--text-muted);
  opacity: 0.7;
}

#menu-footer a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

#menu-footer a:hover {
  color: var(--accent);
}

#menu-footer .deploy-time {
  color: var(--text-muted);
  font-size: 0.7rem;
}

.game-title {
  font-family: var(--font-narrative);
  font-size: 5rem;
  font-weight: 400;
  color: var(--text-primary);
  letter-spacing: 0.3em;
  margin-bottom: var(--space-md);
  text-shadow:
    0 0 10px rgba(255, 255, 255, 0.8),
    0 0 30px var(--accent-glow),
    0 0 60px var(--accent-glow),
    0 0 100px var(--accent-glow);
  animation: titlePulse 4s ease-in-out infinite, glitch 8s ease-in-out infinite;
  position: relative;
}

.game-title::before,
.game-title::after {
  content: attr(data-text);
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  letter-spacing: 0.3em;
}

.game-title::before {
  color: #ff0040;
  animation: glitchTop 8s ease-in-out infinite;
  clip-path: polygon(0 0, 100% 0, 100% 33%, 0 33%);
  -webkit-clip-path: polygon(0 0, 100% 0, 100% 33%, 0 33%);
}

.game-title::after {
  color: #00fff9;
  animation: glitchBottom 8s ease-in-out infinite;
  clip-path: polygon(0 67%, 100% 67%, 100% 100%, 0 100%);
  -webkit-clip-path: polygon(0 67%, 100% 67%, 100% 100%, 0 100%);
}

@keyframes glitch {
  0%, 90%, 100% {
    transform: translate(0);
  }
  92% {
    transform: translate(-2px, 1px);
  }
  94% {
    transform: translate(2px, -1px);
  }
  96% {
    transform: translate(-1px, -1px);
  }
  98% {
    transform: translate(1px, 1px);
  }
}

@keyframes glitchTop {
  0%, 90%, 100% {
    transform: translate(0);
    opacity: 0;
  }
  92% {
    transform: translate(-3px, -1px);
    opacity: 0.8;
  }
  94% {
    transform: translate(3px, 1px);
    opacity: 0.6;
  }
  96% {
    transform: translate(-2px, 0);
    opacity: 0.8;
  }
  98% {
    transform: translate(0);
    opacity: 0;
  }
}

@keyframes glitchBottom {
  0%, 90%, 100% {
    transform: translate(0);
    opacity: 0;
  }
  91% {
    transform: translate(3px, 1px);
    opacity: 0.8;
  }
  93% {
    transform: translate(-3px, -1px);
    opacity: 0.6;
  }
  95% {
    transform: translate(2px, 0);
    opacity: 0.8;
  }
  97% {
    transform: translate(-1px, 1px);
    opacity: 0.6;
  }
  99% {
    transform: translate(0);
    opacity: 0;
  }
}

@keyframes titlePulse {
  0%, 100% {
    text-shadow:
      0 0 10px rgba(255, 255, 255, 0.8),
      0 0 30px var(--accent-glow),
      0 0 60px var(--accent-glow),
      0 0 100px var(--accent-glow);
    opacity: 1;
  }
  50% {
    text-shadow:
      0 0 15px rgba(255, 255, 255, 1),
      0 0 40px var(--accent-glow),
      0 0 80px var(--accent-glow),
      0 0 140px var(--accent-glow),
      0 0 200px var(--accent-glow);
    opacity: 0.95;
  }
}

.game-subtitle {
  font-family: var(--font-narrative);
  font-size: 1.75rem;
  font-style: italic;
  color: var(--text-secondary);
  margin-bottom: var(--space-xl);
  letter-spacing: 0.15em;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8);
}

#btn-start {
  font-family: var(--font-ui);
  font-size: 1.1rem;
  color: var(--text-secondary);
  background: rgba(106, 127, 168, 0.08);
  border: 1px solid var(--accent);
  padding: var(--space-md) calc(var(--space-xl) * 1.5);
  cursor: pointer;
  transition: all var(--transition-medium);
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
}

#btn-start:hover {
  border-color: var(--accent-hover);
  color: var(--text-primary);
  background: rgba(106, 127, 168, 0.15);
  box-shadow: 0 0 20px var(--accent-glow);
}

/* === Utility Classes === */
.hidden {
  display: none !important;
}

.fade-in {
  animation: fadeIn var(--transition-slow) ease forwards;
}

.fade-out {
  animation: fadeOut var(--transition-slow) ease forwards;
}

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

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

/* === Stairwell Light Blink Effect === */
#light-blink-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #000;
  z-index: 120; /* Above fog (100) but below UI layer (150) - only affects background */
  pointer-events: none;
  opacity: 0;
}

#light-blink-overlay.blinking {
  animation: lightBlink 3.5s ease-in-out forwards;
}

#light-blink-overlay.blinking-repeat {
  animation: lightBlinkRepeat 4s ease-in-out infinite;
}

@keyframes lightBlinkRepeat {
  /* Light on */
  0% {
    opacity: 0;
  }
  /* Light goes out */
  10% {
    opacity: 0.85;
  }
  /* Stays dark */
  20% {
    opacity: 0.85;
  }
  /* Flickers */
  25% {
    opacity: 0.3;
  }
  30% {
    opacity: 0.9;
  }
  35% {
    opacity: 0.2;
  }
  40% {
    opacity: 0.85;
  }
  /* Light comes back */
  55% {
    opacity: 0.4;
  }
  70% {
    opacity: 0;
  }
  /* Stay on for a bit before repeating */
  100% {
    opacity: 0;
  }
}

@keyframes lightBlink {
  /* Light on initially */
  0% {
    opacity: 0;
  }
  /* Light goes out */
  8% {
    opacity: 0.85;
  }
  /* Stays dark */
  20% {
    opacity: 0.85;
  }
  /* Flickers - first blink */
  24% {
    opacity: 0.3;
  }
  28% {
    opacity: 0.9;
  }
  /* Second blink */
  32% {
    opacity: 0.2;
  }
  36% {
    opacity: 0.85;
  }
  /* Third quick blink */
  40% {
    opacity: 0.4;
  }
  44% {
    opacity: 0.9;
  }
  /* Fourth blink - longer dark */
  50% {
    opacity: 0.1;
  }
  58% {
    opacity: 0.85;
  }
  /* Light slowly comes back on */
  70% {
    opacity: 0.5;
  }
  85% {
    opacity: 0.2;
  }
  100% {
    opacity: 0;
  }
}

/* === Responsive === */
@media (max-width: 768px) {
  .game-title {
    font-size: 3rem;
    letter-spacing: 0.2em;
  }

  .game-subtitle {
    font-size: 1rem;
  }

  #scene-text {
    font-size: 1.2rem;
    padding: var(--space-lg) var(--space-md);
  }

  .choice-btn {
    min-width: 250px;
    font-size: 0.95rem;
  }
}

@media (max-width: 480px) {
  .game-title {
    font-size: 2.5rem;
  }

  #scene-text {
    font-size: 1.1rem;
  }

  .choice-btn {
    min-width: 200px;
    width: 100%;
  }
}

/* === Mobile Safe Area (for notched devices and browser chrome) === */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  #choices-container {
    padding-bottom: calc(var(--space-lg) + env(safe-area-inset-bottom));
  }

  #title-screen {
    padding-bottom: env(safe-area-inset-bottom);
  }

  #menu-overlay,
  #dialogue-overlay,
  #inventory-overlay,
  #confirm-overlay {
    padding-bottom: env(safe-area-inset-bottom);
  }
}
