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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #1e2029;
  font-family: 'Press Start 2P', monospace;
  color: #f8fafc;
  touch-action: none;
  overscroll-behavior: none;
}

/* MARCOS DE DIÁLOGO URBANO PIXEL ART */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 10px;
}

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

.urban-dialog-box {
  background: #334155;
  border: 4px solid #64748b;
  box-shadow:
    inset 4px 4px 0px #94a3b8,
    inset -4px -4px 0px #0f172a,
    0 12px 30px rgba(0, 0, 0, 0.85);
  border-radius: 6px;
  padding: 16px 12px;
  max-width: 580px;
  width: 95%;
  text-align: center;
  position: relative;
  image-rendering: pixelated;
  max-height: 94vh;
  overflow-y: auto;
}

.dialog-banner {
  background: #1e293b;
  border: 3px solid #38bdf8;
  box-shadow: inset 2px 2px #0284c7, inset -2px -2px #0f172a;
  padding: 8px 12px;
  margin-bottom: 12px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dialog-banner h2 {
  font-size: 11px;
  color: #f8fafc;
  text-shadow: 2px 2px #0f172a;
}

.sub-banner {
  font-size: 8px;
  color: #38bdf8;
}

.close-urban-btn {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 16px;
  cursor: pointer;
  padding: 2px 6px;
}

/* FILA DE RETRATOS DE PERSONAJES */
.urban-portraits-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.portrait-card {
  background: #1e293b;
  border: 3px solid #475569;
  box-shadow: inset 2px 2px #64748b, inset -2px -2px #0f172a;
  border-radius: 4px;
  padding: 8px 4px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: transform 0.1s;
}

.portrait-card:active, .portrait-card.active {
  border-color: #38bdf8;
  background: #0f172a;
  box-shadow: inset 3px 3px #7dd3fc, inset -3px -3px #0369a1, 0 0 12px rgba(56, 189, 248, 0.6);
  transform: translateY(-3px);
}

.portrait-frame {
  width: 70px;
  height: 70px;
  background: #0f172a;
  border: 3px solid #334155;
  box-shadow: inset 2px 2px #020617;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 6px;
}

.pixel-portrait-canvas {
  width: 64px;
  height: 64px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.portrait-name {
  font-size: 9px;
  color: #f8fafc;
  margin-bottom: 4px;
  font-weight: bold;
}

.portrait-tag {
  font-size: 7px;
  color: #38bdf8;
  background: #0f172a;
  padding: 2px 4px;
  border-radius: 2px;
  border: 1px solid #0284c7;
}

.urban-btn-primary {
  font-family: 'Press Start 2P', monospace;
  font-size: 11px;
  background: #16a34a;
  color: white;
  border: 3px solid #86efac;
  box-shadow: inset 2px 2px #4ade80, inset -2px -2px #14532d, 0 4px 0 #052e16;
  padding: 12px 20px;
  cursor: pointer;
  border-radius: 4px;
  width: 100%;
}

.urban-btn-primary:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #052e16;
}

/* JUEGO PANTALLA COMPLETA */
#game-container {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: #1e2029;
}

canvas#gameCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  display: block;
}

/* HUD ULTRA RESPONSIVE MÓVIL */
#urban-hud {
  position: absolute;
  top: env(safe-area-inset-top, 6px);
  left: 6px;
  right: 6px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
  z-index: 50;
  gap: 6px;
}

.hud-player-badge {
  background: rgba(15, 23, 42, 0.92);
  border: 2px solid #475569;
  border-radius: 4px;
  padding: 3px 6px;
  display: flex;
  align-items: center;
  gap: 6px;
  pointer-events: auto;
  max-width: 48vw;
}

.hud-mini-canvas {
  width: 26px;
  height: 26px;
  background: #020617;
  border: 1.5px solid #334155;
  image-rendering: pixelated;
}

.hud-player-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.hud-name-text {
  font-size: 8px;
  color: #f8fafc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hud-zone-text {
  font-size: 6px;
  color: #94a3b8;
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hud-wallet-badge {
  background: rgba(15, 23, 42, 0.92);
  border: 2px solid #eab308;
  border-radius: 4px;
  padding: 3px 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  pointer-events: auto;
}

.wallet-row {
  display: flex;
  align-items: center;
  gap: 4px;
}

.wallet-num {
  font-size: 7px;
  color: #fef08a;
  font-weight: bold;
}

.vault-row .wallet-num {
  color: #7dd3fc;
}

.gold-coin-icon, .vault-icon {
  font-size: 9px;
}

.hud-action-icons {
  display: flex;
  gap: 4px;
  pointer-events: auto;
}

.hud-circle-tool {
  width: 34px;
  height: 34px;
  background: #1e293b;
  border: 2px solid #475569;
  border-radius: 4px;
  font-size: 14px;
  color: #f8fafc;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.special-learn-btn {
  background: #0284c7;
  border-color: #38bdf8;
  animation: pulseGlow 1.8s infinite;
}

@keyframes pulseGlow {
  0% { box-shadow: 0 0 0 0 rgba(56, 189, 248, 0.7); }
  50% { box-shadow: 0 0 10px rgba(56, 189, 248, 0.9); }
  100% { box-shadow: 0 0 0 0 rgba(56, 189, 248, 0.7); }
}

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

/* TOAST */
.urban-toast {
  position: absolute;
  top: calc(env(safe-area-inset-top, 6px) + 50px);
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  border: 2px solid #38bdf8;
  box-shadow: 0 6px 18px rgba(0,0,0,0.6);
  padding: 6px 14px;
  font-size: 8px;
  color: #f8fafc;
  border-radius: 3px;
  z-index: 60;
  max-width: 90vw;
  text-align: center;
  white-space: normal;
  animation: slideToast 0.2s ease;
}

.urban-toast.hidden { display: none; }

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

/* CONTROLES TÁCTILES */
#mobile-controls {
  position: absolute;
  bottom: env(safe-area-inset-bottom, 10px);
  left: 0;
  right: 0;
  height: 120px;
  pointer-events: none;
  z-index: 40;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 0 14px 6px 14px;
}

#joystick-area {
  width: 110px;
  height: 110px;
  pointer-events: auto;
  touch-action: none;
  position: relative;
}

#joystick-ring {
  width: 96px;
  height: 96px;
  background: rgba(15, 23, 42, 0.5);
  border: 3px solid rgba(148, 163, 184, 0.6);
  border-radius: 50%;
  position: absolute;
  bottom: 0;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

#joystick-knob {
  width: 44px;
  height: 44px;
  background: rgba(56, 189, 248, 0.85);
  border: 2.5px solid #ffffff;
  border-radius: 50%;
  box-shadow: 0 0 10px rgba(0,0,0,0.5);
  pointer-events: none;
  transform: translate(0px, 0px);
}

#buttons-area {
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.urban-mini-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #334155;
  border: 2px solid #64748b;
  color: white;
  font-size: 16px;
  box-shadow: 0 3px 8px rgba(0,0,0,0.4);
  cursor: pointer;
}

.urban-mini-btn:active { transform: scale(0.9); }

.urban-action-btn {
  width: 74px;
  height: 74px;
  border-radius: 50%;
  background: #16a34a;
  border: 3.5px solid #86efac;
  box-shadow: inset 2.5px 2.5px #4ade80, inset -2.5px -2.5px #14532d, 0 5px 0 #052e16;
  color: white;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
}

.urban-action-btn:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #052e16;
}

.urban-action-btn.pulse {
  border-color: #facc15;
  animation: actionGlow 1s infinite;
}

@keyframes actionGlow {
  0% { box-shadow: 0 0 0 0 rgba(250, 204, 21, 0.8); }
  50% { box-shadow: 0 0 14px rgba(250, 204, 21, 0.9); }
  100% { box-shadow: 0 0 0 0 rgba(250, 204, 21, 0.8); }
}

#action-btn-emoji { font-size: 24px; line-height: 1; }
#action-btn-label {
  font-size: 7px;
  font-weight: bold;
  margin-top: 2px;
  color: #ffffff;
}

#quick-reactions {
  position: absolute;
  bottom: calc(env(safe-area-inset-bottom, 10px) + 90px);
  right: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: auto;
  z-index: 45;
  max-height: 200px;
  overflow-y: auto;
}

#quick-reactions.hidden { display: none; }

.urban-reaction-pill {
  background: #1e293b;
  border: 2px solid #475569;
  color: #f8fafc;
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  padding: 6px 10px;
  border-radius: 4px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.5);
  text-align: left;
}

.urban-reaction-pill:active {
  background: #0f172a;
  border-color: #38bdf8;
}

/* ============================================== */
/* ESTILOS DE LA ACADEMIA DIDÁCTICA (APRENDIZAJE) */
/* ============================================== */
.learn-dialog-box {
  max-width: 600px;
  background: #1e293b;
  border: 4px solid #38bdf8;
}

.learn-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  margin-bottom: 12px;
}

.tab-btn {
  background: #334155;
  border: 2px solid #475569;
  color: #cbd5e1;
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  padding: 6px 2px;
  cursor: pointer;
  border-radius: 3px;
  white-space: nowrap;
}

.tab-btn.active {
  background: #0284c7;
  border-color: #7dd3fc;
  color: #ffffff;
  box-shadow: inset 1px 1px #38bdf8;
}

.learn-content-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.learn-content-view.hidden { display: none !important; }

.learn-instruction {
  font-size: 8px;
  color: #facc15;
  line-height: 1.4;
  margin-bottom: 6px;
}

/* ANIMALES GRID */
.animals-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  width: 100%;
}

.animal-card {
  background: #0f172a;
  border: 2px solid #475569;
  border-radius: 6px;
  padding: 8px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  transition: transform 0.1s;
}

.animal-card:active {
  transform: scale(0.95);
  border-color: #facc15;
  background: #1e293b;
}

.animal-emoji { font-size: 30px; margin-bottom: 4px; }
.animal-name { font-size: 8px; color: #f8fafc; font-weight: bold; margin-bottom: 3px; }
.animal-sound-label { font-size: 7px; color: #38bdf8; }

/* NÚMEROS Y CONTEO */
.visual-counting-area {
  background: #0f172a;
  border: 2px dashed #eab308;
  border-radius: 8px;
  padding: 14px 10px;
  font-size: 28px;
  letter-spacing: 6px;
  width: 100%;
  text-align: center;
  margin-bottom: 6px;
}

.numbers-choice-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  width: 100%;
}

.num-choice-btn {
  background: #0284c7;
  border: 3px solid #7dd3fc;
  color: white;
  font-family: 'Press Start 2P', monospace;
  font-size: 16px;
  padding: 12px 0;
  border-radius: 6px;
  cursor: pointer;
  box-shadow: 0 4px 0 #0369a1;
}

.num-choice-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #0369a1;
}

/* COLORES */
.colors-choice-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  width: 100%;
}

.color-btn {
  border: 3px solid #ffffff;
  color: white;
  font-family: 'Press Start 2P', monospace;
  font-size: 12px;
  padding: 18px 0;
  border-radius: 8px;
  cursor: pointer;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
  box-shadow: 0 4px 10px rgba(0,0,0,0.5);
}

.color-btn:active {
  transform: scale(0.95);
}

/* MATEMÁTICAS */
.math-display-card {
  background: #0f172a;
  border: 3px solid #38bdf8;
  border-radius: 8px;
  padding: 16px;
  font-size: 16px;
  color: #facc15;
  width: 100%;
  text-align: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

.math-choice-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  width: 100%;
  margin-top: 6px;
}

.math-choice-btn {
  background: #16a34a;
  border: 3px solid #86efac;
  color: white;
  font-family: 'Press Start 2P', monospace;
  font-size: 14px;
  padding: 12px 0;
  border-radius: 6px;
  cursor: pointer;
  box-shadow: 0 4px 0 #052e16;
}

.math-choice-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #052e16;
}

.learn-feedback-box {
  background: #15803d;
  border: 2px solid #86efac;
  color: #fef08a;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 8px;
  width: 100%;
  animation: popIn 0.2s ease;
}

.learn-feedback-box.error {
  background: #b91c1c;
  border-color: #fca5a5;
  color: #ffffff;
}

@keyframes popIn {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* TIENDA */
.shop-modal-box { max-width: 500px; }
.dialog-desc { font-size: 8px; color: #94a3b8; margin-bottom: 12px; }

.urban-shop-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.shop-slot {
  background: #1e293b;
  border: 2px solid #475569;
  border-radius: 4px;
  padding: 8px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.slot-icon { font-size: 28px; margin-bottom: 2px; }
.slot-title { font-size: 7px; color: #f8fafc; margin-bottom: 3px; font-weight: bold; }
.slot-price { font-size: 8px; color: #facc15; margin-bottom: 6px; font-weight: bold; }

.btn-buy-urban {
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  background: #16a34a;
  border: 2px solid #86efac;
  color: white;
  padding: 5px 8px;
  cursor: pointer;
  border-radius: 3px;
}

.btn-buy-urban.bought {
  background: #475569;
  border-color: #94a3b8;
  cursor: default;
}
