/* ymym — hub styles (module F3). Builds on the tokens of app.css (F1). Kid-friendly: targets ≥ 48 CSS px, Nunito,
   bright forest palette, landscape-first tablet layout; a 640×360 phone stays usable (see the media queries). */

:root {
  --c-card: #ffffff;
  --c-line: #e3e8dc;
  --c-soft: #eef6e6;
  --c-sky: #dff3ff;
  --c-sun: #fff3c4;
  --c-berry: #d81b60;
  --c-leaf: #43a047;
  --c-wood: #8d6e63;
  --topbar-h: 64px;
  --stage-pad: 16px;
}

/* ---------- layout ---------- */

#app { z-index: 3; background: var(--c-bg); }
#app.no-nav { --topbar-h: 0px; }
body.playing #app { display: none; }

.stage {
  min-height: 100%;
  padding: 10px var(--stage-pad) 24px;
  max-width: 1100px;
  margin: 0 auto;
}
.screen { display: block; animation: screen-in 0.2s ease; }
@keyframes screen-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.card {
  background: var(--c-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin: 0 0 14px;
}
.empty { color: var(--c-muted); text-align: center; font-size: 18px; padding: 24px 0; }
.empty-card { text-align: center; }

.screen-header {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  margin: 0 0 12px;
}
.screen-title { margin: 0; font-size: 26px; font-weight: 900; color: var(--c-primary); flex: 1 1 auto; line-height: 1.2; }
.screen-header-right { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 18px; }
.screen-back { font-size: 30px; line-height: 1; }

.screen-loading, .screen-error { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 40px 16px; text-align: center; }
.screen-error-icon { display: flex; color: var(--c-muted); }
.screen-error-text { font-size: 20px; font-weight: 700; margin: 0; }

.spinner {
  width: 40px; height: 40px; border-radius: 50%;
  border: 5px solid var(--c-line); border-top-color: var(--c-accent);
  animation: spin 0.9s linear infinite;
}
.spinner-inline { display: inline-block; width: 26px; height: 26px; border-width: 4px; vertical-align: middle; }

.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 13px; font-weight: 800; background: var(--c-soft); color: var(--c-primary); white-space: nowrap;
}
.badge-kind { background: var(--c-sky); color: #0d47a1; }
.badge-first { background: var(--c-sun); color: #6d4c00; font-size: 16px; padding: 6px 14px; }
.badge-new { background: var(--c-berry); color: #fff; }
.badge-skill-fluent { background: #ffe082; color: #5d4000; }
.badge-skill-knows { background: #c8e6c9; color: #1b5e20; }
.badge-skill-learning { background: var(--c-sky); color: #0d47a1; }
.badge-skill-new { background: #eceff1; color: #546e7a; }

/* ---------- boot splash ---------- */

.boot-splash {
  min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  padding: 24px; text-align: center;
}
.boot-logo { font-size: 56px; font-weight: 900; color: var(--c-primary); letter-spacing: 0.04em; }
.boot-text { font-size: 20px; font-weight: 700; margin: 0; }
.boot-icon { display: flex; color: var(--c-primary); }
.boot-old h1 { margin: 0; color: var(--c-primary); }
.boot-old p { max-width: 520px; font-size: 18px; }
.boot-small { font-size: 12px; color: var(--c-muted); }

/* ---------- buttons (extends .btn of app.css) ---------- */

.btn-big { min-height: 60px; font-size: 22px; padding: 12px 30px; }
.btn-small { min-height: 40px; font-size: 15px; padding: 6px 14px; }
.btn-ghost { background: transparent; box-shadow: none; color: var(--c-primary-2); }
.btn-ghost:active { box-shadow: none; }
.btn-danger { background: var(--c-bad); color: #fff; }
.btn-icon-only { width: 52px; min-width: 52px; height: 52px; padding: 0; border-radius: 50%; font-size: 24px; }
.btn-icon { display: inline-flex; align-items: center; justify-content: center; font-size: 1.15em; line-height: 1; }
.btn-icon .icon { display: block; }
.btn.busy { position: relative; color: transparent !important; }
.btn.busy::after {
  content: ''; position: absolute; left: 50%; top: 50%; width: 22px; height: 22px; margin: -11px 0 0 -11px;
  border-radius: 50%; border: 3px solid rgba(0,0,0,0.15); border-top-color: var(--c-primary); animation: spin 0.8s linear infinite;
}
.btn:focus-visible { outline: 3px solid var(--c-info); outline-offset: 2px; }

/* ---------- top bar ---------- */

.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px;
  min-height: var(--topbar-h);
  padding: 6px 12px 6px 8px;
  background: rgba(246, 243, 231, 0.96);
  backdrop-filter: blur(4px);
  border-bottom: 2px solid var(--c-line);
}
.topbar-me { display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 2px 10px 2px 2px; border-radius: 999px; text-decoration: none; color: var(--c-text); font-weight: 800; }
.topbar-me:active { background: var(--c-soft); }
.topbar-avatar { flex: 0 0 auto; }
.topbar-name { font-size: 17px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-stats { display: flex; gap: 6px; flex: 1 1 auto; justify-content: center; flex-wrap: wrap; }
.stat { display: inline-flex; align-items: center; gap: 5px; padding: 6px 12px; border-radius: 999px; background: #fff; box-shadow: 0 1px 4px var(--c-shadow); font-weight: 800; font-size: 16px; white-space: nowrap; }
.stat-icon { line-height: 1; }
.stat-stars .stat-icon { color: var(--c-accent-2); }
.stat-coins .stat-icon { color: var(--c-accent); }
.stat-xp .stat-icon { color: var(--c-info); }
.topbar-links { display: flex; gap: 4px; }
.topbar-link {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  min-width: 56px; min-height: 52px; padding: 4px 8px; border-radius: 14px; text-decoration: none; color: var(--c-muted); font-weight: 800; font-size: 11px;
}
.topbar-link.active { background: var(--c-primary); color: #fff; }
.topbar-link:active { background: var(--c-soft); }
.topbar-icon { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; line-height: 1; }
.topbar-icon .icon { display: block; }

/* ---------- toasts ---------- */

.hub-toasts {
  position: fixed; top: calc(10px + var(--safe-top)); left: 50%; transform: translateX(-50%);
  z-index: 200; display: flex; flex-direction: column; align-items: center; gap: 8px; max-width: min(94vw, 640px); pointer-events: none;
}
.hub-toast {
  display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-radius: var(--radius);
  background: rgba(35, 51, 31, 0.94); color: #fff; font-size: 17px; font-weight: 700; box-shadow: var(--shadow);
  animation: toast-in 0.25s ease; pointer-events: auto;
}
.hub-toast.ok { background: var(--c-ok); }
.hub-toast.bad { background: var(--c-bad); }
.hub-toast.out { animation: toast-out 0.25s ease forwards; }
.hub-toast-action { min-height: 40px; padding: 4px 14px; border: 0; border-radius: 999px; background: #fff; color: var(--c-text); font-weight: 800; }

/* ---------- modal ---------- */

.modal-backdrop {
  position: fixed; inset: 0; z-index: 150; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: rgba(35, 51, 31, 0.55); animation: toast-in 0.15s ease;
}
.modal-card {
  background: var(--c-bg-2); border-radius: var(--radius); box-shadow: var(--shadow);
  width: min(96vw, 560px); max-height: 92vh; overflow: auto; padding: 22px 22px 18px;
}
.modal-big { width: min(96vw, 760px); }
.modal-title { margin: 0 0 12px; font-size: 24px; color: var(--c-primary); }
.modal-body { font-size: 18px; }
.modal-body p { margin: 0 0 12px; }
.modal-buttons { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.modal-card.modal-recovery { background: transparent; box-shadow: none; padding: 0; }
body.modal-open .stage { pointer-events: none; }

/* ---------- stars ---------- */

.stars { display: inline-flex; gap: 4px; }
.star { color: #d7d7d7; font-size: 24px; line-height: 1; transition: color 0.2s ease, transform 0.2s ease; text-shadow: 0 1px 0 rgba(0,0,0,0.08); }
.star.on { color: var(--c-accent); }
.star.pop { animation: star-pop 0.45s ease; }
.stars-small .star { font-size: 20px; }
.stars-big { gap: 10px; }
.stars-big .star { font-size: 64px; }
@keyframes star-pop { 0% { transform: scale(0.3) rotate(-30deg); } 60% { transform: scale(1.35) rotate(8deg); } 100% { transform: scale(1) rotate(0); } }

/* ---------- progress bar ---------- */

.pbar { display: flex; align-items: center; gap: 10px; }
.pbar-track { flex: 1 1 auto; height: 14px; border-radius: 999px; background: var(--c-line); overflow: hidden; }
.pbar-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--c-ok), var(--c-accent)); transition: width 0.4s ease; }
.pbar-small .pbar-track { height: 10px; }
.pbar-label { font-size: 14px; font-weight: 800; color: var(--c-muted); min-width: 42px; text-align: right; }
.pbar-fluent .pbar-fill { background: linear-gradient(90deg, #ffb300, #ffd54f); }
.pbar-knows .pbar-fill { background: var(--c-ok); }
.pbar-learning .pbar-fill { background: var(--c-info); }
.pbar-new .pbar-fill { background: #b0bec5; }

/* ---------- avatar ---------- */

.avatar { position: relative; display: inline-block; border-radius: 50%; overflow: hidden; background: var(--c-soft); flex: 0 0 auto; }
.avatar-layer { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.avatar-placeholder { display: inline-block; width: 44px; height: 44px; border-radius: 50%; background: var(--c-soft); }
.avatar-picker { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; justify-content: center; }
.avatar-preview { flex: 0 0 auto; }
.avatar-rows { flex: 1 1 260px; display: flex; flex-direction: column; gap: 6px; }
.avatar-row { display: flex; align-items: center; gap: 8px; min-height: 52px; }
.avatar-row-label { flex: 0 0 96px; font-weight: 800; }
.avatar-row-counter { flex: 1 1 auto; text-align: center; font-weight: 800; color: var(--c-muted); }
.avatar-arrow { width: 48px; min-width: 48px; height: 48px; font-size: 28px; }
.avatar-swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.avatar-swatch { width: 44px; height: 44px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 1px 4px var(--c-shadow); padding: 0; }
.avatar-swatch.on { outline: 4px solid var(--c-primary); outline-offset: 1px; }
.avatar-row-random { justify-content: flex-end; }

/* ---------- onboarding ---------- */

.screen-onboarding .stage, .onb { max-width: 820px; margin: 0 auto; }
.onb { display: flex; flex-direction: column; gap: 10px; padding: 8px 0; }
.onb-progress { display: flex; align-items: center; justify-content: space-between; color: var(--c-muted); font-weight: 800; }
.onb-dots { display: flex; gap: 6px; }
.onb-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--c-line); }
.onb-dot.on { background: var(--c-primary); }
.onb-card { padding: 22px 24px; }
.onb-title { margin: 0 0 4px; font-size: 34px; color: var(--c-primary); }
.onb-sub { margin: 0 0 14px; font-size: 18px; color: var(--c-muted); }
.onb-q { margin: 0 0 8px; font-size: 24px; }
.onb-hint { margin: 6px 0 12px; color: var(--c-muted); font-size: 16px; }
.onb-nickname { display: flex; align-items: center; justify-content: center; min-height: 84px; margin: 6px 0; padding: 12px 20px; border-radius: var(--radius); background: var(--c-sun); font-size: 34px; font-weight: 900; text-align: center; color: #5d4000; }
.onb-row { display: flex; justify-content: center; gap: 10px; }
.onb-nav { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 18px; }
.onb-nav > .btn:only-child { margin-left: auto; }
.onb-restore-link { margin-top: 6px; text-align: center; }

.grade-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.grade-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 72px; border: 3px solid var(--c-line); border-radius: var(--radius); background: #fff; font-weight: 900; }
.grade-btn .grade-num { font-size: 28px; color: var(--c-primary); }
.grade-btn .grade-lbl { font-size: 13px; color: var(--c-muted); }
.grade-btn.on { border-color: var(--c-primary); background: var(--c-soft); }
.grade-btn.soon { opacity: 0.45; cursor: default; }

.onb-notice { max-height: 40vh; overflow: auto; padding: 12px 16px; border-radius: var(--radius-s); background: var(--c-soft); font-size: 18px; line-height: 1.45; }
.notice-h { margin: 4px 0 8px; font-size: 20px; color: var(--c-primary); }
.notice-p { margin: 0 0 10px; }
.notice-list { margin: 0 0 10px; padding-left: 22px; }

.recovery-card { text-align: center; padding: 28px 24px; max-width: 640px; margin: 0 auto; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.recovery-icon { display: flex; color: var(--c-accent-2); }
.recovery-title { margin: 0; font-size: 30px; color: var(--c-primary); }
.recovery-text { margin: 0; font-size: 20px; }
.recovery-code { font-family: 'Nunito', monospace; font-size: 40px; font-weight: 900; letter-spacing: 0.08em; padding: 14px 22px; border-radius: var(--radius); background: var(--c-sun); color: #5d4000; user-select: text; -webkit-user-select: text; }
.recovery-warn { margin: 0; color: var(--c-muted); font-size: 15px; }
.recovery-done { min-width: 260px; margin-top: 8px; }

.code-input { width: 100%; min-height: 60px; padding: 8px 14px; border: 3px solid var(--c-line); border-radius: var(--radius-s); font-size: 30px; font-weight: 900; letter-spacing: 0.12em; text-align: center; text-transform: uppercase; }
.code-input:focus { outline: none; border-color: var(--c-primary); }
.form-error { margin: 8px 0 0; color: var(--c-bad); font-weight: 800; }

/* ---------- world map ---------- */

.map-stars { display: inline-flex; align-items: center; gap: 6px; font-size: 20px; }
.map-stars .stat-icon { color: var(--c-accent-2); }
.map-world-select { min-height: 48px; padding: 6px 12px; border-radius: 999px; border: 2px solid var(--c-line); background: #fff; font-weight: 800; }
.map-wrap { width: 100%; max-width: calc((100vh - var(--topbar-h) - 150px) * 16 / 9); margin: 0 auto; }
.map-frame { position: relative; width: 100%; padding-top: 56.25%; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); background: #7bc96f; }
.map-nobg { background: radial-gradient(circle at 30% 30%, #a5d86a, #4f9e44); }
.map-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.map-markers { position: absolute; inset: 0; }
.map-marker {
  position: absolute; transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-width: 64px; min-height: 64px; padding: 4px 10px; border: 3px solid #fff; border-radius: 18px;
  background: rgba(255, 255, 255, 0.92); box-shadow: var(--shadow); font-weight: 900; color: var(--c-text);
  animation: marker-in 0.4s ease;
}
.map-marker:active { transform: translate(-50%, -50%) scale(0.96); }
.map-marker-icon { display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; line-height: 1; color: var(--c-primary); }
.map-marker-icon .icon { display: block; }
.map-marker-title { font-size: 15px; white-space: nowrap; }
.map-marker-stars { display: inline-flex; align-items: center; gap: 2px; font-size: 13px; color: var(--c-accent-2); }
/* state is never colour-only: an open marker has a green ring, a locked one a dashed grey ring + a lock badge */
.map-marker-badge {
  position: absolute; top: -8px; right: -8px;
  display: flex; align-items: center; justify-content: center; width: 24px; height: 24px;
  border-radius: 50%; border: 2px solid #fff; background: var(--c-muted); color: #fff;
}
.map-marker.open { border-color: var(--c-ok); }
.map-marker.locked { background: rgba(234, 234, 228, 0.94); color: var(--c-muted); border-style: dashed; border-color: rgba(107, 122, 99, 0.6); }
.map-marker.locked .map-marker-icon { color: var(--c-muted); }
.map-marker.locked .map-marker-stars { color: var(--c-muted); }
.map-marker.completed { border-color: var(--c-accent); border-style: solid; }
.map-marker.completed .map-marker-badge { background: var(--c-ok); }
@keyframes marker-in { from { opacity: 0; transform: translate(-50%, -30%); } to { opacity: 1; transform: translate(-50%, -50%); } }
.map-caption { text-align: center; color: var(--c-muted); font-weight: 800; margin: 10px 0 0; }
.locked-why { margin: 0 0 6px; font-weight: 800; }
.locked-list { margin: 0; padding-left: 22px; font-size: 17px; }
.locked-list li { margin: 4px 0; }
.locked-generic { margin: 0; color: var(--c-muted); }

/* ---------- level select ---------- */

.level-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.level-card { display: flex; flex-direction: column; gap: 10px; margin: 0; }
.level-card.locked { background: #f4f4f0; }
.level-card-top { display: flex; align-items: flex-start; gap: 12px; }
.level-icon { display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; line-height: 1; flex: 0 0 auto; color: var(--c-primary); }
.level-card.locked .level-icon { color: var(--c-muted); }
.level-card-text { flex: 1 1 auto; min-width: 0; }
.level-title { margin: 0 0 4px; font-size: 20px; line-height: 1.2; }
.level-meta { margin: 0; color: var(--c-muted); font-size: 15px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.level-locked { padding: 10px 12px; border-radius: var(--radius-s); background: #fff; font-size: 15px; }
.level-weak { margin: 0; color: var(--c-bad); font-weight: 700; }
.level-plays { margin: 0; color: var(--c-muted); font-size: 14px; }
.level-start { align-self: stretch; }

/* ---------- results ---------- */

.results-card { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 24px; }
.results-title { margin: 0; font-size: 34px; color: var(--c-primary); }
.results-level { margin: 0; color: var(--c-muted); font-weight: 800; }
.results-warn { margin: 0; color: var(--c-bad); font-weight: 800; max-width: 520px; }
.results-count { margin: 0; font-weight: 800; font-size: 18px; }
.results-rewards { display: flex; gap: 24px; justify-content: center; margin: 6px 0; }
.results-reward { display: flex; flex-direction: column; align-items: center; min-width: 120px; padding: 12px 18px; border-radius: var(--radius); background: var(--c-soft); }
.results-reward-icon { font-size: 28px; line-height: 1; }
.results-first { display: inline-flex; align-items: center; gap: 4px; }
.results-first-icon { display: inline-flex; color: #b26a00; }
.results-xp .results-reward-icon { color: var(--c-info); }
.results-coins .results-reward-icon { color: var(--c-accent); }
.results-num { font-size: 34px; font-weight: 900; }
.results-reward-label { color: var(--c-muted); font-weight: 800; font-size: 14px; }
.results-first { margin: 0; }
.results-ach, .results-unlocked { width: 100%; max-width: 520px; text-align: left; }
.results-ach h3, .results-unlocked h3 { margin: 8px 0 4px; font-size: 18px; }
.results-list { list-style: none; margin: 0; padding: 0; }
.results-list li { display: flex; align-items: center; gap: 8px; padding: 6px 0; font-weight: 700; }
.ach-mini { display: inline-flex; align-items: center; color: var(--c-accent-2); }
.results-buttons { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; margin-top: 10px; }

.review-card { padding: 18px 20px; }
.review-title { margin: 0 0 6px; font-size: 24px; color: var(--c-primary); }
.review-none { margin: 0; color: var(--c-ok); font-weight: 800; font-size: 18px; }
.review-hint { margin: 0 0 10px; color: var(--c-muted); }
.review-list { margin: 0; padding-left: 26px; }
.review-item { padding: 10px 0; border-bottom: 1px solid var(--c-line); }
.review-item:last-child { border-bottom: 0; }
.review-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.review-icon { display: inline-flex; align-items: center; color: var(--c-muted); }
.outcome-clean .review-icon { color: var(--c-ok); }
.outcome-eventually_correct .review-icon { color: var(--c-accent-2); }
.outcome-failed .review-icon { color: var(--c-bad); }
.review-prompt { flex: 1 1 auto; font-size: 18px; font-weight: 800; }
.review-outcome { font-size: 13px; font-weight: 800; padding: 2px 10px; border-radius: 999px; background: var(--c-soft); color: var(--c-muted); }
.outcome-clean .review-outcome { background: #c8e6c9; color: #1b5e20; }
.outcome-failed .review-outcome { background: #ffcdd2; color: #b71c1c; }
.review-answer, .review-expl, .review-rule, .review-skill { margin: 6px 0 0; font-size: 17px; }
.review-answer b { color: var(--c-ok); }
.review-skill { color: var(--c-muted); font-size: 14px; }

/* ---------- profile ---------- */

.profile-card { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.profile-me { flex: 1 1 200px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.profile-nick { margin: 0; font-size: 28px; color: var(--c-primary); }
.profile-grade { margin: 0; color: var(--c-muted); font-weight: 800; }
.profile-stats { display: flex; gap: 10px; flex-wrap: wrap; flex: 1 1 100%; }
.profile-stat { flex: 1 1 100px; display: flex; flex-direction: column; align-items: center; padding: 10px; border-radius: var(--radius-s); background: var(--c-soft); }
.profile-stat-icon { display: flex; align-items: center; justify-content: center; min-height: 26px; font-size: 22px; line-height: 1; }
.profile-stat-level .profile-stat-icon { color: var(--c-accent-2); }
.profile-stat-xp .profile-stat-icon { color: var(--c-info); }
.profile-stat-coins .profile-stat-icon { color: var(--c-accent); }
.profile-stat-streak .profile-stat-icon { color: #ef6c00; }
.profile-stat-value { font-size: 24px; font-weight: 900; }
.profile-stat-label { font-size: 13px; color: var(--c-muted); font-weight: 800; }
.grade-question { background: var(--c-sun); }
.grade-question-text { margin: 0 0 10px; font-size: 20px; font-weight: 800; }
.grade-question-buttons { display: flex; gap: 10px; flex-wrap: wrap; }
.settings-card h2 { margin: 0 0 6px; font-size: 22px; }
.settings-row { display: flex; align-items: center; gap: 12px; min-height: 60px; border-top: 1px solid var(--c-line); }
.settings-row:first-of-type { border-top: 0; }
.settings-icon { display: flex; align-items: center; justify-content: center; width: 32px; flex: 0 0 32px; color: var(--c-primary-2); }
.settings-label { flex: 1 1 auto; font-size: 18px; font-weight: 800; }
/* toggles and segmented buttons are tap targets too: ≥ 48 CSS px in both dimensions (ROADMAP M2; E1 measured 74×42 / ×44) */
.switch { position: relative; width: 84px; height: 48px; border: 0; border-radius: 999px; background: #cfd8dc; padding: 0; transition: background 0.2s ease; }
.switch.on { background: var(--c-ok); }
.switch-knob { position: absolute; top: 5px; left: 5px; width: 38px; height: 38px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px var(--c-shadow); transition: transform 0.2s ease; }
.switch.on .switch-knob { transform: translateX(36px); }
.seg { display: inline-flex; border-radius: 999px; background: var(--c-line); padding: 3px; }
.seg-btn { min-height: 48px; padding: 6px 16px; border: 0; border-radius: 999px; background: transparent; font-weight: 800; color: var(--c-muted); }
.seg-btn.on { background: #fff; color: var(--c-primary); box-shadow: 0 1px 4px var(--c-shadow); }
.profile-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.modal-card.modal-avatar { width: min(96vw, 720px); }

/* ---------- knowledge book ---------- */

.book-summary { margin: 0 0 10px; font-weight: 800; color: var(--c-muted); }
.book-subject-title { display: flex; align-items: center; gap: 10px; margin: 0 0 8px; font-size: 22px; color: var(--c-primary); }
.book-subject-icon { display: flex; align-items: center; }
.book-review-due { display: inline-flex; align-items: center; color: var(--c-accent-2); white-space: nowrap; }
.book-topic { border-top: 1px solid var(--c-line); }
.book-topic-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 52px; cursor: pointer; font-size: 18px; font-weight: 800; list-style: none; }
.book-topic-head::-webkit-details-marker { display: none; }
.book-topic-head::before { content: '▸'; margin-right: 8px; color: var(--c-muted); }
.book-topic[open] > .book-topic-head::before { content: '▾'; }
.book-topic-title { flex: 1 1 auto; }
.book-topic-count { color: var(--c-muted); font-size: 15px; }
.book-skills { list-style: none; margin: 0 0 10px; padding: 0 0 0 8px; display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 8px 18px; }
.book-skill { padding: 8px 0; }
.book-skill-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.book-skill-title { font-weight: 800; font-size: 16px; }
.book-skill-extra { margin: 4px 0 0; font-size: 14px; color: var(--c-muted); font-weight: 700; }

/* ---------- achievements ---------- */

.ach-summary { margin: 0 0 10px; font-weight: 800; color: var(--c-muted); }
.ach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.ach-card { position: relative; margin: 0; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.ach-card.locked { opacity: 0.7; background: #f4f4f0; }
.ach-card.earned { background: linear-gradient(160deg, #fff8e1, #fff); border: 2px solid var(--c-accent); }
.ach-card .badge-new { position: absolute; top: 10px; right: 10px; }
.ach-icon { display: flex; align-items: center; justify-content: center; min-height: 46px; color: var(--c-accent-2); }
.ach-card.locked .ach-icon { color: var(--c-muted); opacity: 0.75; }
.ach-reward { display: flex; align-items: center; justify-content: center; gap: 5px; }
.ach-reward-gift { display: inline-flex; align-items: center; }
.ach-title { margin: 4px 0 0; font-size: 17px; }
.ach-desc { margin: 0; font-size: 14px; color: var(--c-muted); }
.ach-reward { margin: 0; font-size: 13px; font-weight: 800; color: var(--c-accent-2); }
.ach-state { margin: 4px 0 0; font-size: 13px; font-weight: 800; color: var(--c-muted); }
.ach-card.earned .ach-state { color: var(--c-ok); }

/* ---------- shop ---------- */

.shop-coins { display: inline-flex; align-items: center; gap: 6px; font-size: 22px; }
.shop-coins .stat-icon { color: var(--c-accent); }
.shop-kind { margin: 8px 0 8px; font-size: 20px; color: var(--c-primary); }
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-bottom: 8px; }
.shop-card { margin: 0; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.shop-card.owned { border: 2px solid var(--c-ok); }
.shop-card.equipped { background: #e8f5e9; }
.shop-card.locked { background: #f4f4f0; }
.shop-icon { position: relative; display: flex; align-items: center; justify-content: center; min-height: 46px; color: var(--c-primary); }
.shop-card.locked .shop-icon { color: var(--c-muted); }
.shop-card.equipped .shop-icon { color: var(--c-ok); }
.shop-icon-badge {
  position: absolute; right: -4px; bottom: -2px;
  display: flex; align-items: center; justify-content: center; width: 22px; height: 22px;
  border-radius: 50%; border: 2px solid #fff; background: var(--c-muted); color: #fff;
}
.shop-title { margin: 2px 0 0; font-size: 17px; }
.shop-price { margin: 0; font-weight: 900; color: var(--c-accent-2); }
.shop-price.short { color: var(--c-muted); }
.shop-state { margin: 0; font-weight: 800; color: var(--c-ok); font-size: 14px; }
.shop-card.locked .shop-state { color: var(--c-muted); }
.shop-card .locked-list { text-align: left; font-size: 14px; }

/* ---------- parent stub ---------- */

.soon-card { text-align: center; padding: 36px 20px; }
.soon-icon { display: flex; justify-content: center; color: var(--c-primary); }
.soon-card h2 { margin: 6px 0; color: var(--c-primary); }

/* ---------- orientation hint on the hub while playing (the engine draws .orient-hint in #layer) ---------- */

body.playing #layer { display: block; }

/* ---------- small screens: phone 640×360 landscape, narrow portrait ---------- */

@media (max-width: 720px), (max-height: 420px) {
  :root { --topbar-h: 52px; --stage-pad: 10px; }
  .topbar { gap: 6px; padding: 4px 8px; }
  .topbar-name, .topbar-label { display: none; }
  .topbar-link { min-width: 48px; min-height: 48px; }
  .stat { padding: 4px 10px; font-size: 14px; }
  .stat-xp { display: none; }
  .card { padding: 12px 14px; }
  .screen-title { font-size: 21px; }
  .btn-big { min-height: 52px; font-size: 18px; padding: 8px 20px; }
  .onb-title { font-size: 26px; }
  .onb-nickname { font-size: 26px; min-height: 64px; }
  .onb-notice { max-height: 34vh; font-size: 16px; }
  .avatar-picker { gap: 12px; }
  .recovery-code { font-size: 28px; }
  .results-title { font-size: 26px; }
  .stars-big .star { font-size: 44px; }
  .results-num { font-size: 26px; }
  .map-marker { min-width: 56px; min-height: 56px; padding: 2px 8px; }
  .map-marker-icon { width: 26px; height: 26px; }
  .map-marker-icon .icon { width: 26px; height: 26px; }
  .map-marker-badge { width: 20px; height: 20px; top: -6px; right: -6px; }
  .map-marker-title { font-size: 12px; }
  .ach-icon .icon, .shop-icon .icon { width: 38px; height: 38px; }
  .grade-grid { grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); }
  .grade-btn { min-height: 60px; }
}

@media (max-height: 420px) {
  .map-wrap { max-width: calc((100vh - var(--topbar-h) - 90px) * 16 / 9); }
  .map-caption { display: none; }
  .onb-notice { max-height: 30vh; }
  .modal-card { max-height: 96vh; padding: 14px 16px; }
}

@media (orientation: portrait) {
  .avatar-picker { flex-direction: column; align-items: center; }
  .profile-card { justify-content: center; text-align: center; }
  .profile-me { align-items: center; }
}
