*{box-sizing:border-box}body{margin:0;font:18px/1.5 'Trebuchet MS',Arial,sans-serif;color:#254653;background:radial-gradient(at 5% 5%,#ffe8ac,transparent 55%),radial-gradient(at 95% 60%,#e7d8ff,transparent 60%),#fffbed}button,select{font:inherit;color:inherit}button,a,select{-webkit-tap-highlight-color:transparent}button{cursor:pointer;border:2px solid #c3dcd6;border-radius:18px;background:white;padding:12px 18px;font-weight:700;min-height:48px}button:focus-visible,a:focus-visible,select:focus-visible{outline:4px solid #245ca9;outline-offset:3px}button:disabled{cursor:default;opacity:1}header,main,footer{max-width:900px;margin:auto}header{display:flex;justify-content:space-between;align-items:center;padding:18px}.brand{font-weight:900;font-size:27px;color:#22566a;text-decoration:none}.brand span{color:#178b80}header a{color:#496a72}main{padding:12px 18px 6px}.hero{display:flex;align-items:center;justify-content:space-between;padding:24px;border:3px solid white;border-radius:30px;background:linear-gradient(110deg,#ffefab,#ffe0d9,#e7ddff);box-shadow:0 6px 0 #e9d7bd}.hero h1{font-size:clamp(30px,6vw,44px);margin:4px 0;color:#61508b}.hero p{margin:5px 0}.hero img{object-fit:contain}.eyebrow{font-size:12px;letter-spacing:2px;font-weight:900;color:#79548b}.switch{display:flex;gap:12px;margin:24px 0 14px}.switch button{flex:1;background:#fff1c2;border-color:#e5bf65}.switch button:nth-child(2){background:#ddf7f0;border-color:#7ccbbd}.switch [aria-pressed=true]{outline:3px solid #57629a;outline-offset:2px}.settings{display:flex;gap:12px;align-items:end;flex-wrap:wrap;margin-bottom:22px}.settings label{display:flex;flex:1;flex-direction:column;font-size:14px;font-weight:bold;min-width:120px}.settings select{background:white;border:2px solid #c9dce2;border-radius:13px;padding:10px;max-width:100%;min-height:48px}.settings label:nth-child(2){flex:2}.settings button{font-size:15px}.progress{display:flex;justify-content:space-between;gap:8px;margin:14px 2px}.question-controls {
  display: flex;
  justify-content: center;
}
.question-controls h2 {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.kg-game-fair .question-controls .listen {
  display: grid;
  place-items: center;
  width: 76px;
  height: 72px;
  padding: 0;
  border: 2px solid #6e399b;
  border-radius: 23px;
  background: linear-gradient(145deg, #fff697, #ffb4d5 53%, #c7afff);
  box-shadow: 0 4px 0 #6e399b;
}
.kg-game-fair .question-controls .listen.is-playing {
  box-shadow: 0 4px 0 #6e399b, 0 0 0 4px #ffd658;
}
.question-controls .listen:disabled {
  opacity: .45;
}
.board{position:relative;display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1.45fr);gap:66px;background:#ffffffb8;border:3px solid white;border-radius:28px;margin-top:18px;padding:12px 18px 20px;isolation:isolate}.column{min-width:0}.column h3{text-align:center;margin:0 0 12px;font-size:17px}.cards{display:grid;gap:16px}.card{height:132px;width:100%;display:flex;position:relative;align-items:center;justify-content:center;flex-direction:column;gap:4px;background:#fff0b7;border:3px solid #e8c45b;box-shadow:0 5px 0 #e2bf68;z-index:1;padding:8px}.card:nth-child(2n){background:#eadfff;border-color:#b7a0dd;box-shadow:0 5px 0 #bda5dc}.card:nth-child(3n){background:#d8f5ef;border-color:#79c7b7;box-shadow:0 5px 0 #79c7b7}.card:nth-child(4n){background:#ffe1ee;border-color:#dc8db3;box-shadow:0 5px 0 #dc8db3}.symbol{font-size:clamp(32px,7vw,52px)}.card.selected{outline:4px solid #3c6ca4;outline-offset:3px;transform:translateY(-2px)}.card.speaking{outline:5px solid #e6a80b;outline-offset:3px}.card.matched{background:#d8f4d9;border-color:#4caa79;box-shadow:0 5px 0 #94cc9f}.card .tick{position:absolute;top:4px;right:8px;color:#14633d;font-size:22px}.card .kg-art{width:74px;height:74px;display:block;background-repeat:no-repeat;flex-shrink:0;border-radius:12px;background-color:#fff}.card .kg-shape-art{width:70px;height:70px}.card .emoji{font-size:48px}.picture-name{font-size:17px}.objects{display:grid;grid-template-columns:repeat(5,1fr);gap:4px;max-width:100%;align-items:center;justify-content:center}.objects .kg-art{width:30px;height:30px;border-radius:5px}.objects .emoji{font-size:27px;line-height:30px}.objects .kg-shape-art{width:30px;height:30px}.objects .count-object{display:flex;align-items:center;justify-content:center;width:30px;height:34px}.count-caption{font-size:14px;font-weight:normal}.board svg#lines{position:absolute;inset:0;width:100%;height:100%;pointer-events:none;z-index:0;overflow:visible}.feedback{font-weight:bold;text-align:center;margin:10px 0 4px;color:#38695b}.garden{text-align:center;font-size:25px;letter-spacing:5px}.garden .bloom{display:inline-block;animation:bloom .6s ease-out}.primary{background:#16877b;color:white;border-color:#116f66;box-shadow:0 4px 0 #0c665d}.quiet{background:#fff;border-color:#c9dcd8}.complete{text-align:center;background:#fff9db;border:4px solid #e7c570;border-radius:28px;padding:35px 20px;margin-top:24px}.complete>div{font-size:45px}.complete button{margin:8px}footer{text-align:center;padding:6px 10px max(8px, env(safe-area-inset-bottom));font-size:13px;color:#61757d}[hidden]{display:none!important}@keyframes bloom{0%{transform:scale(.2) rotate(-30deg)}70%{transform:scale(1.25) rotate(8deg)}100%{transform:scale(1)}}@media(max-width:500px){main{padding:10px 10px 4px}.hero{padding:17px}.hero img{width:70px;height:90px}.eyebrow{font-size:10px;letter-spacing:1px}.board{gap:22px;padding:10px 8px 14px;grid-template-columns:minmax(0,.8fr) minmax(0,1.5fr)}.card{height:126px;padding:5px;border-radius:16px}.steps{gap:6px;font-size:14px}.objects{gap:2px}.objects .kg-art,.objects .count-object{width:25px;height:29px}.objects .emoji{font-size:24px}.settings{gap:8px}.progress{font-size:14px}.switch button{font-size:16px;padding:12px 8px}}@media(prefers-reduced-motion:reduce){*,*::before,*::after{animation:none!important;transition:none!important}}

#loadingPictures { min-height: 160px; text-align: center; padding: 2rem 1rem; color: #496a72; }
.card .kg-art-pair { display: flex; align-items: center; justify-content: center; gap: 4px; }
.card .kg-art-pair .kg-art { width: clamp(40px, 12vw, 66px); height: clamp(40px, 12vw, 66px); }

.board-celebration {
  position: fixed;
  width: min(420px, calc(100% - 32px));
  max-height: calc(100dvh - 36px);
  border: 4px solid #e8bc57;
  border-radius: 30px;
  padding: 24px 16px 28px;
  text-align: center;
  color: #254653;
  background: linear-gradient(145deg, #fff3bd, #fff9f1 55%, #e9ddff);
  box-shadow: 0 12px 44px #25345055;
}
.board-celebration::backdrop { background: #23394b88; }
.board-celebration.game-won { background: linear-gradient(140deg, #ffeb9f, #ffe1ed 54%, #e5d9ff); }
.board-celebration h2 { position: relative; font-size: clamp(25px, 7vw, 34px); line-height: 1.15; margin: 8px 0; }
.board-celebration p { position: relative; margin: 8px 0 18px; }
.board-celebration button { position: relative; }
.celebration-friends { position: relative; display: flex; align-items: center; justify-content: center; gap: 7px; }
.celebration-friends img { width: min(20vw, 86px); height: 100px; object-fit: contain; }
.celebration-friends span { font-size: clamp(46px, 16vw, 68px); animation: bloom .65s ease-out both; }
.matching-confetti { position: absolute; inset: 0; overflow: hidden; border-radius: inherit; pointer-events: none; }
.matching-confetti span {
  position: absolute;
  top: -12px;
  left: var(--x);
  width: 9px;
  height: 13px;
  border-radius: 3px;
  background: var(--color);
  animation: matching-confetti-drop 1.65s ease-out var(--delay) both;
}
.matching-confetti span:nth-child(2n) { height: 8px; border-radius: 50%; }
@keyframes matching-confetti-drop {
  0% { transform: translateY(-12px) rotate(0); opacity: 1; }
  75% { opacity: .9; }
  100% { transform: translate(var(--drift), 295px) rotate(350deg); opacity: 0; }
}

/* Headings receive programmatic focus when a board or the game ends. */
#question:focus,
#achievementTitle:focus {
  outline: none;
}
#complete {
  position: relative;
  isolation: isolate;
}
#complete .achievement-art {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(14px, 5vw, 36px);
  margin: 0 auto 20px;
  color: #9457bc;
  font-size: clamp(22px, 7vw, 42px);
}
#complete .achievement-medal {
  display: grid;
  place-items: center;
  width: 108px;
  aspect-ratio: 1;
  border: 5px solid #edaf3c;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 25%, #fffbd4, #ffd978 78%);
  box-shadow: 0 5px 0 #c97f32, 0 9px 20px #b76e342c;
  font-size: 54px;
  line-height: 1;
}
#complete .matching-confetti { z-index: 1; }
#complete .matching-confetti span { animation-name: achievement-confetti-drop; }
@keyframes achievement-confetti-drop {
  0% { transform: translateY(-12px) rotate(0); opacity: 1; }
  75% { opacity: .9; }
  100% { transform: translate(var(--drift), 360px) rotate(350deg); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  #complete .matching-confetti { display: none; }
}

.match-settings {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: end;
  gap: 8px;
  margin-bottom: 12px;
}
.match-settings .match-stage { min-width: 0; }
.match-settings .match-stage,
.match-settings .kg-lesson-picker > span {
  font-size: 14px;
  line-height: 1.35;
  margin-bottom: 4px;
}
.match-settings .match-stage { margin-bottom: 0; }
.match-settings .match-stage select,
.match-settings .kg-lesson-picker summary {
  min-height: 48px;
  margin-top: 4px;
  padding: 8px 11px;
  border-radius: 14px;
  font-size: 15px;
}
.match-settings .kg-lesson-picker summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 0;
}
.match-settings summary::-webkit-details-marker { display: none; }
.match-settings summary::after {
  content: '';
  width: 7px;
  height: 7px;
  flex-shrink: 0;
  border: solid currentColor;
  border-width: 0 2px 2px 0;
  transform: translateY(-2px) rotate(45deg);
}
.match-settings details[open] summary::after { transform: translateY(2px) rotate(225deg); }
.match-settings .kg-lesson-picker form {
  position: absolute;
  z-index: 5;
  inset: 100% 0 auto;
  box-shadow: 0 8px 18px #49267826;
}
.match-settings .lesson-options { gap: 6px; }
.match-settings .kg-lesson-picker .lesson-options label {
  padding: 6px 8px;
  border-radius: 10px;
  background: #f4ebff;
}
.match-settings .lesson-options input { flex-shrink: 0; }
.match-settings #restart {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 12px;
  border-radius: 14px;
  white-space: nowrap;
}
.match-settings #restart span:first-child { font-size: 22px; }
.question-controls {
  align-items: stretch;
  gap: 10px;
}
.question-controls .help {
  padding: 0 14px;
  color: #422365;
  border: 2px solid #8059a2;
  border-radius: 23px;
  background: linear-gradient(145deg, #fff6bf, #f6ddff);
  box-shadow: 0 4px 0 #8059a2;
}
.question-controls .help span { font-size: 22px; }
.question-controls .help:disabled { opacity: .45; }
.feedback:empty, .garden:empty { display: none; }
#next { display: block; margin: 8px auto 0; }

@media (max-width: 500px) {
  .match-settings #restart { width: 48px; padding: 0; }
  .match-settings .restart-label { display: none; }
  .board .cards { gap: 12px; }
}

.kg-game-fair .progress {
  align-items: center;
  flex-wrap: wrap;
  column-gap: 12px;
}
.board-star-total {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  padding: 2px 8px;
  border: 1px solid #dbac51;
  border-radius: 999px;
  background: #fff2ba;
  color: #553512;
  font-weight: 800;
}
.final-star-total {
  margin: 0 auto 12px;
  padding: 6px 14px;
}

.star-collection {
  margin: 10px 0 14px;
  border: 2px solid #e4c677;
  border-radius: 16px;
  background: #fff9e5;
  color: #553512;
}
.star-collection summary { cursor: pointer; padding: 8px 12px; font-weight: 800; }
.star-slots {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(42px, 1fr));
  gap: 6px;
  margin: 0;
  padding: 0 10px 10px;
}
.star-slots li {
  display: grid;
  justify-items: center;
  padding: 2px;
  border-radius: 10px;
  background: #fff;
  line-height: 1.2;
}
.star-slots li.earned { background: #fff0ac; }
.star-slots li span { font-size: 22px; }
.star-slots li small { font-size: 12px; }
