/* VEILFALL - Core Style Sheet */
:root {
  --bg-color: #080b0e;
  --panel-bg: rgba(14, 20, 26, 0.92);
  --panel-border: #2c3a47;
  --text-primary: #e6edf3;
  --text-muted: #8b9bb4;
  --accent-teal: #38bdf8;
  --accent-cyan: #06b6d4;
  --accent-amber: #f59e0b;
  --accent-violet: #a855f7;
  --accent-red: #ef4444;
  --font-main: 'Cinzel', 'Trajan Pro', 'Palatino Linotype', 'Book Antiqua', Georgia, serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  margin: 0;
  padding: 0;
  background-color: var(--bg-color);
  color: var(--text-primary);
  font-family: var(--font-main);
}

#game-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background-color: #05080c;
}

canvas#game-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  background-color: #05080c;
  outline: none;
  image-rendering: auto;
}

/* Screen Overlay Container */
#ui-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  display: flex;
  flex-direction: column;
}

/* In-game Responsive HUD (Top-Left) */
#hud {
  position: absolute;
  top: clamp(16px, 2.5vh, 32px);
  left: clamp(16px, 2.5vw, 36px);
  display: flex;
  flex-direction: column;
  gap: clamp(10px, 1.4vh, 16px);
  pointer-events: none;
  z-index: 20;
  transition: opacity 0.3s ease;
}

/* Minimap HUD Card (Top-Right) */
#minimap-hud {
  position: absolute;
  top: clamp(16px, 2.5vh, 32px);
  right: clamp(16px, 2.5vw, 36px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
  z-index: 20;
  background: rgba(15, 23, 42, 0.82);
  border: 1px solid rgba(56, 189, 248, 0.5);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.8), 0 0 16px rgba(56, 189, 248, 0.18);
  padding: clamp(6px, 0.8vw, 10px) clamp(8px, 1vw, 14px);
  border-radius: 8px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: opacity 0.3s ease;
}

#minimap-canvas {
  width: clamp(120px, 11vw, 180px);
  height: clamp(80px, 7.5vw, 120px);
  background: #06090f;
  border: 1px solid rgba(71, 85, 105, 0.7);
  border-radius: 4px;
  display: block;
}

#minimap-region-name {
  font-family: var(--font-main);
  font-size: 10px;
  letter-spacing: 2px;
  color: #94a3b8;
  text-transform: uppercase;
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
}

.hud-top-row {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Health Masks Container */
.health-container {
  display: flex;
  gap: 8px;
  align-items: center;
}

.mask-pip {
  width: clamp(28px, 2.4vw, 38px);
  height: clamp(34px, 3.0vw, 48px);
  position: relative;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.7));
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s ease;
}

.mask-pip.active svg path {
  fill: #f1f5f9;
  stroke: #94a3b8;
  filter: drop-shadow(0 0 8px rgba(226, 232, 240, 0.85));
}

.mask-pip.empty svg path {
  fill: #1e293b;
  stroke: #475569;
  opacity: 0.45;
}

.mask-pip.damaged {
  animation: pip-shake 0.35s ease;
}

@keyframes pip-shake {
  0% { transform: scale(1.3) rotate(-8deg); }
  50% { transform: scale(0.9) rotate(8deg); }
  100% { transform: scale(1) rotate(0deg); }
}

/* Energy Vessel */
.energy-meter-wrapper {
  position: relative;
  width: clamp(150px, 14vw, 240px);
  height: clamp(20px, 2.2vh, 26px);
  background: rgba(15, 23, 42, 0.88);
  border: 2px solid #334155;
  border-radius: 13px;
  overflow: hidden;
  box-shadow: 0 0 14px rgba(0,0,0,0.6), inset 0 0 8px rgba(0,0,0,0.8);
}

.energy-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #0284c7 0%, #38bdf8 70%, #bae6fd 100%);
  border-radius: 11px;
  transition: width 0.15s ease-out;
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.8);
}

.energy-label {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: clamp(11px, 1.1vw, 13px);
  letter-spacing: 1.5px;
  font-family: var(--font-sans);
  color: #e2e8f0;
  text-shadow: 0 1px 3px #000;
  font-weight: 600;
}

/* Ability Badges */
.ability-badges {
  display: flex;
  gap: clamp(8px, 1vw, 14px);
  margin-top: 4px;
}

.ability-badge {
  width: clamp(34px, 2.8vw, 44px);
  height: clamp(34px, 2.8vw, 44px);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid #334155;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.3;
  transition: opacity 0.3s ease, border-color 0.3s ease, transform 0.2s ease, box-shadow 0.3s ease;
}

.ability-badge.unlocked {
  opacity: 0.55;
  border-color: #38bdf8;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.35);
}

.ability-badge.unlocked.charged {
  opacity: 1;
  border-color: #38bdf8;
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.75);
  animation: badge-glow-pulse 2.2s infinite ease-in-out;
}

@keyframes badge-glow-pulse {
  0%, 100% { box-shadow: 0 0 8px rgba(56, 189, 248, 0.45); transform: scale(1); }
  50% { box-shadow: 0 0 18px rgba(56, 189, 248, 0.95); transform: scale(1.05); }
}

.ability-badge svg {
  width: clamp(18px, 1.6vw, 24px);
  height: clamp(18px, 1.6vw, 24px);
  fill: #cbd5e1;
}

/* Region Title Banner */
#region-banner {
  position: absolute;
  top: 15%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  opacity: 0;
  transition: opacity 1s cubic-bezier(0.16, 1, 0.3, 1), transform 1s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
  z-index: 15;
}

#region-banner.show {
  opacity: 1;
  transform: translate(-50%, -40%);
}

#region-banner h2 {
  font-size: 28px;
  letter-spacing: 6px;
  text-transform: uppercase;
  color: #f8fafc;
  text-shadow: 0 0 18px rgba(56, 189, 248, 0.8), 0 4px 12px rgba(0,0,0,0.9);
}

#region-banner p {
  font-family: var(--font-sans);
  font-size: 13px;
  letter-spacing: 3px;
  color: #94a3b8;
  margin-top: 4px;
}

/* Boss Health Bar */
#boss-hud {
  position: absolute;
  bottom: 36px;
  left: 50%;
  transform: translateX(-50%);
  width: 60%;
  max-width: 640px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  opacity: 0;
  transition: opacity 0.6s ease;
  pointer-events: none;
  z-index: 25;
}

#boss-hud.show {
  opacity: 1;
}

.boss-name {
  font-size: 18px;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: #f1f5f9;
  text-shadow: 0 2px 8px rgba(0,0,0,0.8);
}

.boss-bar-frame {
  width: 100%;
  height: 14px;
  background: rgba(15, 23, 42, 0.9);
  border: 2px solid #64748b;
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  box-shadow: 0 0 16px rgba(0,0,0,0.8);
}

.boss-bar-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #991b1b, #ef4444, #f87171);
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.8);
  transition: width 0.1s linear;
}

/* Prompt Notification */
#prompt-toast {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.88);
  border: 1px solid #38bdf8;
  padding: 8px 20px;
  border-radius: 20px;
  color: #f8fafc;
  font-size: 14px;
  letter-spacing: 1.5px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.6), 0 0 10px rgba(56, 189, 248, 0.3);
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
  z-index: 30;
}

#prompt-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(-6px);
}

/* Modal Menus */
.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(5, 8, 12, 0.85);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  justify-content: center;
  align-items: center;
  pointer-events: auto;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  z-index: 100;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-box {
  background: var(--panel-bg);
  border: 2px solid var(--panel-border);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.9), 0 0 20px rgba(56, 189, 248, 0.2);
  border-radius: 8px;
  padding: 32px 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 380px;
  max-width: 85%;
  max-height: 85vh;
  overflow-y: auto;
  text-align: center;
  position: relative;
}

.modal-box::-webkit-scrollbar {
  width: 6px;
}

.modal-box::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.6);
  border-radius: 4px;
}

.modal-box::-webkit-scrollbar-thumb {
  background: #334155;
  border-radius: 4px;
}

.modal-box::-webkit-scrollbar-thumb:hover {
  background: #38bdf8;
}

.modal-title {
  font-size: 32px;
  letter-spacing: 5px;
  color: #f8fafc;
  margin-bottom: 24px;
  text-shadow: 0 0 12px rgba(56, 189, 248, 0.6);
  text-transform: uppercase;
}

.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  margin-top: 10px;
}

.btn-game {
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid #475569;
  color: #e2e8f0;
  font-family: var(--font-main);
  font-size: 16px;
  letter-spacing: 3px;
  padding: 12px 28px;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
  text-transform: uppercase;
  outline: none;
}

.btn-game:hover, .btn-game:focus {
  background: rgba(56, 189, 248, 0.25);
  border-color: #38bdf8;
  color: #ffffff;
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(56, 189, 248, 0.4);
}

.btn-game:active {
  transform: translateY(1px);
}

/* Settings Form */
.settings-group {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 10px 0 16px 0;
  text-align: left;
}

.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  font-family: var(--font-sans);
  color: #cbd5e1;
}

.settings-row input[type="range"] {
  accent-color: #38bdf8;
  cursor: pointer;
  width: 140px;
}

.settings-row input[type="checkbox"] {
  accent-color: #38bdf8;
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.setting-select {
  background: #0f172a;
  border: 1px solid #334155;
  color: #f1f5f9;
  font-family: var(--font-sans);
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 4px;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  min-width: 160px;
}

.setting-select:focus, .setting-select:hover {
  border-color: #38bdf8;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.35);
}

.setting-select option {
  background: #0b1120;
  color: #f8fafc;
}

/* Dialogue Box */
#dialogue-container {
  position: absolute;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  width: 80%;
  max-width: 800px;
  background: rgba(11, 16, 24, 0.94);
  border: 2px solid #334155;
  border-radius: 8px;
  padding: 22px 30px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.85), 0 0 20px rgba(56, 189, 248, 0.2);
  z-index: 90;
  pointer-events: auto;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

#dialogue-container.active {
  opacity: 1;
  visibility: visible;
}

.dialogue-speaker {
  font-size: 14px;
  letter-spacing: 2.5px;
  color: #38bdf8;
  text-transform: uppercase;
  font-weight: 700;
}

.dialogue-text {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: #e2e8f0;
  min-height: 52px;
}

.dialogue-footer {
  text-align: right;
  font-size: 12px;
  letter-spacing: 1px;
  color: #64748b;
  font-family: var(--font-sans);
}

/* Map Screen Modal */
#map-modal .modal-box {
  width: 88vw;
  max-width: 1100px;
  height: 80vh;
  padding: 24px;
  display: flex;
  flex-direction: column;
}

#map-canvas {
  flex: 1;
  width: 100%;
  background: #090e15;
  border: 1px solid #1e293b;
  border-radius: 4px;
  margin-bottom: 12px;
}

.map-legend {
  display: flex;
  gap: 20px;
  font-family: var(--font-sans);
  font-size: 12px;
  color: #94a3b8;
  justify-content: center;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

/* Controls Grid */
.controls-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 24px;
  text-align: left;
  font-family: var(--font-sans);
  font-size: 14px;
  margin: 16px 0 24px 0;
  width: 100%;
}

.control-item {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid #1e293b;
  padding-bottom: 6px;
}

.key-pill {
  background: #1e293b;
  border: 1px solid #475569;
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 12px;
  font-family: monospace;
  color: #38bdf8;
  font-weight: bold;
}

/* Death & Victory Visuals */
.game-over-title {
  color: #ef4444 !important;
  text-shadow: 0 0 20px rgba(239, 68, 68, 0.8) !important;
}

.victory-title {
  color: #38bdf8 !important;
  text-shadow: 0 0 25px rgba(56, 189, 248, 0.9) !important;
}

.victory-stats {
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 2;
  color: #cbd5e1;
  margin-bottom: 24px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .modal-box {
    padding: 20px;
    min-width: 90%;
  }
  .controls-grid {
    grid-template-columns: 1fr;
  }
}
