:root {
  --sea-1: #e9fbff;
  --sea-2: #bdeffc;
  --sea-3: #6fd0ee;
  --sea-4: #1aa3d6;
  --deep: #0b5c8c;
  --ink: #12324a;
  --ink-soft: #3f5f75;
  --coral: #ff6f61;
  --coral-d: #e0483b;
  --sun: #ffc93c;
  --sun-d: #f0a500;
  --kelp: #2bb673;
  --kelp-d: #1b8f57;
  --lilac: #8c6cf0;
  --white: #ffffff;
  --card: rgba(255, 255, 255, 0.94);
  --shadow: 0 6px 0 rgba(11, 92, 140, 0.18), 0 12px 28px rgba(11, 92, 140, 0.18);
  --radius: 22px;
  --font: ui-rounded, "SF Pro Rounded", "Arial Rounded MT Bold", "Nunito", "Varela Round", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-read: "Andika", "Comic Neue", ui-rounded, "Arial Rounded MT Bold", system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(180deg, #c9f3ff 0%, #8fdcf3 55%, #5cc2e6 100%) fixed;
  -webkit-user-select: none; user-select: none;
  overflow-x: hidden;
}
body::before {
  content: ""; position: fixed; inset: 0; z-index: -2;
  background: url("img/bg_reef.jpg") center bottom / cover no-repeat;
  opacity: 0.55;
}
body::after {
  content: ""; position: fixed; inset: 0; z-index: -1;
  background: radial-gradient(ellipse at 50% -10%, rgba(255,255,255,0.85), rgba(255,255,255,0) 60%);
  pointer-events: none;
}
button { font-family: inherit; color: inherit; cursor: pointer; border: 0; }
img { max-width: 100%; display: block; }
#app { max-width: 980px; margin: 0 auto; padding: max(14px, env(safe-area-inset-top)) 14px 90px; position: relative; z-index: 1; }

/* rising bubbles */
#bubbles { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
#bubbles span {
  position: absolute; bottom: -40px; border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.95), rgba(255,255,255,0.25) 45%, rgba(255,255,255,0.08) 70%);
  border: 1px solid rgba(255,255,255,0.7);
  animation: rise linear infinite;
}
@keyframes rise {
  0% { transform: translate(0, 0); opacity: 0; }
  10% { opacity: 0.9; }
  50% { transform: translate(18px, -55vh); }
  100% { transform: translate(-12px, -112vh); opacity: 0; }
}
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 50; width: 100%; height: 100%; }

/* top bar */
.topbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.topbar .grow { flex: 1; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 999px;
  background: var(--card); box-shadow: var(--shadow); font-weight: 800; font-size: 16px; white-space: nowrap;
}
.iconbtn {
  width: 46px; height: 46px; border-radius: 50%; background: var(--card); box-shadow: var(--shadow);
  font-size: 22px; display: inline-flex; align-items: center; justify-content: center; transition: transform .12s;
}
.iconbtn.off { opacity: 0.45; }
.iconbtn:active, .btn:active, .opt:active, .station:active, .key:active { transform: translateY(3px) scale(0.98); }
.backbtn { padding: 10px 16px; border-radius: 999px; background: var(--card); box-shadow: var(--shadow); font-weight: 800; font-size: 17px; }

/* hero */
.hero { text-align: center; padding: 10px 6px 6px; }
.hero h1 {
  font-size: clamp(34px, 7vw, 62px); margin: 4px 0; line-height: 1.02; letter-spacing: 0.5px;
  color: #fff; -webkit-text-stroke: 2px var(--deep); paint-order: stroke fill;
  text-shadow: 0 5px 0 var(--deep), 0 10px 24px rgba(11,92,140,.35);
}
.hero .sub { font-size: clamp(17px, 3vw, 22px); font-weight: 800; color: var(--deep); background: rgba(255,255,255,.75); display: inline-block; padding: 6px 14px; border-radius: 999px; }
.countdown { margin-top: 10px; display: inline-flex; gap: 8px; align-items: center; background: var(--sun); color: #5a3d00; font-weight: 900; padding: 8px 16px; border-radius: 999px; box-shadow: 0 5px 0 var(--sun-d); }

.splash { min-height: 82vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; text-align: center; }
.splash .fishline { font-size: 46px; animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 0%,100% { transform: translateY(0) } 50% { transform: translateY(-10px) } }
.bigbtn {
  font-size: clamp(24px, 4.5vw, 34px); font-weight: 900; color: #fff; padding: 18px 34px; border-radius: 999px;
  background: linear-gradient(180deg, #ff8a7d, var(--coral)); box-shadow: 0 8px 0 var(--coral-d), 0 16px 30px rgba(224,72,59,.35);
  animation: pulse 1.8s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { transform: scale(1) } 50% { transform: scale(1.05) } }

/* station map */
.map { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; margin-top: 14px; }
.station {
  position: relative; text-align: left; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden; padding: 0; display: flex; flex-direction: column; transition: transform .15s;
}
.station .ph { height: 120px; background-size: cover; background-position: center; position: relative; }
.station .num {
  position: absolute; top: 10px; left: 10px; width: 38px; height: 38px; border-radius: 50%; background: #fff; color: var(--deep);
  font-weight: 900; font-size: 20px; display: flex; align-items: center; justify-content: center; box-shadow: 0 3px 0 rgba(0,0,0,.15);
}
.station .emo { position: absolute; right: 10px; bottom: -22px; font-size: 40px; filter: drop-shadow(0 3px 2px rgba(0,0,0,.25)); }
.station .body { padding: 12px 14px 14px; }
.station h3 { margin: 0 0 3px; font-size: 21px; line-height: 1.1; }
.station p { margin: 0; color: var(--ink-soft); font-weight: 700; font-size: 15px; }
.station .stars { margin-top: 8px; font-size: 22px; letter-spacing: 2px; }
.station.bonus { outline: 4px dashed var(--sun); }
.station.test { outline: 4px solid var(--coral); }
.station.locked { filter: grayscale(0.8); opacity: 0.75; }
.station .tag { position: absolute; top: 10px; right: 10px; background: var(--sun); color: #5a3d00; font-weight: 900; font-size: 13px; padding: 4px 10px; border-radius: 999px; }
.mapfoot { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 18px; }

/* panels */
.panel { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 14px; }
.panel h2 { margin: 0 0 8px; font-size: 28px; }
.mascot { display: flex; gap: 12px; align-items: flex-start; }
.mascot .fish { font-size: 46px; animation: bob 2.6s ease-in-out infinite; flex: none; }
.mascot .bubble { background: #fff; border-radius: 18px; padding: 12px 14px; font-weight: 800; font-size: 19px; box-shadow: 0 3px 0 rgba(11,92,140,.15); position: relative; flex: 1; }
.say { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 50%; background: var(--sea-2); font-size: 20px; vertical-align: middle; margin-left: 6px; flex: none; }

.btnrow { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 14px; }
.btn {
  font-size: 21px; font-weight: 900; padding: 14px 22px; border-radius: 18px; color: #fff; min-height: 56px;
  background: linear-gradient(180deg, #34c3f5, var(--sea-4)); box-shadow: 0 6px 0 var(--deep); transition: transform .1s;
}
.btn.green { background: linear-gradient(180deg, #4fd690, var(--kelp)); box-shadow: 0 6px 0 var(--kelp-d); }
.btn.coral { background: linear-gradient(180deg, #ff8a7d, var(--coral)); box-shadow: 0 6px 0 var(--coral-d); }
.btn.sun { background: linear-gradient(180deg, #ffd866, var(--sun)); box-shadow: 0 6px 0 var(--sun-d); color: #5a3d00; }
.btn.ghost { background: #fff; color: var(--deep); box-shadow: 0 6px 0 #b9dcea; }
.btn[disabled] { opacity: .45; pointer-events: none; }

/* learn cards */
.learn { position: relative; }
.learn .pic { border-radius: 18px; overflow: hidden; margin-bottom: 12px; max-height: 360px; }
.learn .pic img { width: 100%; height: 100%; object-fit: cover; max-height: 360px; }
.learn h2 { font-size: 30px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.learn .text { font-size: 22px; font-weight: 700; line-height: 1.45; }
.wordchips { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.wordchip { font-family: var(--font-read); font-size: 26px; font-weight: 800; padding: 10px 16px; border-radius: 14px; background: #fff7d6; box-shadow: 0 4px 0 #f0d77a; }
.wordchip .team { color: var(--coral-d); text-decoration: underline; text-decoration-thickness: 3px; text-underline-offset: 5px; }
.example { margin-top: 10px; padding: 12px 14px; background: var(--sea-1); border-radius: 14px; font-family: var(--font-read); font-size: 22px; font-weight: 700; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.example b { color: var(--coral-d); }
.dots { display: flex; gap: 6px; justify-content: center; margin-top: 12px; flex-wrap: wrap; }
.dots i { width: 12px; height: 12px; border-radius: 50%; background: #cfe9f3; display: block; }
.dots i.on { background: var(--sea-4); transform: scale(1.25); }

/* reader */
.reader .pic { border-radius: 18px; overflow: hidden; position: relative; }
.reader .pic img { width: 100%; max-height: 46vh; object-fit: cover; }
.reader .pageno { position: absolute; top: 10px; right: 10px; background: rgba(255,255,255,.9); border-radius: 999px; padding: 4px 12px; font-weight: 900; }
.readtext { font-family: var(--font-read); font-size: clamp(26px, 4.2vw, 36px); line-height: 1.7; font-weight: 700; margin: 14px 4px 4px; }
.readtext .w { padding: 2px 3px; border-radius: 8px; transition: background .12s, color .12s; cursor: pointer; }
.readtext .w.hl { background: var(--sun); }
.readtext .w.heard { color: var(--kelp-d); background: #dcf8e9; }
.micbar { display: flex; align-items: center; gap: 10px; justify-content: center; font-weight: 800; margin-top: 8px; min-height: 30px; }
.micbar .meter { width: 160px; height: 14px; border-radius: 999px; background: #e3f1f6; overflow: hidden; }
.micbar .meter b { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--kelp), #8be0b5); transition: width .2s; }
.recording { animation: pulse 1s ease-in-out infinite; }

/* quiz */
.qtop { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.progress { flex: 1; height: 18px; background: rgba(255,255,255,.8); border-radius: 999px; overflow: hidden; box-shadow: inset 0 2px 0 rgba(0,0,0,.06); }
.progress b { display: block; height: 100%; background: linear-gradient(90deg, var(--sun), var(--coral)); border-radius: 999px; transition: width .3s; }
.modetag { font-weight: 900; padding: 6px 12px; border-radius: 999px; background: var(--coral); color: #fff; font-size: 14px; }
.modetag.practice { background: var(--kelp); }
.q { position: relative; }
.q .prompt { font-size: clamp(22px, 3.6vw, 28px); font-weight: 900; line-height: 1.3; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.q .qimg { border-radius: 16px; overflow: hidden; margin: 10px 0; max-height: 300px; }
.q .qimg img { width: 100%; max-height: 300px; object-fit: cover; }
.passagebox { background: #fffdf3; border: 3px solid #f6e7a8; border-radius: 16px; padding: 12px 14px; margin: 10px 0; }
.passagebox h4 { margin: 0 0 6px; font-size: 22px; display: flex; align-items: center; gap: 6px; }
.passagebox .ps { font-family: var(--font-read); font-size: 22px; line-height: 1.6; font-weight: 700; }
.passagebox .ps .s { border-radius: 8px; padding: 1px 2px; }
.passagebox.pick .ps .s { cursor: pointer; background: #fff; box-shadow: inset 0 -3px 0 #f0d77a; margin-right: 4px; }
.passagebox .ps .s.sel { background: var(--sun); }
.passagebox .ps .s.good { background: #c9f5dc; }
.passagebox .ps .s.bad { background: #ffd6d1; }
.passagebox .thumb { float: right; width: 120px; height: 84px; object-fit: cover; border-radius: 12px; margin: 0 0 6px 10px; }
.sentence { font-family: var(--font-read); font-size: clamp(24px, 4vw, 32px); font-weight: 700; margin: 14px 0; line-height: 1.5; text-align: center; }
.blank { display: inline-block; min-width: 90px; border-bottom: 5px solid var(--sea-4); margin: 0 6px; color: var(--sea-4); }
.options { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-top: 14px; }
.options.words .opt { font-family: var(--font-read); font-size: 28px; }
.opt {
  min-height: 64px; padding: 12px 14px; border-radius: 18px; background: #fff; box-shadow: 0 6px 0 #b9dcea; font-size: 21px; font-weight: 800;
  text-align: center; line-height: 1.25; border: 3px solid transparent; transition: transform .1s, background .15s;
}
.opt.sel { border-color: var(--sea-4); background: #e3f6fd; }
.opt.good { background: #c9f5dc; border-color: var(--kelp); box-shadow: 0 6px 0 var(--kelp-d); }
.opt.bad { background: #ffd6d1; border-color: var(--coral); box-shadow: 0 6px 0 var(--coral-d); }
.opt.locked { pointer-events: none; }
.bigsay { display: flex; justify-content: center; margin: 10px 0; }
.bigsay button { font-size: 22px; font-weight: 900; padding: 14px 22px; border-radius: 999px; background: var(--sun); color: #5a3d00; box-shadow: 0 6px 0 var(--sun-d); }
.gapword { font-family: var(--font-read); font-size: 54px; font-weight: 800; text-align: center; letter-spacing: 3px; margin: 10px 0; }
.gapword .gap { display: inline-block; min-width: 70px; border-bottom: 6px solid var(--coral); color: var(--coral-d); }
.typed { font-family: var(--font-read); font-size: 46px; font-weight: 800; text-align: center; min-height: 72px; background: #fff; border-radius: 16px; border: 3px dashed var(--sea-3); margin: 12px auto; max-width: 420px; padding: 4px 10px; letter-spacing: 4px; }
.typed .caret { display: inline-block; width: 3px; height: 44px; background: var(--sea-4); vertical-align: middle; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0 } }
.keyboard { display: flex; flex-direction: column; gap: 8px; align-items: center; margin-top: 8px; }
.keyboard .row { display: flex; gap: 6px; }
.key { width: clamp(30px, 8.4vw, 56px); height: 56px; border-radius: 12px; background: #fff; box-shadow: 0 4px 0 #b9dcea; font-size: 24px; font-weight: 800; font-family: var(--font-read); }
.key.wide { width: auto; padding: 0 16px; font-size: 18px; }
.tiles { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin: 12px 0; min-height: 66px; }
.tile { min-width: 56px; height: 62px; padding: 0 14px; border-radius: 14px; background: #fff7d6; box-shadow: 0 5px 0 #f0d77a; font-family: var(--font-read); font-size: 28px; font-weight: 800; }
.tile.used { visibility: hidden; }
.answerline { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; min-height: 76px; padding: 8px; border-radius: 16px; background: var(--sea-1); border: 3px dashed var(--sea-3); }
.answerline .tile { background: #fff; box-shadow: 0 5px 0 #b9dcea; }
.capsline { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin: 14px 0; }
.capsline .tok { font-family: var(--font-read); font-size: 30px; font-weight: 800; padding: 8px 12px; border-radius: 12px; background: #fff; box-shadow: 0 4px 0 #b9dcea; border: 3px solid transparent; }
.capsline .tok.on { border-color: var(--lilac); background: #f1ebff; }
.capsline .tok.good { background: #c9f5dc; }
.capsline .tok.bad { background: #ffd6d1; }
.capsline .tok .first { color: var(--lilac); }
.punctopts .opt { font-size: 24px; }
.punctopts .opt .mark { font-size: 46px; display: block; line-height: 1; font-family: var(--font-read); }
.buckets { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-top: 12px; }
.bucket { min-height: 120px; border-radius: 18px; background: #fff; border: 3px dashed var(--sea-3); padding: 8px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.bucket .lab { font-family: var(--font-read); font-weight: 900; font-size: 26px; color: var(--deep); background: var(--sea-2); border-radius: 999px; padding: 2px 14px; }
.bucket.target { border-color: var(--sun-d); background: #fffbe8; }
.bucket .tile { min-width: 0; height: 46px; font-size: 22px; padding: 0 10px; }
.bucket .tile.good { background: #c9f5dc; box-shadow: 0 4px 0 var(--kelp-d); }
.bucket .tile.bad { background: #ffd6d1; box-shadow: 0 4px 0 var(--coral-d); }
.tile.sel { outline: 4px solid var(--sea-4); }
.steplabel { font-weight: 900; color: var(--lilac); margin-top: 12px; font-size: 18px; }
.orgbox { border: 3px solid var(--sea-3); border-radius: 16px; padding: 10px; background: #f4fcff; margin-top: 10px; }
.orgbox .head { font-weight: 900; color: var(--sea-4); text-align: center; font-size: 20px; }
.checkrow { display: flex; justify-content: center; margin-top: 16px; gap: 10px; flex-wrap: wrap; }
.stuck { position: absolute; top: -6px; right: -4px; font-size: 15px; font-weight: 900; padding: 8px 12px; border-radius: 999px; background: #f1ebff; color: #6b3fa0; box-shadow: 0 4px 0 #d5c6fb; }
.hintbox { margin-top: 10px; background: #f1ebff; border-radius: 14px; padding: 10px 14px; font-weight: 800; font-size: 19px; color: #4b2b85; display: flex; gap: 8px; align-items: center; }
.feedback { margin-top: 14px; border-radius: 18px; padding: 14px 16px; font-size: 20px; font-weight: 800; animation: pop .25s ease-out; }
.feedback.good { background: #dcf8e9; border: 3px solid var(--kelp); }
.feedback.bad { background: #fff0ee; border: 3px solid var(--coral); }
.feedback.neutral { background: #eef7fb; border: 3px solid var(--sea-3); }
.feedback .big { font-size: 28px; font-weight: 900; display: flex; align-items: center; gap: 8px; }
.feedback .ans { margin-top: 6px; font-family: var(--font-read); font-size: 24px; }
.feedback .why { margin-top: 6px; color: var(--ink-soft); line-height: 1.4; display: flex; gap: 6px; align-items: flex-start; }
@keyframes pop { from { transform: scale(.92); opacity: 0 } to { transform: scale(1); opacity: 1 } }
.shake { animation: shake .4s; }
@keyframes shake { 20%,60% { transform: translateX(-8px) } 40%,80% { transform: translateX(8px) } }

/* results */
.results { text-align: center; }
.results .bigstars { font-size: 64px; letter-spacing: 6px; margin: 6px 0; }
.results .score { font-size: 44px; font-weight: 900; color: var(--deep); }
.sticker { margin: 12px auto; max-width: 360px; border-radius: 18px; overflow: hidden; border: 6px solid #fff; box-shadow: var(--shadow); transform: rotate(-3deg); animation: pop .5s; }
.breakdown { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 12px 0; }
.breakdown div { background: var(--sea-1); border-radius: 14px; padding: 10px; font-weight: 900; font-size: 18px; }
.review { text-align: left; margin-top: 12px; }
.review .ri { border-radius: 14px; padding: 10px 12px; margin-bottom: 8px; background: #fff; border-left: 8px solid var(--kelp); }
.review .ri.bad { border-left-color: var(--coral); }
.review .ri .p { font-weight: 900; }
.review .ri .a { font-family: var(--font-read); font-size: 19px; margin-top: 4px; }
.review .ri .e { color: var(--ink-soft); margin-top: 4px; font-weight: 700; }

/* stickers */
.stickergrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.stk { background: #fff; border-radius: 16px; padding: 8px; box-shadow: var(--shadow); text-align: center; font-weight: 900; }
.stk img { border-radius: 10px; height: 110px; width: 100%; object-fit: cover; }
.stk.missing img { filter: grayscale(1) blur(6px); opacity: .5; }

/* parents */
.parents table { width: 100%; border-collapse: collapse; font-size: 16px; }
.parents th, .parents td { text-align: left; padding: 6px 8px; border-bottom: 1px solid #e2eef3; vertical-align: top; }
.bar { height: 14px; background: #e3f1f6; border-radius: 999px; overflow: hidden; min-width: 100px; }
.bar b { display: block; height: 100%; background: var(--kelp); }
.bar b.mid { background: var(--sun-d); }
.bar b.low { background: var(--coral); }
.parents pre { white-space: pre-wrap; background: #f4f8fa; padding: 10px; border-radius: 12px; font-size: 13px; max-height: 260px; overflow: auto; -webkit-user-select: text; user-select: text; }
.parents .small { font-size: 14px; color: var(--ink-soft); }
.gate input { font-size: 28px; width: 120px; padding: 8px; border-radius: 12px; border: 3px solid var(--sea-3); text-align: center; font-family: inherit; }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(120px); background: var(--deep); color: #fff; font-weight: 900; padding: 12px 20px; border-radius: 999px; transition: transform .3s; z-index: 60; font-size: 18px; }
#toast.show { transform: translateX(-50%) translateY(0); }

.xpfloat { position: fixed; font-weight: 900; font-size: 26px; color: var(--sun-d); pointer-events: none; z-index: 55; animation: floatup 1s ease-out forwards; text-shadow: 0 2px 0 #fff; }
@keyframes floatup { to { transform: translateY(-80px); opacity: 0 } }

@media (max-width: 520px) {
  .station .ph { height: 100px; }
  .options { grid-template-columns: 1fr 1fr; }
  .readtext { line-height: 1.6; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
