:root {
  color-scheme: dark;
  font-family: "Avenir Next", "Trebuchet MS", system-ui, sans-serif;
  --ground: #102726;
  --panel: #153633;
  --deep: #0e201f;
  --ink: #fff6df;
  --muted: #b6cbc0;
  --lime: #d6f576;
  --edge: #41625a;
  --mint: #a7eaea;
  --peach: #ffd5bc;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-width: 290px;
  min-height: 100vh;
  color: var(--ink);
  background: radial-gradient(ellipse at 56% 10%, #25453c 0, var(--ground) 54%, #0b1d1f 100%);
}
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
button:focus-visible, summary:focus-visible { outline: 3px solid #fff5d5; outline-offset: 4px; }
h1:focus, .feedback:focus { outline: none; }

.top {
  width: min(calc(100% - 64px), 1240px);
  min-height: 77px;
  margin: auto;
  display: flex;
  gap: 15px;
  align-items: center;
  justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 12px; font-size: 1.16rem; font-weight: 900; }
.mark, .map-pin {
  display: block;
  width: 26px;
  height: 28px;
  flex: none;
  background: conic-gradient(from 30deg, #68bdbb 0 33.3%, #37918a 0 66.6%, #adf8d2 0);
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
}
.module { font-size: .89rem; color: var(--muted); font-weight: 700; }
.game-header { justify-content: flex-start; }
.game-header .module { margin-left: auto; }
.collection {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border: 1px solid #4c7868;
  border-radius: 8px;
  background: #142e2b;
  color: #e5fad7;
  font-size: .85rem;
  font-weight: 850;
  white-space: nowrap;
}
.inventory { display: flex; gap: 4px; }
.crystal {
  width: 13px;
  height: 17px;
  clip-path: polygon(50% 0, 100% 32%, 86% 76%, 50% 100%, 14% 76%, 0 32%);
  background: #416452;
}
.crystal.filled { background: conic-gradient(from 35deg, #68cba1, #a0eb70, #eaff9a, #9de9b0, #68cba1); }
.crystal.new { animation: collect .48s ease-out both; }
@keyframes collect { 0% { transform: scale(.35) rotate(20deg); } 60% { transform: scale(1.35); } 100% { transform: scale(1); } }

.app { width: min(calc(100% - 64px), 1240px); margin: 0 auto 32px; }
.island {
  --scene-art: url("./assets/island.webp");
  position: relative;
  display: flex;
  align-items: center;
  min-height: min(660px, 79vh);
  padding: clamp(24px, 4.4vw, 62px);
  isolation: isolate;
  overflow: hidden;
  border: 1px solid #658276;
  border-radius: 25px;
  background: #244c43;
  box-shadow: 0 18px 55px #04121075;
}
.island[data-stage="camp"] { --scene-art: url("./assets/camp.webp"); }
.island[data-stage="workshop"] { --scene-art: url("./assets/workshop.webp"); }
.island[data-stage="cave"] { --scene-art: url("./assets/cave.webp"); }
.island[data-stage="bridge"] { --scene-art: url("./assets/bridge.webp"); }
.island[data-stage="waterfall"] { --scene-art: url("./assets/waterfall.webp"); }
.island[data-stage="portal"], .island[data-stage="finish"] { --scene-art: url("./assets/portal.webp"); }
.scene {
  position: absolute;
  inset: 0;
  overflow: hidden;
  z-index: -1;
}
.scene-picture {
  position: absolute;
  inset: 0;
  background-image: linear-gradient(90deg, #112b27 0%, #112b27da 24%, #16342b44 56%, #10272100 80%), var(--scene-art);
  background-size: cover;
  background-position: center 53%;
}
.scene-picture.travel { animation: travel .66s ease-out both; }
@keyframes travel {
  from { opacity: .45; transform: scale(1.035); }
  to { opacity: 1; transform: scale(1); }
}
.scene i {
  position: absolute;
  z-index: 1;
  width: 7px;
  height: 7px;
  background: #d7ff8b;
  box-shadow: 0 0 18px #d7ff8b;
  opacity: 0;
  animation: rise 5s infinite ease-in-out;
}
.scene i:nth-child(1) { left: 72%; bottom: 34%; }
.scene i:nth-child(2) { left: 87%; bottom: 55%; background: #eba5ff; animation-delay: 1.2s; }
.scene i:nth-child(3) { left: 62%; bottom: 30%; animation-delay: 2.6s; }
.scene i:nth-child(4) { left: 78%; bottom: 21%; width: 5px; height: 5px; animation-delay: 3.2s; }
.sparkle .scene i { animation: reward 1.4s both; }
.sparkle .scene i:nth-child(2) { animation-delay: .21s; }
.sparkle .scene i:nth-child(3) { animation-delay: .38s; }
.sparkle .scene i:nth-child(4) { animation-delay: .53s; }
@keyframes rise {
  0%, 100% { transform: translateY(38px) rotate(15deg); opacity: 0; }
  45% { opacity: .9; }
  80% { transform: translateY(-32px) rotate(105deg); opacity: 0; }
}
@keyframes reward {
  0% { transform: translateY(30px) scale(.5); opacity: 0; }
  28% { opacity: 1; }
  100% { transform: translateY(-112px) rotate(160deg) scale(2); opacity: 0; }
}
.landmark {
  position: absolute;
  bottom: 24px;
  right: 24px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 13px;
  border: 1px solid #afc8a084;
  border-radius: 8px;
  background: #132d2be8;
  font-weight: 800;
  font-size: .87rem;
}
.map-pin { width: 16px; height: 17px; }

.panel { width: min(100%, 510px); position: relative; }
.island[data-stage] .panel {
  padding: clamp(18px, 2.7vw, 34px);
  border: 1px solid #56796b;
  border-radius: 19px;
  background: #102824f5;
  box-shadow: 0 9px 30px #07140eb0;
}
.panel.enter { animation: appear .31s ease-out both; }
@keyframes appear { from { opacity: .45; transform: translateY(7px); } to { opacity: 1; transform: translateY(0); } }
.eyebrow {
  display: inline-block;
  margin: 0;
  color: var(--lime);
  font-size: .91rem;
  font-weight: 900;
  letter-spacing: .075em;
  text-transform: uppercase;
}
.panel h1, .dash-head h1 { margin: 13px 0 17px; line-height: .99; font-size: clamp(2.7rem, 6vw, 5.6rem); letter-spacing: -.065em; font-weight: 950; }
.panel h1 span { color: #bae66f; }
.intro { max-width: 350px; margin: 0 0 26px; font-size: 1.12rem; line-height: 1.5; color: #e7f0d8; }
.primary, .secondary {
  min-height: 49px;
  border-radius: 9px;
  padding: 10px 20px;
  font-weight: 900;
  transition: background .17s, transform .15s, box-shadow .15s;
}
.primary {
  border: 1px solid #e5feb0;
  background: var(--lime);
  color: #193318;
  box-shadow: 0 4px 0 #658643;
}
.primary:hover:not(:disabled) { background: #eeffab; transform: translateY(-2px); box-shadow: 0 6px 0 #658643; }
.primary:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 2px 0 #658643; }
.primary:disabled { color: #d0ddd0; background: #36534b; border-color: #537068; box-shadow: none; }
.secondary { border: 1px solid #78928a; background: #1e3b37; }
.secondary:hover:not(:disabled) { background: #305349; }
.subtle { margin: 15px 0 0; color: #d8e2cc; font-size: .86rem; }
.notice { color: var(--peach); margin-bottom: 0; }
.question-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.story { margin: 10px 0 0; font-size: .9rem; line-height: 1.4; color: var(--muted); }
.revisit-label { margin: 9px 0 0; color: var(--mint); font-size: .88rem; font-weight: 850; }
.progress { flex: none; color: var(--muted); font-weight: 800; font-size: .88rem; }
.panel .question-title { margin: 13px 0 16px; font-size: clamp(1.4rem, 2.65vw, 2rem); line-height: 1.14; letter-spacing: -.033em; }
.sentence { margin: 0 0 14px; color: #c9f4e7; font-size: clamp(1.07rem, 2.25vw, 1.26rem); font-weight: 800; }
.choices { display: grid; gap: 8px; margin: 0 0 17px; }
.option {
  min-height: 49px;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  padding: 7px 11px;
  border: 1px solid #65847b;
  border-radius: 9px;
  background: #1d3d36;
  font-size: 1rem;
  font-weight: 800;
  transition: background .15s, border .15s;
}
.option:hover:not(:disabled) { background: #315748; }
.option-key { display: grid; place-items: center; width: 29px; height: 29px; flex: none; background: #304f47; color: #e1eee3; border-radius: 5px; font-size: .85rem; }
.option[aria-pressed="true"] { border-color: #e4f5a0; background: #3d5940; }
.option.right { border-color: #cefa78; background: #325432; color: #eefbcf; }
.option.right .option-key { background: #c6ec80; color: #1f3d20; }
.option.wrong { border-color: #eeae8b; background: #534338; }
.feedback { display: grid; gap: 4px; margin-bottom: 15px; border-left: 3px solid var(--mint); padding-left: 10px; line-height: 1.36; font-size: .94rem; color: #e4eee2; }
.feedback.positive { border-color: var(--lime); }
.feedback.positive strong { color: var(--lime); }
.feedback.explained strong { color: var(--mint); }
.feedback.warning { border-color: var(--peach); }
.answer-correction { color: #d8fbac; font-weight: 800; }
.answer-highlight { padding: 1px 3px; border-radius: 4px; background: #d6f576; color: #193318; }
.choice-explanation, .example-pair { display: grid; gap: 3px; line-height: 1.4; }
.choice-explanation { margin-top: 9px; }
.example-pair { margin-top: 7px; padding: 8px 10px; border-radius: 7px; background: #25433d; }
.pair-label { color: var(--mint); font-weight: 850; }
.pair-english { color: #ecfac6; font-weight: 800; }

.panel .finish-title { font-size: clamp(2.08rem, 5vw, 3.6rem); }
.score { margin: 0; color: var(--lime); font-weight: 950; font-size: clamp(2rem, 4vw, 3.3rem); line-height: 1.12; }
.score-label { margin: 0 0 12px; color: #d9f6c2; }
.comparison { margin: 0 0 15px; padding: 9px 12px; background: #284640; border-radius: 8px; color: #e2f4da; line-height: 1.35; font-weight: 800; }
.finish-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.end-review { margin: 30px 0 48px; scroll-margin: 15px; }
.end-review h2 { font-size: clamp(1.6rem, 4vw, 2.4rem); margin: 0 0 13px; letter-spacing: -.04em; }
.end-review h2:focus { outline: none; }
.review-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.rule-card { background: #153631; border: 1px solid var(--edge); padding: clamp(15px, 2.9vw, 25px); border-radius: 14px; }
.rule-card h3 { margin: 8px 0 10px; font-size: 1.2rem; line-height: 1.23; }
.rule-card p { margin: 6px 0 11px; line-height: 1.45; }
.rule-card .chosen { color: var(--peach); }
.rule-card .review-label { display: block; margin: 12px 0 4px; color: var(--mint); font-weight: 850; font-size: .87rem; }
.rule-card .example { color: #ecfac6; font-size: 1.08rem; }

.route { margin-top: 16px; }
.route ol { padding: 0; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; list-style: none; margin: 0; }
.route li { display: flex; min-width: 0; border-radius: 10px; border: 1px solid #43665e; background: #142e2a; color: #cadbcf; }
.route-stop { display: flex; width: 100%; min-height: 56px; align-items: center; justify-content: center; gap: 7px; padding: 6px; font-size: .86rem; font-weight: 780; border: 0; border-radius: inherit; background: transparent; }
button.route-stop { box-shadow: inset 0 -2px #9dd58955; }
button.route-stop:hover { background: #ffffff16; }
button.route-stop:focus-visible { outline: 2px solid var(--mint); outline-offset: 2px; }
.checkpoint-icon { display: grid; place-items: center; width: 30px; height: 30px; flex: none; border-radius: 6px; background: #28483d; font-size: 1rem; }
.route li.earned { border-color: #90b855; background: #293f2a; color: #e8f9ca; }
.route li.earned .checkpoint-icon { color: var(--lime); background: #395637; }
.route li.visited { border-color: #74928a; }
.route li.current { border-color: var(--mint); box-shadow: 0 0 0 1px var(--mint); }
.route li.current:not(.earned):not(.visited) { background: #204a41; color: #e0fcf4; }
.route-help { margin: 9px 0 0; color: var(--muted); font-size: .84rem; }

.dashboard { width: min(calc(100% - 64px), 940px); margin: 30px auto 64px; }
.dash-head { display: flex; align-items: end; justify-content: space-between; gap: 17px; margin-bottom: 25px; }
.dash-head h1 { font-size: clamp(2.6rem, 5.5vw, 4.7rem); margin-bottom: 8px; }
.dash-head p { color: var(--muted); margin: 0; }
#parent-status { color: #e6e8cc; }
#parent-status:empty { display: none; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.stat { padding: 18px; display: grid; gap: 4px; background: #193631; border: 1px solid var(--edge); border-radius: 12px; }
.stat b { font-size: clamp(1.5rem, 3vw, 2.6rem); color: var(--lime); line-height: 1.1; }
.stat span, .history-help { color: var(--muted); }
.history-help { margin: 24px 0 12px; }
.attempts { display: grid; gap: 10px; }
.attempt { border: 1px solid var(--edge); border-radius: 12px; background: #15322e; }
.attempt summary { padding: 14px 16px; cursor: pointer; }
.attempt-date { font-weight: 900; margin: 0 8px; }
.badge { display: inline-block; border-radius: 5px; padding: 3px 8px; background: #31564e; font-size: .87rem; font-weight: 780; }
.badge.complete { background: #365738; color: #e0f6bc; }
.history-delta { margin-left: 7px; color: var(--mint); font-size: .89rem; font-weight: 800; }
.answer-row { padding: 12px 18px; border-top: 1px solid var(--edge); }
.answer-row h3 { margin: 0 0 6px; font-size: .98rem; color: #cfebd7; }
.answer-row.missed h3 { color: var(--peach); }
.answer-row p, .attempt-empty { margin: 5px 0; }
.attempt-empty { padding: 3px 18px 15px; }
.attempt-prompt, .answer-tip { color: var(--muted); }
#more { margin-top: 14px; }

@media (max-width: 850px) {
  .route-stop { flex-direction: column; gap: 3px; font-size: .78rem; }
  .landmark { display: none; }
}
@media (max-width: 650px) {
  .top, .app, .dashboard { width: calc(100% - 26px); }
  .top { min-height: 60px; }
  .game-header { flex-wrap: wrap; row-gap: 0; padding: 14px 0 10px; }
  .collection { width: 100%; justify-content: space-between; margin-top: 10px; }
  .brand { gap: 8px; font-size: 1rem; }
  .brand .mark { width: 22px; height: 24px; }
  .module { font-size: .73rem; }
  .island { align-items: flex-end; min-height: 560px; padding: 0; border-radius: 16px; }
  .scene-picture {
    background-image: linear-gradient(180deg, #0d272700 4%, #10282425 26%, #102824 59%), var(--scene-art);
    background-position: 64% top;
    background-size: 100% 100%, auto 72%;
    background-repeat: no-repeat;
  }
  .island[data-stage] .scene-picture {
    background-image: linear-gradient(180deg, #0d272700 0, #10282400 110px, #102824 214px), var(--scene-art);
    background-position: center top, 71% -32px;
    background-size: 100% 100%, 125% auto;
  }
  .island[data-stage] { min-height: 0; padding-top: clamp(160px, 45vw, 220px); }
  .island .panel, .island[data-stage] .panel { width: 100%; }
  .island .panel { padding: 22px 20px 28px; }
  .island[data-stage] .panel { padding: 18px 15px 23px; border: 0; border-top: 1px solid #7b9b7e; border-radius: 0; }
  .panel h1 { font-size: clamp(2.75rem, 12vw, 4.3rem); }
  .intro { font-size: 1rem; margin-bottom: 19px; }
  .route { margin-top: 10px; }
  .route ol { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .route li { border-radius: 7px; }
  .route-stop { min-height: 49px; padding: 4px 3px; flex-direction: row; font-size: .8rem; }
  .checkpoint-icon { width: 22px; height: 22px; font-size: .83rem; }
  .review-cards { grid-template-columns: 1fr; }
  .dashboard { margin-top: 15px; }
  .stats { gap: 5px; }
  .stat { padding: 10px; font-size: .84rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition: none !important; }
}
