:root {
  --ink: #16364e;
  --muted: #5b7487;
  --white: #ffffff;
  --sky: #dff5ff;
  --sun: #ffd154;
  --coral: #ff8d78;
  --mint: #bfeaca;
  --blue: #72c8ee;
  --shadow: 0 20px 55px rgba(43, 76, 99, 0.15);
}

* { box-sizing: border-box; }
html { min-width: 320px; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Trebuchet MS", "Arial Rounded MT Bold", Arial, sans-serif;
  background:
    radial-gradient(circle at 10% 3%, rgba(255, 241, 160, 0.9) 0 8%, transparent 26%),
    radial-gradient(circle at 94% 28%, rgba(255, 177, 162, 0.55) 0 9%, transparent 28%),
    linear-gradient(145deg, #dbf4ff 0%, #f7fbff 48%, #fff0e8 100%);
}

button { font: inherit; }

.app {
  width: min(1580px, 100%);
  margin: 0 auto;
  padding: 25px clamp(14px, 3vw, 48px) 44px;
}

.hero { text-align: center; }

.lesson-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border: 1px solid rgba(255, 255, 255, 0.88);
  border-radius: 999px;
  color: #34749c;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 8px 22px rgba(44, 104, 142, 0.12);
  font-size: 0.8rem;
  font-weight: 900;
  letter-spacing: 0.11em;
}

h1 {
  max-width: 1120px;
  margin: 12px auto 8px;
  font-size: clamp(2rem, 4vw, 4rem);
  line-height: 1.03;
  letter-spacing: -0.055em;
  text-shadow: 0 3px 0 #fff;
}

.hero p {
  margin: 0 auto;
  color: var(--muted);
  font-size: clamp(1rem, 1.35vw, 1.2rem);
  font-weight: 700;
}

.activity-bank {
  position: relative;
  z-index: 20;
  margin: 20px 0;
  padding: 16px 18px 18px;
  border: 1px solid rgba(255, 255, 255, 0.94);
  border-radius: 27px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.bank-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 13px;
}

.bank-kicker { color: #5b85a0; font-size: 0.72rem; font-weight: 900; letter-spacing: 0.13em; }
.bank-bar h2 { margin: 1px 0 0; font-size: clamp(1rem, 1.6vw, 1.28rem); letter-spacing: -0.02em; }
.game-controls { display: flex; align-items: center; gap: 10px; }
.score-pill, .reset-button { min-height: 42px; border-radius: 14px; font-weight: 900; }

.score-pill {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 8px 13px;
  color: #775a00;
  background: #fff3b1;
  box-shadow: inset 0 0 0 1px rgba(168, 123, 0, 0.12);
}

.score-pill > span:first-child { color: #efaa00; }

.reset-button {
  border: 0;
  padding: 8px 14px;
  color: #fff;
  background: #305f7d;
  box-shadow: 0 5px 0 #1e435c;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.reset-button:hover { transform: translateY(-2px); box-shadow: 0 7px 0 #1e435c; }
.reset-button:active { transform: translateY(3px); box-shadow: 0 2px 0 #1e435c; }

.cards {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 11px;
  min-height: 51px;
}

.word-card {
  position: relative;
  border: 0;
  border-radius: 15px;
  padding: 12px 17px;
  color: var(--ink);
  background: var(--card-color, #fff);
  box-shadow: 0 5px 0 var(--card-edge, #ccdae3), 0 10px 20px rgba(36, 71, 95, 0.1);
  cursor: grab;
  font-size: clamp(0.9rem, 1.2vw, 1.04rem);
  font-weight: 900;
  line-height: 1.15;
  touch-action: manipulation;
  user-select: none;
  transition: transform 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
}

.word-card:nth-child(4n+1) { --card-color: #fff1a4; --card-edge: #e3cc65; }
.word-card:nth-child(4n+2) { --card-color: #ffd7d0; --card-edge: #eba89c; }
.word-card:nth-child(4n+3) { --card-color: #cdefff; --card-edge: #8cc9e3; }
.word-card:nth-child(4n) { --card-color: #d6f3c8; --card-edge: #9bce85; }

.word-card:hover,
.word-card:focus-visible {
  z-index: 2;
  outline: 3px solid #fff;
  outline-offset: 3px;
  transform: translateY(-3px) rotate(-1deg);
  box-shadow: 0 8px 0 var(--card-edge), 0 15px 25px rgba(36, 71, 95, 0.15);
}

.word-card.selected {
  outline: 4px solid #2e88bd;
  outline-offset: 3px;
  transform: translateY(-5px) scale(1.025);
  box-shadow: 0 8px 0 var(--card-edge), 0 18px 29px rgba(46, 136, 189, 0.22);
}

.word-card.dragging { opacity: 0.45; cursor: grabbing; }
.word-card.wrong { animation: card-shake 420ms ease; }

.weather-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 17px; }

.weather-panel {
  position: relative;
  min-height: 425px;
  overflow: hidden;
  border: 4px solid rgba(255, 255, 255, 0.96);
  border-radius: 28px;
  background: #466779;
  box-shadow: 0 18px 38px rgba(28, 58, 78, 0.22);
  cursor: pointer;
  isolation: isolate;
  transform: translateZ(0);
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.weather-panel::after {
  content: "";
  position: absolute;
  z-index: 2;
  inset: 0;
  background: linear-gradient(180deg, rgba(6, 25, 38, 0.03) 30%, rgba(7, 28, 43, 0.78) 100%);
  pointer-events: none;
}

.weather-panel:hover,
.weather-panel:focus-visible {
  outline: none;
  transform: translateY(-3px);
  box-shadow: 0 23px 45px rgba(28, 58, 78, 0.27);
}

.weather-panel.drag-over,
.weather-panel.tap-ready {
  border-color: #ffe066;
  box-shadow: 0 0 0 5px rgba(255, 224, 102, 0.35), 0 23px 45px rgba(28, 58, 78, 0.27);
}

.scene-image {
  position: absolute;
  z-index: 0;
  inset: -14px;
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  animation: scene-breathe 16s ease-in-out infinite alternate;
  will-change: transform;
}

.sunny .scene-image { background-image: url("assets/sunny-day.png"); }
.windy .scene-image { background-image: url("assets/windy-day.png"); animation-duration: 10s; }
.rainy .scene-image { background-image: url("assets/rainy-day.png"); animation-duration: 19s; }
.cloudy .scene-image { background-image: url("assets/cloudy-day.png"); animation: cloud-pan 18s ease-in-out infinite alternate; }

.panel-content {
  position: relative;
  z-index: 4;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 417px;
  padding: 15px;
  pointer-events: none;
}

.weather-heading {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  gap: 9px;
  padding: 9px 13px 9px 10px;
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.91);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.13);
  backdrop-filter: blur(8px);
}

.weather-heading h2 { margin: 0; color: #17394f; font-size: clamp(1.2rem, 1.7vw, 1.7rem); letter-spacing: -0.035em; }
.weather-icon { font-size: 1.45rem; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.12)); }

.drop-zone {
  width: 100%;
  min-height: 137px;
  padding: 11px;
  border: 2px dashed rgba(255, 255, 255, 0.74);
  border-radius: 18px;
  color: #fff;
  background: rgba(8, 34, 51, 0.25);
  backdrop-filter: blur(4px);
  transition: background 180ms ease, border-color 180ms ease;
}

.drag-over .drop-zone,
.tap-ready .drop-zone { border-color: #ffe66d; background: rgba(8, 34, 51, 0.48); }

.drop-label {
  display: block;
  margin: 1px 0 8px;
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-align: center;
  text-transform: uppercase;
}

.answers { display: flex; flex-wrap: wrap; align-content: flex-end; justify-content: center; gap: 8px; min-height: 77px; }

.answers .word-card {
  padding: 9px 29px 9px 12px;
  border-radius: 12px;
  color: #16364e;
  cursor: default;
  font-size: 0.83rem;
  box-shadow: 0 4px 0 rgba(15, 48, 67, 0.38), 0 7px 13px rgba(0, 0, 0, 0.18);
  pointer-events: none;
  animation: card-land 420ms cubic-bezier(0.2, 0.9, 0.32, 1.25);
}

.answers .word-card::after {
  content: "✓";
  position: absolute;
  top: 50%;
  right: 9px;
  transform: translateY(-50%);
  color: #087a50;
  font-size: 1rem;
}

.answers:empty::after {
  content: "﹀";
  align-self: center;
  color: rgba(255, 255, 255, 0.8);
  font-size: 2rem;
  line-height: 1;
  animation: hint-bounce 1.5s ease-in-out infinite;
}

.light-wash, .sun-radiance, .wind-layer, .rain-layer, .cloud-shadow {
  position: absolute;
  z-index: 1;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.light-wash { background: linear-gradient(145deg, rgba(255, 250, 197, 0.18), transparent 52%); animation: sunlight 5s ease-in-out infinite alternate; }

.sun-radiance {
  inset: -25% -28% auto auto;
  width: 105%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: repeating-conic-gradient(from 8deg, rgba(255, 237, 149, 0.16) 0 7deg, transparent 7deg 19deg);
  animation: sun-turn 28s linear infinite;
  mix-blend-mode: screen;
}

.wind-streak {
  position: absolute;
  left: -45%;
  width: var(--length);
  height: 2px;
  top: var(--top);
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.82), transparent);
  filter: blur(0.2px);
  animation: wind-sweep var(--speed) linear var(--delay) infinite;
  transform: rotate(-8deg);
}

.rain-drop {
  position: absolute;
  left: var(--left);
  top: -18%;
  width: 1.5px;
  height: var(--length);
  border-radius: 999px;
  background: linear-gradient(180deg, transparent, rgba(225, 244, 255, 0.87));
  opacity: var(--opacity);
  animation: rain-fall var(--speed) linear var(--delay) infinite;
  transform: rotate(8deg);
}

.cloud-shadow {
  width: 170%;
  left: -70%;
  background: linear-gradient(110deg, transparent 8%, rgba(24, 47, 65, 0.26) 38%, rgba(255, 255, 255, 0.14) 56%, transparent 78%);
  animation: cloud-shadow 12s ease-in-out infinite;
}

.weather-panel.correct { animation: panel-correct 600ms ease; }
.weather-panel.incorrect { animation: panel-wrong 420ms ease; }

.toast {
  position: fixed;
  z-index: 50;
  left: 50%;
  bottom: 26px;
  min-width: min(320px, calc(100vw - 30px));
  padding: 12px 18px;
  border-radius: 14px;
  color: #fff;
  background: #183d54;
  box-shadow: 0 14px 30px rgba(16, 47, 68, 0.3);
  font-weight: 900;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 18px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.good { background: #0f815d; }
.toast.try { background: #d4624f; }

.finish-dialog {
  width: min(470px, calc(100% - 30px));
  overflow: hidden;
  padding: 33px 28px 29px;
  border: 0;
  border-radius: 28px;
  color: var(--ink);
  background: linear-gradient(155deg, #fff 35%, #e8f8ff 100%);
  box-shadow: 0 30px 100px rgba(10, 39, 58, 0.42);
  text-align: center;
}

.finish-dialog::backdrop { background: rgba(15, 46, 65, 0.55); backdrop-filter: blur(5px); }
.finish-icon { font-size: 4.3rem; animation: trophy-pop 700ms cubic-bezier(0.1, 1.1, 0.3, 1.3); }
.finish-kicker { margin: 8px 0 1px; color: #e09d00; font-size: 0.78rem; font-weight: 900; letter-spacing: 0.15em; }
.finish-dialog h2 { margin: 3px 0 8px; font-size: 2.2rem; letter-spacing: -0.04em; }
.finish-dialog p:not(.finish-kicker) { margin: 0 auto 22px; color: var(--muted); font-size: 1rem; line-height: 1.5; }
.finish-dialog button { border: 0; border-radius: 15px; padding: 12px 20px; color: #fff; background: #2e83b4; box-shadow: 0 5px 0 #1c5a7e; font-weight: 900; cursor: pointer; }

.confetti i {
  position: absolute;
  left: var(--x);
  top: -12%;
  width: 8px;
  height: 14px;
  border-radius: 2px;
  background: var(--color);
  animation: confetti-fall var(--speed) linear var(--delay) infinite;
}

@keyframes scene-breathe { from { transform: scale(1.03) translate3d(-0.6%, -0.3%, 0); } to { transform: scale(1.09) translate3d(1.2%, 0.8%, 0); } }
@keyframes cloud-pan { from { transform: scale(1.06) translate3d(-2.5%, 0, 0); } to { transform: scale(1.08) translate3d(2.5%, -0.6%, 0); } }
@keyframes sunlight { from { opacity: 0.42; } to { opacity: 1; } }
@keyframes sun-turn { to { transform: rotate(360deg); } }
@keyframes wind-sweep { from { transform: translateX(0) rotate(-8deg); opacity: 0; } 15% { opacity: 0.9; } 70% { opacity: 0.65; } to { transform: translateX(220%) rotate(-8deg); opacity: 0; } }
@keyframes rain-fall { from { transform: translate3d(0, -15%, 0) rotate(8deg); } to { transform: translate3d(-55px, 1500%, 0) rotate(8deg); } }
@keyframes cloud-shadow { 0%, 100% { transform: translateX(-4%); opacity: 0.55; } 50% { transform: translateX(52%); opacity: 0.92; } }
@keyframes hint-bounce { 0%, 100% { transform: translateY(-3px); } 50% { transform: translateY(6px); } }
@keyframes card-land { from { opacity: 0; transform: translateY(-18px) scale(0.84); } to { opacity: 1; transform: none; } }
@keyframes card-shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-8px) rotate(-2deg); } 55% { transform: translateX(8px) rotate(2deg); } 80% { transform: translateX(-4px); } }
@keyframes panel-correct { 0%, 100% { filter: none; } 45% { filter: saturate(1.4) brightness(1.16); } }
@keyframes panel-wrong { 0%, 100% { border-color: #fff; } 50% { border-color: #ff7c6a; } }
@keyframes trophy-pop { from { transform: scale(0.3) rotate(-14deg); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes confetti-fall { to { transform: translateY(390px) rotate(540deg); } }

@media (max-width: 1180px) {
  .weather-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .weather-panel { min-height: 370px; }
  .panel-content { min-height: 362px; }
}

@media (max-width: 680px) {
  .app { padding-top: 17px; }
  .hero p { max-width: 520px; line-height: 1.45; }
  .activity-bank { margin: 16px 0; padding: 14px; border-radius: 22px; }
  .bank-bar { align-items: flex-end; }
  .bank-kicker { display: none; }
  .bank-bar h2 { font-size: 0.98rem; }
  .reset-button { padding: 8px 11px; }
  .word-card { flex: 1 1 43%; padding: 12px 9px; }
  .weather-grid { grid-template-columns: 1fr; }
  .weather-panel { min-height: 330px; border-radius: 24px; }
  .panel-content { min-height: 322px; }
}

@media (max-width: 430px) {
  h1 { font-size: 2rem; }
  .lesson-tag { font-size: 0.68rem; }
  .game-controls { gap: 7px; }
  .score-pill { padding-inline: 10px; }
  .reset-button { font-size: 0.9rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}
