:root {
  color-scheme: light;
  font-family: Arial, Helvetica, sans-serif;
  --teal: #2aa995;
  --deep-teal: #157a69;
  --blue: #4da0e7;
  --ink: #24313a;
  --cream: #fff7dc;
  --sun: #ffd65a;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #102f5e;
}

body {
  display: grid;
  place-items: center;
}

button {
  font: inherit;
}

.shell {
  width: 100vw;
  height: 100vh;
  display: grid;
  place-items: center;
  padding: clamp(8px, 1.4vw, 18px);
  background:
    radial-gradient(circle at 12% 14%, rgba(100, 174, 255, 0.28), transparent 22%),
    linear-gradient(135deg, #071b45, #153b72 55%, #0c2d54);
}

.game {
  position: relative;
  width: min(100%, calc(100vh * 1.78));
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: clamp(22px, 4vw, 58px);
  background: #aade52 url("../assets/images/background-field.png") center / cover no-repeat;
  box-shadow: 0 18px 0 rgba(34, 65, 47, 0.34), 0 28px 54px rgba(0, 0, 0, 0.34);
  isolation: isolate;
}

.topbar {
  position: absolute;
  z-index: 10;
  top: 4.5%;
  left: 4.2%;
  right: 4.2%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}

.icon-button,
.play-again {
  border: 0;
  cursor: pointer;
  pointer-events: auto;
}

.icon-button {
  width: clamp(48px, 6.5vw, 78px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 5px 0 rgba(68, 120, 86, 0.24);
}

.pause-icon,
.pause-icon::after {
  display: block;
  width: clamp(9px, 1.1vw, 14px);
  height: clamp(24px, 3.2vw, 38px);
  border-radius: 999px;
  background: var(--blue);
  content: "";
}

.pause-icon {
  position: relative;
  transform: translateX(-7px);
}

.pause-icon::after {
  position: absolute;
  left: clamp(16px, 2vw, 24px);
  top: 0;
}

.icon-button.is-paused .pause-icon {
  width: 0;
  height: 0;
  border-top: clamp(16px, 2vw, 24px) solid transparent;
  border-bottom: clamp(16px, 2vw, 24px) solid transparent;
  border-left: clamp(26px, 3vw, 40px) solid var(--blue);
  border-radius: 0;
  background: transparent;
  transform: translateX(3px);
}

.icon-button.is-paused .pause-icon::after {
  display: none;
}

.round-track {
  display: flex;
  gap: clamp(7px, 1vw, 12px);
  align-items: center;
  padding: clamp(7px, 1vw, 12px);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.65);
}

.round-dot {
  width: clamp(13px, 1.7vw, 22px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(36, 49, 58, 0.22);
}

.round-dot.active {
  background: var(--sun);
  box-shadow: 0 0 0 4px rgba(255, 214, 90, 0.24);
}

.prompt {
  position: absolute;
  z-index: 7;
  top: 8%;
  left: 50%;
  transform: translateX(-50%);
  min-width: 11ch;
  padding: clamp(8px, 1.1vw, 13px) clamp(18px, 2.2vw, 30px);
  border-radius: 999px;
  background: rgba(255, 247, 220, 0.94);
  color: var(--ink);
  font-size: clamp(18px, 2.2vw, 34px);
  font-weight: 900;
  text-align: center;
  box-shadow: 0 6px 0 rgba(102, 117, 68, 0.2);
}

.word-card {
  position: absolute;
  z-index: 20;
  top: 19%;
  left: 50%;
  min-width: clamp(112px, 14vw, 210px);
  padding: clamp(6px, 0.9vw, 12px) clamp(18px, 2.2vw, 28px);
  border: clamp(4px, 0.55vw, 7px) solid #ffffff;
  border-radius: clamp(18px, 2vw, 28px);
  background: #ffdf60;
  color: #253343;
  font-size: clamp(34px, 6vw, 88px);
  font-weight: 900;
  line-height: 1;
  text-align: center;
  box-shadow: 0 8px 0 rgba(127, 105, 29, 0.28);
  opacity: 0;
  transform: translate(-50%, -18px) scale(0.88);
  transition: opacity 180ms ease, transform 220ms cubic-bezier(0.2, 1.4, 0.35, 1);
  pointer-events: none;
}

.word-card.show {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}

.board {
  position: absolute;
  z-index: 5;
  left: 16%;
  right: 16%;
  top: 31%;
  bottom: 16%;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  column-gap: clamp(28px, 5.4vw, 86px);
  row-gap: clamp(12px, 2.4vw, 36px);
}

.slot {
  position: relative;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  min-width: 0;
  min-height: 0;
  filter: drop-shadow(0 10px 0 rgba(82, 112, 53, 0.25));
}

.slot:focus-visible {
  outline: clamp(4px, 0.45vw, 7px) solid #ffffff;
  outline-offset: 5px;
  border-radius: 24px;
}

.slot[disabled] {
  cursor: default;
}

.animal,
.bush {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  user-select: none;
  pointer-events: none;
}

.animal {
  z-index: 1;
  bottom: 22%;
  width: min(58%, 170px);
  max-height: 85%;
  object-fit: contain;
  opacity: 0;
  transform: translateX(-50%) translateY(34%) scale(0.68);
  transition: opacity 170ms ease, transform 320ms cubic-bezier(0.2, 1.45, 0.38, 1);
}

.bush {
  z-index: 2;
  bottom: 0;
  width: min(94%, 300px);
  max-height: 72%;
  object-fit: contain;
  transition: transform 260ms ease, opacity 240ms ease;
}

.slot.revealed .animal,
.slot.matched .animal {
  opacity: 1;
  transform: translateX(-50%) translateY(-12%) scale(1);
}

.slot.revealed .bush {
  transform: translateX(-50%) translateY(12%) scale(0.96);
}

.slot.matched {
  animation: celebrate 620ms ease both;
}

.slot.matched .animal,
.slot.matched .bush {
  opacity: 0;
  transform: translateX(-50%) translateY(-22%) scale(0.72);
}

.slot.shake {
  animation: shake 420ms ease;
}

.npc {
  position: absolute;
  z-index: 8;
  right: 2.2%;
  bottom: -1.5%;
  width: clamp(110px, 16vw, 230px);
  max-height: 38%;
  object-fit: contain;
  filter: drop-shadow(0 10px 0 rgba(74, 82, 46, 0.2));
  animation: npc-bob 2.8s ease-in-out infinite;
  pointer-events: none;
}

.complete-panel {
  position: absolute;
  z-index: 30;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: clamp(16px, 2vw, 28px);
  background: rgba(78, 168, 99, 0.36);
  backdrop-filter: blur(3px);
}

.complete-panel[hidden] {
  display: none;
}

.complete-title {
  padding: clamp(12px, 1.5vw, 20px) clamp(28px, 3vw, 48px);
  border: clamp(5px, 0.7vw, 9px) solid #ffffff;
  border-radius: clamp(22px, 2.7vw, 36px);
  background: #ffdf60;
  color: #253343;
  font-size: clamp(46px, 7vw, 104px);
  font-weight: 900;
  line-height: 0.95;
  box-shadow: 0 10px 0 rgba(127, 105, 29, 0.28);
}

.review-words {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: clamp(8px, 1vw, 16px);
  max-width: 70%;
}

.review-words span {
  padding: 0.45em 0.75em;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.95);
  color: var(--deep-teal);
  font-size: clamp(18px, 2vw, 32px);
  font-weight: 900;
}

.play-again {
  padding: 0.7em 1.2em;
  border-radius: 999px;
  background: var(--blue);
  color: #ffffff;
  font-size: clamp(18px, 2vw, 30px);
  font-weight: 900;
  box-shadow: 0 7px 0 #2778b8;
}

.is-paused .slot {
  pointer-events: none;
}

@keyframes celebrate {
  0%,
  100% {
    transform: scale(1);
  }
  46% {
    transform: scale(1.08) rotate(-1deg);
  }
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-6px);
  }
  50% {
    transform: translateX(6px);
  }
  75% {
    transform: translateX(-3px);
  }
}

@keyframes npc-bob {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-5px);
  }
}

@media (max-aspect-ratio: 4 / 3) {
  .shell {
    place-items: start center;
    padding-top: 8px;
  }

  .game {
    width: 100vw;
  }
}

@media (max-width: 760px) {
  .board {
    left: 10%;
    right: 10%;
    top: 32%;
    bottom: 17%;
    column-gap: 18px;
  }

  .npc {
    width: 120px;
    right: 0.5%;
  }
}
