/* ZHA Learning Quest — student app styles.
   Palette: Gulf sea + desert sand. School brand colours (--brand, --brand-2, --brand-3, --paper)
   are injected at runtime from the admin Branding settings. */
:root {
  --ink: #1B2A4A;
  --ink-2: #44546F;
  --sea: #0E7C86;
  --sea-deep: #0A5C66;
  --sand: #F6E7C8;
  --sky: #DDF1F6;
  --sun: #F4B63E;
  --paper: #F4F7FC;
  --card: #FFFFFF;
  --line: #CBD5E3;
  --brand: #1D3F8F;
  --brand-2: #C9A227;
  --brand-3: #1BA672;
  --good: #1B7F4E;
  --good-bg: #E3F6EC;
  --retry: #A8500F;
  --retry-bg: #FFF1E3;
  --hint-bg: #FFF8DB;
  --font: ui-rounded, "SF Pro Rounded", "Nunito", "Varela Round", "Segoe UI", system-ui, -apple-system, sans-serif;
  --display: ui-rounded, "Arial Rounded MT Bold", "Nunito", "Trebuchet MS", "Segoe UI", sans-serif;
  --r-sheet: 26px;
  --r-ctl: 14px;
  --r-chip: 999px;
  --press: 0 4px 0 var(--ink);
  --t: 160ms;
  font-size: 17px;
}
.large-text { font-size: 20px; }
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font); color: var(--ink); line-height: 1.5; -webkit-font-smoothing: antialiased;
  background: linear-gradient(180deg, var(--sky) 0, var(--paper) 340px, var(--paper) 100%);
  min-height: 100vh;
}
h1, h2, h3 { font-family: var(--display); line-height: 1.15; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: clamp(1.6rem, 4vw, 2.3rem); font-weight: 800; }
h2 { font-size: 1.25rem; font-weight: 800; margin-top: 1.4em; }
p { margin: 0 0 .8em; }
a { color: var(--sea-deep); }
img { max-width: 100%; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 4px solid var(--sun); outline-offset: 3px; border-radius: 8px; }
[hidden] { display: none !important; }
h1[tabindex="-1"]:focus { outline: none; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--card); padding: .5rem 1rem; z-index: 99; border-radius: 8px; }
.skip:focus { left: 8px; }
.reduce-motion *, .reduce-motion *::before, .reduce-motion *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }

/* ------------------------------------------------ layout */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 1rem; justify-content: space-between;
  padding: .55rem max(1rem, env(safe-area-inset-left)); background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: blur(8px); border-bottom: 2px solid color-mix(in srgb, var(--ink) 10%, transparent);
}
.topbar:empty { display: none; }
.brand { display: flex; align-items: center; gap: .55rem; text-decoration: none; color: var(--ink); font-family: var(--display); font-weight: 800; font-size: 1.1rem; }
.top-nav { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; justify-content: flex-end; }
.top-link { text-decoration: none; color: var(--ink); font-weight: 700; padding: .4rem .7rem; border-radius: var(--r-ctl); }
.top-link:hover { background: var(--sky); }
.main { max-width: 1120px; margin: 0 auto; padding: 1.2rem 1rem 4rem; outline: none; }
.loading { display: flex; gap: .8rem; align-items: center; justify-content: center; padding: 5rem 0; font-weight: 700; }
.spinner { width: 26px; height: 26px; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--sea); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.sheet { background: var(--card); border-radius: var(--r-sheet); padding: clamp(1.1rem, 3vw, 2rem); border: 2px solid color-mix(in srgb, var(--ink) 12%, transparent); max-width: 860px; margin: 0 auto; position: relative; }
.help { color: var(--ink-2); font-size: .92rem; }
.center { justify-content: center; }

/* ------------------------------------------------ controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 48px; padding: .6rem 1.2rem;
  border-radius: var(--r-ctl); border: 2px solid var(--ink); background: var(--card); color: var(--ink); font-weight: 800;
  box-shadow: var(--press); cursor: pointer; text-decoration: none; transition: transform var(--t), box-shadow var(--t);
}
.btn:hover { background: var(--sky); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: var(--press); }
.btn-go { background: var(--sea); color: #fff; border-color: var(--sea-deep); box-shadow: 0 4px 0 var(--sea-deep); }
.btn-go:hover { background: var(--sea-deep); }
.btn-quiet { border-color: var(--line); box-shadow: 0 3px 0 var(--line); }
.btn-danger { background: #B3261E; color: #fff; border-color: #7D1A15; box-shadow: 0 4px 0 #7D1A15; }
.btn-sm { min-height: 40px; padding: .35rem .8rem; font-size: .9rem; }
.btn-lg { min-height: 60px; padding: .8rem 2rem; font-size: 1.2rem; }
.btn-round { width: 56px; height: 56px; border-radius: 50%; padding: 0; font-size: 1.6rem; }
.row-actions { display: flex; flex-wrap: wrap; gap: .7rem; margin-top: 1.2rem; align-items: center; }
.row-actions .btn-go { margin-left: auto; }
.row-actions.center .btn-go { margin-left: 0; }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--line); background: var(--card); font-size: 1.2rem; cursor: pointer; }
.avatar-btn { display: flex; align-items: center; gap: .35rem; border: 2px solid var(--line); background: var(--card); border-radius: var(--r-chip); padding: .2rem .7rem .2rem .3rem; cursor: pointer; font-weight: 800; min-height: 44px; }
.avatar-btn > span:first-child { font-size: 1.5rem; }
.chip { display: inline-block; padding: .2rem .7rem; border-radius: var(--r-chip); background: var(--sky); font-weight: 800; font-size: .88rem; }
.chip-row { display: flex; gap: .4rem; flex-wrap: wrap; }
.chip-stars { background: #FFF2C9; }
.back { margin-bottom: 1rem; }
.field-label { display: block; font-weight: 800; margin: 1rem 0 .35rem; }
.text-input { width: 100%; min-height: 52px; font: inherit; font-size: 1.1rem; padding: .6rem .9rem; border: 2px solid var(--ink-2); border-radius: var(--r-ctl); background: #fff; color: var(--ink); }
.code-input { text-transform: uppercase; letter-spacing: .3em; font-weight: 800; max-width: 260px; }
.form-error { color: #B3261E; font-weight: 700; min-height: 1.4em; margin-top: .8rem; }

/* ------------------------------------------------ welcome */
.welcome { display: grid; place-items: center; min-height: 80vh; }
.welcome-card { text-align: center; max-width: 760px; background: var(--card); border-radius: 34px; padding: clamp(1.4rem, 5vw, 3rem);
  border: 2px solid color-mix(in srgb, var(--ink) 12%, transparent); position: relative; overflow: hidden; }
.welcome-card::before { content: ""; position: absolute; inset: auto -10% -42px -10%; height: 110px; background: var(--sand); border-radius: 50% 50% 0 0; z-index: 0; }
.welcome-card > * { position: relative; z-index: 1; }
.school-name { font-weight: 800; letter-spacing: .08em; color: var(--brand); margin: .5rem 0 .2rem; }
.welcome-title { font-size: clamp(2rem, 6vw, 3.2rem); color: var(--ink); }
.welcome-text { font-size: 1.15rem; max-width: 34ch; margin: 0 auto 1.2rem; }
.vision { margin-top: 1.6rem; font-style: italic; color: var(--ink-2); max-width: 46ch; margin-inline: auto; }
.vision span { font-style: normal; font-weight: 800; }
.staff-link { margin-top: 1rem; font-size: .9rem; }
.team { display: flex; gap: .8rem; justify-content: center; flex-wrap: wrap; margin: 1rem 0 .4rem; }
.team-member { margin: 0; width: 96px; }
.team-face { width: 72px; height: 72px; margin: 0 auto; }
.team-member figcaption { display: grid; font-size: .8rem; line-height: 1.2; }
.team-member figcaption span { color: var(--ink-2); }
.logo { display: inline-block; }
.logo-sm { width: 34px; height: 38px; }
.logo-md { width: 64px; height: 72px; }
.logo-lg { width: 92px; height: 104px; }
img.logo { object-fit: contain; width: auto; }
img.logo-lg { max-height: 110px; }
img.logo-sm { max-height: 40px; }
.logo-crest svg { width: 100%; height: 100%; }

/* ------------------------------------------------ players & forms */
.player-list { list-style: none; padding: 0; display: grid; gap: .7rem; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.player { width: 100%; display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: .8rem; text-align: left; padding: .9rem; border-radius: 18px; border: 2px solid var(--line); background: var(--card); cursor: pointer; box-shadow: 0 3px 0 var(--line); }
.player:hover { border-color: var(--sea); }
.player-avatar { grid-row: span 2; font-size: 2.4rem; }
.player-name { font-weight: 800; font-size: 1.1rem; }
.player-meta { color: var(--ink-2); font-size: .88rem; }
.avatar-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); gap: .5rem; }
.avatar-opt { font-size: 2rem; height: 64px; border-radius: 16px; border: 2px solid var(--line); background: var(--card); cursor: pointer; }
.avatar-opt[aria-checked="true"] { border-color: var(--sea); background: var(--sky); box-shadow: inset 0 0 0 3px var(--sea); }
.year-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .6rem; }
.year-card { display: grid; text-align: left; gap: .1rem; padding: .9rem 1rem; border-radius: 18px; border: 2px solid var(--line); background: var(--card); cursor: pointer; min-height: 110px; }
.year-card[aria-checked="true"] { border-color: var(--sea); background: var(--sky); box-shadow: inset 0 0 0 3px var(--sea); }
.year-num { font-family: var(--display); font-weight: 800; font-size: 1.2rem; }
.year-title { font-weight: 800; color: var(--sea-deep); }
.year-blurb { font-size: .82rem; color: var(--ink-2); line-height: 1.3; }

/* ------------------------------------------------ hub & map */
.announce { background: #FFF2C9; border: 2px solid var(--sun); border-radius: 16px; padding: .7rem 1rem; font-weight: 700; margin-bottom: 1rem; }
.announce.warn { background: var(--retry-bg); border-color: var(--retry); }
.hub { display: grid; grid-template-columns: 1.1fr 1fr; gap: 1rem; align-items: stretch; }
.hub-hello { display: flex; gap: 1rem; align-items: center; background: var(--card); border-radius: var(--r-sheet); padding: 1rem 1.2rem; border: 2px solid color-mix(in srgb, var(--ink) 12%, transparent); }
.hub-hello h1 { font-size: clamp(1.4rem, 3vw, 1.9rem); margin-bottom: .1em; }
.hub-hello p { margin: 0 0 .4rem; color: var(--ink-2); font-weight: 700; }
.hub-avatar { font-size: 3.2rem; line-height: 1; }
.level-bar { display: block; height: 14px; background: var(--sky); border-radius: 99px; overflow: hidden; border: 2px solid color-mix(in srgb, var(--ink) 15%, transparent); min-width: 120px; }
.level-bar > span { display: block; height: 100%; background: var(--zc, var(--sea)); border-radius: 99px; transition: width .6s; }
.rec-card { display: flex; align-items: center; gap: .9rem; padding: 1rem 1.2rem; background: var(--ink); color: #fff; border-radius: var(--r-sheet); text-decoration: none; box-shadow: 0 5px 0 #0C1730; }
.rec-card:hover { background: #24375E; }
.rec-card small { display: block; color: #BFD3F2; font-weight: 700; }
.rec-card strong { font-family: var(--display); font-size: 1.3rem; }
.rec-icon { font-size: 2.2rem; }
.rec-go { margin-left: auto; width: 46px; height: 46px; border-radius: 50%; background: var(--sun); color: var(--ink); display: grid; place-items: center; font-size: 1.1rem; flex: none; }
.hub-actions { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.quest-btn { display: flex; gap: .8rem; align-items: center; padding: .8rem 1.1rem; border-radius: 20px; border: 2px solid var(--ink); background: var(--card); color: var(--ink); text-decoration: none; box-shadow: var(--press); }
.quest-btn strong { display: block; font-family: var(--display); font-size: 1.1rem; }
.quest-btn small { display: block; color: var(--ink-2); font-weight: 700; }
.quest-icon { font-size: 1.9rem; }
.quest-final { background: #FFF6DA; }
.quest-btn.is-locked { border-style: dashed; box-shadow: none; opacity: .8; }
.story { margin: 1.2rem auto .6rem; max-width: 64ch; text-align: center; font-weight: 700; color: var(--ink-2); }

/* the archipelago */
.sea {
  position: relative; aspect-ratio: 16 / 9.2; margin-top: .4rem; border-radius: 34px; overflow: hidden;
  background:
    radial-gradient(circle at 20% 15%, #5CC3CB 0 14%, transparent 15%),
    radial-gradient(ellipse at 50% 120%, #0A5C66 0 40%, transparent 70%),
    linear-gradient(160deg, #39AAB4, #0E7C86 60%, #0A6670);
  border: 3px solid var(--sea-deep);
}
.sea-route { position: absolute; inset: 0; width: 100%; height: 100%; }
.sea-route path { fill: none; stroke: #ffffffb0; stroke-width: 4; stroke-dasharray: 2 10; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.wave { position: absolute; color: #ffffff55; font-size: 2rem; pointer-events: none; }
.w1 { left: 30%; top: 8%; } .w2 { left: 64%; top: 52%; } .w3 { left: 8%; top: 52%; }
.island {
  position: absolute; left: calc(var(--x) * 1%); top: calc(var(--y) * 1%); transform: translate(-50%, -50%);
  display: grid; justify-items: center; gap: .2rem; text-decoration: none; color: var(--ink); width: clamp(120px, 17%, 190px);
}
.isle-land {
  width: clamp(84px, 9vw, 120px); aspect-ratio: 1.15; display: grid; place-items: center;
  background: radial-gradient(circle at 50% 42%, var(--sand) 0 55%, color-mix(in srgb, var(--zc) 35%, var(--sand)) 56% 100%);
  border: 4px solid var(--zc); border-radius: 46% 54% 50% 50% / 55% 48% 52% 45%;
  box-shadow: 0 0 0 7px #ffffff40, 0 8px 0 color-mix(in srgb, var(--zc) 70%, #000);
  transition: transform var(--t);
}
.isle-icon { font-size: clamp(2rem, 3.4vw, 2.8rem); }
.island:hover .isle-land, .island:focus-visible .isle-land { transform: translateY(-4px) scale(1.04); }
.isle-label { background: var(--card); border: 2px solid var(--zc); border-radius: 14px; padding: .25rem .6rem; text-align: center; line-height: 1.2; box-shadow: 0 3px 0 var(--zc); }
.isle-label strong { display: block; font-size: .95rem; }
.isle-label small { color: var(--ink-2); font-weight: 700; font-size: .78rem; }
.isle-badge, .isle-flag { position: absolute; top: -4px; font-size: 1.4rem; }
.isle-badge { right: 14%; } .isle-flag { left: 14%; }
.dhow { position: absolute; left: -10%; top: 6%; font-size: 2.2rem; animation: bob 2.4s ease-in-out infinite; filter: drop-shadow(0 3px 0 #0006); }
@keyframes bob { 50% { transform: translateY(-6px) rotate(-4deg); } }
.map-key { text-align: center; color: var(--ink-2); font-size: .88rem; margin-top: .6rem; }

/* ------------------------------------------------ zone */
.zone { max-width: 860px; margin: 0 auto; }
.zone-head { display: flex; gap: 1.2rem; align-items: center; background: var(--card); border-radius: var(--r-sheet); padding: 1.2rem; border: 3px solid var(--zc); box-shadow: 0 6px 0 var(--zc); margin-bottom: 1.4rem; }
.zone-head h1 { margin-bottom: .2em; }
.zone-head > div:last-child { flex: 1; }
.zone-face { width: 110px; height: 110px; flex: none; }
.zone-guide { font-weight: 800; color: var(--ink-2); }
.mission-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .8rem; }
.mission { display: flex; gap: 1rem; align-items: center; padding: 1rem 1.2rem; border-radius: 20px; background: var(--card); color: var(--ink); text-decoration: none; border: 2px solid var(--ink); box-shadow: var(--press); }
.mission:hover { background: color-mix(in srgb, var(--zc) 10%, white); }
.mission.is-done { border-color: var(--zc); box-shadow: 0 4px 0 var(--zc); }
.mission.is-locked { border-style: dashed; border-color: var(--line); box-shadow: none; background: #ffffffaa; color: var(--ink-2); }
.m-icon { font-size: 2rem; width: 2.6rem; text-align: center; }
.m-text { flex: 1; display: grid; }
.m-text strong { font-size: 1.1rem; font-family: var(--display); }
.m-text small { color: var(--ink-2); }
.m-assigned { color: var(--retry) !important; font-weight: 800; }
.m-stars span { color: #C7CFDB; font-size: 1.4rem; }
.m-stars span.on { color: var(--sun); text-shadow: 0 2px 0 #C38412; }

/* ------------------------------------------------ guide & briefing */
.guide { display: flex; gap: 1rem; align-items: flex-start; margin: 1rem 0; }
.guide-face { width: 92px; height: 92px; flex: none; }
.guide-bubble { position: relative; background: var(--sky); border-radius: 22px; padding: .8rem 1.1rem; flex: 1; }
.guide-bubble::before { content: ""; position: absolute; left: -12px; top: 26px; border: 12px solid transparent; border-right-color: var(--sky); border-left: 0; }
.guide-name { font-weight: 800; color: var(--sea-deep); margin-bottom: .2rem; font-size: .9rem; }
.guide-bubble p:last-child { margin-bottom: 0; }
.objective, .scoring-note { border: 2px dashed var(--sea); border-radius: 18px; padding: .9rem 1.1rem; }
.objective h2, .scoring-note h2 { margin-top: 0; font-size: 1.05rem; }
.scoring-note ul, .rules { margin: 0; padding-left: 1.2rem; }
.rules li, .scoring-note li { margin: .3rem 0; }

/* ------------------------------------------------ play */
.play-head { display: flex; align-items: center; gap: .8rem; margin-bottom: .6rem; }
.play-title { font-size: 1.15rem; margin: 0; flex: 1; text-align: center; }
.dots { list-style: none; display: flex; gap: .35rem; padding: 0; margin: 0 0 1rem; justify-content: center; flex-wrap: wrap; }
.dots li { width: 14px; height: 14px; border-radius: 50%; background: var(--line); }
.dots li.done { background: var(--good); }
.dots li.missed { background: var(--sun); }
.dots li.now { background: var(--sea); box-shadow: 0 0 0 4px #0E7C8633; }
.timer { position: relative; height: 26px; border-radius: 99px; background: var(--sky); overflow: hidden; margin-bottom: 1rem; border: 2px solid var(--line); }
.timer-fill { position: absolute; inset: 0; transform-origin: left; transform: scaleX(var(--left, 1)); background: linear-gradient(90deg, var(--brand-3), var(--sea)); transition: transform .25s linear; }
.timer-text { position: relative; display: block; text-align: center; font-weight: 800; font-size: .85rem; line-height: 22px; }
.passage { background: #FFFBF0; border: 2px solid var(--sand); border-radius: 18px; padding: .7rem 1rem; margin-bottom: 1rem; }
.passage summary { font-weight: 800; cursor: pointer; }
.passage p { margin: .6rem 0; font-size: 1.05rem; line-height: 1.65; max-width: 70ch; }
.round { min-height: 200px; }
.round-q { font-size: 1.3rem; font-weight: 800; font-family: var(--display); max-width: 60ch; }
.clue-label { color: var(--sea-deep); }
.play-tools { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1rem; }
.feedback { margin-top: 1rem; border-radius: 18px; }
.feedback:empty { display: none; }
.feedback-retry, .feedback-nudge, .feedback-hint, .feedback-good, .feedback-reveal { padding: .8rem 1rem; border: 2px solid; }
.feedback-retry { background: var(--retry-bg); border-color: var(--retry); }
.feedback-nudge { background: var(--sky); border-color: var(--sea); }
.feedback-hint { background: var(--hint-bg); border-color: var(--sun); }
.feedback-good { background: var(--good-bg); border-color: var(--good); }
.feedback-reveal { background: #EEF1FA; border-color: var(--brand); }
.fb-main { font-weight: 800; font-size: 1.05rem; margin: 0; }
.fb-sub { margin: .3rem 0 0; }
.fb-icon { display: inline-grid; place-items: center; width: 1.7em; height: 1.7em; border-radius: 50%; background: #fff; margin-right: .4rem; }
.fb-row { display: flex; gap: .8rem; align-items: center; }
.fb-face { width: 58px; height: 58px; flex: none; }
.fb-why { margin: .3rem 0 0; }

/* choices */
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .7rem; }
.choice { display: flex; align-items: center; gap: .8rem; text-align: left; min-height: 64px; padding: .7rem 1rem; border-radius: 18px; border: 2px solid var(--ink); background: var(--card); box-shadow: var(--press); cursor: pointer; font-size: 1.08rem; font-weight: 700; }
.choice:hover:not(:disabled) { background: var(--sky); }
.choice:disabled { cursor: default; }
.choice-key { flex: none; width: 2rem; height: 2rem; border-radius: 10px; background: var(--sky); display: grid; place-items: center; font-weight: 800; }
.choice.is-right { border-color: var(--good); background: var(--good-bg); box-shadow: 0 4px 0 var(--good); }
.choice.is-right .choice-key { background: var(--good); color: #fff; }
.choice.is-wrong { border-color: var(--retry); background: var(--retry-bg); box-shadow: none; opacity: .85; text-decoration: line-through; text-decoration-thickness: 2px; }
.choice.is-wrong .choice-key { background: var(--retry); color: #fff; }
.lab-scene { display: flex; justify-content: center; gap: 1rem; font-size: 3.4rem; background: linear-gradient(#EAF7FA, #fff); border-radius: 20px; padding: .6rem; margin-bottom: .8rem; border: 2px solid var(--sky); }
.observe { margin-top: .9rem; padding: .7rem 1rem; border-radius: 16px; background: #EAF7FA; border-left: 6px solid var(--sea); }

/* typed answers */
.answer-row { display: flex; gap: .6rem; flex-wrap: wrap; }
.answer-input { flex: 1; min-width: 160px; min-height: 60px; font: inherit; font-size: 1.6rem; font-weight: 800; padding: .4rem 1rem; border-radius: 16px; border: 3px solid var(--ink); text-align: center; }
.answer-input.is-wrong { border-color: var(--retry); background: var(--retry-bg); }
.answer-input.is-right { border-color: var(--good); background: var(--good-bg); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: .45rem; max-width: 320px; margin-top: .9rem; }
.key { min-height: 52px; border-radius: 14px; border: 2px solid var(--line); background: var(--card); font-size: 1.3rem; font-weight: 800; cursor: pointer; box-shadow: 0 3px 0 var(--line); }
.key:active { transform: translateY(2px); box-shadow: none; }
.key-del { grid-column: span 3; }
@media (pointer: fine) and (min-width: 900px) { .keypad { display: none; } }

/* tiles */
.tile-line { list-style: none; display: flex; flex-wrap: wrap; gap: .45rem; padding: .7rem; margin: .4rem 0 .9rem; min-height: 72px; border-radius: 18px; background: var(--sky); border: 2px dashed var(--sea); }
.tile-line.is-right { background: var(--good-bg); border-color: var(--good); border-style: solid; }
.tile-line li.slot { min-width: 54px; height: 52px; border-radius: 12px; border: 2px dashed #9EC3CC; display: grid; place-items: center; color: #7DA3AD; font-weight: 800; }
.tile-line-letters li.slot { min-width: 48px; }
.tile-pool { display: flex; flex-wrap: wrap; gap: .5rem; }
.tile { min-height: 52px; padding: .45rem .9rem; border-radius: 12px; border: 2px solid var(--ink); background: var(--card); font-size: 1.05rem; font-weight: 700; cursor: pointer; box-shadow: 0 3px 0 var(--ink); text-align: left; }
.tile-letter { min-width: 52px; font-size: 1.5rem; font-weight: 800; text-align: center; font-family: var(--display); }
.tile-placed { background: #fff; box-shadow: 0 3px 0 var(--sea-deep); border-color: var(--sea-deep); }
.tile-chip { font-family: ui-monospace, Menlo, Consolas, monospace; }

/* match & sort */
.match-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.match-col { display: grid; gap: .55rem; align-content: start; }
.match-item, .sort-item { min-height: 54px; padding: .5rem .8rem; border-radius: 14px; border: 2px solid var(--ink); background: var(--card); cursor: pointer; font-weight: 700; font-size: 1.02rem; text-align: left; box-shadow: 0 3px 0 var(--ink); }
.match-item.is-selected, .sort-item.is-selected { background: #FFF2C9; border-color: #B57A06; box-shadow: 0 3px 0 #B57A06, inset 0 0 0 2px #B57A06; }
.match-item.is-right { background: var(--good-bg); border-color: var(--good); box-shadow: none; cursor: default; }
.pair-tag { font-weight: 800; color: var(--good); }
.sort-pool { display: flex; flex-wrap: wrap; gap: .5rem; min-height: 60px; padding: .4rem 0 1rem; }
.sort-bins { display: grid; grid-template-columns: repeat(var(--cols, 2), 1fr); gap: .7rem; }
.bin { display: grid; align-content: start; gap: .4rem; min-height: 150px; padding: .7rem; border-radius: 18px; border: 3px dashed var(--sea); background: #F2FAFB; cursor: pointer; text-align: left; }
.bin:hover:not(:disabled) { background: var(--sky); }
.bin-name { font-family: var(--display); font-weight: 800; font-size: 1.05rem; }
.bin-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .3rem; font-size: .92rem; }
.bin-list li { background: var(--good-bg); border-radius: 10px; padding: .25rem .5rem; font-weight: 700; }
.shake { animation: shake .4s; }
@keyframes shake { 25% { transform: translateX(-6px); } 50% { transform: translateX(6px); } 75% { transform: translateX(-3px); } }

/* inspect */
.msg-card { border: 2px solid var(--ink-2); border-radius: 18px; overflow: hidden; background: #fff; }
.msg-head { background: #F1F4F9; padding: .7rem 1rem; display: grid; gap: .15rem; font-size: .95rem; border-bottom: 2px solid var(--line); }
.msg-label { font-weight: 800; color: var(--ink-2); }
.msg-from { font-family: ui-monospace, Menlo, Consolas, monospace; word-break: break-all; }
.msg-note { font-size: .8rem; color: var(--retry); font-weight: 700; }
.msg-body { padding: .8rem; display: grid; gap: .4rem; }
.msg-part { text-align: left; padding: .55rem .8rem; border-radius: 12px; border: 2px dashed transparent; background: transparent; cursor: pointer; font-size: 1.02rem; line-height: 1.4; min-height: 44px; }
.msg-part:hover:not(:disabled) { border-color: var(--sea); background: #F2FAFB; }
.msg-part.is-flagged { background: #FFE9E4; border: 2px solid #C2410C; color: #7C2D12; font-weight: 700; }
.msg-part.is-normal { opacity: .55; }
.found-count { font-weight: 800; margin: .8rem 0 .3rem; }
.why-list p { background: #FFF5F2; border-radius: 12px; padding: .4rem .7rem; margin: .3rem 0; }
.safety-note { background: #FFF2C9; border-radius: 12px; padding: .4rem .8rem; font-weight: 700; display: inline-block; }

/* password lab */
.pw-box { background: #0F1B33; color: #fff; border-radius: 18px; padding: 1rem; margin: .4rem 0 1rem; }
.pw-display { display: block; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 1.5rem; min-height: 2.2rem; word-break: break-all; }
.meter { height: 16px; border-radius: 99px; background: #ffffff22; overflow: hidden; margin: .6rem 0 .3rem; }
.meter-fill { height: 100%; width: calc(var(--score, 0) * 25%); background: #E05A47; transition: width .3s, background .3s; }
.meter[data-score="2"] .meter-fill { background: var(--sun); }
.meter[data-score="3"] .meter-fill, .meter[data-score="4"] .meter-fill { background: #3CCB7F; }
.meter-label { margin: 0; font-weight: 700; color: #D6E2F5; }
.pw-tips { list-style: none; padding: 0; margin: 1rem 0 0; display: grid; gap: .2rem; color: var(--ink-2); }
.pw-tips li.ok { color: var(--good); font-weight: 800; }

/* maze */
.maze-wrap { display: grid; grid-template-columns: minmax(0, 1fr) minmax(220px, 300px); gap: 1rem; align-items: start; }
.maze { position: relative; display: grid; grid-template-columns: repeat(var(--w), 1fr); gap: 4px; background: #CFE8D5; padding: 6px; border-radius: 16px; border: 3px solid #2F7D4F; max-width: 520px; }
.cell { aspect-ratio: 1; border-radius: 8px; background: #F3FBF4; display: grid; place-items: center; font-size: clamp(1rem, 3.5vw, 1.8rem); }
.cell.wall { background: #A9C7AF; }
.robot { position: absolute; width: calc((100% - 12px - (var(--w) - 1) * 4px) / var(--w)); aspect-ratio: 1; left: calc(6px + var(--x) * ((100% - 12px - (var(--w) - 1) * 4px) / var(--w) + 4px)); top: calc(6px + var(--y) * ((100% - 12px - (var(--w) - 1) * 4px) / var(--w) + 4px)); display: grid; place-items: center; font-size: clamp(1.1rem, 4vw, 2rem); transition: left .22s, top .22s; }
.robot.bump { animation: shake .4s; }
.palette { display: grid; grid-template-columns: repeat(4, 1fr); gap: .4rem; }
.cmd { min-height: 56px; font-size: 1.7rem; font-weight: 800; border-radius: 14px; border: 2px solid var(--ink); background: #FFF6DA; cursor: pointer; box-shadow: 0 3px 0 var(--ink); }
.program { list-style: decimal inside; padding: .5rem; margin: .7rem 0 .3rem; background: #0F1B33; border-radius: 14px; color: #fff; display: grid; gap: .35rem; min-height: 60px; }
.block { display: flex; align-items: center; gap: .4rem; background: #20304F; border-radius: 10px; padding: .25rem .4rem; }
.block-arrow { font-size: 1.4rem; width: 2rem; text-align: center; cursor: pointer; background: #2E4470; border-radius: 8px; }
.block-n { display: flex; align-items: center; gap: .3rem; font-weight: 800; }
.block-empty { list-style: none; color: #9FB3D6; font-size: .9rem; padding: .4rem; }
.mini { width: 30px; height: 30px; border-radius: 8px; border: 0; background: #3A5385; color: #fff; cursor: pointer; font-weight: 800; }
.mini-del { margin-left: auto; background: #6B2F35; }

/* number target, fractions, shapes */
.target-goal { display: inline-grid; justify-items: center; background: var(--ink); color: #fff; border-radius: 22px; padding: .5rem 1.6rem; margin-bottom: 1rem; }
.target-label { font-weight: 700; color: #BFD3F2; font-size: .9rem; }
.target-num { font-family: var(--display); font-weight: 800; font-size: 2.6rem; line-height: 1; }
.num-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: .6rem; max-width: 520px; }
.num-btn { min-height: 74px; border-radius: 18px; border: 3px solid var(--ink); background: var(--card); font-family: var(--display); font-size: 1.7rem; font-weight: 800; cursor: pointer; box-shadow: var(--press); }
.num-btn.is-selected { background: #FFF2C9; border-color: #B57A06; box-shadow: 0 4px 0 #B57A06; transform: translateY(-2px); }
.target-sum { font-weight: 800; font-size: 1.15rem; margin-top: .8rem; }
.fraction-box { display: flex; justify-content: center; }
.fraction-svg { width: 100%; max-width: 560px; }
.fraction-svg.is-circle { max-width: 300px; }
.seg { fill: #fff; stroke: var(--ink); stroke-width: 3; cursor: pointer; transition: fill .15s; }
.seg:hover { fill: #EAF7FA; }
.seg.on { fill: var(--sun); }
.seg:focus-visible { outline: none; stroke: var(--sea); stroke-width: 6; }
.shape-box { display: flex; align-items: center; justify-content: center; gap: 1rem; }
.shape-svg { width: 220px; height: 220px; }
.shape-svg polygon { fill: #DDF1F6; stroke: var(--brand); stroke-width: 5; stroke-linejoin: round; }

/* memory */
.memory { display: grid; grid-template-columns: repeat(var(--cols), 1fr); gap: .6rem; max-width: 560px; }
.mcard { aspect-ratio: 1; border-radius: 16px; border: 3px solid var(--ink); background: var(--brand); color: #fff; cursor: pointer; font-weight: 800; font-size: clamp(.9rem, 3.2vw, 1.4rem); box-shadow: var(--press); padding: .2rem; }
.mcard-face { display: none; }
.mcard.up { background: #fff; color: var(--ink); }
.mcard.up .mcard-face { display: block; }
.mcard.up .mcard-back { display: none; }
.mcard-back { font-size: 2rem; }
.mcard.is-right { background: var(--good-bg); border-color: var(--good); box-shadow: none; }

/* ------------------------------------------------ results */
.results { text-align: center; }
.stars { display: flex; justify-content: center; gap: .6rem; margin: .4rem 0 1rem; }
.big-star { font-size: 4.4rem; color: #D5DCE7; line-height: 1; }
.big-star.on { color: var(--sun); text-shadow: 0 4px 0 #C38412; animation: pop .5s calc(var(--d) * .18s) both; }
@keyframes pop { 0% { transform: scale(.3); opacity: 0; } 70% { transform: scale(1.2); } 100% { transform: scale(1); opacity: 1; } }
.results .guide { text-align: left; }
.final-note { font-weight: 800; font-size: 1.1rem; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .7rem; margin: 1rem 0; }
.stat-grid > div { background: var(--sky); border-radius: 18px; padding: .7rem .9rem; text-align: left; }
.stat-grid dt { font-size: .85rem; color: var(--ink-2); font-weight: 700; }
.stat-grid dd { margin: 0; font-family: var(--display); font-weight: 800; font-size: 1.5rem; }

/* ------------------------------------------------ dashboard */
.dash-head { display: flex; gap: 1rem; align-items: center; }
.dash-head p { margin: 0; }
.subject-bars { list-style: none; padding: 0; display: grid; gap: .6rem; }
.subject-bars li { display: grid; grid-template-columns: 180px 1fr 110px; gap: .8rem; align-items: center; font-weight: 700; }
.sb-num { text-align: right; color: var(--ink-2); }
.badge-shelf { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .6rem; }
.badge { display: grid; justify-items: center; text-align: center; gap: .15rem; background: #FFF8E4; border: 2px solid #E8C266; border-radius: 18px; padding: .8rem .5rem; }
.badge.is-locked { background: #F3F5F9; border: 2px dashed var(--line); color: var(--ink-2); }
.badge-icon { font-size: 2.2rem; }
.badge small { font-size: .78rem; line-height: 1.25; }
.badge.big { padding: 1.2rem; }
.badge.big .badge-icon { font-size: 3.6rem; animation: pop .6s both; }
.badge-pop { display: grid; gap: .8rem; }
.cert-list { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: .5rem; }

/* certificate */
.certificate { text-align: center; padding: 2rem 1.5rem; border: 6px double var(--brand-2); border-radius: 12px; background: #FFFDF6; }
.cert-school { font-weight: 800; letter-spacing: .08em; color: var(--brand); }
.cert-pre { color: var(--ink-2); margin: .4rem 0; }
.cert-name { font-family: var(--display); font-size: 2.4rem; font-weight: 800; margin: .2rem 0; color: var(--ink); }
.cert-title { font-family: var(--display); font-size: 1.6rem; font-weight: 800; color: var(--sea-deep); }
.cert-meta { font-weight: 700; }
.cert-vision { font-style: italic; color: var(--ink-2); font-size: .9rem; margin-top: 1rem; }

/* ------------------------------------------------ modal, toast, settings */
.modal-back { position: fixed; inset: 0; background: #1B2A4A99; display: grid; place-items: center; padding: 1rem; z-index: 50; }
.modal { background: var(--card); border-radius: var(--r-sheet); padding: 1.4rem; width: min(520px, 100%); max-height: 90vh; overflow: auto; border: 3px solid var(--ink); box-shadow: 0 8px 0 var(--ink); }
.modal-wide { width: min(760px, 100%); }
.modal-actions { display: flex; flex-wrap: wrap; gap: .6rem; justify-content: flex-end; margin-top: 1.2rem; }
#toasts { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); display: grid; gap: .5rem; z-index: 60; width: min(480px, 92vw); }
.toast { background: var(--ink); color: #fff; padding: .7rem 1rem; border-radius: 14px; font-weight: 700; transition: opacity .3s; }
.toast-good { background: var(--good); } .toast-warn { background: var(--retry); }
.toast.out { opacity: 0; }
.toggle { display: flex; gap: .8rem; align-items: center; padding: .6rem 0; border-bottom: 1px solid var(--line); }
.toggle input { width: 28px; height: 28px; accent-color: var(--sea); flex: none; }
.toggle label { display: grid; cursor: pointer; }
.toggle small { color: var(--ink-2); }
.noscript { padding: 2rem; text-align: center; }

/* ------------------------------------------------ responsive */
@media (max-width: 820px) {
  .hub { grid-template-columns: 1fr; }
  .hub-actions { grid-template-columns: 1fr; }
  .maze-wrap { grid-template-columns: 1fr; }
  .subject-bars li { grid-template-columns: 1fr 90px; }
  .subject-bars .level-bar { grid-column: 1 / -1; grid-row: 2; }
}
@media (max-width: 720px) {
  .brand-name, .top-link span, .avatar-name { display: none; }
  .topbar { gap: .3rem; padding: .45rem .6rem; }
  .top-nav { flex-wrap: nowrap; gap: .25rem; }
  .top-link { padding: .3rem .4rem; }
  .chip-stars { font-size: .8rem; padding: .2rem .5rem; white-space: nowrap; }
  .icon-btn { width: 40px; height: 40px; }
  .answer-input { font-size: 1.3rem; }
  .sea { aspect-ratio: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 1.6rem .6rem; padding: 1.6rem .6rem; }
  .sea-route, .wave { display: none; }
  .island { position: relative; left: auto; top: auto; transform: none; width: auto; }
  .zone-head { flex-direction: column; text-align: center; }
  .zone-face { width: 90px; height: 90px; }
  .match-grid { gap: .5rem; }
  .match-item { font-size: .92rem; }
  .sort-bins { grid-template-columns: 1fr; }
  .guide-face { width: 64px; height: 64px; }
  .round-q { font-size: 1.15rem; }
  .row-actions .btn-go { margin-left: 0; flex: 1 1 100%; }
}

/* ------------------------------------------------ print (certificates) */
@media print {
  body.printing-cert * { visibility: hidden; }
  body.printing-cert #certificate, body.printing-cert #certificate * { visibility: visible; }
  body.printing-cert #certificate { position: fixed; inset: 0; border-width: 10px; display: grid; align-content: center; }
}
