:root {
  color-scheme: light;
  font-family: "Arial Rounded MT Bold", "Noto Sans TC", system-ui, sans-serif;
  background: #c8efff;
  color: #17314f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 10%, rgba(255, 231, 102, 0.9), transparent 20rem),
    radial-gradient(circle at 80% 18%, rgba(126, 211, 255, 0.72), transparent 22rem),
    linear-gradient(180deg, #a9e7ff 0%, #e6f7cf 58%, #79c568 100%);
  overflow-x: hidden;
}

button,
select {
  font: inherit;
}

.weather-game {
  width: min(100%, 760px);
  min-height: 100vh;
  margin: 0 auto;
  padding: calc(14px + env(safe-area-inset-top)) 14px calc(24px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.topbar {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 10px;
  align-items: center;
}

.home-link,
.soft-btn,
.result-card button,
.result-card a {
  min-height: 44px;
  border: 0;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.92);
  color: #17314f;
  box-shadow: 0 8px 18px rgba(38, 79, 113, 0.18);
  font-weight: 900;
  text-decoration: none;
}

.home-link {
  display: grid;
  place-items: center;
  font-size: 1.4rem;
}

.title-block p,
.title-block h1 {
  margin: 0;
}

.title-block p {
  font-size: 0.74rem;
  font-weight: 900;
  color: rgba(23, 49, 79, 0.68);
}

.title-block h1 {
  font-size: clamp(1.08rem, 4.4vw, 2rem);
  line-height: 1.04;
}

.language-picker {
  min-width: 118px;
  display: grid;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 900;
  color: rgba(23, 49, 79, 0.7);
}

.language-picker select {
  width: 100%;
  border: 0;
  border-radius: 12px;
  padding: 8px 9px;
  background: rgba(255, 255, 255, 0.92);
  color: #17314f;
  font-weight: 900;
}

.menu-panel,
.play-panel {
  flex: 1;
  display: grid;
  align-content: start;
  gap: 14px;
}

.cover {
  width: 100%;
  aspect-ratio: 1.14 / 1;
  border-radius: 22px;
  object-fit: cover;
  object-position: center;
  box-shadow: 0 18px 38px rgba(38, 79, 113, 0.22);
}

.menu-copy {
  display: grid;
  gap: 4px;
}

.menu-copy strong {
  font-size: 1.35rem;
}

.menu-copy span {
  color: rgba(23, 49, 79, 0.72);
  font-weight: 800;
}

.stage-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.stage-card {
  min-height: 96px;
  border: 0;
  border-radius: 18px;
  padding: 12px;
  display: grid;
  gap: 5px;
  text-align: left;
  background: linear-gradient(145deg, #fff5d4, #ffffff);
  color: #17314f;
  box-shadow: 0 10px 22px rgba(38, 79, 113, 0.17);
  font-weight: 900;
}

.stage-card.locked {
  filter: grayscale(1);
  opacity: 0.58;
}

.stage-card b {
  font-size: 2rem;
}

.stage-card span {
  color: rgba(23, 49, 79, 0.68);
}

.play-head {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: center;
}

.soft-btn {
  padding: 0 14px;
}

.stats {
  min-height: 44px;
  padding: 6px;
  border-radius: 14px;
  display: grid;
  grid-template-columns: minmax(64px, auto) 1fr minmax(74px, auto);
  gap: 6px;
  align-items: center;
  background: rgba(255, 255, 255, 0.78);
  font-weight: 900;
}

.stats span {
  min-width: 0;
  padding: 5px 8px;
  border-radius: 10px;
  background: rgba(72, 169, 214, 0.14);
  text-align: center;
}

.round-progress {
  min-width: 118px;
  height: 32px;
  position: relative;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: rgba(23, 49, 79, 0.14) !important;
}

.round-progress b {
  position: relative;
  z-index: 2;
  font-size: 0.88rem;
}

.round-progress i {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, #5bd174, #ffda63);
  transition: width 0.22s ease;
}

.board {
  width: min(94vw, 620px, 72svh);
  min-height: min(84svh, 620px);
  margin: 0 auto;
  padding: 12px;
  border-radius: 28px;
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0.48)),
    url("../../assets/tiny-weather-rescue-cover.png") center / cover;
  box-shadow: inset 0 0 0 1000px rgba(255, 255, 255, 0.28), 0 18px 34px rgba(38, 79, 113, 0.2);
}

.weather-scene {
  min-height: calc(min(84svh, 620px) - 24px);
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  justify-items: center;
  position: relative;
}

.weather-scene::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 22px;
  background:
    radial-gradient(circle at 24% 18%, rgba(255, 255, 255, 0.86), transparent 10rem),
    linear-gradient(180deg, rgba(87, 185, 232, 0.3), rgba(255, 247, 210, 0.52));
  z-index: 0;
}

.weather-scene > * {
  position: relative;
  z-index: 1;
}

.rescue-scene {
  width: min(100%, 460px);
  min-height: min(46svh, 330px);
  border-radius: 28px;
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-rows: 1fr auto;
  justify-items: center;
  align-items: end;
  padding: 20px 16px 16px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.52), rgba(255, 253, 232, 0.72)),
    linear-gradient(180deg, #9edcff 0%, #c5f2b2 68%, #73c778 100%);
  box-shadow: inset 0 -10px rgba(0, 0, 0, 0.06), 0 16px 30px rgba(38, 79, 113, 0.16);
  animation: cardIn 0.24s ease both;
}

.weather-scene.rain .rescue-scene,
.weather-scene.thunder .rescue-scene {
  background:
    linear-gradient(180deg, rgba(76, 112, 150, 0.32), rgba(255, 255, 255, 0.58)),
    linear-gradient(180deg, #7fb7e0 0%, #aacbd5 62%, #73b86e 100%);
}

.weather-scene.dark .rescue-scene {
  background:
    radial-gradient(circle at 72% 18%, rgba(255, 239, 148, 0.55), transparent 4rem),
    linear-gradient(180deg, #465b91 0%, #8393bd 62%, #6ab177 100%);
}

.weather-scene.heat .rescue-scene {
  background:
    radial-gradient(circle at 78% 18%, rgba(255, 207, 62, 0.88), transparent 4.5rem),
    linear-gradient(180deg, #ffd17c 0%, #fbf0b5 62%, #89c56a 100%);
}

.weather-scene.cold .rescue-scene {
  background:
    radial-gradient(circle at 70% 18%, rgba(255, 255, 255, 0.9), transparent 4rem),
    linear-gradient(180deg, #bde9ff 0%, #e8f9ff 62%, #a7d3db 100%);
}

.weather-scene.muddy .rescue-scene {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.48), rgba(255, 247, 218, 0.66)),
    linear-gradient(180deg, #bbe4ff 0%, #b5dc9b 58%, #9c7045 100%);
}

.weather-scene.windy .rescue-scene {
  background:
    linear-gradient(115deg, rgba(255, 255, 255, 0.72) 0 8%, transparent 8% 18%, rgba(255, 255, 255, 0.45) 18% 26%, transparent 26%),
    linear-gradient(180deg, #abd8ff 0%, #d9f0dd 64%, #75bd6d 100%);
}

.weather-effects {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.weather-effects span {
  position: absolute;
  font-size: clamp(2rem, 9vw, 3.8rem);
  animation: floaty 1.9s ease-in-out infinite;
}

.weather-effects span:nth-child(1) {
  top: 8%;
  left: 16%;
}

.weather-effects span:nth-child(2) {
  top: 18%;
  right: 16%;
  animation-delay: 0.22s;
}

.weather-effects span:nth-child(3) {
  top: 34%;
  left: 48%;
  animation-delay: 0.44s;
}

.problem-bubble {
  position: absolute;
  top: 14px;
  left: 14px;
  width: 58px;
  height: 58px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.82);
  font-size: 2.1rem;
  box-shadow: inset 0 -5px rgba(0, 0, 0, 0.07), 0 10px 18px rgba(38, 79, 113, 0.12);
}

.animal-zone {
  width: min(46vw, 190px);
  aspect-ratio: 1;
  border-radius: 38%;
  position: relative;
  display: grid;
  place-items: center;
  transition: transform 0.18s ease, filter 0.18s ease;
}

.animal-zone.drag-over {
  transform: scale(1.08);
  filter: drop-shadow(0 0 18px rgba(255, 211, 107, 0.66));
}

.animal-shadow {
  position: absolute;
  bottom: 14px;
  width: 78%;
  height: 18%;
  border-radius: 50%;
  background: rgba(28, 53, 62, 0.16);
}

.animal-face {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  border: 6px solid rgba(255, 255, 255, 0.78);
  border-radius: 38%;
  display: grid;
  place-items: center;
  background: #fffdf4;
  font-size: clamp(4rem, 21vw, 7.2rem);
  box-shadow: inset 0 -10px rgba(0, 0, 0, 0.06), 0 16px 28px rgba(38, 79, 113, 0.16);
}

.animal-zone.happy .animal-face {
  animation: pop 0.34s ease;
}

.animal-zone.sad .animal-face {
  animation: shake 0.28s ease;
}

.need-line {
  min-height: 34px;
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  color: rgba(23, 49, 79, 0.74);
  font-size: clamp(0.78rem, 3.2vw, 0.95rem);
  font-weight: 900;
}

.tool-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  align-self: end;
}

.tool-btn {
  min-width: 0;
  min-height: 96px;
  border: 0;
  border-radius: 18px;
  display: grid;
  gap: 5px;
  place-items: center;
  padding: 10px 8px;
  background: rgba(255, 255, 255, 0.9);
  color: #17314f;
  font-weight: 900;
  box-shadow: inset 0 -6px rgba(0, 0, 0, 0.07), 0 10px 20px rgba(38, 79, 113, 0.14);
  transition: transform 0.16s ease, filter 0.16s ease, background 0.16s ease;
  touch-action: manipulation;
  user-select: none;
}

.tool-btn i {
  width: 62px;
  height: 62px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  background: rgba(87, 185, 232, 0.16);
  font-style: normal;
  font-size: 2.75rem;
}

.tool-btn.towel i {
  color: #ffffff;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.28), transparent 34% 66%, rgba(255, 255, 255, 0.22)),
    linear-gradient(180deg, #72c9ff, #3b8fd8);
  text-shadow: 0 2px 0 rgba(13, 67, 112, 0.24);
}

.tool-btn span {
  max-width: 100%;
  font-size: clamp(0.66rem, 2.6vw, 0.8rem);
  line-height: 1.05;
  opacity: 0.58;
}

.tool-btn.correct {
  background: #d8ffcb;
  animation: pop 0.32s ease;
}

.tool-btn.wrong {
  background: #ffd6d6;
  animation: shake 0.28s ease;
}

.tool-drag-ghost {
  position: fixed;
  z-index: 100;
  width: 74px;
  height: 74px;
  border-radius: 22px;
  display: grid;
  place-items: center;
  pointer-events: none;
  translate: -50% -50%;
  background: rgba(255, 255, 255, 0.94);
  color: #17314f;
  font-size: 3rem;
  box-shadow: 0 18px 34px rgba(38, 79, 113, 0.24);
}

.face-pop {
  position: absolute;
  top: 30%;
  left: 50%;
  z-index: 4;
  translate: -50% -50%;
  font-size: clamp(3.2rem, 16vw, 6rem);
  filter: drop-shadow(0 12px 16px rgba(38, 79, 113, 0.22));
  animation: faceRise 0.72s ease forwards;
}

.event-pop {
  position: absolute;
  top: 45%;
  left: 50%;
  translate: -50% -50%;
  padding: 8px 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: #238447;
  font-size: 1.4rem;
  font-weight: 900;
  box-shadow: 0 12px 24px rgba(38, 79, 113, 0.18);
  animation: eventPop 0.58s ease both;
}

.hint {
  min-height: 38px;
  margin: 0;
  display: grid;
  place-items: center;
  color: rgba(23, 49, 79, 0.76);
  font-weight: 900;
  text-align: center;
}

.hidden {
  display: none !important;
}

.loading-panel,
.result-panel {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(24, 48, 72, 0.44);
  backdrop-filter: blur(8px);
}

.loading-card,
.result-card {
  width: min(92vw, 420px);
  border-radius: 24px;
  padding: 22px;
  display: grid;
  gap: 12px;
  background: #fffdf2;
  color: #17314f;
  text-align: center;
  box-shadow: 0 24px 50px rgba(18, 48, 70, 0.28);
  animation: cardIn 0.28s ease both;
}

.result-card strong {
  font-size: 1.65rem;
}

.stars {
  color: #ffb300;
  font-size: 2.1rem;
}

.result-card button,
.result-card a {
  display: grid;
  place-items: center;
  padding: 10px 14px;
  background: #ffdf70;
}

.result-card button:nth-of-type(2),
.result-card button:nth-of-type(3) {
  background: rgba(255, 255, 255, 0.94);
}

.loading-card div {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(23, 49, 79, 0.15);
}

.loading-card i {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #57b9e8, #ffcf48);
  transition: width 0.2s ease;
}

.floating-toast {
  position: fixed;
  left: 50%;
  top: 46%;
  z-index: 40;
  translate: -50% -50%;
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  color: #17314f;
  font-weight: 900;
  box-shadow: 0 18px 38px rgba(38, 79, 113, 0.22);
  animation: toastUp 1.28s ease forwards;
}

@keyframes cardIn {
  from { transform: translateY(16px) scale(0.96); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

@keyframes pop {
  50% { transform: scale(1.09); }
}

@keyframes shake {
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

@keyframes floaty {
  50% { transform: translateY(-8px); }
}

@keyframes pulseArrow {
  50% { transform: translateX(4px) scale(1.08); }
}

@keyframes faceRise {
  0% { transform: translateY(20px) scale(0.68); opacity: 0; }
  26% { transform: translateY(0) scale(1.08); opacity: 1; }
  100% { transform: translateY(-48px) scale(0.94); opacity: 0; }
}

@keyframes eventPop {
  0% { transform: scale(0.72); opacity: 0; }
  30% { transform: scale(1.08); opacity: 1; }
  100% { transform: translateY(-22px) scale(0.96); opacity: 0; }
}

@keyframes toastUp {
  to { transform: translateY(-44px); opacity: 0; }
}

@media (max-width: 430px) {
  .weather-game {
    padding-inline: 10px;
    gap: 10px;
  }

  .topbar {
    grid-template-columns: 44px 1fr 112px;
  }

  .cover {
    aspect-ratio: 1.04 / 1;
  }

  .stage-grid {
    grid-template-columns: 1fr;
  }

  .board {
    min-height: min(78svh, 560px);
    padding: 8px;
    border-radius: 22px;
  }

  .weather-scene {
    min-height: calc(min(78svh, 560px) - 16px);
    gap: 10px;
  }

  .rescue-scene {
    min-height: min(38svh, 280px);
    padding: 14px 10px 12px;
  }

  .tool-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .tool-btn {
    min-height: 82px;
    border-radius: 15px;
  }

  .tool-btn i {
    width: 54px;
    height: 54px;
    font-size: 2.38rem;
  }

  .stats {
    font-size: 0.76rem;
    grid-template-columns: 58px 1fr 64px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
html,
body,
button,
a,
canvas,
[role="button"] {
  -webkit-user-select: none;
  user-select: none;
}

input,
textarea,
select,
[contenteditable="true"] {
  -webkit-user-select: text;
  user-select: text;
}
