/* ==========================================
   RUTICUTI — ENCONTRE OS MORADORES
========================================== */

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Nunito", sans-serif;
  color: #26352d;
  background:
    radial-gradient(
      circle at top,
      #fff7cf 0%,
      #dff4d5 42%,
      #abd3b0 100%
    );
}

button,
a {
  font-family: inherit;
}

.game-shell {
  width: min(1180px, calc(100% - 28px));
  margin: 22px auto 50px;
}

/* ==========================================
   BARRA SUPERIOR
========================================== */

.game-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  margin-bottom: 22px;
}

.top-btn,
.game-score {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 11px 19px;
  border: 3px solid #ffffff;
  border-radius: 999px;
  box-shadow: 0 6px 0 rgba(34, 79, 55, 0.22);
  font-size: 16px;
  font-weight: 900;
}

.top-btn {
  color: #ffffff;
  text-decoration: none;
  background: #287557;
  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease,
    background 0.18s ease;
}

.top-btn:hover {
  transform: translateY(-2px);
  background: #1e6147;
  box-shadow: 0 8px 0 rgba(34, 79, 55, 0.22);
}

.top-btn:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 rgba(34, 79, 55, 0.22);
}

.game-score {
  color: #613711;
  background: #ffd75e;
}

.game-score strong {
  margin-left: 5px;
  font-size: 20px;
}

/* ==========================================
   INTRODUÇÃO
========================================== */

.game-intro {
  max-width: 820px;
  margin: 0 auto 22px;
  text-align: center;
}

.eyebrow {
  margin: 0 0 4px;
  color: #a64b28;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 2px;
}

.game-intro h1 {
  margin: 0;
  color: #245d43;
  font-size: clamp(31px, 5vw, 56px);
  font-weight: 900;
  line-height: 1.05;
  text-shadow: 0 3px 0 rgba(255, 255, 255, 0.8);
}

.game-intro p:last-child {
  max-width: 690px;
  margin: 10px auto 0;
  color: #43594b;
  font-size: clamp(16px, 2vw, 20px);
  font-weight: 700;
  line-height: 1.45;
}

/* ==========================================
   CENÁRIO
========================================== */

.game-board {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 7px solid #ffffff;
  border-radius: 28px;
  background: #6cb681;
  box-shadow:
    0 18px 45px rgba(30, 74, 48, 0.28),
    0 8px 0 #377454;
  isolation: isolate;
  user-select: none;
}

.game-background {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

/* ==========================================
   PERSONAGENS
========================================== */

.character {
  position: absolute;
  z-index: 3;
  display: block;
  padding: 0;
  border: 0;
  outline: none;
  background: transparent;
  cursor: pointer;
  transition: transform 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

/*
  A SOMBRA É APLICADA DIRETAMENTE NO PNG.
  As imagens da lista de baixo não são afetadas.
*/

.game-board .character img {
  display: block;
  width: 100%;
  height: auto;
  pointer-events: none;

  filter:
    brightness(0)
    saturate(0)
    contrast(2)
    opacity(0.72)
    drop-shadow(0 2px 2px rgba(0, 0, 0, 0.5))
    !important;

  transition:
    filter 0.2s ease,
    transform 0.2s ease;
}

.game-board .character:hover,
.game-board .character:focus-visible {
  z-index: 5;
  transform: scale(1.08);
}

.game-board .character:hover img,
.game-board .character:focus-visible img {
  filter:
    brightness(0)
    saturate(0)
    contrast(2)
    opacity(0.9)
    drop-shadow(0 0 7px rgba(255, 246, 154, 0.95))
    !important;
}

.character.found {
  z-index: 6;
  pointer-events: none;
  animation: characterJump 0.9s ease forwards;
}

.game-board .character.found img {
  animation: revealCharacter 0.9s ease forwards;
}

/* ==========================================
   POSIÇÕES
========================================== */

.character-aranha {
  top: 7%;
  left: 17%;
  width: 5.8%;
}

.character-barata {
  right: 12%;
  bottom: 11%;
  width: 7.3%;
}

.character-grilo {
  left: 4%;
  bottom: 18%;
  width: 5.8%;
}

.character-lagarta {
  left: 39%;
  bottom: 5%;
  width: 8.5%;
}

.character-lagartixa {
  top: 32%;
  right: 4%;
  width: 8.5%;
}

.character-rato {
  left: 20%;
  bottom: 7%;
  width: 8%;
}

.character-sapo {
  right: 26%;
  bottom: 10%;
  width: 8%;
}

.character-zeze {
  top: 17%;
  right: 24%;
  width: 5.5%;
}

/* ==========================================
   LISTA INFERIOR
========================================== */

.character-list {
  margin-top: 30px;
  padding: 25px;
  border: 4px solid #ffffff;
  border-radius: 25px;
  background: rgba(255, 255, 255, 0.7);
  box-shadow: 0 11px 30px rgba(34, 79, 55, 0.16);
  backdrop-filter: blur(5px);
}

.character-list h2 {
  margin: 0 0 18px;
  color: #2d6649;
  font-size: clamp(20px, 3vw, 29px);
  font-weight: 900;
  text-align: center;
}

.character-list-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(75px, 1fr));
  gap: 12px;
}

.list-item {
  position: relative;
  min-width: 0;
  padding: 10px 6px;
  border: 3px solid #ffffff;
  border-radius: 18px;
  background: #fff5c5;
  box-shadow: 0 5px 0 rgba(54, 95, 66, 0.18);
  text-align: center;
  transition:
    opacity 0.3s ease,
    transform 0.3s ease,
    background 0.3s ease;
}

/*
  OS PERSONAGENS DA LISTA FICAM COLORIDOS.
*/

.character-list .list-item img {
  display: block;
  width: 58px;
  height: 58px;
  margin: 0 auto 5px;
  object-fit: contain;
  filter: none !important;
  opacity: 1;
}

.list-item span {
  display: block;
  overflow: hidden;
  color: #4d3a1d;
  font-size: 13px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-item.found {
  opacity: 0.42;
  background: #c9efcf;
  transform: scale(0.94);
}

.list-item.found::after {
  content: "✓";
  position: absolute;
  top: 6px;
  right: 7px;
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border: 2px solid #ffffff;
  border-radius: 50%;
  color: #ffffff;
  background: #2b9b5c;
  font-size: 17px;
  font-weight: 900;
}

/* ==========================================
   VITÓRIA
========================================== */

.victory-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  visibility: hidden;
  opacity: 0;
  background: rgba(20, 52, 35, 0.78);
  backdrop-filter: blur(8px);
  transition:
    opacity 0.35s ease,
    visibility 0.35s ease;
}

.victory-overlay.show {
  visibility: visible;
  opacity: 1;
}

.victory-card {
  width: min(550px, 100%);
  padding: clamp(28px, 5vw, 50px);
  border: 6px solid #ffffff;
  border-radius: 32px;
  background:
    radial-gradient(
      circle at top,
      #fff9c9 0%,
      #ffd96f 58%,
      #ffb34f 100%
    );
  box-shadow:
    0 24px 70px rgba(0, 0, 0, 0.35),
    0 9px 0 #cb762f;
  text-align: center;
  transform: scale(0.8) translateY(25px);
  transition: transform 0.4s cubic-bezier(0.2, 1.4, 0.4, 1);
}

.victory-overlay.show .victory-card {
  transform: scale(1) translateY(0);
}

.victory-stars {
  margin-bottom: 6px;
  font-size: clamp(32px, 8vw, 60px);
  animation: starsDance 1.2s ease infinite alternate;
}

.victory-card h2 {
  margin: 0;
  color: #39623f;
  font-size: clamp(30px, 6vw, 49px);
  font-weight: 900;
  line-height: 1.05;
}

.victory-card p {
  margin: 15px auto 23px;
  color: #64431d;
  font-size: clamp(16px, 3vw, 20px);
  font-weight: 800;
  line-height: 1.45;
}

.victory-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.victory-btn {
  min-height: 51px;
  padding: 12px 21px;
  border: 3px solid #ffffff;
  border-radius: 999px;
  color: #ffffff;
  background: #2e8057;
  box-shadow: 0 6px 0 #1d583c;
  font-size: 16px;
  font-weight: 900;
  text-decoration: none;
  cursor: pointer;
  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease;
}

.victory-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 0 #1d583c;
}

.victory-btn:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #1d583c;
}

.victory-btn-secondary {
  color: #5b3515;
  background: #ffffff;
  box-shadow: 0 6px 0 #d49755;
}

/* ==========================================
   ANIMAÇÕES
========================================== */

@keyframes characterJump {
  0% {
    opacity: 1;
    transform: scale(1);
  }

  30% {
    opacity: 1;
    transform: scale(1.45) rotate(-7deg);
  }

  60% {
    opacity: 1;
    transform: scale(1.3) rotate(7deg);
  }

  100% {
    opacity: 0;
    transform: scale(1.65);
  }
}

@keyframes revealCharacter {
  0% {
    filter:
      brightness(0)
      saturate(0)
      contrast(2)
      opacity(0.72)
      drop-shadow(0 2px 2px rgba(0, 0, 0, 0.5));
  }

  30%,
  70% {
    filter:
      brightness(1.1)
      saturate(1.25)
      contrast(1)
      opacity(1)
      drop-shadow(0 0 12px #fff36b);
  }

  100% {
    filter:
      brightness(1)
      saturate(1)
      contrast(1)
      opacity(0)
      drop-shadow(0 0 5px #ffffff);
  }
}

@keyframes starsDance {
  from {
    transform: rotate(-4deg) scale(0.95);
  }

  to {
    transform: rotate(4deg) scale(1.08);
  }
}

/* ==========================================
   TABLET
========================================== */

@media (max-width: 900px) {
  .character-list-grid {
    grid-template-columns: repeat(4, minmax(70px, 1fr));
  }

  .character {
    min-width: 35px;
  }

  .character-aranha,
  .character-grilo,
  .character-zeze {
    width: 7%;
  }

  .character-barata,
  .character-lagarta,
  .character-lagartixa,
  .character-rato,
  .character-sapo {
    width: 9.5%;
  }
}

/* ==========================================
   CELULAR
========================================== */

@media (max-width: 600px) {
  .game-shell {
    width: min(100% - 14px, 1180px);
    margin-top: 10px;
  }

  .game-topbar {
    margin-bottom: 17px;
  }

  .top-btn,
  .game-score {
    min-height: 42px;
    padding: 8px 12px;
    border-width: 2px;
    font-size: 13px;
  }

  .game-score strong {
    font-size: 16px;
  }

  .game-intro {
    padding: 0 7px;
  }

  .eyebrow {
    font-size: 10px;
    letter-spacing: 1.4px;
  }

  .game-intro p:last-child {
    margin-top: 7px;
    font-size: 14px;
  }

  .game-board {
    border-width: 4px;
    border-radius: 17px;
  }

  .character-list {
    margin-top: 20px;
    padding: 15px 10px;
    border-width: 3px;
    border-radius: 18px;
  }

  .character-list h2 {
    margin-bottom: 12px;
    font-size: 19px;
  }

  .character-list-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
  }

  .list-item {
    padding: 7px 3px;
    border-width: 2px;
    border-radius: 13px;
  }

  .character-list .list-item img {
    width: 40px;
    height: 40px;
  }

  .list-item span {
    font-size: 10px;
  }

  .list-item.found::after {
    top: 3px;
    right: 3px;
    width: 21px;
    height: 21px;
    font-size: 13px;
  }

  .victory-actions {
    flex-direction: column;
  }

  .victory-btn {
    width: 100%;
  }
}

/* ==========================================
   ACESSIBILIDADE
========================================== */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}