* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  overscroll-behavior: none;
  background-color: #11131b;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  color: #f5efdc;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

/* Canvas de juego a pantalla completa */
#gameCanvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1;
  display: block;
  background-color: #141720;
}

/* ========================================================
   TOOLBAR COMPLETO PARA ESCRITORIO (PANTALLAS > 768px)
======================================================== */
.desktop-toolbar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 56px;
  z-index: 40;
  background: rgba(25, 25, 29, 0.97);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(211, 163, 75, 0.34);
  padding: 0 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  width: 32px;
  height: 32px;
  object-fit: contain;
  filter: drop-shadow(0 0 7px rgba(74, 222, 128, 0.55)) saturate(0.8);
}

.brand-title {
  font-size: 1.35rem;
  color: #c6a455;
  font-weight: 800;
  letter-spacing: 0.5px;
}

.brand-title span {
  color: #55c7a2;
}

.toolbar-center {
  display: flex;
  align-items: center;
  gap: 14px;
}

.stat-pill {
  background: rgba(47, 47, 50, 0.78);
  border: 1px solid rgba(198, 164, 85, 0.2);
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-label {
  color: #a8b79d;
  font-size: 0.78rem;
  text-transform: uppercase;
}

.stat-value {
  color: #69d3b4;
  font-weight: 700;
  font-size: 1.05rem;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.select-box {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: #d6dfc9;
}

.styled-select {
  background: #2b2b2e;
  color: #f5efdc;
  border: 1px solid #5b594f;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.82rem;
  cursor: pointer;
  outline: none;
}

.icon-btn {
  background: #2b2b2e;
  border: 1px solid #5b594f;
  font-size: 1.05rem;
  border-radius: 8px;
  width: 36px;
  height: 36px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #f5efdc;
  transition: background-color 0.15s, transform 0.1s;
}

.icon-btn:hover {
  background-color: #414044;
}

.icon-btn:active {
  transform: scale(0.92);
}

.btn {
  padding: 8px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, #c6a455, #947335);
  color: #101a13;
  box-shadow: 0 4px 12px rgba(198, 164, 85, 0.24);
}

.btn-primary:active {
  transform: scale(0.96);
}

.btn-secondary {
  background: linear-gradient(135deg, #535154, #343337);
  color: #f5efdc;
}

.btn-outline {
  background: transparent;
  border: 1px solid #756b56;
  color: #e2d8c1;
}

/* ========================================================
   HUD MINIMALISTA PARA MÓVILES (PANTALLAS <= 768px)
======================================================== */
.mobile-hud {
  display: none; /* Por defecto oculto en escritorio */
  position: fixed;
  top: max(8px, env(safe-area-inset-top));
  left: max(10px, env(safe-area-inset-left));
  right: max(10px, env(safe-area-inset-right));
  z-index: 35;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  pointer-events: none;
}

.hud-btn {
  background: rgba(31, 31, 34, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(198, 164, 85, 0.25);
  color: #f5efdc;
  font-size: 1.1rem;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  pointer-events: auto;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  touch-action: manipulation;
}

.hud-btn:active {
  transform: scale(0.92);
}

.hud-center-pill {
  background: rgba(31, 31, 34, 0.94);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(198, 164, 85, 0.2);
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  color: #f5efdc;
  display: flex;
  align-items: center;
  gap: 6px;
  pointer-events: auto;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.hud-center-pill strong {
  color: #69d3b4;
  font-size: 0.95rem;
}

.hud-game-title {
  color: #d2b264;
  font-size: 0.7rem;
  font-weight: 800;
  white-space: nowrap;
}

.hud-stat {
  white-space: nowrap;
}

.hud-mini-logo {
  width: 18px;
  height: 18px;
  object-fit: contain;
}

.hud-divider {
  opacity: 0.3;
}

/* ========================================================
   INSIGNIAS Y ALERTAS FLOTANTES
======================================================== */
.status-badges-container {
  position: fixed;
  top: max(64px, calc(env(safe-area-inset-top) + 52px));
  right: max(12px, calc(env(safe-area-inset-right) + 12px));
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  pointer-events: none;
}

.hud-badge {
  padding: 5px 12px;
  border-radius: 18px;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

.hud-badge.hidden {
  display: none !important;
}

.immunity-badge {
  background: rgba(25, 105, 91, 0.88);
  border: 1px solid rgba(105, 211, 180, 0.7);
  color: #ffffff;
  box-shadow: 0 2px 10px rgba(8, 8, 8, 0.25);
}

.threat-badge {
  background: rgba(127, 29, 29, 0.76);
  border: 1px solid rgba(248, 113, 113, 0.62);
  color: #ffffff;
  box-shadow: 0 2px 10px rgba(127, 29, 29, 0.2);
}

/* ========================================================
   FURIA DE KUKULCÁN
======================================================== */
.turbo-container {
  position: fixed;
  bottom: max(18px, calc(env(safe-area-inset-bottom) + 12px));
  left: max(18px, calc(env(safe-area-inset-left) + 12px));
  z-index: 25;
}

.turbo-btn {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #d9b75f, #ac772e 70%, #704a25);
  border: 2px solid rgba(238, 212, 137, 0.7);
  color: #ffffff;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: 0 4px 15px rgba(198, 164, 85, 0.32);
  position: relative;
  overflow: visible;
  transition: transform 0.1s ease, filter 0.15s ease, opacity 0.2s ease;
}

.turbo-btn:active {
  transform: scale(0.92);
}

.turbo-btn.active {
  background: radial-gradient(circle at 35% 35%, #f2d77b, #c79c42 70%, #947335);
  border-color: #fff2c2;
  box-shadow: 0 0 22px rgba(255, 114, 45, 0.82), 0 0 38px rgba(219, 67, 35, 0.5);
  animation: pulse-turbo 0.6s ease-in-out infinite alternate;
}

.turbo-btn.active::before,
.turbo-btn.active::after {
  content: "";
  position: absolute;
  z-index: 0;
  left: 50%;
  bottom: 27px;
  width: 13px;
  height: 21px;
  border-radius: 55% 0 55% 55%;
  background: linear-gradient(155deg, #fff4a3 4%, #ffb02e 42%, #ef4c24 82%);
  box-shadow: 0 0 12px rgba(255, 112, 31, 0.82);
  transform: translateX(-50%) rotate(45deg);
  transform-origin: center bottom;
  animation: sacred-flame 0.32s ease-in-out infinite alternate;
  pointer-events: none;
}

.turbo-btn.active::after {
  left: 76%;
  bottom: 24px;
  width: 9px;
  height: 15px;
  opacity: 0.8;
  animation-delay: -0.16s;
}

@keyframes pulse-turbo {
  from { box-shadow: 0 0 12px rgba(255, 114, 45, 0.68), 0 0 24px rgba(219, 67, 35, 0.35); }
  to { box-shadow: 0 0 22px rgba(255, 154, 55, 0.94), 0 0 35px rgba(219, 67, 35, 0.62); }
}

.turbo-btn.active .turbo-icon {
  animation: turbo-flame 0.28s ease-in-out infinite alternate;
  transform-origin: center bottom;
  filter: drop-shadow(0 0 5px rgba(255, 104, 35, 0.9));
}

@keyframes turbo-flame {
  from { transform: scale(0.88) rotate(-9deg); }
  to { transform: scale(1.18) rotate(9deg); }
}

@keyframes sacred-flame {
  from { transform: translateX(-50%) rotate(40deg) scale(0.82, 0.92); }
  to { transform: translateX(-50%) rotate(50deg) scale(1.12, 1.08); }
}

.turbo-btn.cooldown {
  opacity: 0.72;
  cursor: not-allowed;
}

.turbo-icon {
  font-size: 1.35rem;
  line-height: 1;
  position: relative;
  z-index: 1;
}

.turbo-label {
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.4px;
  position: relative;
  z-index: 1;
}

.turbo-progress {
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  background: conic-gradient(
    from -90deg,
    #38bdf8 var(--turbo-charge, 100%),
    rgba(148, 163, 184, 0.22) 0
  );
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3px));
  pointer-events: none;
  transition: background 0.08s linear;
}

/* ========================================================
   CRUCETA TÁCTIL (OPCIONAL)
======================================================== */
.touch-controls {
  position: fixed;
  bottom: max(16px, calc(env(safe-area-inset-bottom) + 10px));
  right: max(16px, calc(env(safe-area-inset-right) + 10px));
  z-index: 25;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  opacity: 0.65;
  transition: opacity 0.2s ease;
}

.touch-controls.hidden {
  display: none !important;
}

.pad-row {
  display: flex;
  gap: 3px;
  align-items: center;
}

.pad-center {
  width: 40px;
  height: 40px;
  background-color: rgba(30, 41, 59, 0.35);
  border-radius: 10px;
}

.pad-btn {
  width: 40px;
  height: 40px;
  background-color: rgba(51, 65, 85, 0.8);
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  font-size: 1.05rem;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  touch-action: manipulation;
  transition: background-color 0.1s, transform 0.08s;
}

.pad-btn:active {
  background-color: #3e8d66;
  transform: scale(0.92);
}

/* ========================================================
   MODALES Y FONDOS
======================================================== */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(4, 13, 9, 0.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 70;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 16px;
}

.modal-backdrop.hidden {
  display: none !important;
}

/* Menú Drawer en Móviles */
.drawer-card {
  background: rgba(30, 29, 32, 0.98);
  border: 1px solid rgba(198, 164, 85, 0.34);
  border-radius: 20px;
  padding: 22px;
  max-width: 380px;
  width: 100%;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.85);
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 90vh;
  overflow-y: auto;
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(211, 190, 147, 0.16);
}

.drawer-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.drawer-logo {
  width: 26px;
  height: 26px;
  object-fit: contain;
}

.drawer-header h2 {
  font-size: 1.25rem;
  color: #d2b264;
}

.close-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 1.3rem;
  cursor: pointer;
}

.drawer-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stat-summary-box {
  display: flex;
  justify-content: space-around;
  background: rgba(46, 44, 45, 0.78);
  padding: 10px;
  border-radius: 12px;
  border: 1px solid rgba(211, 190, 147, 0.12);
}

.summary-col {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.sum-lbl {
  font-size: 0.72rem;
  color: #a8b79d;
  text-transform: uppercase;
}

.sum-val {
  font-size: 1.25rem;
  font-weight: 800;
  color: #69d3b4;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
  color: #d6dfc9;
}

.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: #d6dfc9;
  padding: 4px 0;
}

.styled-checkbox {
  width: 20px;
  height: 20px;
  accent-color: #c6a455;
}

.drawer-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 6px;
}

/* ========================================================
   TUTORIAL INTERACTIVO PASO A PASO (ONBOARDING)
======================================================== */
.tutorial-card {
  background: rgba(30, 29, 32, 0.99);
  border: 1px solid rgba(198, 164, 85, 0.36);
  border-radius: 22px;
  padding: 24px;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.9);
  display: flex;
  flex-direction: column;
  gap: 16px;
  text-align: center;
}

.tutorial-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.tutorial-logo {
  width: 36px;
  height: 36px;
  object-fit: contain;
  filter: drop-shadow(0 0 8px rgba(74, 222, 128, 0.6));
}

.tutorial-header h2 {
  font-size: 1.35rem;
  color: #d2b264;
}

.tutorial-step {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  min-height: 140px;
  justify-content: center;
}

.tutorial-step.active {
  display: flex;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.tutorial-icon-banner {
  font-size: 2.2rem;
  margin-bottom: 2px;
}

.tutorial-lead {
  font-size: 0.95rem;
  color: #f1f5f9;
  line-height: 1.4;
}

.tutorial-tip {
  font-size: 0.84rem;
  color: #b7c5ad;
  background: rgba(47, 45, 46, 0.82);
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid rgba(198, 164, 85, 0.12);
  line-height: 1.35;
}

.step-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 4px 0;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #294536;
  transition: all 0.2s ease;
}

.dot.active {
  background: #c6a455;
  width: 22px;
  border-radius: 10px;
}

.tutorial-footer {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.tutorial-footer .btn {
  flex: 1;
}

.hidden {
  display: none !important;
}

/* Modal Game Over */
.modal-card {
  background: rgba(30, 29, 32, 0.98);
  border: 1px solid rgba(198, 164, 85, 0.28);
  border-radius: 20px;
  padding: 24px;
  max-width: 400px;
  width: 100%;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.85);
}

.modal-gameover-logo {
  width: 48px;
  height: 48px;
  margin: 0 auto;
  object-fit: contain;
}

#overlay-title {
  color: #f87171;
  font-size: 1.6rem;
}

.death-reason {
  font-size: 0.92rem;
  color: #cbd5e1;
}

.final-stats {
  background: #302e30;
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.final-stats strong {
  color: #69d3b4;
  font-size: 1.25rem;
}

/* ========================================================
   MEDIA QUERIES RESPONSIVE (MÓVIL VS ESCRITORIO)
======================================================== */
@media (max-width: 768px) {
  .desktop-toolbar {
    display: none !important;
  }
  .mobile-hud {
    display: flex !important;
  }
  .status-badges-container {
    top: max(50px, calc(env(safe-area-inset-top) + 46px));
  }
}

@media (max-width: 480px) {
  .hud-game-title {
    font-size: 0.62rem;
  }
  .hud-stat {
    font-size: 0;
  }
  .hud-stat strong {
    font-size: 0.85rem;
  }
}
