/* 3D Horror Game: Kanchanaburi Chronicles Stylesheet */

:root {
  --font-thai: 'Kanit', sans-serif;
  --font-eng: 'Outfit', sans-serif;
  --color-bg: #03080f;
  --color-primary: #00ffd2;
  --color-accent: #ff2e63;
  --color-text: #e2e8f0;
  --color-glass: rgba(5, 12, 24, 0.7);
  --color-border: rgba(0, 255, 210, 0.2);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--color-bg);
  font-family: var(--font-eng);
  color: var(--color-text);
}

#gameCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

/* Atmospheric Vignette and Overlays */
#vignette {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle, transparent 30%, rgba(2, 6, 12, 0.85) 70%, rgba(0, 0, 0, 0.98) 100%);
  pointer-events: none;
  z-index: 2;
  transition: background 0.3s ease;
}

#vignette.panic {
  background: radial-gradient(circle, transparent 20%, rgba(120, 0, 20, 0.6) 65%, rgba(0, 0, 0, 0.98) 100%);
}

#vignette.suffocating {
  background: radial-gradient(circle, transparent 10%, rgba(10, 30, 60, 0.7) 60%, rgba(0, 0, 0, 1) 100%);
}

#flashOverlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: #fff;
  opacity: 0;
  pointer-events: none;
  z-index: 5;
}

#glitchOverlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: repeating-linear-gradient(0deg, rgba(0, 255, 210, 0.05) 0px, rgba(0, 255, 210, 0.05) 1px, transparent 1px, transparent 2px);
  pointer-events: none;
  z-index: 4;
  opacity: 0;
}

#glitchOverlay.active {
  animation: glitch-anim 0.15s infinite;
  background-color: rgba(255, 0, 0, 0.15);
  opacity: 1;
}

/* UI Container & Screens */
#uiContainer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 3;
  pointer-events: none;
}

.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background-color: rgba(3, 8, 15, 0.9);
  pointer-events: auto;
  opacity: 1;
  transition: opacity 1s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* 1. Main Menu */
#mainMenu {
  background: linear-gradient(135deg, rgba(2, 6, 12, 0.95), rgba(7, 18, 32, 0.95));
}

#mainMenu::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at center, transparent 40%, rgba(2, 6, 12, 1) 100%);
  pointer-events: none;
}

.menu-content {
  text-align: center;
  z-index: 10;
  max-width: 600px;
  padding: 2rem;
}

.game-title {
  font-family: var(--font-eng);
  font-size: 3.5rem;
  font-weight: 800;
  letter-spacing: 6px;
  line-height: 1.1;
  text-shadow: 0 0 10px rgba(0, 255, 210, 0.3), 0 0 30px rgba(0, 255, 210, 0.1);
  margin-bottom: 0.5rem;
}

.game-title .accent {
  color: var(--color-primary);
  text-shadow: 0 0 15px rgba(0, 255, 210, 0.6);
}

.game-subtitle {
  font-family: var(--font-thai);
  font-size: 1.5rem;
  font-weight: 300;
  letter-spacing: 4px;
  color: #718096;
  margin-bottom: 3.5rem;
}

.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  align-items: center;
}

.btn {
  font-family: var(--font-eng);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 2px;
  color: #000;
  background-color: var(--color-primary);
  border: none;
  padding: 1rem 3rem;
  cursor: pointer;
  border-radius: 4px;
  box-shadow: 0 0 15px rgba(0, 255, 210, 0.4);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  min-width: 250px;
}

.btn:hover {
  background-color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 0 25px rgba(0, 255, 210, 0.8);
}

.btn.secondary {
  color: var(--color-primary);
  background-color: transparent;
  border: 1px solid var(--color-border);
  box-shadow: none;
}

.btn.secondary:hover {
  background-color: rgba(0, 255, 210, 0.08);
  border-color: var(--color-primary);
  color: #fff;
}

.menu-footer {
  position: absolute;
  bottom: 2rem;
  color: #4a5568;
  font-size: 0.85rem;
  letter-spacing: 1px;
  z-index: 10;
}

/* Modals */
.modal {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(2, 6, 12, 0.95);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 20;
  pointer-events: auto;
  opacity: 1;
  transition: opacity 0.5s ease;
}

.modal.hidden {
  opacity: 0;
  pointer-events: none;
}

.modal-content {
  background: var(--color-glass);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 3rem;
  max-width: 500px;
  width: 90%;
  backdrop-filter: blur(12px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.modal-content h2 {
  font-family: var(--font-thai);
  font-weight: 600;
  color: var(--color-primary);
  letter-spacing: 2px;
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 0.8rem;
}

.setting-row {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.setting-row label {
  font-size: 0.95rem;
  color: #a0aec0;
}

.setting-row input[type="range"] {
  accent-color: var(--color-primary);
  background-color: #1a202c;
  height: 6px;
  border-radius: 3px;
  outline: none;
}

.setting-row span {
  text-align: right;
  font-size: 0.85rem;
  color: var(--color-primary);
}

.credits-text {
  line-height: 1.8;
  font-size: 0.95rem;
  color: #a0aec0;
}

/* Chapter Intro */
#chapterIntro {
  background-color: rgba(0, 0, 0, 1);
}

.intro-content {
  text-align: center;
  max-width: 700px;
  padding: 2rem;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.intro-chapter {
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: 4px;
  color: var(--color-primary);
}

.intro-title {
  font-size: 2.8rem;
  font-weight: 800;
  letter-spacing: 2px;
}

.intro-lore {
  font-size: 1.1rem;
  color: #a0aec0;
  line-height: 1.6;
  max-width: 600px;
}

.click-to-continue {
  margin-top: 3rem;
  cursor: pointer;
}

.pulse-text {
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 3px;
  color: var(--color-primary);
  animation: pulse-glow 1.5s infinite alternate;
}

/* In-Game HUD */
#hud {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 3;
}

#hud.hidden {
  display: none !important;
}

/* Crosshair */
#crosshair {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 6px;
  height: 6px;
  background-color: rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  z-index: 10;
}

/* Dialogue / Subtitles */
#subtitles {
  position: absolute;
  bottom: 12%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(2, 6, 12, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 0.8rem 2rem;
  border-radius: 4px;
  font-family: var(--font-thai);
  font-size: 1.1rem;
  max-width: 70%,
  text-align: center;
  color: #fff;
  z-index: 10;
  backdrop-filter: blur(8px);
  pointer-events: none;
  animation: fade-in-up 0.3s ease;
}

#subtitles.hidden {
  display: none;
}

/* Action Prompt */
#actionPrompt {
  position: absolute;
  top: 60%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--color-glass);
  border: 1px solid var(--color-border);
  padding: 0.5rem 1.2rem;
  border-radius: 4px;
  font-size: 0.9rem;
  letter-spacing: 1px;
  color: var(--color-primary);
  z-index: 10;
  backdrop-filter: blur(5px);
  box-shadow: 0 0 10px rgba(0, 255, 210, 0.2);
}

#actionPrompt.hidden {
  display: none;
}

/* HUD Objective Panel */
.hud-objective-box {
  position: absolute;
  top: 2rem;
  left: 2rem;
  background: var(--color-glass);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 0.8rem 1.5rem;
  backdrop-filter: blur(8px);
  width: 280px;
}

.hud-label {
  font-size: 0.7rem;
  letter-spacing: 2px;
  color: #718096;
  font-weight: 600;
  margin-bottom: 0.2rem;
}

#hudObjectiveText {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

#hudCounterText {
  font-size: 0.85rem;
  font-weight: 800;
}

/* HUD Bars (Stamina / Breath) */
.hud-status-box {
  position: absolute;
  bottom: 2rem;
  left: 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  width: 220px;
}

.status-bar-container {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--color-glass);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 0.4rem 0.8rem;
  backdrop-filter: blur(8px);
}

.bar-icon {
  font-size: 0.9rem;
  width: 15px;
  text-align: center;
}

.bar-bg {
  flex-grow: 1;
  height: 8px;
  background-color: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  width: 100%;
  transition: width 0.1s ease;
}

.bar-fill.stamina {
  background-color: var(--color-primary);
  box-shadow: 0 0 10px rgba(0, 255, 210, 0.5);
}

.bar-fill.breath {
  background-color: #3182ce;
  box-shadow: 0 0 10px rgba(49, 130, 206, 0.5);
}

/* Flashlight, Crouch & Minimap */
.hud-tool-box {
  position: absolute;
  bottom: 2rem;
  right: 2rem;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.8rem;
}

#minimapContainer {
  width: 130px;
  height: 130px;
  border-radius: 50%;
  border: 1px solid var(--color-border);
  background: var(--color-glass);
  backdrop-filter: blur(8px);
  overflow: hidden;
  box-shadow: 0 0 15px rgba(0, 255, 210, 0.15);
  margin-bottom: 0.2rem;
  pointer-events: auto;
}

#minimap {
  display: block;
}

.crouch-icon {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  border-radius: 4px;
  padding: 0.3rem 0.8rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 2px;
  backdrop-filter: blur(8px);
  animation: breathe 1.5s ease-in-out infinite;
}

.crouch-icon.hidden {
  display: none;
}

.flashlight-battery {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--color-glass);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 0.4rem 0.8rem;
  backdrop-filter: blur(8px);
  width: 180px;
}

.battery-bg {
  flex-grow: 1;
  height: 8px;
  background-color: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
  overflow: hidden;
}

.battery-fill {
  height: 100%;
  width: 100%;
  background-color: var(--color-primary);
  box-shadow: 0 0 8px rgba(0, 255, 210, 0.4);
  transition: width 0.2s ease, background-color 0.2s ease;
}

.battery-fill.warning {
  background-color: var(--color-accent);
  box-shadow: 0 0 8px rgba(255, 46, 99, 0.6);
}

#batteryPercent {
  font-size: 0.8rem;
  font-weight: 600;
  min-width: 32px;
  text-align: right;
}

/* Death Screen */
#deathScreen {
  background-color: rgba(10, 2, 2, 0.95);
  z-index: 50;
}

.death-title {
  font-size: 3.5rem;
  font-weight: 800;
  letter-spacing: 4px;
  color: var(--color-accent);
  text-shadow: 0 0 15px rgba(255, 46, 99, 0.5);
  margin-bottom: 1rem;
  animation: shake 0.5s ease infinite alternate;
}

.death-subtitle {
  font-size: 1.1rem;
  color: #718096;
  margin-bottom: 3rem;
}

#deathScreen .btn {
  background-color: var(--color-accent);
  box-shadow: 0 0 15px rgba(255, 46, 99, 0.4);
  color: #fff;
}

#deathScreen .btn:hover {
  background-color: #fff;
  color: #000;
  box-shadow: 0 0 25px rgba(255, 46, 99, 0.8);
}

/* Ending Screen */
#endingScreen {
  background: linear-gradient(180deg, #02060c 0%, #0d1b2a 50%, #90e0ef 100%);
  z-index: 100;
}

.ending-title {
  font-size: 4rem;
  font-weight: 800;
  letter-spacing: 10px;
  text-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
}

.ending-text {
  font-size: 1.2rem;
  line-height: 1.8;
  max-width: 650px;
}

.ending-thai {
  font-family: var(--font-thai);
  font-size: 1.6rem;
  color: var(--color-primary);
  letter-spacing: 4px;
  text-shadow: 0 0 10px rgba(0, 255, 210, 0.5);
  margin-top: 1rem;
}

/* Animations */
@keyframes pulse-glow {
  0% {
    opacity: 0.3;
    text-shadow: 0 0 5px rgba(0, 255, 210, 0.2);
  }
  100% {
    opacity: 1;
    text-shadow: 0 0 15px rgba(0, 255, 210, 0.8);
  }
}

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

@keyframes fade-in-up {
  from {
    opacity: 0;
    transform: translate(-50%, 10px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

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

@keyframes glitch-anim {
  0% {
    clip-path: inset(10% 0 85% 0);
    transform: skew(1deg);
  }
  10% {
    clip-path: inset(80% 0 1% 0);
    transform: skew(-2deg);
  }
  20% {
    clip-path: inset(5% 0 50% 0);
    transform: skew(3deg);
  }
  30% {
    clip-path: inset(90% 0 5% 0);
    transform: skew(-1deg);
  }
  40% {
    clip-path: inset(20% 0 60% 0);
    transform: skew(2deg);
  }
  50% {
    clip-path: inset(60% 0 35% 0);
    transform: skew(-3deg);
  }
  60% {
    clip-path: inset(15% 0 75% 0);
    transform: skew(4deg);
  }
  70% {
    clip-path: inset(75% 0 10% 0);
    transform: skew(-2deg);
  }
  80% {
    clip-path: inset(5% 0 45% 0);
    transform: skew(1deg);
  }
  90% {
    clip-path: inset(85% 0 5% 0);
    transform: skew(-1deg);
  }
  100% {
    clip-path: inset(0% 0 95% 0);
    transform: skew(2deg);
  }
}

.lang-toggle-btn {
  position: absolute;
  top: 2rem;
  right: 2rem;
  z-index: 50;
  background: var(--color-glass);
  border: 1px solid var(--color-border);
  color: var(--color-primary);
  padding: 0.6rem 1.4rem;
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--font-eng);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 1.5px;
  backdrop-filter: blur(8px);
  box-shadow: 0 0 10px rgba(0, 255, 210, 0.15);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: auto;
}

.lang-toggle-btn:hover {
  background: var(--color-primary);
  color: #000;
  box-shadow: 0 0 20px rgba(0, 255, 210, 0.6);
  transform: translateY(-1px);
}

.chapter-select-box {
  margin-top: 2.5rem;
  padding: 1.2rem;
  border: 1px dashed var(--color-border);
  border-radius: 4px;
  background: rgba(0, 255, 210, 0.03);
}

.chapter-select-label {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 2px;
  color: var(--color-primary);
  margin-bottom: 0.8rem;
  text-transform: uppercase;
}

.chapter-buttons {
  display: flex;
  justify-content: center;
  gap: 0.8rem;
}

.btn-chapter {
  font-family: var(--font-eng);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-primary);
  background: transparent;
  border: 1px solid var(--color-border);
  padding: 0.5rem 1.2rem;
  cursor: pointer;
  border-radius: 3px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  min-width: 60px;
  pointer-events: auto;
}

.btn-chapter:hover {
  background: var(--color-primary);
  color: #000;
  box-shadow: 0 0 12px rgba(0, 255, 210, 0.5);
  transform: translateY(-1px);
}

.chapter-preview-container {
  margin-top: 1.2rem;
  padding: 1rem;
  background: rgba(5, 12, 24, 0.5);
  border: 1px solid rgba(0, 255, 210, 0.1);
  border-radius: 4px;
  min-height: 85px;
  display: flex;
  justify-content: center;
  align-items: center;
  backdrop-filter: blur(4px);
  transition: all 0.3s ease;
}

.chapter-preview-text {
  font-family: var(--font-thai);
  font-size: 0.85rem;
  line-height: 1.5;
  color: #a0aec0;
  text-align: center;
  margin: 0;
  max-width: 500px;
}
