/* =========================================================
   FACTORHEX - Estilos del Juego Incremental con Iconos SVG
   ========================================================= */

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

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background-color: #eef1f5; /* Gris suave neutro */
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  color: #1f2937;
}

#game {
  display: block;
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* UI Superior Fija */
.ui-layer {
  position: fixed;
  top: env(safe-area-inset-top, 14px);
  left: env(safe-area-inset-left, 14px);
  right: env(safe-area-inset-right, 14px);
  z-index: 50;
  pointer-events: none;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

/* Panel Principal de Recursos */
.stats-panel {
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 18px;
  padding: 10px 16px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.08);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.resource-main {
  display: flex;
  align-items: center;
  gap: 10px;
}

.res-icon-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: #fef3c7;
  color: #d97706;
}

.icon-zap {
  fill: #f59e0b;
  stroke: #d97706;
}

.res-details {
  display: flex;
  flex-direction: column;
}

.res-val-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.res-value {
  font-size: 24px;
  font-weight: 900;
  color: #0f172a;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  letter-spacing: -0.5px;
}

.res-unit {
  font-size: 12px;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.res-rate {
  font-size: 13px;
  font-weight: 700;
  color: #10b981;
  font-variant-numeric: tabular-nums;
}

.meta-stats {
  display: flex;
  gap: 6px;
  margin-top: 2px;
}

.meta-tag {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  background: #f1f5f9;
  color: #475569;
}

.tag-mult {
  background: #eff6ff;
  color: #2563eb;
}

/* Acciones arriba a la derecha */
.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
}

.icon-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 12px;
  color: #374151;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: transform 0.15s, background-color 0.15s;
  outline: none;
}

.icon-action-btn:hover {
  background: #ffffff;
  transform: translateY(-2px) scale(1.04);
}

.icon-action-btn:active {
  transform: translateY(1px) scale(0.96);
}

/* Toast flotante informativo */
.toast {
  position: fixed;
  top: 90px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(17, 24, 39, 0.92);
  color: #ffffff;
  padding: 10px 22px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
  z-index: 100;
  pointer-events: none;
  backdrop-filter: blur(8px);
  transition: opacity 0.25s, transform 0.25s;
  text-align: center;
  max-width: 90vw;
}

/* =========================================================
   DRAWER INFERIOR DE CONSTRUCCIÓN Y MEJORAS
   ========================================================= */
.build-drawer {
  position: fixed;
  bottom: env(safe-area-inset-bottom, 16px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  width: calc(100% - 32px);
  max-width: 500px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 20px;
  padding: 14px 16px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.14);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: slideUp 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

@keyframes slideUp {
  from { transform: translate(-50%, 40px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  font-weight: 800;
  color: #64748b;
  letter-spacing: 0.5px;
}

.drawer-cost {
  color: #0f172a;
}

.drawer-close {
  background: transparent;
  border: none;
  font-size: 22px;
  color: #94a3b8;
  cursor: pointer;
  line-height: 1;
}

.drawer-close:hover {
  color: #0f172a;
}

.building-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.build-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  padding: 10px 6px;
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: 14px;
  cursor: pointer;
  transition: transform 0.12s, border-color 0.12s, background-color 0.12s;
  outline: none;
}

.build-card:hover {
  background: #ffffff;
  border-color: #3b82f6;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
}

.build-card:active {
  transform: translateY(1px);
}

.bcard-icon-wrap {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-gen .bcard-icon-wrap {
  background: #ecfdf5;
  color: #10b981;
}

.card-mult .bcard-icon-wrap {
  background: #eff6ff;
  color: #3b82f6;
}

.card-reactor .bcard-icon-wrap {
  background: #f5f3ff;
  color: #8b5cf6;
}

.bcard-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.bcard-name {
  font-size: 12px;
  color: #0f172a;
  font-weight: 800;
  line-height: 1.1;
}

.bcard-desc {
  font-size: 10px;
  color: #64748b;
  line-height: 1.1;
}

/* Upgrade Drawer */
.upg-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.upg-current-info {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
}

.upg-icon-badge {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: #eff6ff;
  border: 1.5px solid #bfdbfe;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #2563eb;
}

.upg-text h4 {
  margin: 0;
  font-size: 15px;
  font-weight: 800;
  color: #0f172a;
}

.upg-text p {
  margin: 2px 0 0 0;
  font-size: 12px;
  color: #10b981;
  font-weight: 600;
}

.btn-upgrade {
  width: 100%;
  padding: 12px 16px;
  border-radius: 12px;
  background: #3b82f6;
  color: #ffffff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 800;
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.35);
  transition: background-color 0.15s, transform 0.15s;
}

.btn-upgrade:hover {
  background: #2563eb;
  transform: translateY(-1px);
}

.btn-upgrade:disabled {
  background: #cbd5e1;
  cursor: not-allowed;
  box-shadow: none;
}

.hidden {
  display: none !important;
}
