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

/* ============================================================
   CONFIGURACIÓN GENERAL
============================================================ */

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  min-height: 100%;
  font-family: "Nunito", sans-serif;
  background: #8bd5ff;
  color: #20284a;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
}

button {
  font: inherit;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible {
  outline: 4px solid #ffe66d;
  outline-offset: 3px;
}

.hidden {
  display: none !important;
}

.screen {
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
}


/* ============================================================
   PANTALLA DE SELECCIÓN
============================================================ */

.select-screen {
  min-height: 100vh;
  min-height: 100dvh;

  overflow: hidden;
  position: relative;

  padding:
    max(20px, env(safe-area-inset-top))
    max(18px, 4vw)
    max(24px, env(safe-area-inset-bottom));

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;

  background:
    radial-gradient(
      circle at 50% 12%,
      #fff 0,
      rgba(255, 255, 255, .35) 18%,
      transparent 40%
    ),
    linear-gradient(
      180deg,
      #72c8ff 0%,
      #c7efff 54%,
      #9fe0a0 100%
    );
}

.select-screen::after {
  content: "";

  position: absolute;

  left: -10%;
  right: -10%;
  bottom: -22%;

  height: 45%;

  background: #80c978;

  border-radius: 50% 50% 0 0;

  z-index: 0;
}

.select-screen > * {
  position: relative;
  z-index: 2;
}


/* ============================================================
   TÍTULO
============================================================ */

.title {
  width: min(1100px, 96%);

  display: flex;
  align-items: center;
  justify-content: center;

  gap: clamp(6px, 2vw, 20px);

  margin-bottom: clamp(14px, 3vh, 24px);
}

.title h1 {
  margin: 0;

  padding:
    clamp(9px, 1.2vw, 12px)
    clamp(14px, 3vw, 34px)
    clamp(11px, 1.4vw, 15px);

  color: #fff5c5;

  font-family: "Baloo 2", cursive;

  font-size: clamp(1.55rem, 5vw, 4.7rem);

  line-height: .9;

  letter-spacing: 2px;

  text-align: center;

  text-shadow:
    0 5px 0 #222d50,
    0 9px 18px rgba(24, 57, 105, .35);

  background: #293555;

  border: 5px solid #fff;

  border-radius: 28px;

  transform: rotate(-1deg);

  box-shadow:
    0 9px 0 rgba(31, 47, 84, .22);
}

.title > span {
  font-size: clamp(1.5rem, 4vw, 4rem);

  filter:
    drop-shadow(
      0 5px 0 rgba(30, 40, 72, .2)
    );
}


/* ============================================================
   PERSONAJES
============================================================ */

.characters {
  width: min(1100px, 96%);

  display: flex;

  justify-content: center;

  align-items: stretch;

  gap: clamp(8px, 5vw, 65px);

  margin:
    clamp(8px, 2vh, 15px)
    auto
    clamp(15px, 3vh, 23px);
}

.character {
  --accent: #4f91ff;

  position: relative;

  flex: 1;

  width: 100%;

  max-width: 480px;

  min-width: 0;

  padding: clamp(7px, 1vw, 12px);

  border:
    clamp(4px, .5vw, 7px)
    solid
    rgba(255, 255, 255, .95);

  border-radius: clamp(18px, 2.5vw, 30px);

  background:
    linear-gradient(
      145deg,
      #eaf4ff,
      #8ebcff
    );

  box-shadow:
    0 12px 0 rgba(42, 83, 147, .22),
    0 22px 35px rgba(33, 76, 135, .2);

  cursor: pointer;

  transform: rotate(1.3deg);

  transition:
    transform .22s ease,
    box-shadow .22s ease;
}

.character:nth-child(2) {
  transform: rotate(-1.3deg);
}

.character:hover {
  transform:
    translateY(-8px)
    rotate(0)
    scale(1.015);
}

.character.selected {
  --accent: #ff5f87;

  background:
    linear-gradient(
      145deg,
      #ff8cab,
      #ff4f80
    );

  border-color: #fff4a8;

  box-shadow:
    0 0 0 5px rgba(255, 239, 115, .65),
    0 0 32px rgba(255, 92, 132, .7),
    0 14px 0 rgba(168, 55, 91, .22);

  transform:
    translateY(-8px)
    rotate(-1deg)
    scale(1.025);
}


/* ============================================================
   FOTO
============================================================ */

.photo-frame {
  width: 100%;

  aspect-ratio: 1 / .83;

  overflow: hidden;

  border-radius: clamp(13px, 2vw, 21px);

  background: #fff;

  border:
    clamp(3px, .4vw, 5px)
    solid
    #fff;
}

.photo-frame img {
  width: 100%;
  height: 100%;

  display: block;

  object-fit: cover;

  transition:
    transform .35s;
}

.character:hover img,
.character.selected img {
  transform: scale(1.035);
}


/* ============================================================
   NOMBRE
============================================================ */

.name-banner {
  margin:
    -2px
    clamp(3px, 1vw, 12px)
    3px;

  padding:
    clamp(5px, .8vw, 7px)
    clamp(3px, 1vw, 12px)
    clamp(7px, 1vw, 10px);

  background: var(--accent);

  border:
    clamp(2px, .35vw, 4px)
    solid
    #fff;

  border-radius:
    clamp(12px, 1.8vw, 18px);

  color: #fff;

  box-shadow:
    0 5px 0 rgba(34, 47, 80, .18);

  text-align: center;
}

.name-banner h2 {
  margin: 0;

  font-family: "Baloo 2";

  font-size: clamp(1.4rem, 4vw, 3.5rem);

  line-height: .85;

  letter-spacing: 2px;

  text-shadow:
    0 4px 0 rgba(28, 40, 72, .55);
}

.name-banner p {
  margin: 5px 0 0;

  font-size: clamp(.65rem, 1.8vw, 1.15rem);

  font-weight: 900;

  text-shadow:
    0 2px 0 rgba(28, 40, 72, .4);
}


/* ============================================================
   P1
============================================================ */

.player-tag {
  display: none;

  position: absolute;

  top: -23px;
  left: -20px;

  z-index: 5;

  padding: 6px 15px;

  color: #fff;

  background: #ff4e70;

  border: 5px solid #fff;

  border-radius: 15px;

  font-family: "Baloo 2";

  font-size: 1.8rem;

  font-weight: 900;

  transform: rotate(-7deg);

  box-shadow:
    0 5px 0 rgba(31, 47, 84, .22);
}

.selected .player-tag {
  display: block;
}


/* ============================================================
   CORONA
============================================================ */

.crown {
  display: none;

  position: absolute;

  right: clamp(9px, 2vw, 24px);

  bottom: clamp(43px, 5vw, 66px);

  color: #ffe56d;

  font-size: clamp(2rem, 4vw, 3.4rem);

  filter:
    drop-shadow(
      0 3px 0 #7f5260
    );
}

.selected .crown {
  display: block;

  animation:
    float 1.2s ease-in-out infinite alternate;
}

@keyframes float {
  to {
    transform:
      translateY(-6px)
      rotate(10deg);
  }
}


/* ============================================================
   INFORMACIÓN DE SELECCIÓN
============================================================ */

.selection-info {
  width: min(560px, 90%);

  min-width: 0;

  padding:
    clamp(6px, 1vw, 10px)
    clamp(13px, 3vw, 28px);

  display: flex;

  justify-content: center;

  align-items: center;

  gap: clamp(10px, 2vw, 22px);

  color: #fff;

  background: #242d4b;

  border: 4px solid white;

  border-radius: 30px;

  box-shadow:
    0 7px 0 rgba(31, 47, 84, .25);

  font-size: clamp(1rem, 2.4vw, 1.5rem);
}

.selection-info strong {
  font-family: "Baloo 2";

  font-size: 1.6em;

  letter-spacing: 2px;

  color: #ffe87b;
}


/* ============================================================
   CONTROLES SELECCIÓN
============================================================ */

.controls {
  width: min(1100px, 96%);

  display: flex;

  justify-content: space-between;

  gap: 15px;

  margin-top: clamp(12px, 2vh, 18px);

  color: #fff;

  font-weight: 900;
}

.controls div {
  padding: 10px 18px;

  background: rgba(30, 40, 72, .94);

  border: 3px solid #fff;

  border-radius: 16px;

  box-shadow:
    0 5px 0 rgba(31, 47, 84, .22);
}

.controls b {
  padding: 4px 9px;

  background: #ffe66d;

  color: #273252;

  border-radius: 8px;
}


/* ============================================================
   JUEGO
============================================================ */

.game-screen {
  width: 100%;

  min-height: 100vh;
  min-height: 100dvh;

  background: #bcecff;

  overflow: hidden;

  display: flex;

  flex-direction: column;
}

.game-top {
  flex: 0 0 auto;

  min-height: 62px;

  height: clamp(58px, 8vh, 70px);

  padding:
    8px
    max(18px, 4vw);

  display: flex;

  justify-content: space-between;

  align-items: center;

  gap: 10px;

  background: #273252;

  color: #fff;

  border-bottom: 5px solid #fff;

  position: relative;

  z-index: 10;
}

.game-logo {
  font-family: "Baloo 2";

  font-weight: 900;

  font-size:
    clamp(1rem, 3vw, 2rem);

  letter-spacing: 1px;

  white-space: nowrap;
}

.score-box {
  font-family: "Baloo 2";

  font-size:
    clamp(1.15rem, 2.5vw, 1.7rem);

  display: flex;

  gap: clamp(8px, 2vw, 20px);

  align-items: center;

  white-space: nowrap;
}

.score-box .best {
  font-family: "Nunito";

  font-size: .75rem;

  color: #ffe77b;
}


/* ============================================================
   MUNDO DEL JUEGO
============================================================ */

.game-world {
  position: relative;

  width: 100%;

  flex: 1 1 auto;

  height: calc(100vh - 120px);
  height: calc(100dvh - 120px);

  min-height: 300px;

  overflow: hidden;

  background:
    linear-gradient(
      #9ddcff 0%,
      #dff7ff 70%,
      #9bd88b 70.1%,
      #80c877 100%
    );
}

.game-world::after {
  content: "";

  position: absolute;

  left: 0;
  right: 0;
  bottom: 0;

  height: 29%;

  background:
    repeating-linear-gradient(
      160deg,
      transparent 0 18px,
      rgba(255, 255, 255, .12) 19px 21px
    ),
    #84cc78;

  border-top:
    5px solid
    rgba(255, 255, 255, .7);

  z-index: 1;

  pointer-events: none;
}


/* ============================================================
   CANVAS
============================================================ */

#gameCanvas {
  position: absolute;

  inset: 0;

  width: 100%;
  height: 100%;

  display: block;

  z-index: 3;

  touch-action: none;

  user-select: none;

  -webkit-user-select: none;
}


/* ============================================================
   DECORACIÓN DEL MUNDO
============================================================ */

.sun {
  position: absolute;

  width: clamp(55px, 9vw, 90px);
  height: clamp(55px, 9vw, 90px);

  border-radius: 50%;

  background: #ffe982;

  right: 10%;
  top: 10%;

  box-shadow:
    0 0 45px rgba(255, 226, 95, .65);

  z-index: 0;
}

.cloud {
  position: absolute;

  width: clamp(100px, 15vw, 150px);
  height: clamp(30px, 4vw, 45px);

  border-radius: 50px;

  background: rgba(255, 255, 255, .82);

  z-index: 1;
}

.cloud::before,
.cloud::after {
  content: "";

  position: absolute;

  background: inherit;

  border-radius: 50%;
}

.cloud::before {
  width: 65px;
  height: 65px;

  left: 22px;
  bottom: 5px;
}

.cloud::after {
  width: 80px;
  height: 80px;

  right: 22px;
  bottom: 0;
}

.cloud-a {
  top: 17%;
  left: -180px;
}

.cloud-b {
  top: 30%;
  left: -400px;

  transform: scale(.75);
}

.hill {
  position: absolute;

  border-radius: 50%;

  z-index: 0;
}

.hill-back {
  width: 70%;
  height: 38%;

  left: -12%;
  bottom: 21%;

  background: #a9df9d;
}

.hill-front {
  width: 75%;
  height: 36%;

  right: -18%;
  bottom: 17%;

  background: #8dd384;
}


/* ============================================================
   MENSAJES DEL JUEGO
============================================================ */

.start-hint,
.game-over {
  position: absolute;

  inset: 0;

  display: grid;

  place-items: center;

  padding:
    15px;

  background:
    rgba(31, 45, 78, .18);

  backdrop-filter: blur(2px);

  z-index: 8;

  overflow: auto;
}

.hint-card,
.over-card {
  width: min(480px, 92%);

  max-height: 90%;

  overflow: auto;

  padding:
    clamp(20px, 4vw, 28px);

  text-align: center;

  background:
    rgba(255, 255, 255, .96);

  border: 6px solid #fff;

  border-radius: 28px;

  box-shadow:
    0 14px 0 rgba(39, 50, 82, .25),
    0 25px 55px rgba(39, 50, 82, .22);
}

.hint-cat,
.sad-cat {
  font-size: clamp(3rem, 8vw, 4rem);
}

.hint-card h2,
.over-card h2 {
  margin: 0;

  color: #ff5b82;

  font-family: "Baloo 2";

  font-size: clamp(2rem, 7vw, 2.7rem);

  line-height: 1;
}

.hint-card p {
  font-weight: 800;
}

.small {
  font-size: .8rem;

  color: #63708d;
}


/* ============================================================
   BOTONES
============================================================ */

button {
  cursor: pointer;
}

#startButton,
#restartButton,
#changeButton {
  border: 0;

  border-radius: 15px;

  padding:
    13px 22px;

  background: #ff5f87;

  color: #fff;

  font-weight: 900;

  box-shadow:
    0 5px 0 #d83f67;

  touch-action: manipulation;
}

#startButton:active,
#restartButton:active {
  transform: translateY(4px);

  box-shadow:
    0 1px 0 #d83f67;
}

.secondary {
  display: block;

  margin: 14px auto 0;

  background: #4f91ff !important;

  box-shadow:
    0 5px 0 #3170dc !important;
}

.final-score {
  margin: 15px 0;

  font-family: "Baloo 2";

  font-size: 1.5rem;
}


/* ============================================================
   CONTROLES DEL JUEGO
============================================================ */

.game-controls {
  flex: 0 0 auto;

  min-height: 50px;

  height: clamp(50px, 7vh, 58px);

  padding:
    5px
    max(10px, env(safe-area-inset-right))
    max(5px, env(safe-area-inset-bottom))
    max(10px, env(safe-area-inset-left));

  background: #273252;

  color: #fff;

  display: flex;

  align-items: center;

  justify-content: center;

  gap: clamp(8px, 3vw, 28px);

  font-weight: 900;

  font-size:
    clamp(.65rem, 1.5vw, .85rem);

  text-align: center;
}

#mobileJump {
  display: none;

  border: 0;

  background: #ff5f87;

  color: white;

  border-radius: 12px;

  padding:
    8px 15px;

  font-weight: 900;

  touch-action: manipulation;

  min-height: 40px;
}


/* ============================================================
   PARTÍCULAS
============================================================ */

.particle {
  position: absolute;

  z-index: 7;

  pointer-events: none;

  animation:
    particle .7s ease-out forwards;
}

@keyframes particle {
  to {
    transform:
      translate(
        var(--x),
        var(--y)
      )
      scale(.3);

    opacity: 0;
  }
}


/* ============================================================
   TABLETS
============================================================ */

@media (max-width: 900px) {

  .characters {
    gap: 12px;
  }

  .character {
    box-shadow:
      0 9px 0 rgba(42, 83, 147, .22),
      0 15px 25px rgba(33, 76, 135, .2);
  }

  .controls {
    justify-content: center;
  }

}


/* ============================================================
   CELULARES
============================================================ */

@media (max-width: 700px) {

  .select-screen {
    padding:
      max(12px, env(safe-area-inset-top))
      2vw
      max(15px, env(safe-area-inset-bottom));
  }

  .title {
    gap: 5px;

    margin-bottom: 12px;
  }

  .title h1 {
    padding:
      8px 12px 10px;

    font-size:
      clamp(1.45rem, 8vw, 2.8rem);

    border-width: 4px;

    border-radius: 20px;

    text-shadow:
      0 3px 0 #222d50,
      0 6px 12px rgba(24, 57, 105, .35);
  }

  .title > span {
    font-size: 1.3rem;
  }

  .characters {
    width: 96%;

    gap: 7px;

    margin-top: 8px;
    margin-bottom: 14px;
  }

  .character {
    min-width: 0;

    padding: 6px;

    border-width: 4px;

    border-radius: 18px;

    box-shadow:
      0 7px 0 rgba(42, 83, 147, .22),
      0 12px 18px rgba(33, 76, 135, .2);
  }

  .character:hover {
    transform: none;
  }

  .character.selected {
    transform:
      translateY(-4px)
      rotate(-1deg)
      scale(1.02);
  }

  .photo-frame {
    border-width: 3px;

    border-radius: 12px;
  }

  .name-banner {
    margin:
      -1px
      3px
      2px;

    padding:
      5px
      3px
      7px;

    border-width: 2px;

    border-radius: 11px;
  }

  .name-banner h2 {
    font-size:
      clamp(1.25rem, 7vw, 2.4rem);
  }

  .name-banner p {
    font-size: .65rem;

    white-space: nowrap;
  }

  .crown {
    right: 8px;

    bottom: 42px;

    font-size: 1.9rem;
  }

  .player-tag {
    top: -13px;
    left: -9px;

    padding:
      2px 8px;

    border-width: 3px;

    border-radius: 9px;

    font-size: 1rem;
  }

  .selection-info {
    width: 90%;

    padding:
      6px 13px;

    gap: 10px;

    border-width: 3px;
  }

  .controls {
    width: 96%;

    justify-content: center;

    gap: 6px;

    margin-top: 12px;
  }

  .controls div {
    padding:
      6px 8px;

    font-size: .67rem;

    border-width: 2px;

    border-radius: 12px;
  }


  /* -------------------------
     JUEGO
  ------------------------- */

  .game-top {
    min-height: 55px;

    height: 55px;

    padding:
      6px 10px;

    border-bottom-width: 3px;
  }

  .game-logo {
    font-size: 1rem;
  }

  .score-box {
    font-size: 1.2rem;

    gap: 7px;
  }

  .score-box .best {
    display: none;
  }

  .game-world {
    height:
      calc(100dvh - 110px);

    min-height: 260px;
  }

  .game-controls {
    min-height: 55px;

    height: 55px;

    gap: 8px;

    font-size: .68rem;
  }

  .game-controls div:nth-child(2) {
    display: none;
  }

  #mobileJump {
    display: block;

    padding:
      8px 14px;

    min-height: 40px;

    font-size: .8rem;
  }

  .hint-card,
  .over-card {
    width: min(92%, 400px);

    border-width: 4px;

    border-radius: 22px;

    padding:
      18px;
  }

  .hint-card p {
    margin:
      7px 0;
  }

  #startButton,
  #restartButton,
  #changeButton {
    width: min(100%, 280px);

    min-height: 44px;
  }
}


/* ============================================================
   CELULARES MUY PEQUEÑOS
============================================================ */

@media (max-width: 420px) {

  .title h1 {
    font-size: 1.4rem;

    letter-spacing: 1px;
  }

  .title > span {
    font-size: 1.05rem;
  }

  .characters {
    gap: 5px;
  }

  .name-banner p {
    font-size: .57rem;
  }

  .selection-info {
    font-size: .9rem;
  }

  .controls div {
    font-size: .58rem;

    padding:
      5px 6px;
  }

  .game-logo {
    font-size: .85rem;
  }

  .score-box {
    font-size: 1rem;
  }

}


/* ============================================================
   CELULAR HORIZONTAL
============================================================ */

@media (max-height: 500px) and (orientation: landscape) {

  .select-screen {
    padding:
      8px 2vw 10px;
  }

  .title {
    margin-bottom: 7px;
  }

  .title h1 {
    font-size: 1.55rem;

    padding:
      6px 14px 8px;
  }

  .characters {
    width: min(650px, 90%);

    margin:
      4px auto
      8px;
  }

  .selection-info {
    padding:
      4px 12px;

    font-size: .85rem;
  }

  .controls {
    margin-top: 6px;
  }

  .controls div {
    padding:
      4px 8px;

    font-size: .58rem;
  }

  .game-top {
    height: 45px;
    min-height: 45px;

    padding:
      4px 10px;
  }

  .game-world {
    min-height: 210px;

    height:
      calc(100dvh - 95px);
  }

  .game-controls {
    height: 50px;
    min-height: 50px;
  }

  .hint-card,
  .over-card {
    padding: 12px;

    max-height: 88%;
  }

  .hint-cat,
  .sad-cat {
    font-size: 2rem;
  }

  .hint-card h2,
  .over-card h2 {
    font-size: 1.7rem;
  }
}


/* ============================================================
   PANTALLAS GRANDES
============================================================ */

@media (min-width: 1400px) {

  .game-world {
    max-height: calc(100dvh - 120px);
  }

}


/* ============================================================
   REDUCIR ANIMACIONES SI EL USUARIO LO PREFIERE
============================================================ */

@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }

}