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

body {
  background: linear-gradient(145deg, #0a1a2a 0%, #030c14 100%);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: "Oxanium", "Segoe UI", system-ui, sans-serif;
}

.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.5);
  flex-shrink: 0;
}

.header-title {
  flex: 0 0 auto;
}

.header-stats {
  display: flex;
  gap: 24px;
  align-items: center;
}

h1 {
  font-size: 1.5rem;
  color: #95c8ee;
  font-weight: 600;
  margin: 0;
  white-space: nowrap;
}

.stat {
  font-weight: 400;
  font-size: 1rem;
  color: rgba(255, 255, 255, 0.9);
  white-space: nowrap;
}

.stat span {
  color: #ffe484;
  font-weight: 600;
  margin-left: 4px;
}

#btn-restart,
#btn-ranking {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.6);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 6px 18px;
  border-radius: 40px;
  color: #ffffff;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

#btn-restart:hover,
#btn-ranking:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: #95c8ee;
}
#btn-ranking:hover {
  background: rgba(255, 188, 66, 0.08);

  border-color: rgba(255, 188, 66, 0.7);
}
#grid {
  display: grid;
  grid-template-columns: repeat(6, 155px);
  grid-auto-rows: 155px;
  gap: 16px 20px;
  padding: 30px 40px;
  margin: auto;
}

.card-slot {
  width: 155px;
  height: 155px;
  display: flex;
  align-items: center;
  justify-content: center;
  justify-items: center;
}

#match-footer {
  text-align: center;
  min-height: 28px;
  padding: 10px 0 18px;
  font-size: 1rem;
  font-weight: 600;
  color: #fefdfe;
  letter-spacing: 0.3px;
}

.card-wrap {
  width: 155px;
  height: 155px;
  cursor: pointer;
  transition:
    transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94),
    opacity 0.25s ease;
  transform: rotate(var(--rot, 0deg)) translateZ(0);
  will-change: transform;
}

.card-wrap:not(.matched):hover {
  transform: rotate(0deg) scale(1.05) translateY(-4px) !important;
  z-index: 10;
}

.card-wrap.hovered {
  transform: rotate(0deg) scale(1.05) translateY(-4px) !important;
  z-index: 10;
}

.card-inner {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.28s cubic-bezier(0.23, 1, 0.32, 1);
}

.card-wrap.flipped .card-inner {
  transform: rotateY(180deg);
}

.face {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;

  overflow: hidden; /* ← esto corta las esquinas del img */
}

.face img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  transform: translateZ(0);
}

.face:hover {
  /* agregás la sombra acá, sobre el contenedor con border-radius */
  filter: drop-shadow(0px 6px 12px rgba(0, 0, 0, 0.6))
    drop-shadow(0px 2px 4px rgba(255, 255, 255, 0.4));
}

/* Brillo dorado solo para Maradona cuando está de frente */
.card-wrap[data-id="maradona"].flipped .face-front:hover {
  filter: drop-shadow(0px 6px 12px rgba(0, 0, 0, 0.6))
    drop-shadow(0px 2px 4px rgba(255, 188, 66, 0.4));
}

.face-back {
  transform: rotateY(0deg);
}

.face-front {
  transform: rotateY(180deg);
}

.card-wrap.matched {
  pointer-events: none;
  transition:
    filter 1.5s ease,
    opacity 1.5s ease;
  filter: grayscale(65%);
  opacity: 0.35;
  cursor: default;
}

/* ----------------------------------------
   OVERLAY BASE (win + ranking)
---------------------------------------- */
#win-overlay,
#ranking-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  z-index: 100;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

/* ----------------------------------------
   WIN MODAL
---------------------------------------- */
#win-modal {
  background: linear-gradient(160deg, #0d2135 0%, #071320 100%);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 20px;
  padding: 36px 40px;
  max-width: 420px;
  width: 90%;
  text-align: center;
  animation: bouncePop 0.45s ease;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: relative;
}

#win-title {
  font-size: 1.7rem;
  font-weight: 700;
  background: linear-gradient(120deg, #ffe484, #ffbc42);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  letter-spacing: 0.5px;
  line-height: 1.3;
}

#win-score-text {
  color: rgba(255, 255, 255, 0.8);
  font-size: 1rem;
}

#player-name {
  width: 100%;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

#player-name:focus {
  border-color: rgba(255, 188, 66, 0.7);
}

#player-name::placeholder {
  color: rgba(255, 255, 255, 0.35);
}

#btn-win-close {
  color: rgba(255, 255, 255, 0.5);
  transition: color 0.2s;
}

#btn-win-close:hover {
  color: #ffbc42;
}

#ranking-modal #btn-ranking-close {
  color: rgba(255, 255, 255, 0.5);
  transition: color 0.2s;
  border: none;
  border-radius: 0;
  padding: 0;
  display: inline;
  margin: 0;
}

#ranking-modal #btn-ranking-close:hover {
  color: #ffbc42;
  border-color: transparent;
}

#btn-save-score {
  background: linear-gradient(120deg, #ffbc42, #ffe484);
  color: #0a1a2a;
  border: none;
  border-radius: 40px;
  padding: 10px 28px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.2s;
}

#btn-save-score:disabled {
  opacity: 0.5;
  cursor: default;
}

#btn-save-score:hover:not(:disabled) {
  opacity: 0.88;
}

#btn-skip {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 40px;
  color: rgba(255, 255, 255, 0.6);
  padding: 8px 22px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
}

#btn-skip:hover {
  border-color: rgba(255, 255, 255, 0.7);
  color: #fff;
}

#save-feedback {
  font-size: 0.9rem;
  color: #ffe484;
  min-height: 20px;
}

/* ----------------------------------------
   RANKING MODAL
---------------------------------------- */
#ranking-modal {
  position: relative;
  background: linear-gradient(160deg, #0d2135 0%, #071320 100%);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 20px;
  padding: 32px 36px;
  max-width: 480px;
  width: 92%;
  max-height: 80vh;
  overflow: hidden;
  animation: bouncePop 0.4s ease;
  display: flex;
  flex-direction: column;
}

/* Scrollbar personalizada del ranking */
#ranking-list::-webkit-scrollbar {
  width: 6px;
}
#ranking-list::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 10px;
}
#ranking-list::-webkit-scrollbar-thumb {
  background: rgba(149, 200, 238, 0.35);
  border-radius: 10px;
}
#ranking-list::-webkit-scrollbar-thumb:hover {
  background: rgba(149, 200, 238, 0.6);
}

#ranking-modal h2 {
  color: #ffe484;
  font-size: 1.4rem;
  margin-bottom: 20px;
  text-align: center;
}

#ranking-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rank-row {
  display: grid;
  grid-template-columns: 36px 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.rank-pos {
  color: #ffe484;
  font-weight: 700;
  font-size: 1.2rem;
  text-align: center;
}

.rank-name {
  color: #fff;
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rank-score {
  color: #ffe484;
  font-weight: 700;
  font-size: 0.9rem;
  white-space: nowrap;
}

.rank-date {
  color: rgba(255, 255, 255, 0.4);
  font-size: 0.78rem;
  white-space: nowrap;
}

@keyframes bouncePop {
  0% {
    transform: scale(0.85);
    opacity: 0;
  }
  80% {
    transform: scale(1.04);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.letra-blanca {
  color: white;
}

.letra-chica {
  font-size: 1.1rem;
  color: #95c8ee;
}

/* ----------------------------------------
   TITULO - G R T flip animation
---------------------------------------- */
.titulo-flip-wrap {
  display: inline-block;
  perspective: 300px;
  cursor: default;
}

.titulo-flip-inner {
  display: inline-block;
  transform-style: preserve-3d;
  will-change: transform;
}

.titulo-flip-wrap.flipping .titulo-flip-inner {
  animation: letterFlip 0.9s cubic-bezier(0.23, 1, 0.32, 1) forwards;
}

@keyframes letterFlip {
  0% {
    transform: rotateY(0deg);
  }
  40% {
    transform: rotateY(180deg);
  }
  65% {
    transform: rotateY(180deg);
  }
  100% {
    transform: rotateY(360deg);
  }
}

/* ----------------------------------------
   WIDGET REDES SOCIALES
---------------------------------------- */

/* Oculto en mobile por defecto */
#social-trigger,
#social-icons {
  display: none;
}

@media (min-width: 751px) {
  #social-trigger {
    display: block;
    position: fixed;
    bottom: 0;
    right: 0;
    width: 140px;
    height: 140px;
    z-index: 198;
    pointer-events: all;
    background: transparent;
  }

  #social-icons {
    display: flex;
    position: fixed;
    bottom: 24px;
    right: 24px;
    flex-direction: column;
    gap: 12px;
    z-index: 201;
    pointer-events: none;
  }

  .social-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(10, 26, 42, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.5);
    text-decoration: none;
    transition:
      transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
      opacity 0.3s ease,
      color 0.2s ease,
      border-color 0.2s ease,
      background 0.2s ease;
    transform: translateX(80px);
    opacity: 0;
    pointer-events: none;
    backdrop-filter: blur(8px);
  }

  .social-btn svg {
    width: 18px;
    height: 18px;
  }

  #social-icons.visible {
    pointer-events: all;
  }

  #social-icons.visible .social-btn {
    transform: translateX(0);
    opacity: 1;
    pointer-events: all;
  }

  #social-icons.visible .social-btn:nth-child(1) {
    transition-delay: 0s;
  }
  #social-icons.visible .social-btn:nth-child(2) {
    transition-delay: 0.06s;
  }
  #social-icons.visible .social-btn:nth-child(3) {
    transition-delay: 0.12s;
  }

  #social-github:hover {
    color: #95c8ee;
    background: rgba(36, 41, 46, 0.95);
    border-color: #95c8ee;
    transform: translateX(0) scale(1.12);
    filter: drop-shadow(0px 6px 12px rgba(0, 0, 0, 0.6))
      drop-shadow(0px 2px 4px rgba(255, 255, 255, 0.4));
  }

  #social-linkedin:hover {
    color: #95c8ee;
    background: rgba(36, 41, 46, 0.95);
    border-color: #95c8ee;
    transform: translateX(0) scale(1.12);
    filter: drop-shadow(0px 6px 12px rgba(0, 0, 0, 0.6))
      drop-shadow(0px 2px 4px rgba(255, 255, 255, 0.4));
  }

  #social-instagram:hover {
    color: #95c8ee;
    background: rgba(36, 41, 46, 0.95);
    border-color: #95c8ee;
    transform: translateX(0) scale(1.12);
    filter: drop-shadow(0px 6px 12px rgba(0, 0, 0, 0.6))
      drop-shadow(0px 2px 4px rgba(255, 255, 255, 0.4));
  }
}

/* ----------------------------------------
   MESSI PEEK - esquina inferior izquierda
---------------------------------------- */
#messi-peek {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 95px;
  z-index: 199;
  pointer-events: all;
  will-change: transform;
}

#messi-img {
  width: 100%;
  display: block;
  transform: translateY(100%);
  transition: transform 0.45s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  filter: drop-shadow(0 -4px 16px rgba(0, 0, 0, 0.7));
}

#messi-peek.visible #messi-img {
  transform: translateY(11%);
}

#messi-bobo {
  position: absolute;
  bottom: 52px;
  left: 46px;
  width: 91px;
  opacity: 0;
  transform: scale(0.7);
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
  pointer-events: none;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.5));
}

#messi-peek.bobo-visible #messi-bobo {
  opacity: 1;
  transform: scale(1);
}

@media (max-width: 750px) {
  #messi-peek {
    width: 13vw; /* ~95px en 1200px → proporcional en mobile */
    min-width: 52px; /* piso para pantallas muy chicas */
    max-width: 80px;
    pointer-events: none; /* no interfiere con el grid mientras está oculto */
  }
  #messi-peek.visible {
    pointer-events: all;
  }
  #messi-bobo {
    width: 12.5vw;
    min-width: 60px;
    max-width: 95px;
    left: 52%; /* se mantiene a la derecha de messi relativo a su ancho */
    bottom: 45%;
  }
}

@media (max-width: 750px) {
  body {
    min-height: 100dvh;
    overflow-x: hidden;
  }

  .game-header {
    flex-direction: column;
    gap: 12px;
    padding: 12px 16px;
  }

  .header-stats {
    width: 100%;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
  }

  h1 {
    font-size: 1.1rem;
    text-align: center;
  }

  .letra-chica {
    font-size: 0.8rem;
  }

  #grid {
    display: flex !important;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    width: 100%;
    max-width: 440px;
    margin: 2rem auto;
    box-sizing: border-box;
  }

  .card-slot {
    width: calc(25% - 6px) !important;
    height: auto !important;
    aspect-ratio: 1 / 1;
  }

  .card-wrap {
    width: 100% !important;
    height: 100% !important;
  }

  .card-slot:nth-last-child(2),
  .card-slot:nth-last-child(1) {
    grid-column: unset;
  }

  #win-modal,
  #ranking-modal {
    padding: 24px 20px;
  }

  .rank-row {
    grid-template-columns: 30px 1fr auto;
  }

  .rank-date {
    display: none;
  }
}

/* ----------------------------------------
   FOOTER MOBILE (overscroll reveal)
---------------------------------------- */
#mobile-footer {
  display: none;
}

@media (max-width: 750px) {
  #mobile-footer {
    display: block;
    height: 90px;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
  }

  #mobile-footer-inner {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
  }

  #footer-scroll-hint {
    display: none;
  }

  #footer-social-links {
    display: flex;
    gap: 20px;
    align-items: center;
  }

  .footer-social-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.45);
    text-decoration: none;
    transition: all 0.2s ease;
  }

  .footer-social-btn svg {
    width: 17px;
    height: 17px;
  }

  #footer-github:hover,
  #footer-github:active {
    color: #95c8ee;
    background: rgba(36, 41, 46, 0.95);
    border-color: #95c8ee;
    transform: scale(1.12);
    filter: drop-shadow(0px 6px 12px rgba(0, 0, 0, 0.6))
      drop-shadow(0px 2px 4px rgba(255, 255, 255, 0.4));
  }

  #footer-linkedin:hover,
  #footer-linkedin:active {
    color: #95c8ee;
    background: rgba(36, 41, 46, 0.95);
    border-color: #95c8ee;
    transform: scale(1.12);
    filter: drop-shadow(0px 6px 12px rgba(0, 0, 0, 0.6))
      drop-shadow(0px 2px 4px rgba(255, 255, 255, 0.4));
  }

  #footer-instagram:hover,
  #footer-instagram:active {
    color: #95c8ee;
    background: rgba(36, 41, 46, 0.95);
    border-color: #95c8ee;
    transform: scale(1.12);
    filter: drop-shadow(0px 6px 12px rgba(0, 0, 0, 0.6))
      drop-shadow(0px 2px 4px rgba(255, 255, 255, 0.4));
  }

  @keyframes bounceDown {
    0%,
    100% {
      transform: translateY(0);
    }
    50% {
      transform: translateY(4px);
    }
  }
}
