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

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: radial-gradient(ellipse at center, #1a1a3e 0%, #0a0a1a 70%);
}

#game-wrapper {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 12px;
}

/* En 2 jugadores queremos llenar el ancho del viewport */
#game-wrapper.split-2p-wrapper {
  padding: 0;
  align-items: stretch;
}

#game-stage {
  position: relative;
  max-width: 100%;
  max-height: calc(100% - 48px);
}

/* En split (2P), el área total (2 mitades) = 100% del ancho disponible */
#game-stage.split-2p {
  width: 100vw;
  max-width: 100vw;
}

#game-stage.split-2p #game-container {
  width: 100vw;
  max-width: 100vw;
  border-left: 0;
  border-right: 0;
  border-radius: 0;
}

.menu-logo {
  position: absolute;
  top: 4%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  max-width: min(440px, 92%);
  max-height: clamp(70px, 14vh, 130px);
  width: auto;
  height: auto;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
  filter: drop-shadow(0 0 12px rgba(79, 195, 247, 0.5));
}

.author-web {
  margin-top: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.match-counter {
  padding: 6px 10px;
  border-radius: 999px;
  border: 2px solid rgba(79, 195, 247, 0.55);
  background: rgba(10, 10, 26, 0.65);
  color: #e8f4ff;
  font-family: "Segoe UI", Arial, sans-serif;
  font-weight: 800;
  letter-spacing: 0.2px;
  box-shadow:
    0 0 18px rgba(79, 195, 247, 0.18),
    inset 0 0 26px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

#game-container {
  border: 3px solid #4fc3f7;
  border-radius: 12px;
  box-shadow:
    0 0 24px rgba(79, 195, 247, 0.45),
    inset 0 0 40px rgba(0, 0, 0, 0.35);
  overflow: hidden;
  max-width: 100%;
  max-height: calc(100vh - 72px);
}

#character-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
  overflow: visible;
}

#character-layer .player-chars {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

#game-stage.split-2p #character-layer .char-sprite,
#game-stage.split-2p #character-layer #dom-mando-0,
#game-stage.split-2p #character-layer #dom-mando-1 {
  height: clamp(58px, 10vh, 88px);
}

#game-stage.split-2p #dom-mando-0,
#game-stage.split-2p #dom-mando-1 {
  min-width: 70px;
  min-height: 96px;
}

#game-stage.split-2p .char-hint {
  font-size: 9px;
  max-width: 120px;
  white-space: normal;
}

#dom-mando-img-0,
#dom-mando-img-1 {
  filter: drop-shadow(0 0 10px rgba(79, 195, 247, 0.85))
    drop-shadow(0 4px 12px rgba(0, 0, 0, 0.9));
}

#dom-grogu-0,
#dom-grogu-1 {
  filter: drop-shadow(0 0 10px rgba(79, 195, 247, 0.85))
    drop-shadow(0 4px 12px rgba(0, 0, 0, 0.9));
  transition: filter 0.2s ease;
}

#dom-grogu-0.grogu-active,
#dom-grogu-1.grogu-active {
  filter: drop-shadow(0 0 12px rgba(118, 255, 122, 0.95))
    drop-shadow(0 0 22px rgba(76, 175, 80, 0.85))
    drop-shadow(0 4px 12px rgba(0, 0, 0, 0.9));
}


#character-layer .char-sprite {
  position: absolute;
  transform: translate(-50%, -50%);
  height: clamp(80px, 14vh, 130px);
  width: auto;
  user-select: none;
  -webkit-user-drag: none;
}


#dom-mando-0,
#dom-mando-1 {
  position: absolute;
  transform: translate(-50%, -50%);
  padding: 8px;
  border: none;
  background: transparent;
  cursor: pointer;
  pointer-events: auto;
  z-index: 20;
  height: clamp(80px, 14vh, 130px);
  min-width: 90px;
  min-height: 120px;
  touch-action: manipulation;
}

#dom-mando-img-0,
#dom-mando-img-1 {
  display: block;
  height: 100%;
  width: auto;
  pointer-events: none;
}

#dom-grogu-0,
#dom-grogu-1 {
  display: block;
  pointer-events: none;
}

#dom-grogu-0.grogu-cookie,
#dom-grogu-1.grogu-cookie {
  filter: drop-shadow(0 0 12px rgba(255, 213, 79, 0.95))
    drop-shadow(0 0 22px rgba(255, 193, 7, 0.8))
    drop-shadow(0 4px 12px rgba(0, 0, 0, 0.9));
  transform: translate(-50%, -50%) scaleX(-1);
}

.char-hint {
  position: absolute;
  transform: translate(-50%, 0);
  margin: 0;
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 11px;
  color: #90caf9;
  text-align: center;
  white-space: nowrap;
  pointer-events: none;
}

#dom-grogu-0.grogu-jump,
#dom-grogu-1.grogu-jump {
  animation: grogu-jump 0.2s ease-out 3;
}

@keyframes grogu-jump {
  0%,
  100% {
    transform: translate(-50%, -50%);
  }
  50% {
    transform: translate(-50%, calc(-50% - 22px));
  }
}

#game-container canvas {
  display: block;
  width: auto !important;
  max-width: 100% !important;
  height: auto !important;
  max-height: 100vh;
}

/* En 2 jugadores queremos maximizar el ancho (evitar que la altura limite el escalado) */
#game-stage.split-2p {
  max-height: 100vh;
}

#game-stage.split-2p #game-container {
  max-height: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

#game-stage.split-2p #game-container canvas {
  /* Evita que se corte arriba/abajo: el canvas debe respetar el alto disponible */
  max-height: 100vh !important;
  width: auto !important;
  height: auto !important;
  max-width: 100vw !important;
  margin: 0 auto;
}

.footer-hint {
  margin-top: 10px;
  color: #90caf9;
  font-size: clamp(0.75rem, 2vw, 0.9rem);
  text-align: center;
  opacity: 0.85;
  max-width: 520px;
}

.author-footer {
  margin-top: 14px;
  padding: 12px 16px 6px;
  text-align: center;
  color: #b0bec5;
  font-size: clamp(0.72rem, 1.8vw, 0.88rem);
  max-width: 640px;
  line-height: 1.45;
}

.author-credit {
  margin-bottom: 8px;
  color: #e3f2fd;
  font-size: clamp(0.85rem, 2vw, 1rem);
}

.author-credit strong {
  color: #4fc3f7;
  font-weight: 700;
}

.author-networks {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px 16px;
  margin: 0 0 8px;
  padding: 0;
}

.social-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #81d4fa;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.social-icon {
  display: inline-flex;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.social-icon svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
}

.social-link:hover,
.social-link:focus-visible {
  color: #ffffff;
  border-bottom-color: #4fc3f7;
}

.social-link:focus-visible {
  outline: 2px solid #4fc3f7;
  outline-offset: 2px;
}

.author-web .social-link {
  font-weight: 600;
}

.music-toggle {
  position: absolute;
  top: 10px;
  right: 14px;
  z-index: 50;
  padding: 10px 14px;
  border-radius: 12px;
  border: 2px solid rgba(79, 195, 247, 0.7);
  background: rgba(10, 10, 26, 0.65);
  color: #e8f4ff;
  font-family: "Segoe UI", Arial, sans-serif;
  font-weight: 800;
  letter-spacing: 0.2px;
  cursor: pointer;
  box-shadow:
    0 0 18px rgba(79, 195, 247, 0.25),
    inset 0 0 30px rgba(0, 0, 0, 0.4);
}

.music-toggle:focus-visible {
  outline: 3px solid rgba(229, 57, 205, 0.8);
  outline-offset: 2px;
}

.menu-toggle {
  position: absolute;
  top: 10px;
  left: 14px;
  z-index: 50;
  padding: 10px 14px;
  border-radius: 12px;
  border: 2px solid rgba(229, 57, 205, 0.75);
  background: rgba(10, 10, 26, 0.65);
  color: #f3e5f5;
  font-family: "Segoe UI", Arial, sans-serif;
  font-weight: 800;
  letter-spacing: 0.2px;
  cursor: pointer;
  box-shadow:
    0 0 18px rgba(229, 57, 205, 0.25),
    inset 0 0 30px rgba(0, 0, 0, 0.4);
}

.menu-toggle:focus-visible {
  outline: 3px solid rgba(229, 57, 205, 0.85);
  outline-offset: 2px;
}

@media (max-width: 600px) {
  #game-wrapper {
    padding: 6px;
  }

  .footer-hint {
    display: none;
  }

  .author-footer {
    padding: 8px 10px 4px;
    font-size: 0.72rem;
  }

  .author-networks {
    gap: 6px 10px;
  }
}
