:root {
  --ink: #233746;
  --ink-soft: #5a7080;
  --forest: #2f9d68;
  --forest-dark: #176347;
  --leaf: #55b96b;
  --sky: #bfe9ff;
  --sky-deep: #77c9f4;
  --sun: #ffd65a;
  --orange: #ff9f43;
  --coral: #ff7868;
  --pink: #ff86b5;
  --purple: #8a79dc;
  --blue: #478ed8;
  --cream: #fff6db;
  --paper: #fffdf8;
  --line: rgba(35, 55, 70, 0.13);
  --shadow: 0 18px 48px rgba(41, 94, 119, 0.22);
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  color: var(--ink);
  background: var(--sky);
  font-family: "Trebuchet MS", "Segoe UI", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; }

button:focus-visible {
  outline: 5px solid var(--sun);
  outline-offset: 3px;
}

.game-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(680px, 860px);
  width: 100vw;
  height: 100vh;
  background:
    radial-gradient(circle at 8% 11%, rgba(255,255,255,.95) 0 22px, transparent 23px),
    radial-gradient(circle at 12% 11%, rgba(255,255,255,.9) 0 32px, transparent 33px),
    radial-gradient(circle at 17% 12%, rgba(255,255,255,.9) 0 24px, transparent 25px),
    radial-gradient(circle at 77% 8%, rgba(255,214,90,.72) 0 54px, transparent 55px),
    radial-gradient(circle at 28% 86%, rgba(255,255,255,.35) 0 80px, transparent 81px),
    linear-gradient(155deg, #c9efff 0%, #a9e0f8 43%, #d7f1cd 100%);
}

.poster-area {
  min-width: 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.poster-stage {
  position: relative;
  height: calc(100vh - 32px);
  max-width: 100%;
  aspect-ratio: 1439 / 2048;
  overflow: hidden;
  background: #f4f0e8;
  border: 6px solid rgba(255,255,255,.96);
  border-radius: 22px;
  outline: 5px solid rgba(255,214,90,.9);
  outline-offset: -1px;
  box-shadow:
    0 22px 55px rgba(49, 91, 108, .24),
    0 0 0 1px rgba(35,55,70,.08);
  user-select: none;
  touch-action: manipulation;
}

.poster-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: translate3d(0, 0, 0) scale(1);
  transform-origin: 0 0;
  transition: transform 520ms cubic-bezier(.22,.72,.2,1);
  will-change: transform;
}

.poster-image, .birds-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.poster-image {
  display: block;
  object-fit: contain;
  pointer-events: none;
}

.birds-layer { pointer-events: none; }

.bird-spot {
  position: absolute;
  display: block;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  pointer-events: auto;
  touch-action: manipulation;
}

.bird-silhouette {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  opacity: 1;
  transform: scale(1.025);
  transform-origin: center;
  shape-rendering: geometricPrecision;
  filter:
    drop-shadow(0 2px 1px rgba(255,255,255,.45))
    drop-shadow(0 3px 2px rgba(35,55,70,.2));
  transition: opacity 260ms ease, transform 260ms ease, filter 260ms ease;
  pointer-events: none;
}

.bird-spot:hover .bird-silhouette,
.bird-spot:focus-visible .bird-silhouette {
  transform: scale(1.055);
  filter:
    drop-shadow(0 0 8px rgba(255,214,90,1))
    drop-shadow(0 0 14px rgba(255,159,67,.85));
}

.bird-spot.revealed .bird-silhouette {
  opacity: 0;
  transform: scale(1.06);
}

.bird-spot.selected::after,
.bird-spot.random-highlight::after {
  content: "";
  position: absolute;
  inset: -6px;
  border: 4px solid var(--sun);
  border-radius: 16px;
  box-shadow:
    0 0 0 5px rgba(255,134,181,.28),
    0 0 20px rgba(255,159,67,.42);
  pointer-events: none;
}

.bird-spot.random-highlight::after {
  border-color: var(--coral);
  box-shadow:
    0 0 0 5px rgba(255,214,90,.35),
    0 0 22px rgba(255,120,104,.6);
  animation: pulse-highlight 800ms ease-in-out infinite alternate;
}

.zoom-out-button {
  position: absolute;
  z-index: 20;
  top: 14px;
  left: 14px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 64px;
  padding: 0 24px;
  border: 4px solid white;
  border-radius: 20px;
  color: white;
  background: linear-gradient(135deg, var(--blue), var(--purple));
  box-shadow: 0 9px 22px rgba(67,95,146,.3);
  cursor: pointer;
  font-size: 18px;
  font-weight: 900;
  touch-action: manipulation;
}

.zoom-out-button[hidden] { display: none; }

.zoom-out-button span {
  font-size: 30px;
  line-height: 1;
}

@keyframes pulse-highlight {
  from { transform: scale(.97); opacity: .65; }
  to { transform: scale(1.045); opacity: 1; }
}

.side-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 22px 22px 18px;
  background:
    radial-gradient(circle at 93% 4%, rgba(255,214,90,.38) 0 54px, transparent 55px),
    radial-gradient(circle at 8% 92%, rgba(255,134,181,.17) 0 90px, transparent 91px),
    linear-gradient(180deg, rgba(255,253,248,.98), rgba(255,247,222,.98));
  border-left: 5px solid rgba(255,255,255,.8);
  box-shadow: -12px 0 38px rgba(49,91,108,.12);
}

.school-brand {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 66px;
  padding: 8px 10px 16px;
  border-bottom: 3px dashed rgba(71,142,216,.22);
}

.school-logo {
  display: block;
  width: min(100%, 340px);
  height: auto;
  aspect-ratio: 8 / 1;
  object-fit: contain;
  filter: drop-shadow(0 4px 6px rgba(61,86,101,.12));
}

.school-logo-fallback {
  color: var(--forest-dark);
  font-size: 18px;
  font-weight: 900;
  text-align: center;
}

.game-heading {
  padding: 22px 0 15px;
  position: relative;
}

.eyebrow, .start-kicker {
  display: inline-block;
  margin: 0 0 8px;
  padding: 5px 10px;
  border-radius: 999px;
  color: #79540a;
  background: rgba(255,214,90,.58);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .11em;
  text-transform: uppercase;
}

.game-heading h1, .start-card h1 {
  margin: 0;
  color: #2b6fa6;
  font-size: clamp(36px, 3.2vw, 50px);
  line-height: .98;
  letter-spacing: -.035em;
  text-shadow: 2px 2px 0 rgba(255,214,90,.55);
}

.game-intro, .start-text {
  margin: 12px 0 0;
  color: var(--ink-soft);
  line-height: 1.48;
}

.progress-wrap {
  margin-bottom: 18px;
  padding: 11px 13px 13px;
  border-radius: 16px;
  background: rgba(255,255,255,.74);
  box-shadow: inset 0 0 0 2px rgba(71,142,216,.10);
}

.progress-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
  font-size: 14px;
}

.progress-row span {
  color: #496777;
  font-weight: 800;
}

.progress-row strong {
  min-width: 64px;
  padding: 2px 8px;
  border-radius: 999px;
  color: white;
  background: var(--coral);
  text-align: center;
}

.progress-track {
  height: 14px;
  overflow: hidden;
  border: 3px solid white;
  border-radius: 99px;
  background: #dceef5;
  box-shadow: inset 0 2px 4px rgba(35,55,70,.1);
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #55c96f 0%, #67c8ef 36%, #8a79dc 68%, #ff86b5 100%);
  transition: width 300ms ease;
}

.bird-card {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 20px;
  border: 3px solid rgba(255,255,255,.92);
  border-radius: 24px;
  background:
    linear-gradient(rgba(255,255,255,.94), rgba(255,255,255,.94)),
    radial-gradient(circle at 12% 15%, var(--sun) 0 12px, transparent 13px);
  box-shadow:
    0 12px 28px rgba(57,93,111,.12),
    0 0 0 2px rgba(71,142,216,.08);
}

.empty-state {
  min-height: 220px;
  display: grid;
  align-content: center;
  justify-items: center;
  text-align: center;
}

.empty-icon {
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  margin-bottom: 15px;
  border: 5px solid white;
  border-radius: 50%;
  color: white;
  background: linear-gradient(145deg, var(--orange), var(--coral));
  box-shadow:
    0 8px 18px rgba(255,120,104,.28),
    0 0 0 4px rgba(255,214,90,.34);
  font-size: 40px;
  font-weight: 900;
  transform: rotate(-5deg);
}

.empty-state h2, .answer h2 {
  margin: 0;
  color: #2b6fa6;
}

.empty-state h2 { font-size: 26px; }

.empty-state p, .prompt {
  margin: 8px 0 0;
  color: var(--ink-soft);
  line-height: 1.45;
}

.prompt {
  margin: 0 0 16px;
  padding: 12px 14px;
  border-radius: 16px;
  color: #37586b;
  background: #edf8ff;
  font-size: 18px;
  font-weight: 800;
}

.bird-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.action-button {
  min-height: 92px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 4px solid rgba(255,255,255,.88);
  border-radius: 20px;
  color: white;
  cursor: pointer;
  font-weight: 900;
  letter-spacing: .01em;
  box-shadow: 0 8px 18px rgba(41,72,90,.17);
  transition: transform 120ms ease, box-shadow 120ms ease, filter 120ms ease;
}

.action-button:hover {
  transform: translateY(-2px);
  filter: saturate(1.08);
  box-shadow: 0 11px 21px rgba(41,72,90,.20);
}

.action-button:active { transform: scale(.96); }

.song-button {
  background: linear-gradient(145deg, #52a9ed, #7a78dc);
}

.info-button {
  background: linear-gradient(145deg, #55bf72, #36a59e);
}

.song-button.is-playing,
.info-button.is-playing {
  background: linear-gradient(145deg, var(--coral), var(--orange));
  box-shadow:
    0 10px 22px rgba(255,120,104,.24),
    0 0 0 4px rgba(255,214,90,.18);
}

.action-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 3px solid rgba(255,255,255,.55);
  border-radius: 50%;
  background: rgba(255,255,255,.16);
  font-size: 24px;
  font-family: Georgia, serif;
  font-weight: 900;
}

.audio-status {
  min-height: 20px;
  margin: 10px 0 0;
  color: #b56b12;
  font-size: 13px;
  font-weight: 800;
}

.answer {
  margin-top: 10px;
  padding: 17px 16px 15px;
  border: 0;
  border-radius: 18px;
  background: linear-gradient(135deg, #fff7d6, #eefbea);
  box-shadow: inset 0 0 0 2px rgba(255,214,90,.25);
  animation: answer-in 220ms ease-out;
}

@keyframes answer-in {
  from { opacity: 0; transform: translateY(6px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.answer h2 {
  font-size: 30px;
  line-height: 1.05;
  color: #e16a4f;
}

.answer dl { margin: 15px 0 0; }
.answer dl > div + div { margin-top: 14px; }

.answer dt {
  display: inline-block;
  margin-bottom: 5px;
  padding: 3px 8px;
  border-radius: 999px;
  color: #2d7654;
  background: rgba(85,201,111,.16);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .07em;
  text-transform: uppercase;
}

.answer dd {
  margin: 0;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.42;
}

.teacher-controls {
  display: flex;
  gap: 10px;
  padding-top: 16px;
}

.small-button, .icon-button {
  min-height: 68px;
  border: 4px solid white;
  border-radius: 20px;
  color: #665016;
  background: linear-gradient(145deg, #ffe47c, #ffc85a);
  box-shadow: 0 7px 17px rgba(143,104,31,.17);
  cursor: pointer;
  font-weight: 900;
  touch-action: manipulation;
  transition: transform 120ms ease, filter 120ms ease;
}

.small-button:hover, .icon-button:hover {
  transform: translateY(-1px);
  filter: saturate(1.08);
}

.small-button {
  flex: 1 1 auto;
  padding: 0 18px;
  font-size: 17px;
  line-height: 1.1;
}

.small-button:disabled {
  cursor: default;
  opacity: .48;
  transform: none;
}

.icon-button {
  flex: 0 0 68px;
  width: 68px;
  color: white;
  background: linear-gradient(145deg, var(--coral), var(--pink));
  font-size: 31px;
}

.start-screen, .finish-screen {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 12% 14%, rgba(255,255,255,.85) 0 34px, transparent 35px),
    radial-gradient(circle at 17% 14%, rgba(255,255,255,.75) 0 47px, transparent 48px),
    radial-gradient(circle at 82% 13%, rgba(255,214,90,.9) 0 70px, transparent 71px),
    linear-gradient(rgba(68,161,197,.30), rgba(66,154,117,.43)),
    url("../assets/main_birds.webp") center 39% / cover no-repeat;
}

.start-screen[hidden], .finish-screen[hidden] { display: none; }

.start-card, .finish-card {
  position: relative;
  width: min(700px, 94vw);
  padding: clamp(32px, 5vw, 60px);
  overflow: hidden;
  border: 6px solid white;
  border-radius: 34px;
  background:
    radial-gradient(circle at 7% 8%, rgba(255,214,90,.35) 0 65px, transparent 66px),
    radial-gradient(circle at 94% 92%, rgba(255,134,181,.19) 0 90px, transparent 91px),
    rgba(255,253,248,.98);
  box-shadow: 0 30px 90px rgba(34,75,93,.32);
}

.start-card::after,
.finish-card::after {
  content: "★  ●  ★  ●  ★";
  position: absolute;
  right: 22px;
  bottom: 15px;
  color: rgba(255,120,104,.32);
  font-size: 14px;
  letter-spacing: 7px;
  pointer-events: none;
}

.start-school {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 34px;
  padding: 12px 16px;
  border-radius: 20px;
  background: rgba(255,255,255,.76);
}

.start-logo {
  display: block;
  width: min(100%, 480px);
  height: auto;
  aspect-ratio: 8 / 1;
  object-fit: contain;
  filter: drop-shadow(0 5px 8px rgba(61,86,101,.13));
}

.start-text {
  max-width: 560px;
  margin-top: 18px;
  color: #4d6979;
  font-size: 18px;
}

.start-button {
  min-width: 210px;
  min-height: 62px;
  margin-top: 28px;
  padding: 0 34px;
  border: 4px solid white;
  border-radius: 20px;
  color: white;
  background: linear-gradient(145deg, var(--coral), var(--orange));
  box-shadow:
    0 12px 25px rgba(255,120,104,.28),
    0 0 0 4px rgba(255,214,90,.22);
  cursor: pointer;
  font-size: 20px;
  font-weight: 900;
  transition: transform 120ms ease, filter 120ms ease;
}

.start-button:hover {
  transform: translateY(-2px) rotate(-.4deg);
  filter: saturate(1.08);
}

.start-button:active { transform: scale(.97); }

.start-card .start-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: min(420px, 100%);
  min-height: 112px;
  margin: 34px auto 0;
  padding: 0 44px;
  border-width: 5px;
  border-radius: 28px;
  font-size: 30px;
  letter-spacing: .01em;
  touch-action: manipulation;
}

.finish-card { text-align: center; }

.finish-mark {
  display: grid;
  place-items: center;
  width: 92px;
  height: 92px;
  margin: 0 auto 18px;
  border: 5px solid white;
  border-radius: 50%;
  color: white;
  background: linear-gradient(145deg, #55c96f, #31aa96);
  box-shadow:
    0 10px 22px rgba(49,170,150,.25),
    0 0 0 5px rgba(255,214,90,.3);
  font-size: 48px;
  font-weight: 900;
}

.finish-card p {
  display: inline-block;
  margin: 0 0 8px;
  padding: 5px 12px;
  border-radius: 999px;
  color: #8a5b00;
  background: rgba(255,214,90,.5);
  font-size: 16px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .1em;
}

.finish-card h2 {
  margin: 0;
  color: #2b6fa6;
  font-size: clamp(36px, 5vw, 60px);
  line-height: 1.02;
  text-shadow: 2px 2px 0 rgba(255,214,90,.48);
}

@media (max-width: 1500px) {
  body { overflow: auto; }

  .game-shell {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
  }

  .poster-area { padding-bottom: 6px; }

  .poster-stage {
    width: min(100%, 720px);
    height: auto;
  }

  .side-panel {
    border-left: 0;
    border-top: 5px solid rgba(255,255,255,.8);
  }
}

@media (max-width: 560px) {
  .side-panel { padding: 18px 14px; }

  .bird-actions { grid-template-columns: 1fr; }

  .action-button {
    min-height: 70px;
    flex-direction: row;
  }

  .start-card { padding: 28px 24px; }

  .teacher-controls {
    gap: 8px;
  }

  .small-button, .icon-button {
    min-height: 62px;
  }

  .icon-button {
    flex-basis: 62px;
    width: 62px;
  }

  .zoom-out-button {
    top: 8px;
    left: 8px;
    min-height: 58px;
    padding: 0 18px;
    font-size: 16px;
  }

  .start-card .start-button {
    min-height: 96px;
    font-size: 27px;
  }
}
