/* ============================================
   DIỆT DỤC QUỶ VƯƠNG - Main Styles
   Pixel Art RPG Aesthetic
   ============================================ */

:root {
  --bg-primary: #0A0E27;
  --bg-secondary: #1A1F3A;
  --bg-panel: #2A2F4A;
  --accent-gold: #FFD700;
  --accent-orange: #FF8C00;
  --accent-purple: #9370DB;
  --text-primary: #FFFFFF;
  --text-secondary: #CCCCCC;
  --hp-color: #FF4444;
  --mp-color: #44AAFF;
  --success: #44FF44;
  --warning: #FFAA44;
  --danger: #FF4444;
  
  --pixel-font: 'Courier New', monospace;
}

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

body {
  font-family: var(--pixel-font);
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
}

.hidden {
  display: none !important;
}

/* ============================================
   LOADING SCREEN
   ============================================ */

#loading-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #0A0E27 0%, #1A1F3A 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10000;
  flex-direction: column;
}

.loading-content {
  text-align: center;
}

.loading-content h1 {
  font-size: 3rem;
  margin-bottom: 2rem;
  text-shadow: 0 0 20px var(--accent-gold);
  animation: pulse 2s infinite;
}

.loading-bar {
  width: 300px;
  height: 20px;
  background: var(--bg-secondary);
  border: 2px solid var(--accent-gold);
  border-radius: 0;
  overflow: hidden;
  margin: 1rem auto;
}

.loading-progress {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-gold), var(--accent-orange));
  width: 0%;
  animation: loading 3s ease-in-out;
  box-shadow: 0 0 10px var(--accent-gold);
}

.loading-text {
  margin-top: 1rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* ============================================
   HUD (Heads-Up Display)
   ============================================ */

#hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 80px;
  background: linear-gradient(180deg, rgba(10, 14, 39, 0.95) 0%, rgba(10, 14, 39, 0.7) 100%);
  border-bottom: 2px solid var(--accent-gold);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 1rem;
  z-index: 1000;
  backdrop-filter: blur(10px);
}

.hud-left, .hud-right {
  display: flex;
  gap: 1rem;
  flex: 1;
}

.hud-center {
  flex: 2;
  text-align: center;
}

.stat-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 150px;
}

.stat-icon {
  font-size: 1.2rem;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.bar-container {
  position: relative;
  width: 100px;
  height: 20px;
  background: var(--bg-secondary);
  border: 2px solid var(--text-secondary);
  border-radius: 0;
  overflow: hidden;
}

.stat-bar-fill {
  height: 100%;
  transition: width 0.3s ease;
  box-shadow: 0 0 10px currentColor;
}

#hp-bar {
  background: linear-gradient(90deg, var(--hp-color), #FF8888);
  width: 100%;
}

#mp-bar {
  background: linear-gradient(90deg, var(--mp-color), #88CCFF);
  width: 100%;
}

.stat-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.7rem;
  font-weight: bold;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
  z-index: 1;
}

.player-info {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

#player-name {
  font-size: 1.1rem;
  font-weight: bold;
}

.title-badge {
  font-size: 0.8rem;
  color: var(--accent-gold);
  text-shadow: 0 0 5px var(--accent-gold);
}

.level-info {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 0.9rem;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
}

/* BrowserQuest inspired HUD */
.stat-cluster {
  margin-bottom: 0.35rem;
}

.stat-meter {
  width: 200px;
  height: 14px;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(10,14,39,0.6);
  border-radius: 4px;
  position: relative;
  overflow: hidden;
}

.stat-meter span {
  position: absolute;
  top: -18px;
  right: 0;
  font-size: 0.7rem;
  color: #fff;
}

.stat-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.25s ease;
}

.stat-fill.hp {
  background: linear-gradient(90deg, #ff5f6d, #ffc371);
  box-shadow: 0 0 10px rgba(255,95,109,0.6);
}

.stat-fill.mp {
  background: linear-gradient(90deg, #4facfe, #00f2fe);
  box-shadow: 0 0 10px rgba(79,172,254,0.6);
}

.player-info-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: rgba(0,0,0,0.35);
  padding: 0.5rem 1rem;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.1);
}

.player-avatar {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: radial-gradient(circle, #f6d365, #fda085);
  box-shadow: inset 0 0 10px rgba(0,0,0,0.5);
}

.level-strip {
  margin-top: 0.4rem;
  display: flex;
  gap: 1rem;
  font-size: 0.8rem;
  color: #d5e1ff;
}

.minimap-card {
  width: 150px;
  padding: 0.5rem;
  background: rgba(0,0,0,0.3);
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.1);
  text-align: center;
}

#mini-canvas {
  width: 100%;
  height: 120px;
  image-rendering: pixelated;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.15);
  background: #0c1424;
}

.minimap-label {
  font-size: 0.7rem;
  color: #9db5ff;
  margin-top: 0.25rem;
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* ============================================
   GAME WORLD
   ============================================ */

#game-container {
  width: 100vw;
  height: 100vh;
  position: relative;
  overflow: hidden;
}

#game-world {
  position: absolute;
  top: 80px;
  left: 0;
  right: 0;
  bottom: 100px;
  background: linear-gradient(180deg, #070b18 0%, #04060f 100%);
  overflow: hidden;
}

#world-wrapper {
  position: absolute;
  top: 40px;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: center;
  align-items: center;
}

#game-canvas {
  width: 90%;
  height: 90%;
  max-width: 1100px;
  max-height: 640px;
  display: block;
  border: 4px solid #3a325a;
  border-radius: 12px;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  image-rendering: -webkit-optimize-contrast;
  background: #0a0e27;
  box-shadow: inset 0 0 40px rgba(0,0,0,0.6), 0 20px 35px rgba(0,0,0,0.7);
}

#mini-map-container {
  position: absolute;
  top: 120px;
  left: 40px;
  width: 240px;
  border: 3px solid rgba(255, 215, 0, 0.9);
  border-radius: 12px;
  background: rgba(8, 13, 32, 0.92);
  padding: 14px;
  box-shadow: 0 20px 30px rgba(0,0,0,0.5);
  z-index: 10;
}

#mini-map {
  width: 100%;
  height: auto;
  border: 2px solid #4d4a74;
  border-radius: 10px;
  background: #0b1934;
}

.mini-map-caption {
  margin-top: 10px;
  color: #f7e9c8;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.8rem;
}

.mini-map-caption strong {
  font-size: 0.95rem;
  color: #ffd673;
}

.mini-map-legend {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 0.7rem;
  color: #c8c3ff;
}

.legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  display: inline-block;
  margin-right: 4px;
}

.swatch-road { background: #c9c2a1; }
.swatch-building { background: #8b5a2b; }
.swatch-forest { background: #2f6b3f; }

#world-overlay-ui {
  position: absolute;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  width: min(900px, 90%);
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 5;
}

.cta.talk-thay {
  background: linear-gradient(90deg, #f8cf62, #ff8f38);
  border: none;
  border-radius: 999px;
  padding: 16px 28px;
  color: #2d1400;
  font-weight: bold;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 15px 35px rgba(0,0,0,0.4);
  text-align: left;
}

.cta.talk-thay small {
  display: block;
  font-weight: normal;
  color: rgba(45, 20, 0, 0.8);
  margin-top: 4px;
}

.world-hints {
  background: rgba(8, 15, 37, 0.95);
  border: 2px solid rgba(255, 215, 0, 0.5);
  border-radius: 10px;
  padding: 14px 18px;
  color: #f0e5c5;
  font-size: 0.9rem;
  box-shadow: 0 12px 25px rgba(0,0,0,0.35);
}

#demon {
  position: absolute;
  top: 25%;
  right: 12%;
  pointer-events: none;
  text-align: center;
}

.demon-hp-bar {
  width: 160px;
  height: 10px;
  background: rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.2);
  margin: 0 auto 6px;
  border-radius: 6px;
  overflow: hidden;
}

.demon-hp-fill {
  height: 100%;
  background: linear-gradient(90deg, #ff4f6d, #ffa260);
  transition: width 0.3s ease;
}

.npc-dialogue {
  position: absolute;
  top: 30%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(14, 18, 42, 0.95);
  border: 2px solid rgba(255, 215, 0, 0.7);
  padding: 0.85rem 1.1rem;
  border-radius: 10px;
  min-width: 260px;
  max-width: 360px;
  font-size: 0.9rem;
  color: #f7e9c8;
  box-shadow: 0 6px 18px rgba(0,0,0,0.4);
  z-index: 30;
}

.npc-dialogue::after {
  content: '';
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  border: 10px solid transparent;
  border-top-color: rgba(255, 215, 0, 0.7);
}

/* ============================================
   UI PANELS
   ============================================ */

#ui-panels {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2000;
}

.panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  background: var(--bg-panel);
  border: 3px solid var(--accent-gold);
  border-radius: 8px;
  box-shadow: 0 0 30px rgba(255, 215, 0, 0.5);
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-header {
  background: linear-gradient(90deg, var(--accent-gold), var(--accent-orange));
  color: var(--bg-primary);
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: bold;
}

.panel-header h2 {
  margin: 0;
  font-size: 1.2rem;
}

.close-btn {
  background: transparent;
  border: 2px solid var(--bg-primary);
  color: var(--bg-primary);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.close-btn:hover {
  background: var(--bg-primary);
  color: var(--accent-gold);
  transform: rotate(90deg);
}

.panel-content {
  padding: 1rem;
  overflow-y: auto;
  flex: 1;
}

/* Quest Panel */
.quest-card {
  background: var(--bg-secondary);
  border: 2px solid var(--accent-purple);
  padding: 1rem;
  margin-bottom: 1rem;
  border-radius: 4px;
}

.quest-card h3 {
  color: var(--accent-gold);
  margin-bottom: 0.5rem;
}

.quest-progress {
  margin-top: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.progress-bar {
  flex: 1;
  height: 20px;
  background: var(--bg-primary);
  border: 1px solid var(--text-secondary);
  overflow: hidden;
}

.progress-bar::after {
  content: '';
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent-gold), var(--accent-orange));
  width: 0%;
  transition: width 0.3s ease;
}

/* Meditation Panel */
#body-parts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 0.5rem;
}

.body-part-card {
  background: rgba(12, 18, 40, 0.95);
  border: 2px solid rgba(255, 215, 0, 0.3);
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  cursor: pointer;
  transition: all 0.2s;
  border-radius: 10px;
  overflow: hidden;
}

.body-part-card:hover {
  border-color: var(--accent-gold);
  transform: scale(1.05);
  box-shadow: 0 0 10px var(--accent-gold);
}

.body-part-image {
  width: 100%;
  height: 120px;
  border-radius: 8px;
  background-size: cover;
  background-position: center;
  border: 1px solid rgba(255,255,255,0.2);
}

.body-part-info h4 {
  margin: 0;
  color: #ffd673;
}

.body-part-info p {
  font-size: 0.75rem;
  color: #c8c3ff;
  min-height: 40px;
}

.body-part-card.completed {
  border-color: var(--success);
  background: rgba(68, 255, 68, 0.1);
}

.body-part-card.locked {
  opacity: 0.5;
  cursor: not-allowed;
}

.meditation-image {
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  border-radius: 12px;
  border: 2px solid rgba(255, 215, 0, 0.5);
  margin-bottom: 1rem;
  box-shadow: 0 10px 20px rgba(0,0,0,0.4);
}

#breathing-guide {
  text-align: center;
  margin: 2rem 0;
}

.breathing-circle {
  width: 150px;
  height: 150px;
  border: 4px solid var(--accent-gold);
  border-radius: 50%;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: breathe 4s ease-in-out infinite;
}

.breathing-circle::before {
  content: '🧘';
  font-size: 3rem;
}

#breathing-text {
  margin-top: 1rem;
  font-size: 1.2rem;
  color: var(--accent-gold);
}

.meditation-timer {
  text-align: center;
  font-size: 2rem;
  color: var(--accent-gold);
  margin: 1rem 0;
  font-weight: bold;
}

/* Buttons */
.btn-primary, .btn-secondary {
  padding: 0.75rem 1.5rem;
  border: 2px solid;
  border-radius: 4px;
  font-family: var(--pixel-font);
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: bold;
}

.btn-primary {
  background: var(--accent-gold);
  border-color: var(--accent-gold);
  color: var(--bg-primary);
}

.btn-primary:hover {
  background: var(--accent-orange);
  border-color: var(--accent-orange);
  transform: scale(1.05);
  box-shadow: 0 0 15px var(--accent-gold);
}

.btn-secondary {
  background: transparent;
  border-color: var(--text-secondary);
  color: var(--text-secondary);
}

.btn-secondary:hover {
  border-color: var(--accent-gold);
  color: var(--accent-gold);
}

/* ============================================
   BOTTOM NAVIGATION
   ============================================ */

#action-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 90px;
  background: rgba(5, 9, 18, 0.95);
  border-top: 2px solid #f4c95d;
  display: flex;
  justify-content: center;
  gap: 1rem;
  padding: 0.5rem 1.5rem;
  z-index: 1000;
  box-shadow: 0 -10px 30px rgba(0,0,0,0.6);
}

.action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 80px;
  height: 70px;
  background: linear-gradient(180deg, rgba(255,255,255,0.1), rgba(0,0,0,0.6));
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  color: #e1e8ff;
  font-size: 1.4rem;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.action-btn span {
  font-size: 0.6rem;
  margin-top: 0.2rem;
}

.action-btn:hover, .action-btn:focus {
  transform: translateY(-4px);
  box-shadow: 0 10px 20px rgba(0,0,0,0.4);
  border-color: #f4c95d;
}

/* ============================================
   CELEBRATION & REWARDS
   ============================================ */

#celebration-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 5000;
  display: flex;
  justify-content: center;
  align-items: center;
  pointer-events: none;
}

#celebration-content {
  text-align: center;
  color: var(--accent-gold);
  font-size: 3rem;
  font-weight: bold;
  text-shadow: 0 0 20px var(--accent-gold);
}

#floating-rewards {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 3000;
}

.floating-text {
  position: absolute;
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--accent-gold);
  text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
  animation: floatUp 2s ease-out forwards;
  pointer-events: none;
}

/* ============================================
   LANGUAGE SWITCHER
   ============================================ */

#language-switcher {
  position: fixed;
  top: 10px;
  right: 10px;
  z-index: 1500;
}

#lang-select {
  background: var(--bg-panel);
  border: 2px solid var(--accent-gold);
  color: var(--text-primary);
  padding: 0.5rem;
  border-radius: 4px;
  font-family: var(--pixel-font);
  cursor: pointer;
}

/* ============================================
   MODAL
   ============================================ */

.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10000;
}

.modal-content {
  background: var(--bg-panel);
  border: 3px solid var(--accent-gold);
  border-radius: 8px;
  padding: 2rem;
  max-width: 400px;
  text-align: center;
}

.modal-content h2 {
  margin-bottom: 1rem;
  color: var(--accent-gold);
}

.modal-content p {
  margin-bottom: 1.5rem;
  color: var(--text-secondary);
}

.modal-content button {
  margin: 0.5rem;
}

.modal-content.wide {
  max-width: 900px;
}

.modal-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 1rem;
  align-items: center;
}

.modal-visual img {
  width: 100%;
  border-radius: 12px;
  border: 2px solid rgba(255,255,255,0.2);
  box-shadow: 0 15px 35px rgba(0,0,0,0.6);
}

.meditation-video {
  width: 100%;
  border-radius: 12px;
  border: 2px solid rgba(255,255,255,0.2);
  box-shadow: 0 15px 35px rgba(0,0,0,0.6);
  background: #000;
}

.modal-visual #body-visual-caption {
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: #9db5ff;
}

.modal-notes {
  background: rgba(0,0,0,0.4);
  padding: 1rem;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.05);
}

.mantra-card {
  margin: 1rem 0;
  padding: 1rem;
  background: rgba(244,201,93,0.15);
  border: 1px solid #f4c95d;
  border-radius: 8px;
  font-style: italic;
  color: #fcead1;
  line-height: 1.5;
}

/* ============================================
   INVENTORY & ACHIEVEMENTS GRID
   ============================================ */

#inventory-grid, #achievements-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.75rem;
}

.inventory-item, .achievement-item {
  background: var(--bg-secondary);
  border: 2px solid var(--text-secondary);
  padding: 1rem;
  text-align: center;
  border-radius: 4px;
  transition: all 0.2s;
}

.inventory-item:hover, .achievement-item:hover {
  border-color: var(--accent-gold);
  transform: scale(1.05);
}

.achievement-item.unlocked {
  border-color: var(--accent-gold);
  background: rgba(255, 215, 0, 0.1);
  box-shadow: 0 0 10px var(--accent-gold);
}

.achievement-item.locked {
  opacity: 0.5;
  filter: grayscale(100%);
}

/* ============================================
   CHAT PANEL
   ============================================ */

#chat-messages {
  height: 400px;
  overflow-y: auto;
  margin-bottom: 1rem;
  padding: 0.5rem;
  background: var(--bg-secondary);
  border-radius: 4px;
}

.chat-message {
  margin-bottom: 0.75rem;
  padding: 0.5rem;
  border-radius: 4px;
}

.chat-message.user {
  background: rgba(68, 170, 255, 0.2);
  text-align: right;
}

.chat-message.gemini {
  background: rgba(255, 215, 0, 0.2);
}

.chat-message .sender {
  font-weight: bold;
  margin-bottom: 0.25rem;
  color: var(--accent-gold);
}

.chat-input-container {
  display: flex;
  gap: 0.5rem;
}

#chat-input {
  flex: 1;
  padding: 0.75rem;
  background: var(--bg-secondary);
  border: 2px solid var(--text-secondary);
  color: var(--text-primary);
  font-family: var(--pixel-font);
  border-radius: 4px;
}

#chat-input:focus {
  outline: none;
  border-color: var(--accent-gold);
}

/* ============================================
   SKILLS PANEL
   ============================================ */

#skills-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.skill-item {
  background: var(--bg-secondary);
  border: 2px solid var(--text-secondary);
  padding: 1rem;
  border-radius: 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.skill-item.unlocked {
  border-color: var(--accent-gold);
}

.skill-item.locked {
  opacity: 0.5;
}

.skill-info {
  flex: 1;
}

.skill-name {
  font-weight: bold;
  color: var(--accent-gold);
  margin-bottom: 0.25rem;
}

.skill-description {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

