@font-face{font-family:Aha;src:url("regular.woff2") format("woff2");font-weight:400;font-display:swap;unicode-range:U+0400-045F,U+0490-0491,U+2116}
@font-face{font-family:Aha;src:url("bold.woff2") format("woff2");font-weight:700;font-display:swap;unicode-range:U+0400-045F,U+0490-0491,U+2116}
@font-face{font-family:Aha;src:url("latin-bold.woff2") format("woff2");font-weight:700;font-display:swap;unicode-range:U+0000-03FF,U+2000-22FF}
:root{font-family:Aha,Arial,sans-serif;color:#261645;background:#fbf7f2;line-height:1.45;font-synthesis:none;--purple:#612caa;--ink:#261645;--muted:#625275;--border:#e3d8f1}
*{box-sizing:border-box}
[hidden]{display:none!important}
body{margin:0;min-width:280px}
button,a{-webkit-tap-highlight-color:transparent}
button{font:inherit;color:inherit;cursor:pointer}
h2[tabindex="-1"]:focus{outline:none}
button:focus-visible,a:focus-visible{outline:3px solid #2a7772;outline-offset:4px}
.sr-only{position:absolute;width:1px;height:1px;padding:0;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
.shell{width:min(1120px,calc(100% - 64px));margin:0 auto}
.top{height:86px;display:flex;align-items:center;justify-content:space-between}
.brand{display:flex;align-items:center;gap:9px;color:var(--ink);text-decoration:none;font-weight:700;letter-spacing:.07em;font-size:1.37rem}
.brandmark{display:grid;place-items:center;color:white;background:#6d33b8;font-size:1.1rem;border-radius:10px;width:31px;height:31px}
.reward{display:flex;gap:7px;justify-content:center;align-items:center;min-height:39px;min-width:60px;border:1px solid #f0d69e;border-radius:999px;background:#fff0cf;padding:4px 11px}
.reward span:first-child{color:#a76100;font-size:1.18rem}
.layout{display:grid;grid-template-columns:minmax(240px,.88fr) minmax(0,1.42fr);gap:18px;padding-bottom:32px}
.cover{position:relative;min-height:628px;display:flex;align-items:end;isolation:isolate;overflow:hidden;border-radius:29px;background:#b873c2;color:white}
.cover img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;z-index:-2}
.cover::after{content:"";position:absolute;inset:35% 0 0;background:linear-gradient(transparent,#211039ed);z-index:-1}
.cover-copy{padding:29px 32px 37px}
.cover .kicker{font-size:.86rem;font-weight:700;color:#fff0c5;margin:0 0 10px}
h1,h2,p{margin:0}
.cover h1{font-size:clamp(2.3rem,4.1vw,3.9rem);letter-spacing:-.065em;line-height:.97;margin-bottom:12px;font-weight:700}
.cover-copy>p:last-child{color:#fff4fd}
.game{border:1px solid #e7ddec;border-radius:29px;background:#fffefa;padding:34px clamp(22px,4.3vw,57px) 32px;box-shadow:0 18px 55px #51317e0c;min-width:0}
.track{display:grid;grid-template-columns:repeat(3,1fr);gap:7px;list-style:none;margin:0 0 26px;padding:0}
.track li{display:flex;align-items:center;gap:5px;color:#6f627d;font-size:.87rem;font-weight:700;white-space:nowrap;min-width:0;border-bottom:2px solid #ebdff4;padding:0 0 8px}
.track li span{display:grid;place-items:center;width:23px;height:23px;border-radius:50%;background:#f4ecf9;font-size:.78rem}
.track li[aria-current="step"]{color:#562399;border-color:#854ccc}
.track li[aria-current="step"] span{background:#672bb0;color:white}
.track li.done{color:#376954;border-color:#90c6ad}
.track li.done span{background:#e4f4e9;color:#246247}
.step-label{color:#6a389f;font-weight:700;font-size:.9rem;margin-bottom:4px}
h2{font-size:clamp(1.95rem,4vw,3.15rem);line-height:1.03;letter-spacing:-.06em;font-weight:700;margin-bottom:8px}
.instruction{color:var(--muted);min-height:24px}
.playarea{margin-top:21px}
.tray{background:radial-gradient(ellipse at 50% 0,#f7e6ff,#eee0fc 75%);border:1px solid #e8d7f5;border-radius:23px;padding:16px;display:flex;justify-content:center}
.bar{width:min(100%,400px);display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:6px;background:#50251b;padding:7px;border-radius:16px;box-shadow:0 6px 0 #351813,0 10px 16px #44203c3d;touch-action:none;user-select:none}
.tile{aspect-ratio:1.18;border:1px solid #a26344;border-radius:10px;position:relative;min-width:0;background:linear-gradient(145deg,#a66347,#733a29 55%,#4d2219);box-shadow:inset 0 3px 1px #ffceaa50,inset 0 -4px 2px #3a170d99;color:#fff;font-weight:700;font-size:1.15rem;transition:background .15s,border-color .15s,opacity .15s}
.tile::before{content:"";position:absolute;inset:17%;border:1px solid #dba68869;border-radius:7px;box-shadow:inset 0 2px 2px #4f221e78;pointer-events:none}
.tile:not(:disabled):hover{filter:brightness(1.12)}
.tile.picked,.tile.from-first{background:linear-gradient(145deg,#f8b970,#e68b4e 68%,#bf573e);border-color:#ffdc92;box-shadow:inset 0 3px 1px #fff3b760,inset 0 -4px 2px #9d462888;color:#542b1a}
.tile.picked::before,.tile.from-first::before{border-color:#fff2b4b0}
.tile.half{background:linear-gradient(145deg,#b6edd4,#50bba0 75%,#298775);border-color:#d0fff0;box-shadow:inset 0 3px 1px #ffffff60,inset 0 -4px 2px #2c786c90;color:#183e36}
.tile.half::before{border-color:#d0fff0a0}
.tile.faded{opacity:.44}
.underboard{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-top:8px;min-height:36px;color:var(--muted);font-weight:700;font-size:.92rem}
.text-button{background:none;border:0;color:#5e2ca2;text-decoration:underline;text-underline-offset:.18em;padding:6px 0;font-weight:700;font-size:.92rem;min-height:34px}
.text-button:disabled{visibility:hidden}
.feedback{font-size:.92rem;color:#8c3e28;font-weight:700;margin-top:4px}
.feedback:empty{display:none}
.hint-wrap{margin:2px 0 12px}
.hint-text{border-left:3px solid #d4b4f4;background:#f9f0fc;border-radius:4px 10px 10px 4px;padding:8px 10px;color:#533775;font-size:.92rem}
.primary{width:100%;min-height:53px;border:0;border-radius:14px;background:#672bb0;color:white;font-weight:700;font-size:1.06rem;box-shadow:0 4px 0 #471c83}
.primary:hover{background:#753bc1}
.primary:active{transform:translateY(2px);box-shadow:0 2px 0 #471c83}
.answer{border:0;margin:8px 0 0;padding:0}
.choices{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:8px}
.choice{display:grid;place-items:center;min-height:46px;border:1px solid #e0c9f1;border-radius:11px;background:#faf3ff;color:#532c86;font-weight:700;font-size:1.12rem}
.choice[aria-pressed="true"]{background:#642ca9;color:white;border-color:#642ca9}
.victory{text-align:center;margin:24px 0 25px;padding:19px 16px 22px;background:#f6eafc;border:1px solid #e9d9f7;border-radius:22px}
.medallion{margin:0 auto 10px;display:grid;place-items:center;width:65px;height:65px;border:1px solid #f0be66;border-radius:50%;background:#ffd987;color:#714200;font-size:2rem;box-shadow:0 4px 0 #e9a845}
.equation{font-size:2rem;font-weight:700;margin-bottom:5px}
.victory > p:not(.equation){max-width:350px;margin:auto;color:var(--muted)}
@media(max-width:800px){.shell{width:calc(100% - 36px)}.top{height:65px}.game{padding:24px}.cover-copy{padding:24px}.layout{grid-template-columns:minmax(190px,.73fr) minmax(0,1.27fr);gap:13px}}
@media(max-width:620px){.shell{width:calc(100% - 24px)}.top{height:58px;padding-inline:4px}.layout{grid-template-columns:1fr;gap:10px;padding-bottom:23px}.cover{border-radius:19px;min-height:108px;align-items:center}.cover img{object-position:65% 54%}.cover::after{inset:0;background:linear-gradient(90deg,#241133ed 0%,#291339aa 57%,#29133900 100%)}.cover-copy{padding:13px 17px}.cover h1{font-size:1.75rem;margin-bottom:5px;letter-spacing:-.048em}.cover .kicker{margin-bottom:4px}.cover-copy>p:last-child{font-size:.88rem}.game{padding:19px max(13px,4vw) 22px;border-radius:19px}.track{margin-bottom:15px;gap:6px}.track li{font-size:.79rem}.track li span{width:20px;height:20px}.step-label{font-size:.84rem}.playarea{margin-top:12px}.tray{padding:12px 11px;border-radius:17px}.bar{gap:5px;padding:5px}.tile{aspect-ratio:1.34;border-radius:8px}.underboard{margin-top:5px}.hint-wrap{margin-bottom:9px}.primary{min-height:49px}.victory{margin:15px 0 17px}}
@media(prefers-reduced-motion:reduce){*{transition:none!important}}
.top-actions{display:flex;align-items:center;gap:9px}
.sound-toggle{min-height:39px;padding:5px 10px;border:1px solid #e3d8f1;border-radius:999px;background:#fffefa;color:#592c86;font-weight:700;font-size:.88rem;white-space:nowrap}
.sound-toggle[aria-pressed="false"]{color:#625275;background:#eee9f2}
@media(max-width:360px){.top-actions{gap:5px}.sound-toggle{padding-inline:8px}.reward{min-width:54px;padding-inline:8px}}
.order-slip{display:flex;justify-content:space-between;align-items:center;gap:10px;background:#f7eefb;border:1px solid #e9d9f4;border-radius:14px;padding:10px 13px;margin-bottom:16px}
.order-slip #order-copy{font-weight:700;line-height:1.25}
.order-math{flex-shrink:0;color:#612caa;font-size:1.28rem;font-weight:700;white-space:nowrap}
.tile,.column-cell{aspect-ratio:1.48}
.tile.column{display:grid;gap:6px;padding:0;background:none;border:0;box-shadow:none;border-radius:9px;aspect-ratio:auto}
.tile.column::before,.tile.empty::before{display:none}
.column-cell{display:grid;place-items:center;position:relative;border:1px solid #a26344;border-radius:9px;background:linear-gradient(145deg,#a66347,#733a29 55%,#4d2219);box-shadow:inset 0 3px 1px #ffceaa50,inset 0 -4px 2px #3a170d99;pointer-events:none}
.column-cell::after{content:"";position:absolute;inset:17%;border:1px solid #dba68869;border-radius:6px;box-shadow:inset 0 2px 2px #4f221e78}
.picked .column-cell{background:linear-gradient(145deg,#f8b970,#e68b4e 68%,#bf573e);border-color:#ffdc92;box-shadow:inset 0 3px 1px #fff3b760,inset 0 -4px 2px #9d462888}
.picked .column-cell::after{border-color:#fff2b4b0}
.tile.empty{opacity:1;border:1px dashed #ca8d72;background:#452016;box-shadow:none}
.tile.faded:not(.empty){opacity:.53}
.box{border:2px dashed #af89c7;border-radius:15px;background:#fbf2ff;min-height:100px;padding:8px 10px;margin-top:11px}
.box-heading{display:flex;align-items:center;justify-content:space-between;gap:9px;color:#5e347c;font-size:.9rem}
.box-pieces{display:flex;align-items:center;flex-wrap:wrap;gap:5px;min-height:48px;padding-top:5px;touch-action:none}
.box-empty{color:#625275;font-size:.92rem}
.box-tile{min-width:44px;min-height:44px;font-size:.95rem}
.box.drop-ready,.tray.drop-ready{outline:2px solid #2c8873;background:#e1f6ed}
.drag-ghost{width:45px;height:39px;position:fixed;z-index:2;pointer-events:none;transform:translate(-50%,-50%);opacity:.92}
@media(max-width:620px){
  .order-slip{padding:8px 10px;margin-bottom:11px}
  .order-slip #order-copy{font-size:.93rem}
  .order-math{font-size:1.1rem}
  .tile.column{gap:5px}
  .tile,.column-cell{aspect-ratio:1.42}
  .box-tile{min-width:44px;min-height:44px}
}

.lesson-nav{display:flex;flex-wrap:wrap;gap:7px;margin:0 0 12px}
.lesson-nav a{padding:8px 13px;border:1px solid var(--border);border-radius:999px;color:#562399;background:#fffefa;text-decoration:none;font-weight:700;font-size:.88rem}
.lesson-nav a:hover{text-decoration:underline}
.lesson-nav a[aria-current="page"]{background:#672bb0;color:white;border-color:#672bb0}
.music-toggle{display:block;margin:14px auto 0}

.star-dialog {
  box-sizing: border-box;
  width: min(360px, calc(100% - 32px));
  max-height: calc(100% - 32px);
  border: 2px solid #f0c571;
  border-radius: 28px;
  padding: 26px;
  text-align: center;
  color: #301b46;
  background: radial-gradient(ellipse at top, #ffedbf, #fff9ee 65%);
  box-shadow: 0 18px 60px #21103955;
}
.star-dialog::backdrop { background: #211039b8; }
.star-dialog .medallion { width: 84px; height: 84px; font-size: 2.7rem; }
.star-dialog h2 { margin: 12px 0 6px; }
.star-dialog p { margin: 0 0 8px; }
.star-dialog #star-balance { font-weight: 700; }
.star-dialog form { margin-top: 18px; }
@media (prefers-reduced-motion: no-preference) {
  .star-dialog[open] { animation: star-arrive .25s ease-out both; }
  @keyframes star-arrive {
    from { transform: translateY(12px) scale(.92); opacity: 0; }
    to { transform: none; opacity: 1; }
  }
}

.harbor-lesson, .picnic-lesson { background: var(--scene-canvas); }
.harbor-lesson .game, .picnic-lesson .game {
  background: var(--scene-paper);
  border-color: var(--scene-border);
  box-shadow: 0 10px 0 -6px var(--scene-border);
}
.harbor-lesson .primary, .picnic-lesson .primary {
  background: var(--scene-action);
  color: var(--scene-action-ink);
  box-shadow: 0 4px 0 var(--scene-action-shadow);
}
.harbor-lesson .primary:hover, .picnic-lesson .primary:hover {
  filter: brightness(.96);
}
:is(.harbor-lesson, .picnic-lesson) .hint-wrap summary {
  display: list-item;
  padding-block: 10px;
  min-height: 44px;
  width: fit-content;
  cursor: pointer;
}
:is(.harbor-lesson, .picnic-lesson) .hint-text { background: var(--scene-note); }

.activity-scene {
  display: grid;
  grid-template-columns: minmax(68px, 1fr) minmax(0, 2.5fr);
  align-items: center;
  gap: 8px;
  overflow: hidden;
  border-radius: 18px;
  padding: 8px;
}
.harbor-lesson .activity-scene {
  margin: 12px 0;
  background: linear-gradient(#cbece9, #94c8c1 75%, #e9c28d 75%);
}
.activity-character {
  width: 100%;
  height: clamp(108px, 30vw, 192px);
  object-fit: cover;
  object-position: center 26%;
  border-radius: 12px;
}
.activity-scene .flag-board { margin: 0; }
.activity-scene .lawn-diagram { --cell: clamp(20px, 6vw, 42px); }
.character-line {
  grid-column: 1 / -1;
  margin: 0;
  padding: 8px 10px;
  border-radius: 10px;
  background: #fff7e6;
  color: #3e3128;
  font-size: .9rem;
}
.speech-bubble {
  position: relative;
  margin-top: 6px;
  border: 1px solid var(--speech-border, #d5b98c);
  border-radius: 14px;
  background: #fffdf2;
}
.speech-bubble::before {
  content: "";
  position: absolute;
  top: -7px;
  left: 24px;
  width: 12px;
  height: 12px;
  border-top: inherit;
  border-left: inherit;
  background: inherit;
  transform: rotate(45deg);
}
@media (max-width: 360px) {
  .activity-scene .flag-board { padding: 6px; }
  .activity-scene .flag-line { gap: 4px; }
  .activity-scene .lawn-diagram { --cell: 18px; gap: 4px; font-size: .84rem; }
}
@media (prefers-reduced-motion: no-preference) {
  .scene-placed { animation: scene-place .36s ease-out both; }
  @keyframes scene-place {
    from { transform: translate(-22px, -8px) rotate(-7deg); opacity: .5; }
    to { transform: none; opacity: 1; }
  }
}

.games-link {
  display: grid;
  place-items: center;
  text-decoration: none;
}
.games-link:not([hidden]) + .primary {
  margin-top: 14px;
  background: #f2edf6;
  color: #4b3364;
  box-shadow: none;
  border: 1px solid var(--border);
}
.flag-overflow {
  grid-column: 1 / -1;
  margin: 0;
  border: 1px dashed #a55b3d;
  border-radius: 10px;
  padding: 6px 10px;
  background: #fff2de;
  color: #743d28;
}
.tile.packed-group .column-cell {
  background: #236b59;
  color: white;
  border-color: #7ed8b6;
  box-shadow: none;
}

/* Keep controls clear of system and Telegram insets. */
body {
  padding-inline-start: max(env(safe-area-inset-left), var(--tg-safe-area-inset-left, 0px), var(--tg-content-safe-area-inset-left, 0px));
  padding-inline-end: max(env(safe-area-inset-right), var(--tg-safe-area-inset-right, 0px), var(--tg-content-safe-area-inset-right, 0px));
  padding-top: max(env(safe-area-inset-top), var(--tg-safe-area-inset-top, 0px), var(--tg-content-safe-area-inset-top, 0px));
  padding-bottom: max(env(safe-area-inset-bottom), var(--tg-safe-area-inset-bottom, 0px), var(--tg-content-safe-area-inset-bottom, 0px));
}
