/* CSS para el juego Merge Emociones - Rediseño Warm Light 100vh No-Scroll & Mobile-First */

@import url('https://fonts.googleapis.com/css2?family=Baloo+2:wght@700;800&family=Nunito:wght@400;600;700;800;900&display=swap');

:root {
  --bg-primary: oklch(98% 0.006 185); /* Fondo claro y cálido oficial */
  --bg-panel: #ffffff;
  --text-dark: #0A5E66; /* Verde oscuro principal */
  --text-body: #1f3644;
  --text-muted: #5b7f94;
  --accent-teal: #0A5E66;
  --accent-orange: #E46A4B; /* Coral oficial */
  --accent-orange-shadow: #b94f34;
  --accent-gold: #ffb74f;
  --line-color: oklch(91% 0.01 185); /* Bordes sutiles oficiales */
  --font-title: "Baloo 2", cursive;
  --font-body: "Nunito", sans-serif;
  --shadow-color: rgba(10, 94, 102, 0.06);
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden; /* Forzar que no haya sliders verticales en la página */
}

body {
  font-family: var(--font-body);
  color: var(--text-body);
  background: radial-gradient(circle at 20% 10%, #fff6d7 0%, transparent 35%),
              radial-gradient(circle at 80% 20%, #dcf5ff 0%, transparent 30%),
              var(--bg-primary);
  display: flex;
  justify-content: center;
  align-items: center;
}

.game-shell {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100dvh;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: none; /* Dejar pasar clics al canvas */
  z-index: 10;
}

/* Header HUD */
.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.85); /* Semi-transparente */
  backdrop-filter: blur(8px);
  border: 2px solid var(--line-color);
  border-radius: 20px;
  box-shadow: 0 4px 16px var(--shadow-color);
  flex-shrink: 0;
  pointer-events: auto;
}

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

.game-header .back-link {
  font-weight: 800;
  color: var(--accent-teal);
  text-decoration: none;
  display: flex;
  align-items: center;
  font-size: 14px;
  transition: transform 0.2s;
}

.game-header .back-link:hover {
  transform: translateX(-3px);
}

.game-header h1 {
  font-family: var(--font-title);
  font-size: 20px;
  color: var(--text-dark);
  font-weight: 800;
  line-height: 1;
}

.hud-top-stats {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-reset-hud {
  background: #fff;
  border: 1.5px solid var(--line-color);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 14px;
  box-shadow: 0 2px 4px var(--shadow-color);
  transition: background 0.2s;
  pointer-events: auto;
}

.btn-reset-hud:hover {
  background: #f1f5f9;
}

.hud-pill {
  background: rgba(244, 251, 255, 0.9);
  border: 1.5px solid var(--line-color);
  padding: 6px 12px;
  border-radius: 99px;
  font-weight: 900;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--accent-orange);
  pointer-events: auto;
}

.hud-pill.gps {
  color: var(--accent-teal);
}

/* Layout responsivo */
.game-layout {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  flex: 1;
  min-height: 0;
}

/* Contenedor del Canvas */
.canvas-container-wrap {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1;
}

#game-container {
  width: 100%;
  height: 100%;
}

#game-container canvas {
  width: 100% !important;
  height: 100% !important;
}

/* Sidebar panel */
.sidebar-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-height: 35vh; /* Ocupar tercio inferior en movil */
  pointer-events: auto;
}

.panel-card {
  background: var(--bg-panel);
  border: 2px solid var(--line-color);
  border-radius: 20px;
  padding: 16px;
  box-shadow: 0 8px 24px var(--shadow-color);
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: 100%;
  min-height: 0;
}

.panel-card h2 {
  font-family: var(--font-title);
  font-size: 17px;
  color: var(--text-dark);
  border-bottom: 2px solid var(--bg-primary);
  padding-bottom: 4px;
  flex-shrink: 0;
}

/* Tienda de Emociones */
.shop-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  overflow-y: auto;
  flex: 1;
  padding-right: 4px;
}

.shop-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  border: 1.5px solid var(--line-color);
  border-radius: 12px;
  padding: 6px;
  transition: border-color 0.2s;
  text-align: center;
}

.shop-item.unlocked:hover {
  border-color: var(--accent-teal);
}

.shop-item-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.shop-item-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  overflow: hidden;
}

.shop-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.shop-item-details {
  display: none; /* Hide details on mobile to save space */
}

.shop-item-name {
  font-size: 13px;
  font-weight: 800;
  color: var(--text-body);
}

.shop-item-gps {
  font-size: 10px;
  color: var(--accent-teal);
  font-weight: 700;
}

.btn-buy-item {
  width: 100%;
  margin-top: 4px;
  padding: 4px 0;
  font-size: 11px;
  background: var(--accent-orange);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--accent-orange-shadow);
  transition: all 0.1s;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.btn-buy-item:active:not(:disabled) {
  transform: translateY(4px);
  box-shadow: 0 0 0 var(--accent-orange-shadow);
}

.btn-buy-item:disabled {
  background: #cbd5e1;
  color: #94a3b8;
  box-shadow: 0 4px 0 #94a3b8;
  cursor: not-allowed;
}

.buy-label {
  display: none; /* Hide 'Comprar' text to save space */
}

.buy-price {
  font-size: 11px;
}

.btn-buy-item.locked {
  background: #e2e8f0;
  border-bottom-color: #cbd5e1;
  color: var(--text-muted);
  box-shadow: none;
  cursor: not-allowed;
  font-size: 10px;
}

.buy-locked {
  font-size: 10px;
}

/* Modal de Ganancia Offline */
.offline-modal {
  position: fixed;
  inset: 0;
  background: rgba(10, 94, 102, 0.25);
  backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.offline-modal.active {
  opacity: 1;
  pointer-events: auto;
}

.offline-card {
  width: min(340px, 92vw);
  background: var(--bg-panel);
  border: 3px solid var(--line-color);
  border-radius: 24px;
  padding: 20px;
  text-align: center;
  box-shadow: 0 16px 40px rgba(10, 94, 102, 0.15);
  transform: scale(0.85);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.offline-modal.active .offline-card {
  transform: scale(1);
}

.offline-icon {
  font-size: 48px;
  margin-bottom: 8px;
  animation: float 2s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.offline-card h3 {
  font-family: var(--font-title);
  font-size: 22px;
  color: var(--text-dark);
  margin-bottom: 6px;
}

.offline-earnings {
  font-size: 28px;
  font-weight: 900;
  color: var(--accent-orange);
  margin: 10px 0;
}

.offline-card p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 16px;
}

.offline-btn {
  background: linear-gradient(135deg, var(--accent-teal) 0%, #3cd3b7 100%);
  color: #ffffff;
  border: none;
  border-bottom: 4px solid #166a5b;
  border-radius: 12px;
  padding: 8px 24px;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 900;
  cursor: pointer;
  transition: transform 0.1s;
}

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

/* MOBILE FIRST - AJUSTE 100VH SIN SCROLL */
@media (max-width: 880px) {
  .game-shell {
    padding: 6px;
    gap: 6px;
  }

  .game-header {
    padding: 6px 10px;
    border-radius: 12px;
    height: 42px;
  }

  .game-header h1 {
    display: none; /* Ocultar el título 'Fusión' para ganar espacio vertical */
  }

  .hud-top-stats {
    gap: 4px;
  }

  .btn-reset-hud {
    width: 30px;
    height: 30px;
    font-size: 11px;
  }

  .hud-pill {
    padding: 4px 8px;
    font-size: 11px;
    gap: 2px;
  }

  .sidebar-panel {
    max-height: none;
    flex: none;
  }

  .panel-card {
    padding: 6px;
    border-radius: 14px;
    gap: 0;
    border-width: 1.5px;
  }

  .panel-card h2 {
    display: none; /* Ocultar "Tienda de Emociones" para ahorrar espacio */
  }

  /* GRID DE TIENDA 4 COLUMNAS - AMPLIO Y SIN SCROLL */
  .shop-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    overflow: visible;
    padding: 0;
    margin: 0;
    flex: none;
    max-height: none;
  }

  .shop-item {
    gap: 2px;
    padding: 4px;
    border-radius: 8px;
    border-width: 1.5px;
  }

  .shop-item-info {
    gap: 2px;
  }

  .shop-item-icon {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: none;
  }

  .btn-buy-item {
    padding: 4px 2px;
    border-radius: 6px;
  }

  .btn-buy-item .buy-price {
    font-size: 10px;
  }
}

  .btn-buy-item .buy-locked {
    display: block;
    font-size: 9px;
    font-weight: 800;
    white-space: nowrap;
  }
}
