/* style.css - Hoja de estilos para «El Jardín del Ser» (Maximizado & Bitmap) */

:root {
  --bg-deep: #050811;
  --bg-panel: rgba(15, 23, 42, 0.92);
  --border-line: rgba(255, 255, 255, 0.14);
  --gold: #f59e0b;
  --gold-glow: rgba(245, 158, 11, 0.4);
  --cyan: #06b6d4;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --danger: #ef4444;
  --success: #22c55e;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-serif: 'Newsreader', Georgia, serif;
}

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

html, body {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background-color: var(--bg-deep);
  color: var(--text-main);
  font-family: var(--font-sans);
  touch-action: manipulation;
}

#gameContainer {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  background: #050811;
  position: relative;
  overflow: hidden;
}

/* --- BARRA SUPERIOR / ESTANTERÍA DE CARTAS (FIJA, NO EMPUJA) --- */
.game-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 14px;
  background: rgba(10, 15, 29, 0.96);
  border-bottom: 1px solid var(--border-line);
  backdrop-filter: blur(12px);
  z-index: 30;
  height: 76px;
  flex-shrink: 0;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 600;
  transition: all 0.2s;
  padding: 5px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-line);
}
.brand-link:hover {
  color: #fff;
  border-color: var(--gold);
}

.doubt-bank {
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.25), rgba(217, 119, 6, 0.15));
  border: 1.5px solid rgba(245, 158, 11, 0.5);
  padding: 4px 12px;
  border-radius: 18px;
  box-shadow: 0 0 14px var(--gold-glow);
}
.doubt-icon {
  font-size: 1.25rem;
  font-weight: 900;
  color: var(--gold);
  filter: drop-shadow(0 0 5px #fbbf24);
}
.doubt-text {
  font-size: 1.15rem;
  font-weight: 800;
  color: #fff;
}
.doubt-label {
  font-size: 0.72rem;
  color: #fde68a;
  text-transform: uppercase;
  font-weight: 700;
}

/* ESTANTERÍA DE FILÓSOFOS (CARTAS) */
.cards-shelf {
  display: flex;
  align-items: center;
  gap: 6px;
}

.philosopher-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  width: 68px;
  height: 64px;
  background: rgba(24, 33, 52, 0.9);
  border: 1.5px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  padding: 2px 2px 4px 2px;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  overflow: hidden;
}

.philosopher-card:hover {
  transform: translateY(-2px);
  border-color: var(--gold);
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.35);
}

.philosopher-card.selected {
  border-color: #38bdf8;
  background: rgba(14, 165, 233, 0.3);
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.7);
  transform: translateY(-3px);
}

.philosopher-card.disabled {
  opacity: 0.42;
  filter: grayscale(0.6);
  cursor: not-allowed;
}

.card-avatar-img {
  width: 38px;
  height: 38px;
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

.card-bottom-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0 3px;
}

.card-name {
  font-size: 0.62rem;
  font-weight: 700;
  color: #f1f5f9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-cost {
  font-size: 0.6rem;
  font-weight: 800;
  background: #d97706;
  color: #fff;
  padding: 1px 4px;
  border-radius: 6px;
}

.card-cooldown-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 0%;
  background: rgba(0, 0, 0, 0.75);
  color: #fde047;
  font-size: 0.8rem;
  font-weight: 800;
  display: none;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

/* HERRAMIENTA PALA */
.shovel-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 64px;
  background: rgba(239, 68, 68, 0.12);
  border: 1.5px solid rgba(239, 68, 68, 0.4);
  border-radius: 8px;
  color: #fca5a5;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 1.3rem;
}
.shovel-btn:hover {
  background: rgba(239, 68, 68, 0.28);
  border-color: #ef4444;
}
.shovel-btn.selected {
  background: rgba(239, 68, 68, 0.45);
  border-color: #ef4444;
  box-shadow: 0 0 14px rgba(239, 68, 68, 0.7);
  transform: translateY(-2px);
}
.shovel-label {
  font-size: 0.58rem;
  font-weight: 800;
  text-transform: uppercase;
}

/* CONTROLES DERECHA (Progreso, audio, pantalla completa, códice) */
.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.wave-tracker {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  min-width: 120px;
}
.wave-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: #fde047;
  letter-spacing: 0.5px;
}
.progress-track {
  width: 100%;
  height: 7px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 3px;
}
.progress-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #38bdf8 0%, #34d399 50%, #f59e0b 100%);
  transition: width 0.3s ease;
}

.icon-btn {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--border-line);
  color: var(--text-main);
  padding: 6px 9px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: all 0.2s;
  white-space: nowrap;
}
.icon-btn:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.35);
}
.icon-btn.btn-fullscreen {
  background: rgba(59, 130, 246, 0.18);
  border-color: rgba(59, 130, 246, 0.45);
  color: #93c5fd;
}
.icon-btn.btn-fullscreen:hover {
  background: rgba(59, 130, 246, 0.3);
  color: #fff;
}
.icon-btn.muted {
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.4);
}

/* --- ZONA CENTRAL / CANVAS MAXIMIZADO --- */
.canvas-wrapper {
  flex: 1;
  width: 100vw;
  height: calc(100vh - 76px);
  position: relative;
  display: flex;
  align-items: stretch;
  justify-content: center;
  overflow: hidden;
  padding: 0;
  margin: 0;
}

canvas#gameCanvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  cursor: crosshair;
  background-color: #050811;
}

/* BARRA DE VIDA DEL JEFE FINAL */
.boss-health-bar {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: none;
  flex-direction: column;
  align-items: center;
  width: 460px;
  background: rgba(15, 23, 42, 0.95);
  border: 2px solid #eab308;
  border-radius: 20px;
  padding: 6px 16px;
  box-shadow: 0 0 30px rgba(234, 179, 8, 0.55);
  z-index: 25;
}
.boss-title {
  font-size: 0.85rem;
  font-weight: 800;
  color: #fde047;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.boss-track {
  width: 100%;
  height: 11px;
  background: #334155;
  border-radius: 6px;
  overflow: hidden;
}
.boss-fill {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #ef4444 0%, #f59e0b 100%);
  transition: width 0.15s ease;
}

/* BANNER DE CAMBIO DE OLEADA */
.wave-banner {
  position: absolute;
  top: 25%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  background: rgba(11, 15, 30, 0.96);
  border: 2px solid var(--gold);
  border-radius: 16px;
  padding: 16px 32px;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.85), 0 0 30px var(--gold-glow);
  opacity: 0;
  pointer-events: none;
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 35;
}
.wave-banner.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}
.wave-banner .wave-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: #fbbf24;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}
.wave-banner .wave-sub {
  font-size: 0.92rem;
  color: #e2e8f0;
  margin-top: 5px;
  font-style: italic;
  font-family: var(--font-serif);
}

/* --- FICHA EDUCATIVA FLOTANTE (HUD OVERLAY - NO DESPLAZA NADA) --- */
.floating-hud-tooltip {
  position: absolute;
  right: 18px;
  bottom: 18px;
  max-width: 420px;
  background: rgba(11, 17, 33, 0.95);
  border: 1.5px solid var(--gold);
  border-radius: 14px;
  padding: 14px 18px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.85), 0 0 20px rgba(245, 158, 11, 0.25);
  backdrop-filter: blur(12px);
  pointer-events: none;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 40;
}
.floating-hud-tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}

.tip-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border-line);
  padding-bottom: 6px;
}
.tip-name {
  font-size: 1.1rem;
  font-weight: 800;
  color: #38bdf8;
}
.tip-title {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 600;
}
.tip-cost {
  font-size: 0.82rem;
  font-weight: 800;
  color: #fbbf24;
}
.tip-desc {
  font-size: 0.84rem;
  color: #f1f5f9;
  line-height: 1.45;
  margin-bottom: 8px;
}
.tip-quote {
  font-size: 0.8rem;
  color: #cbd5e1;
  font-style: italic;
  font-family: var(--font-serif);
  border-left: 2.5px solid var(--gold);
  padding-left: 8px;
  line-height: 1.4;
}

/* --- MODALES (INICIO, VICTORIA, DERROTA, CÓDICE) --- */
.game-modal {
  position: absolute;
  inset: 0;
  background: rgba(5, 8, 17, 0.88);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}
.game-modal.open {
  display: flex;
}

.modal-card {
  width: 100%;
  max-width: 680px;
  background: #0f172a;
  border: 1.5px solid rgba(255, 255, 255, 0.16);
  border-radius: 20px;
  padding: 30px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.95);
  position: relative;
  max-height: 92vh;
  overflow-y: auto;
}

.modal-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 12px;
  background: rgba(245, 158, 11, 0.15);
  color: var(--gold);
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.modal-title {
  font-size: 2.1rem;
  font-weight: 900;
  letter-spacing: 1px;
  color: #fff;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.modal-subtitle {
  font-size: 1.15rem;
  color: #94a3b8;
  font-style: italic;
  font-family: var(--font-serif);
  margin-bottom: 18px;
}

.modal-text {
  font-size: 0.92rem;
  color: #cbd5e1;
  line-height: 1.6;
  margin-bottom: 22px;
  text-align: left;
}

.philosophical-quote-box {
  background: rgba(255, 255, 255, 0.04);
  border-left: 3px solid var(--gold);
  border-radius: 8px;
  padding: 12px 16px;
  margin: 16px 0;
  text-align: left;
}
.quote-text {
  font-family: var(--font-serif);
  font-size: 1.02rem;
  color: #f1f5f9;
  font-style: italic;
  line-height: 1.5;
}
.quote-author {
  font-size: 0.78rem;
  color: var(--gold);
  font-weight: 700;
  margin-top: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 18px 0;
}
.stat-item {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  padding: 10px 6px;
}
.stat-num {
  display: block;
  font-size: 1.35rem;
  font-weight: 800;
  color: #38bdf8;
}
.stat-label {
  display: block;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: #0f172a;
  font-weight: 800;
  font-size: 1.02rem;
  padding: 12px 26px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(245, 158, 11, 0.35);
  transition: all 0.2s;
  text-decoration: none;
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 22px rgba(245, 158, 11, 0.5);
  background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #f1f5f9;
  font-weight: 700;
  font-size: 0.92rem;
  padding: 10px 20px;
  border-radius: 12px;
  border: 1px solid var(--border-line);
  cursor: pointer;
  transition: all 0.2s;
}
.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.16);
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 10px;
}

/* CÓDICE / MANUAL MODAL */
.codex-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 16px 0;
  text-align: left;
}
.codex-column h3 {
  font-size: 0.95rem;
  color: var(--gold);
  border-bottom: 1px solid var(--border-line);
  padding-bottom: 5px;
  margin-bottom: 8px;
  text-transform: uppercase;
}
.codex-item {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 8px;
}
.codex-name {
  font-weight: 700;
  font-size: 0.86rem;
  color: #38bdf8;
}
.codex-role {
  font-size: 0.72rem;
  color: #fde047;
}
.codex-text {
  font-size: 0.78rem;
  color: #cbd5e1;
  margin-top: 3px;
  line-height: 1.35;
}

/* ============================================================== */
/* SELECTOR DE DIFICULTAD E INDICADOR EN HUD                      */
/* ============================================================== */
.difficulty-picker-box {
  margin: 16px 0;
  text-align: left;
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  padding: 14px 16px;
}

.difficulty-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.difficulty-label {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #94a3b8;
  display: flex;
  align-items: center;
  gap: 6px;
}

.difficulty-active-tag {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 12px;
  background: rgba(34, 197, 94, 0.2);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.4);
}
.difficulty-active-tag.easy {
  background: rgba(34, 197, 94, 0.2);
  color: #4ade80;
  border-color: rgba(34, 197, 94, 0.4);
}
.difficulty-active-tag.medium {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.4);
}
.difficulty-active-tag.hard {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.4);
}

.difficulty-options-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.diff-btn {
  background: rgba(30, 41, 59, 0.7);
  border: 1.5px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 10px 8px;
  cursor: pointer;
  color: #e2e8f0;
  text-align: center;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.diff-btn:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.3);
  background: rgba(51, 65, 85, 0.8);
}

.diff-btn.active[data-diff="easy"] {
  border-color: #22c55e;
  background: linear-gradient(180deg, rgba(34, 197, 94, 0.25) 0%, rgba(34, 197, 94, 0.08) 100%);
  box-shadow: 0 0 14px rgba(34, 197, 94, 0.35);
}

.diff-btn.active[data-diff="medium"] {
  border-color: #f59e0b;
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.25) 0%, rgba(245, 158, 11, 0.08) 100%);
  box-shadow: 0 0 14px rgba(245, 158, 11, 0.35);
}

.diff-btn.active[data-diff="hard"] {
  border-color: #ef4444;
  background: linear-gradient(180deg, rgba(239, 68, 68, 0.25) 0%, rgba(239, 68, 68, 0.08) 100%);
  box-shadow: 0 0 14px rgba(239, 68, 68, 0.35);
}

.diff-icon {
  font-size: 1.4rem;
}

.diff-name {
  font-weight: 700;
  font-size: 0.88rem;
}

.diff-desc {
  font-size: 0.72rem;
  color: #94a3b8;
  line-height: 1.25;
}

.diff-btn.active .diff-desc {
  color: #f1f5f9;
}

/* Indicador de dificultad en el HUD superior */
.difficulty-hud-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(30, 41, 59, 0.85);
  border: 1.5px solid rgba(255, 255, 255, 0.15);
  border-radius: 20px;
  padding: 4px 10px;
  font-size: 0.82rem;
  font-weight: 700;
  color: #f8fafc;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.difficulty-hud-pill:hover {
  transform: translateY(-1px) scale(1.04);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.difficulty-hud-pill.easy {
  border-color: rgba(34, 197, 94, 0.6);
  background: rgba(34, 197, 94, 0.15);
  color: #4ade80;
}

.difficulty-hud-pill.medium {
  border-color: rgba(245, 158, 11, 0.6);
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
}

.difficulty-hud-pill.hard {
  border-color: rgba(239, 68, 68, 0.6);
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}

/* RESPONSIVE DESIGN */
@media (max-width: 900px) {
  .game-topbar {
    height: auto;
    flex-wrap: wrap;
    padding: 6px 10px;
  }
  .philosopher-card {
    width: 54px;
    height: 56px;
  }
  .card-avatar-img {
    width: 32px;
    height: 32px;
  }
  .card-name {
    font-size: 0.55rem;
  }
  .shovel-btn {
    width: 44px;
    height: 56px;
  }
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .codex-grid {
    grid-template-columns: 1fr;
  }
  .floating-hud-tooltip {
    max-width: 90vw;
    right: 5vw;
    bottom: 10px;
  }
}
