/* ===== New question types, lessons, algebra path, learning dashboard and new games ===== */

/* Typed expressions */
.expr-wrap { display: flex; flex-direction: column; align-items: center; gap: 12px; width: 100%; }
.expr-input { width: min(100%, 360px); font-family: var(--font-head); font-weight: 800; font-size: 1.8rem; text-align: center; padding: .25em .5em;
  border: 3px solid var(--purple-2); border-radius: 18px; background: #faf8ff; color: var(--ink); }
.expr-input:focus { outline: 4px solid var(--yellow); outline-offset: 2px; }
.expr-input:disabled { border-color: var(--line); }
.expr-keys { display: grid; grid-template-columns: repeat(5, 60px); gap: 8px; }
.expr-keys .key { height: 52px; font-size: 1.4rem; }

/* Sequencing (tap to order) */
.order-wrap { display: flex; flex-direction: column; gap: 14px; width: 100%; }
.order-slots { list-style: none; counter-reset: slot; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 0; padding: 0; }
.order-slots .slot { counter-increment: slot; min-width: 74px; min-height: 56px; border: 3px dashed var(--line); border-radius: 16px; display: flex; align-items: center; justify-content: center; position: relative; }
.order-slots .slot::before { content: counter(slot); position: absolute; top: -10px; left: -6px; font-size: .75rem; font-weight: 800; background: var(--purple-2); color: #fff; border-radius: 99px; padding: 0 6px; }
.order-slots .slot:not(.empty) { border-style: solid; border-color: var(--purple-2); }
.order-tiles, .match-col { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.tile { min-height: 52px; min-width: 64px; padding: 6px 14px; border: 0; border-radius: 14px; background: var(--purple-soft); box-shadow: 0 4px 0 #d8cdfb;
  font-family: var(--font-head); font-weight: 800; font-size: 1.25rem; color: var(--ink); cursor: pointer; }
.tile:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 #d8cdfb; }
.tile:focus-visible { outline: 4px solid var(--yellow); outline-offset: 2px; }
.tile.placed { background: #fff; box-shadow: none; }
.tile.selected { background: var(--yellow); box-shadow: 0 4px 0 #d9a520; }
.tile.correct { background: #e7f8ec; box-shadow: 0 4px 0 #9fdcb6; color: #1f7a45; }
.tile.wrong { background: #ffe3e3; box-shadow: 0 4px 0 #f3a9a9; }
.tile:disabled { cursor: default; }
.tile .frac { font-size: .9em; }

/* Matching */
.match-wrap { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; width: 100%; }
.match-col { flex-direction: column; flex-wrap: nowrap; align-items: stretch; }

/* Worked steps */
.wsteps { margin: .5em 0 0; padding-left: 1.3em; text-align: left; }
.wsteps li { margin: .2em 0; }
.steps-box summary { cursor: pointer; font-weight: 700; color: var(--purple); margin-top: .3em; }
.q-visual .grid-svg { max-width: 300px; }
.math { font-family: var(--font-head); font-weight: 800; white-space: nowrap; }

@media (max-width: 560px) {
  .expr-keys { grid-template-columns: repeat(5, 52px); }
  .match-wrap { gap: 10px; }
  .tile { font-size: 1.05rem; min-height: 48px; padding: 6px 10px; }
}

.tag { display: inline-block; background: var(--purple-soft); color: var(--purple); font-size: .75rem; font-weight: 800; padding: .1em .6em; border-radius: 999px; vertical-align: middle; }
.badge.done { background: var(--green); }

/* Today strip on the kid map */
.today-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 0 0 18px; }
.today-item { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 12px; border-radius: 18px; background: #fff; border: 2px solid var(--line);
  text-decoration: none; color: var(--ink); font: inherit; cursor: default; text-align: center; min-height: 92px; justify-content: center; }
a.today-item, button.today-item { cursor: pointer; }
a.today-item:hover, button.today-item:hover { border-color: var(--purple-2); }
.today-item b { font-family: var(--font-head); font-size: 1.15rem; line-height: 1.1; }
.today-item small { color: var(--muted); font-size: .8rem; }
.today-emoji { font-size: 1.5rem; line-height: 1; }
.today-item.next { background: #fff8e6; border-color: #ffd66b; }
.goal-bar { width: 100%; max-width: 160px; height: 12px; border-radius: 99px; background: var(--purple-soft); overflow: hidden; margin: 4px 0; }
.goal-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--teal), var(--green)); border-radius: 99px; transition: width .4s; }

/* Algebra Quest path */
.quest-path { list-style: none; margin: 10px auto 30px; padding: 0; max-width: 620px; position: relative; }
.quest-path::before { content: ''; position: absolute; left: 33px; top: 20px; bottom: 20px; width: 6px; border-radius: 6px; background: var(--line); }
.quest-node { position: relative; margin: 0 0 12px; animation: pop .35s both; animation-delay: calc(var(--i) * 40ms); }
.quest-node a { display: flex; align-items: center; gap: 14px; text-decoration: none; color: var(--ink); background: #fff; border: 2px solid var(--line); border-radius: 20px; padding: 10px 14px 10px 8px; }
.quest-node a:hover, .quest-node a:focus-visible { border-color: var(--blue); outline: none; box-shadow: var(--shadow); }
.quest-dot { flex: none; width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; font-size: 1.5rem; background: #eaf2ff; border: 4px solid #fff; box-shadow: 0 0 0 3px var(--line); position: relative; z-index: 1; }
.quest-node.learning .quest-dot { box-shadow: 0 0 0 3px var(--blue); }
.quest-node.mastered .quest-dot { background: var(--green); color: #fff; box-shadow: 0 0 0 3px #2a8c57; font-weight: 800; }
.quest-node.locked a { opacity: .7; }
.quest-body { display: flex; flex-direction: column; gap: 2px; }
.quest-body b { font-family: var(--font-head); font-size: 1.1rem; }
.quest-body small { color: var(--muted); }

/* Lessons */
.lesson-card { max-width: 760px; margin: 20px auto 40px; }
.lesson { text-align: left; }
.lesson-goal { background: #eaf2ff; border-radius: 14px; padding: 10px 14px; }
.lesson-body ul, .lesson-body ol, .lesson-mistakes ul { padding-left: 1.3em; }
.lesson-example { background: #f3fbf6; border: 2px solid #c9ecd6; border-radius: 16px; padding: 12px 16px; margin: 12px 0; }
.lesson-mistakes { background: #fff5f5; border: 2px solid #ffd3d3; border-radius: 16px; padding: 12px 16px; margin: 12px 0; }
.lesson h3 { font-size: 1.1rem; }
.modal .lesson { max-height: 70vh; overflow: auto; }
.small { font-size: .85rem; }

/* Badges */
.badge-list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; max-height: 60vh; overflow: auto; }
.badge-list li { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 10px; border-radius: 16px; background: #f6f4fb; opacity: .6; }
.badge-list li.got { background: #fff8e6; opacity: 1; border: 2px solid #ffd66b; }
.badge-list span { font-size: 1.8rem; }
.badge-list small { color: var(--muted); font-size: .78rem; }

/* Function tables */
.fn-table { margin: 0 auto; }
.fn-table td, .fn-table th { text-align: center; min-width: 44px; }

/* Parent learning summary */
.learn-summary { margin: 0 0 18px; }
.learn-summary .mini-stats { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); }
.subject-bars { display: grid; gap: 8px; margin: 14px 0; }
.subject-bar { display: grid; grid-template-columns: 150px 1fr; gap: 4px 12px; align-items: center; }
.subject-bar small { grid-column: 2; }
.sbar { height: 14px; border-radius: 99px; background: var(--purple-soft); overflow: hidden; display: flex; }
.sbar .m { background: var(--green); }
.sbar .l { background: var(--blue); opacity: .6; }
.summary-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.plain { list-style: none; padding: 0; margin: 0; }
.plain li { padding: 4px 0; border-bottom: 1px dashed var(--line); }
.badge-row span { font-size: 1.6rem; margin-right: 4px; }
@media (max-width: 560px) { .subject-bar { grid-template-columns: 1fr; } .subject-bar small { grid-column: 1; } }

/* ===== New games ===== */
.games .island-emoji { background: #ffe3ea; }
/* Daily challenge */
.daily-dots { display: flex; gap: 8px; justify-content: center; margin: 0 0 12px; }
.daily-dots i { width: 14px; height: 14px; border-radius: 50%; background: var(--line); }
.daily-dots i.done { background: var(--green); }
.daily-dots i.now { background: var(--yellow); box-shadow: 0 0 0 3px #fff3c4; }
.daily .q-card { box-shadow: none; }

/* Equation balance */
.scale { position: relative; height: 230px; max-width: 560px; margin: 8px auto 0; }
.scale .beam { position: absolute; left: 4%; right: 4%; top: 120px; height: 10px; border-radius: 8px; background: var(--ink); transform: rotate(var(--tilt)); transition: transform .35s ease; display: flex; justify-content: space-between; }
.scale .post { position: absolute; left: 50%; top: 125px; width: 0; height: 0; border-left: 22px solid transparent; border-right: 22px solid transparent; border-bottom: 90px solid #6b6785; transform: translateX(-50%); }
.pan { position: relative; bottom: 0; transform: translateY(-100%) rotate(calc(-1 * var(--tilt))); transform-origin: bottom center; width: 44%; min-height: 40px; display: flex; flex-wrap: wrap-reverse; gap: 4px; justify-content: center; align-content: flex-start; padding: 0 4px 4px; transition: transform .35s ease; }
.weight { border: 0; cursor: pointer; font-family: var(--font-head); font-weight: 800; display: grid; place-items: center; transition: transform .15s, opacity .15s; }
.weight.xbox { width: 38px; height: 38px; border-radius: 8px; background: var(--purple-2); color: #fff; font-size: 1.2rem; box-shadow: 0 3px 0 var(--purple); }
.weight.coin { width: 26px; height: 26px; border-radius: 50%; background: #ffc93c; color: #7a5200; font-size: .8rem; box-shadow: 0 2px 0 #d9a520; }
.weight.pending { opacity: .35; transform: translateY(-8px); outline: 3px dashed var(--coral); }
.weight:focus-visible { outline: 3px solid var(--yellow); }

/* Sequence detective */
.seq-row { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px; font-family: var(--font-head); font-weight: 800; font-size: clamp(1.3rem, 4.5vw, 2rem); margin: 10px 0 16px; }
.seq-cell { min-width: 56px; padding: 4px 10px; border-radius: 14px; background: #f6f4fb; text-align: center; }
.seq-cell.blank { border: 3px dashed var(--purple-2); background: #fff; color: var(--purple-2); }
.seq-cell.blank.now { border-color: var(--coral); animation: wiggle 2s ease-in-out infinite; }
.seq-cell.filled { border-style: solid; border-color: var(--green); background: #e7f8ec; color: #1f7a45; animation: none; }
.seq-comma { color: var(--muted); }

/* Fraction builder */
.fbar { position: relative; display: flex; height: 64px; max-width: 640px; margin: 10px auto 6px; border: 3px solid var(--ink); border-radius: 12px; background: repeating-linear-gradient(45deg, #fff, #fff 8px, #f6f4fb 8px, #f6f4fb 16px); overflow: hidden; }
.fbar.over { border-color: var(--coral); }
.fpiece { display: grid; place-items: center; border-right: 2px solid #fff; color: #fff; font-weight: 800; font-size: .85rem; animation: pop .25s; }
.fgoal { position: absolute; top: -4px; bottom: -4px; width: 4px; margin-left: -2px; background: var(--coral); }
.frac-target { font-family: var(--font-head); font-size: 1.3rem; color: var(--coral); }
.d2 { background: #7c5cff; } .d3 { background: #ef476f; } .d4 { background: #2ec4b6; } .d5 { background: #ffb020; } .d6 { background: #ff7ac6; }
.d8 { background: #4d96ff; } .d10 { background: #3bb273; } .d12 { background: #a855f7; } .d20 { background: #8d6e63; }
.fpiece-btn { color: #fff; box-shadow: 0 4px 0 rgba(0,0,0,.2); }

/* Logic grid */
.clue-list { text-align: left; max-width: 560px; margin: 0 auto 12px; padding-left: 1.2em; }
.clue-list li { margin: 4px 0; }
.logic-grid { border-collapse: collapse; margin: 0 auto; }
.logic-grid th { padding: 6px 8px; font-size: .9rem; }
.logic-grid td { padding: 3px; text-align: center; }
.lg-cell { width: 52px; height: 52px; border-radius: 12px; border: 2px solid var(--line); background: #fff; font-size: 1.5rem; font-weight: 800; cursor: pointer; }
.lg-cell.s1 { color: var(--coral); background: #fff5f5; }
.lg-cell.s2 { color: #fff; background: var(--green); border-color: var(--green); }

/* Area builder */
.ab-grid { display: grid; grid-template-columns: repeat(var(--n), 1fr); gap: 2px; width: min(420px, 90vw); aspect-ratio: 1; margin: 0 auto; background: var(--line); padding: 2px; border-radius: 10px; }
.ab-cell { border: 0; background: #fff; cursor: pointer; padding: 0; border-radius: 3px; }
.ab-cell.on { background: var(--purple-2); }
.ab-cell.anchor { background: var(--coral); }
.ab-cell:focus-visible { outline: 3px solid var(--yellow); z-index: 1; }
@media (max-width: 560px) { .lg-cell { width: 42px; height: 42px; } .weight.xbox { width: 32px; height: 32px; } .weight.coin { width: 22px; height: 22px; } }
@media (prefers-reduced-motion: reduce) { .scale .beam, .pan { transition: none; } .seq-cell.blank.now { animation: none; } }

/* Six subjects: let the tabs wrap instead of overflowing the page */
.subject-tabs { flex-wrap: wrap; row-gap: 12px; }
.subject-tab { white-space: nowrap; padding: .5em 1.2em; }
@media (max-width: 560px) { .subject-tabs { gap: 8px; } .subject-tab { font-size: 1rem; padding: .45em .9em; } }

/* Phone fixes: header and kid bar fit in 375px, islands never push the page wider */
@media (max-width: 480px) {
  .island-map { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .island { min-width: 0; }
  .island-name { overflow-wrap: anywhere; }
  .kid-links { gap: 2px; }
  .kid-link { padding: .35em .5em; }
  .kid-id span { max-width: 70px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .nav { gap: 2px; }
  .nav-link { padding: .4em .45em; }
  .nav .btn-sm { padding: .35em .7em; }
  .nav-pro { display: none; }
  .quest-path::before { left: 29px; }
  .quest-dot { width: 44px; height: 44px; font-size: 1.25rem; }
}
@media (max-width: 480px) {
  .nav-inner { gap: 6px; }
  .brand { font-size: 1.1rem; gap: 6px; min-width: 0; flex-shrink: 1; }
  .brand svg, .brand img { width: 30px; height: 30px; }
}
@media (max-width: 400px) { .site-header .brand span { display: none; } }

/* ===== Skill Library & homepage features ===== */
.lib-tools { display: flex; flex-direction: column; gap: 14px; margin-bottom: 10px; }
.lib-search { width: 100%; max-width: 520px; font: inherit; font-size: 1.05rem; padding: .75em 1.1em; border-radius: 999px; border: 2px solid var(--line); background: #fff; }
.lib-search:focus { outline: 4px solid var(--yellow); border-color: var(--purple-2); }
.lib-subject { margin: 28px 0 12px; font-size: 1.5rem; }
.lib-subject small { font-family: var(--font-body); font-size: .9rem; font-weight: 600; }
.skill-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.skill-card { display: flex; gap: 14px; align-items: flex-start; padding: 16px; border-radius: 20px; background: #fff; border: 2px solid var(--line); text-decoration: none; color: var(--ink); transition: transform .15s, box-shadow .15s, border-color .15s; }
.skill-card:hover, .skill-card:focus-visible { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--purple-2); outline: none; }
.skill-emoji { flex: none; width: 52px; height: 52px; display: grid; place-items: center; font-size: 1.8rem; border-radius: 16px; background: var(--purple-soft); }
.skill-card.reading .skill-emoji { background: #ffe9e9; } .skill-card.world .skill-emoji { background: #e6fbf8; }
.skill-card.games .skill-emoji { background: #ffe3ea; } .skill-card.create .skill-emoji { background: #fff4d6; } .skill-card.algebra .skill-emoji { background: #eaf2ff; }
.skill-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.skill-body b { font-family: var(--font-head); font-size: 1.1rem; }
.skill-body small { color: var(--muted); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.skill-meta { font-size: .78rem; font-weight: 700; color: var(--purple); }
a.chip { text-decoration: none; color: inherit; }
a.chip:hover { outline: 2px solid var(--purple-2); }

.back-link { display: inline-block; margin-bottom: 12px; font-weight: 700; text-decoration: none; }
.skill-hero { display: flex; gap: 24px; align-items: flex-start; padding: 28px; border-radius: 28px; background: linear-gradient(135deg, #efeaff, #fff); margin-bottom: 20px; }
.skill-hero.reading { background: linear-gradient(135deg, #ffe9e9, #fff); } .skill-hero.world { background: linear-gradient(135deg, #e6fbf8, #fff); }
.skill-hero.games { background: linear-gradient(135deg, #ffe3ea, #fff); } .skill-hero.create { background: linear-gradient(135deg, #fff4d6, #fff); } .skill-hero.algebra { background: linear-gradient(135deg, #eaf2ff, #fff); }
.skill-hero-emoji { flex: none; font-size: 3.4rem; width: 96px; height: 96px; display: grid; place-items: center; border-radius: 28px; background: #fff; box-shadow: var(--shadow); }
.skill-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.guide-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; margin-bottom: 16px; }
.guide-card h2 { font-size: 1.25rem; }
.guide-card { margin-bottom: 16px; }
.guide-grid .guide-card { margin-bottom: 0; }
.check-list { list-style: none; padding: 0; margin: 0; }
.check-list li { padding: 6px 0 6px 28px; position: relative; }
.check-list li::before { content: '✓'; position: absolute; left: 0; top: 6px; width: 20px; height: 20px; border-radius: 50%; background: var(--green); color: #fff; font-size: .75rem; font-weight: 800; display: grid; place-items: center; }
.guide-example { font-family: var(--font-head); font-size: 1.15rem; }
.takeaway { background: #fff8e6; border: 2px solid #ffd66b; }

.feature-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.feature-card { display: flex; flex-direction: column; gap: 6px; padding: 22px; border-radius: 24px; background: #fff; border: 2px solid var(--line); text-decoration: none; color: var(--ink); transition: transform .15s, box-shadow .15s; }
.feature-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.feature-card h3 { margin: 0; }
.feature-card p { margin: 0; color: var(--muted); }
.feature-emoji { font-size: 2.2rem; }
.feature-card.big { grid-column: span 4; background: linear-gradient(120deg, #4d96ff, #7c5cff); color: #fff; border: 0; padding: 30px; }
.feature-card.big p { color: #eef; max-width: 640px; font-size: 1.05rem; }
.feature-card.big h3 { font-size: 2rem; }
.feature-kicker { font-weight: 800; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; opacity: .9; }
.feature-link { font-weight: 800; margin-top: 6px; }
@media (max-width: 900px) { .feature-grid { grid-template-columns: repeat(2, 1fr); } .feature-card.big { grid-column: span 2; } }
@media (max-width: 560px) { .feature-grid { grid-template-columns: 1fr; } .feature-card.big { grid-column: span 1; } .skill-hero { flex-direction: column; padding: 20px; } }
.skill-hero > div { min-width: 0; }
.skill-hero .lead { white-space: normal; overflow-wrap: anywhere; }
@media (min-width: 900px) { .guide-grid { grid-template-columns: repeat(2, 1fr); } }
