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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0b0e1a;
  font-family: 'Segoe UI', system-ui, sans-serif;
  touch-action: none; /* evita pull-to-refresh, pinch-zoom y doble-tap-zoom durante el juego */
  overscroll-behavior: none;
}

#game-canvas {
  display: block;
  width: 100vw;
  height: 100vh;
}

#ui-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  color: #f5f6fa;
  pointer-events: none;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
}

#ui-left-stack,
#ui-center-stack {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#ui-center-stack {
  align-items: center;
}

#ui-wallet {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: rgba(245, 246, 250, 0.7);
}

#ui-lives {
  font-size: 18px;
  letter-spacing: 3px;
  color: #ff4757;
}

#ui-level {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: #c8cdd8;
}

#ui-coins,
#ui-score {
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

#ui-bottom-right {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

#ui-controls-hint {
  color: rgba(245, 246, 250, 0.6);
  font-size: 13px;
  text-align: right;
  line-height: 1.4;
}

#btn-mute-music {
  border: none;
  border-radius: 6px;
  padding: 6px 14px;
  background: rgba(21, 26, 46, 0.75);
  color: #f5f6fa;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.3px;
  cursor: pointer;
  transition: background 0.15s ease;
}

#btn-mute-music:hover {
  background: rgba(42, 49, 80, 0.9);
}

#hit-flash-overlay {
  position: fixed;
  inset: 0;
  background: #ff0000;
  opacity: 0;
  pointer-events: none;
  z-index: 40;
}

#hit-flash-overlay.hit-flash-active {
  animation: hitFlash 0.35s ease-out;
}

@keyframes hitFlash {
  0% { opacity: 0.6; }
  100% { opacity: 0; }
}

#game-hud.hidden {
  display: none;
}

.menu-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(11, 14, 26, 0.85);
  backdrop-filter: blur(2px);
}

.menu-overlay.hidden {
  display: none;
}

.menu-panel {
  text-align: center;
  color: #f5f6fa;
  padding: 32px 48px;
  border-radius: 12px;
  background: #151a2e;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  min-width: 280px;
  max-width: 420px;
  max-height: 85vh;
  max-height: 85dvh;
  overflow-y: auto;
}

.menu-panel h1 {
  font-size: 32px;
  margin-bottom: 24px;
  color: #f5f6fa;
}

#game-over-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  background: rgba(11, 14, 26, 0.93);
  text-align: center;
  padding: 24px;
  overflow-y: auto; /* si el contenido no entra verticalmente (landscape mobile), scrollea en vez de cortarse */
  max-height: 100vh;
  max-height: 100dvh; /* dvh: descuenta la barra del navegador en mobile, más preciso que vh */
}

#game-over-overlay.hidden {
  display: none;
}

#game-over-title {
  font-size: clamp(2rem, 9vmin, 8rem);
  line-height: 1.05;
  font-weight: 900;
  color: #ff4757;
  text-shadow: 0 4px 32px rgba(255, 71, 87, 0.55);
  max-width: 92vw;
  margin: 0;
}

#game-over-subtitle {
  font-size: clamp(1rem, 3.5vmin, 1.6rem);
  color: #c8cdd8;
  margin: 0;
}

#game-over-save-status {
  font-size: 14px;
  color: #ffa502;
  max-width: 340px;
  margin: -8px 0 4px;
}

#game-over-save-status.hidden {
  display: none;
}

#btn-retry-save-score.hidden {
  display: none;
}

#game-over-overlay .menu-button {
  width: auto;
  padding: 14px 40px;
  font-size: clamp(1rem, 3vmin, 1.4rem);
}

#splash-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #000000 center / cover no-repeat;
  /* Poné tu imagen acá cuando la tengas, mismo nombre exacto: */
  background-image: url('../assets/images/splash.jpg');
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 64px;
}

#splash-screen.hidden {
  display: none;
}

#splash-loading-text {
  color: rgba(245, 246, 250, 0.7);
  font-size: 15px;
  letter-spacing: 1px;
  text-transform: uppercase;
  animation: splashPulse 1.4s ease-in-out infinite;
}

@keyframes splashPulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

#main-menu-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  background: rgba(11, 14, 26, 0.85);
  text-align: center;
  padding: 24px;
  overflow-y: auto;
  max-height: 100vh;
  max-height: 100dvh;
}

#main-menu-overlay.hidden {
  display: none;
}

#main-menu-overlay h1 {
  font-size: clamp(1.5rem, 6vmin, 3rem);
  color: #f5f6fa;
  margin: 0 0 8px;
  text-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

#menu-logo {
  max-width: min(320px, 60vw);
  max-height: min(160px, 25vh);
  width: auto;
  height: auto;
  object-fit: contain;
  margin-bottom: 8px;
}


#main-menu-overlay .menu-button {
  width: auto;
  min-width: 220px;
  padding: 14px 40px;
}

#identity-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 320px;
  margin-bottom: 4px;
}

#wallet-reassurance {
  font-size: 13px;
  line-height: 1.4;
  color: rgba(245, 246, 250, 0.55);
  margin: 0 0 4px;
}

#wallet-connected-address {
  padding: 10px 16px;
  border-radius: 8px;
  background: rgba(46, 204, 113, 0.12);
  border: 1px solid rgba(46, 204, 113, 0.4);
  color: #2ecc71;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

#wallet-connected-address.hidden {
  display: none;
}

#btn-connect-wallet.hidden,
#btn-disconnect-wallet.hidden {
  display: none;
}

#identity-form input {
  width: 100%;
  padding: 12px 16px;
  border-radius: 8px;
  border: 1px solid rgba(245, 246, 250, 0.2);
  background: rgba(255, 255, 255, 0.06);
  color: #f5f6fa;
  font-size: 15px;
}

#identity-form input::placeholder {
  color: rgba(245, 246, 250, 0.45);
}

#identity-form input:focus {
  outline: none;
  border-color: #2e86de;
}

#identity-form-error {
  color: #ff4757;
  font-size: 13px;
  margin-top: -2px;
}

#identity-form-error.hidden {
  display: none;
}

.menu-button {
  display: block;
  width: 100%;
  font-size: 18px;
  font-weight: 700;
  padding: 12px 32px;
  border: none;
  border-radius: 8px;
  background: #2a3150;
  color: #ffffff;
  cursor: pointer;
  transition: background 0.15s ease;
  margin-top: 12px;
}

.menu-button:hover {
  background: #3a4270;
}

.menu-button--primary {
  background: #2e86de;
}

.menu-button--primary:hover {
  background: #4aa3ff;
}

.menu-button:disabled {
  background: #2a3150;
  color: rgba(245, 246, 250, 0.5);
  cursor: not-allowed;
}

.menu-button:disabled:hover {
  background: #2a3150;
}

.leaderboard-list {
  list-style: none;
  padding: 0;
  margin: 0 0 16px 0;
  max-height: 220px;
  overflow-y: auto;
  text-align: left;
}

.leaderboard-list li {
  padding: 6px 10px;
  font-size: 14px;
  color: #f5f6fa;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 6px;
  margin-bottom: 4px;
}

.leaderboard-list li.leaderboard-empty,
.leaderboard-list li.leaderboard-loading {
  color: #8395a7;
  font-style: italic;
  background: none;
}

#touch-controls-left,
#touch-controls-right {
  display: none; /* la media query de abajo los muestra solo en touch */
  position: fixed;
  bottom: 28px;
  gap: 16px;
  z-index: 60;
}

#touch-controls-left {
  left: 24px;
}

#touch-controls-right {
  right: 24px;
  flex-direction: column; /* salto arriba, agachar abajo */
}

.touch-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 2px solid rgba(245, 246, 250, 0.35);
  background: rgba(21, 26, 46, 0.55);
  color: #f5f6fa;
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none; /* evita scroll/zoom del navegador al tocar el botón */
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.touch-btn:active {
  background: rgba(46, 134, 222, 0.55);
  border-color: rgba(46, 134, 222, 0.8);
}

/* pointer:coarse = dedo/touch (a diferencia de mouse, que es "fine") -- así
   no aparecen en desktop. */
@media (pointer: coarse) {
  #touch-controls-left,
  #touch-controls-right {
    display: flex;
  }

  #ui-controls-hint {
    display: none; /* el hint de teclado no aplica acá */
  }
}

/* Landscape mobile (altura chica, aunque el ancho sea grande): apretar
   espaciados en los menús para que quepan sin necesidad de scroll. */
@media (max-height: 500px) {
  #main-menu-overlay,
  #game-over-overlay {
    gap: 8px;
    padding: 12px;
  }

  #menu-logo {
    max-height: 14vh;
    margin-bottom: 2px;
  }

  #main-menu-overlay h1,
  #game-over-title {
    margin-bottom: 2px;
  }

  #game-over-title {
    font-size: clamp(1.6rem, 7vmin, 4rem);
  }

  #wallet-reassurance {
    display: none; /* texto secundario, no crítico -- libera espacio vertical */
  }

  .menu-button {
    padding: 8px 24px;
    margin-top: 6px;
  }

  #identity-form {
    gap: 6px;
    margin-bottom: 0;
  }

  #identity-form input,
  #btn-connect-wallet,
  #btn-disconnect-wallet,
  #wallet-connected-address {
    padding: 8px 14px;
  }

  .menu-panel {
    padding: 16px 24px;
  }
}
