:root {
  color-scheme: light;
  --forest: #173f35;
  --forest-2: #24594b;
  --sage: #78968c;
  --mint: #dce9d8;
  --cream: #f8f3e6;
  --paper: #fffef8;
  --sun: #f2bd57;
  --coral: #db746d;
  --ink: #17352f;
  --muted: #60736e;
  --line: #ccd9d2;
  --shadow: 0 14px 35px rgba(25, 57, 49, .13);
  --wise-wolf-viewport-height: 100vh;
  font-family: ui-rounded, "SF Pro Rounded", "Avenir Next", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { width: 100%; max-width: 100%; min-height: 100%; overflow-x: hidden; }

body {
  min-height: var(--wise-wolf-viewport-height);
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 5% 5%, rgba(242, 189, 87, .18), transparent 23rem),
    linear-gradient(145deg, #eef4e8 0%, var(--cream) 55%, #e7f0e7 100%);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

button, input { font: inherit; }
select { max-width: 100%; }

button {
  min-height: 48px;
  min-width: 48px;
  border: 0;
  cursor: pointer;
  touch-action: manipulation;
}

button:focus-visible, input:focus-visible, canvas:focus-visible {
  outline: 4px solid rgba(242, 189, 87, .7);
  outline-offset: 2px;
}

button:disabled { cursor: default; opacity: .42; }
.hidden { display: none !important; }

textarea, select { font: inherit; }
textarea:focus-visible, select:focus-visible { outline: 3px solid var(--sun); outline-offset: 3px; }
.mode-grid .demand-mode { background: #dce9d8; border-color: #8db29a; }
.demand-setup { width: min(960px, 100%); margin: 0 auto; padding: 28px max(20px, env(safe-area-inset-left)); }
.demand-intro { max-width: 700px; margin: 24px 0; }
.demand-intro h2 { margin: 8px 0; font-size: clamp(28px, 5vw, 42px); letter-spacing: -.03em; }
.demand-intro p { line-height: 1.6; }
#demandStudent { font-weight: 800; }
.demand-form { display: grid; gap: 14px; padding: clamp(18px, 4vw, 30px); border: 1px solid var(--line); border-radius: 22px; background: var(--paper); box-shadow: var(--shadow); }
.demand-form label { font-weight: 800; }
.demand-form label small { font-weight: 500; color: var(--muted); }
.demand-form textarea, .demand-form select { width: 100%; padding: 14px; border: 1px solid #a0b3a7; border-radius: 12px; color: var(--ink); background: white; line-height: 1.6; }
.demand-form textarea { resize: vertical; font-size: 17px; }
.demand-examples { display: flex; flex-wrap: wrap; gap: 8px; }
.demand-examples button, .demand-session-actions button:not(.check-button) { padding: 10px 16px; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); background: #edf3e8; }
.demand-note { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.demand-status { margin: 0; color: #8b4139; line-height: 1.5; }
.demand-status:empty { display: none; }
.demand-history { margin-top: 32px; }
.demand-history-item { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 15px 0; border-top: 1px solid var(--line); }
.demand-history-item p { margin: 5px 0; color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.demand-history-item button { flex-shrink: 0; border-radius: 12px; padding: 10px 16px; background: var(--forest); color: white; }
.demand-hud { margin-bottom: 18px; padding: 18px 22px; border: 1px solid #bad0bc; border-radius: 18px; background: #e6efdc; display: flex; justify-content: space-between; align-items: center; gap: 18px; }
.demand-hud h2 { font-size: 22px; margin: 5px 0; }
.demand-hud p { margin: 5px 0; }
.demand-session-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.on-demand-active .lesson-selector, .on-demand-active .mastery-chip, .on-demand-active #harderButton, .on-demand-active #easierButton, .on-demand-active #newProblemButton { display: none; }
.teaching-board { position: absolute; z-index: 2; inset: 0; padding: 16px 18px; overflow: auto; background: #fffef3; display: flex; flex-direction: column; justify-content: flex-start; align-items: center; }
.teaching-board svg { width: 100%; max-width: 700px; flex: 0 0 auto; height: clamp(200px, 24vw, 290px); }
.canvas-wrap.lesson-visible { min-height: 360px !important; }
.teaching-caption { margin: 0 0 10px; width: 100%; font-size: clamp(15px, 1.5vw, 19px); line-height: 1.5; color: var(--forest); font-weight: 700; }
.teaching-equation { margin: auto 0; padding: 8px 10px; max-width: 100%; font-size: clamp(21px, 3vw, 34px); font-weight: 850; text-align: center; overflow-wrap: anywhere; color: var(--forest); }
.teaching-controls { display: flex; gap: 7px; align-items: center; padding: 10px 14px 0; flex-wrap: wrap; }
.teaching-controls button { min-height: 44px; border-radius: 10px; padding: 8px 12px; font-size: 13px; font-weight: 800; background: #dce9d8; color: var(--forest); }
.teaching-controls span { font-size: 12px; color: white; margin-left: auto; }
.board-mark { animation: draw-board-mark .38s ease-out both; }
@keyframes draw-board-mark { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) { .board-mark { animation: none; } }
@media (max-width: 700px) { .demand-hud { align-items: flex-start; flex-direction: column; } .demand-session-actions { justify-content: flex-start; } .teaching-controls span { width: 100%; text-align: center; } }

.app-header {
  min-height: 78px;
  padding: calc(12px + env(safe-area-inset-top)) max(22px, env(safe-area-inset-right)) 12px max(22px, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  color: #fff;
  background: var(--forest);
  box-shadow: 0 7px 24px rgba(23, 63, 53, .25);
}

.brand { display: flex; align-items: center; gap: 13px; min-width: 0; }
.brand-mark, .install-wolf {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  border-radius: 16px 16px 19px 19px;
  color: var(--forest);
  background: var(--sun);
  font-size: 25px;
  font-weight: 900;
  clip-path: polygon(13% 12%, 35% 22%, 50% 6%, 65% 22%, 87% 12%, 82% 83%, 50% 100%, 18% 83%);
}
.eyebrow { margin: 0 0 2px; color: #cfe1d9; font-size: 11px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
h1 { margin: 0; font-size: clamp(18px, 2.6vw, 28px); line-height: 1.05; letter-spacing: -.03em; }
.header-actions { display: flex; align-items: center; gap: 9px; }
.server-pill { min-height: 44px; display: flex; align-items: center; gap: 9px; padding: 0 14px; border: 1px solid rgba(255,255,255,.17); border-radius: 99px; background: rgba(255,255,255,.09); font-size: 13px; font-weight: 750; white-space: nowrap; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--sun); box-shadow: 0 0 0 4px rgba(242,189,87,.16); }
.status-dot.online { background: #7fe092; box-shadow: 0 0 0 4px rgba(127,224,146,.16); }
.status-dot.offline { background: var(--coral); box-shadow: 0 0 0 4px rgba(219,116,109,.18); }
.icon-button { display: grid; place-items: center; border-radius: 14px; color: #fff; background: rgba(255,255,255,.1); }
.update-button { min-height: 44px; padding: 0 14px; border-radius: 13px; color: var(--forest); background: var(--sun); font-size: 12px; font-weight: 900; white-space: nowrap; }
.icon-button svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.app-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: clamp(14px, 2vw, 26px) max(clamp(14px, 2vw, 26px), env(safe-area-inset-right)) calc(22px + env(safe-area-inset-bottom)) max(clamp(14px, 2vw, 26px), env(safe-area-inset-left));
}

.home-screen {
  width: min(1320px, 100%);
  min-height: calc(100vh - 82px);
  margin: 0 auto;
  padding: clamp(28px, 5vw, 76px) max(clamp(18px, 4vw, 52px), env(safe-area-inset-right)) calc(38px + env(safe-area-inset-bottom)) max(clamp(18px, 4vw, 52px), env(safe-area-inset-left));
  display: grid;
  grid-template-columns: minmax(290px, .85fr) minmax(460px, 1.15fr);
  align-items: center;
  gap: clamp(30px, 6vw, 90px);
}
.home-kicker { margin: 0 0 12px; color: var(--forest-2); font-size: 12px; font-weight: 900; letter-spacing: .13em; text-transform: uppercase; }
.home-copy h2 { margin: 0; color: var(--forest); font-size: clamp(44px, 6vw, 78px); line-height: .98; letter-spacing: -.055em; }
.home-copy h2 span { color: var(--coral); }
.home-copy > p:not(.home-kicker) { max-width: 590px; margin: 24px 0; color: var(--muted); font-size: clamp(17px, 2vw, 21px); line-height: 1.55; }
.profile-start { width: 100%; max-width: 520px; display: grid; grid-template-columns: minmax(0, 1fr) max-content; gap: 9px; }
.profile-start label { grid-column: span 2; color: var(--forest); font-size: 13px; font-weight: 900; text-transform: uppercase; letter-spacing: .08em; }
.profile-start select, .lesson-selector select, .profile-dialog select {
  min-height: 52px; padding: 0 42px 0 15px; border: 2px solid var(--line); border-radius: 14px;
  color: var(--ink); background: #fff; font: inherit; font-weight: 800;
}
.profile-start select { width: 100%; min-width: 0; }
.profile-start button { min-width: 128px; padding: 0 18px; border-radius: 14px; color: #fff; background: var(--forest-2); font-weight: 850; }
#homeGrade, .grade-switch-status { grid-column: 1 / -1; }
.grade-switch-status { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.35; }

html[data-standalone="true"] .app-header {
  padding-top: max(calc(12px + env(safe-area-inset-top)), 34px);
}
.mode-panel { padding: clamp(22px, 3vw, 35px); border: 1px solid rgba(30,74,62,.1); border-radius: 30px; background: rgba(255,254,248,.93); box-shadow: var(--shadow); }
.mode-panel h3 { margin: 0 0 18px; color: var(--forest); font-size: clamp(21px, 2.5vw, 29px); }
.mode-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
.mode-grid button { min-height: 112px; padding: 20px; display: grid; grid-template-columns: 54px minmax(0, 1fr); grid-template-rows: auto auto; column-gap: 14px; row-gap: 4px; align-items: center; text-align: left; border: 2px solid #dfe9dd; border-radius: 18px; color: var(--forest); background: #f7faf4; }
.mode-grid button span { grid-row: span 2; width: 54px; height: 54px; display: grid; place-items: center; border-radius: 16px; color: var(--forest); background: var(--mint); font-size: 25px; font-weight: 900; }
.mode-grid button strong { align-self: end; font-size: 23px; }
.mode-grid button small { align-self: start; color: var(--muted); font-size: 14px; line-height: 1.45; }
.mode-grid button[data-start-mode="practice"] span { background: #f9e5b7; }
.mode-grid button:hover { border-color: var(--sage); }
.mode-grid button:active { transform: scale(.98); }
.mode-grid .game-mode { border-color: #e2b13f; background: linear-gradient(135deg, #fff8d8, #f6e2a4); }
.mode-grid .game-mode span { color: #fff7cf; background: #b87913; box-shadow: inset 0 0 0 4px #f3ca61; }
.parent-link { width: 100%; margin-top: 12px; color: var(--forest-2); background: transparent; font-size: 14px; font-weight: 800; }

.lesson-toolbar { margin-bottom: 14px; padding: 10px; display: grid; grid-template-columns: auto minmax(180px, 1fr) minmax(130px, .4fr) minmax(120px, .35fr) auto; gap: 10px; align-items: end; border: 1px solid rgba(30,74,62,.1); border-radius: 19px; background: rgba(255,254,248,.88); box-shadow: 0 8px 22px rgba(25,57,49,.08); }
.home-button { padding: 0 15px; border-radius: 12px; color: var(--forest); background: var(--mint); font-weight: 850; }
.lesson-selector { min-width: 0; }
.lesson-selector label { display: block; margin: 0 0 3px 4px; color: var(--muted); font-size: 10px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.lesson-selector select { width: 100%; min-height: 48px; white-space: nowrap; text-overflow: ellipsis; }
.mastery-chip { min-width: 105px; min-height: 48px; padding: 6px 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; border-radius: 13px; color: #fff; background: var(--forest-2); }
.mastery-chip span { font-size: 19px; font-weight: 900; line-height: 1; }
.mastery-chip small { margin-top: 3px; font-size: 10px; }

.game-hud {
  margin-bottom: 14px;
  padding: 12px;
  display: grid;
  grid-template-columns: minmax(235px, 1.5fr) repeat(4, minmax(105px, .65fr));
  align-items: stretch;
  gap: 9px;
  border: 2px solid #e1b240;
  border-radius: 20px;
  background: linear-gradient(120deg, #fff7cf, #f3dfa0 58%, #f8ecc2);
  box-shadow: 0 9px 24px rgba(142, 96, 21, .16);
}
.game-hud-title { min-height: 66px; display: grid; grid-template-columns: 48px 1fr; grid-template-rows: auto auto; align-content: center; column-gap: 11px; }
.game-hud-title .coin-mark { grid-row: span 2; width: 48px; height: 48px; display: grid; place-items: center; align-self: center; border: 4px solid #f7d56e; border-radius: 50%; color: #fff8d8; background: #ad7110; font-size: 22px; font-weight: 950; box-shadow: 0 4px 0 #80500a; }
.game-hud-title strong { align-self: end; color: #684107; font-size: 18px; }
.game-hud-title small { align-self: start; color: #805d25; font-size: 12px; font-weight: 750; }
.game-stat { min-height: 66px; padding: 8px 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; border: 1px solid rgba(128,80,10,.15); border-radius: 13px; text-align: center; background: rgba(255,255,255,.58); }
.game-stat small { color: #805d25; font-size: 10px; font-weight: 900; letter-spacing: .05em; text-transform: uppercase; }
.game-stat strong { margin-top: 4px; color: #684107; font-size: 17px; line-height: 1.1; }
.game-hud.coin-earned .coin-mark { animation: coin-pop .62s ease-out; }
.game-hud.level-up { animation: level-glow 1.15s ease-in-out 2; }

.learning-stage { display: grid; grid-template-columns: minmax(230px, .68fr) minmax(420px, 1.7fr); gap: clamp(14px, 2vw, 24px); }
.wolf-card, .board-card, .interaction-card { border: 1px solid rgba(30,74,62,.11); border-radius: 25px; background: rgba(255,254,248,.91); box-shadow: var(--shadow); overflow: hidden; }
.wolf-card { position: relative; display: flex; flex-direction: column; min-height: 510px; padding: 20px 20px 18px; }
.card-label { color: var(--forest-2); font-size: 12px; font-weight: 900; letter-spacing: .14em; text-transform: uppercase; }
.card-label.light { color: #cce0d7; }
.wolf-card-heading { position: relative; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.voice-status { max-width: 175px; min-height: 28px; padding: 5px 9px; display: inline-flex; align-items: center; overflow: hidden; border-radius: 99px; color: var(--forest-2); background: var(--mint); font-size: 10px; font-weight: 850; white-space: nowrap; text-overflow: ellipsis; }
.voice-status.unavailable { color: #8b423d; background: #f8ddda; }
.voice-status.speaking { color: #fff; background: var(--forest-2); }
.narration-status { font-size: .82rem; color: var(--forest-2); }
.narration-status:empty { display: none; }
.spoken-segment { background: #fff0bd; border-radius: .2em; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.wolf-scene { position: relative; display: grid; place-items: end center; flex: 1 1 auto; min-height: 315px; overflow: hidden; isolation: isolate; }
.wise-wolf-avatar { position: relative; z-index: 3; width: min(100%, 336px); height: min(37vw, 370px); min-height: 285px; max-height: 370px; touch-action: manipulation; user-select: none; }
.avatar-stage { position: absolute; inset: 0; transform-origin: center bottom; animation: avatar-breathe 4.1s ease-in-out infinite; will-change: transform; }
.avatar-layer { position: absolute; display: block; pointer-events: none; -webkit-user-drag: none; user-select: none; }
.avatar-body { inset: 0; width: 100%; height: 100%; object-fit: contain; object-position: center bottom; filter: drop-shadow(0 12px 8px rgba(23,63,53,.16)); transition: opacity .18s ease, transform .28s ease; }
.avatar-depth-back { position: absolute; z-index: -1; left: 15%; right: 15%; bottom: 4%; height: 45%; border-radius: 50%; background: radial-gradient(ellipse, rgba(120,150,140,.18), transparent 69%); transform: translateZ(-1px); }
.ground-shadow { position: absolute; z-index: 1; bottom: 1px; width: 66%; height: 20px; border-radius: 50%; background: rgba(23,63,53,.15); filter: blur(5px); }
.wise-wolf-avatar[data-pose="thinking"] .avatar-stage { animation: avatar-think 2.1s ease-in-out infinite alternate; }
.wise-wolf-avatar[data-pose="listening"] .avatar-stage,
.wise-wolf-avatar[data-pose="waiting_for_answer"] .avatar-stage { animation: avatar-listen 3s ease-in-out infinite; }
.wise-wolf-avatar[data-speaking="true"] .avatar-stage { animation: avatar-speaking .78s ease-in-out infinite; }
.wise-wolf-avatar.speech-pulse .avatar-body { transform: translateY(-2px) scale(1.006,.994); }
.wise-wolf-avatar[data-pose="celebrate"] .avatar-body,
.wise-wolf-avatar[data-emotion="celebrating"] .avatar-body { animation: avatar-celebrate .72s ease-in-out 2; }
.wise-wolf-avatar[data-pose="pointing_board"] { transform: translateX(2%); }
.thinking-dots { position: absolute; z-index: 5; top: 11%; right: 8%; display: flex; align-items: flex-end; gap: 5px; padding: 10px 12px; border-radius: 99px; background: rgba(255,255,255,.9); box-shadow: 0 7px 18px rgba(23,63,53,.14); }
.thinking-dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--forest-2); animation: thinking-dot 1s ease-in-out infinite; }
.thinking-dots i:nth-child(2) { animation-delay: .13s; }
.thinking-dots i:nth-child(3) { animation-delay: .26s; }
.speech-bubble { position: relative; z-index: 3; min-height: 76px; padding: 16px 18px; border: 2px solid var(--mint); border-radius: 19px; background: #fff; font-size: clamp(15px, 1.55vw, 18px); font-weight: 700; line-height: 1.35; }
.speech-bubble::before { content: ""; position: absolute; top: -13px; left: 45px; width: 21px; height: 21px; border-left: 2px solid var(--mint); border-top: 2px solid var(--mint); background: #fff; transform: rotate(45deg); }
.speech-controls { position: relative; z-index: 4; margin-top: 9px; display: flex; flex-wrap: wrap; gap: 7px; }
.speech-controls button { min-height: 44px; padding: 0 12px; border: 1px solid var(--mint); border-radius: 12px; color: var(--forest); background: #f4f8ef; font-size: 12px; font-weight: 850; }
.voice-choice { min-height: 44px; padding: 4px 7px 4px 10px; display: flex; flex: 1 1 155px; align-items: center; gap: 7px; border: 1px solid var(--mint); border-radius: 12px; color: var(--forest); background: #f4f8ef; font-size: 11px; font-weight: 900; }
.voice-choice select { min-width: 0; min-height: 36px; flex: 1 1 auto; padding: 0 26px 0 8px; border: 0; border-radius: 9px; color: var(--forest); background: #fff; font-family: inherit; font-size: 12px; font-weight: 800; }
.speech-controls .voice-toggle[aria-pressed="true"] { color: #fff; background: var(--forest-2); }
.speech-controls .speech-control:disabled { display: none; }
.speech-controls #stopTalkingButton { color: #fff; background: var(--coral); border-color: var(--coral); }

.board-card { min-height: 460px; display: flex; flex-direction: column; background: var(--forest); }
.board-heading { min-height: 96px; padding: 19px 22px 15px; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; color: #fff; }
.problem-prompt { max-width: 820px; margin: 6px 0 0; font-size: clamp(17px, 2vw, 24px); font-weight: 780; line-height: 1.25; }
.problem-prompt.board-highlight { border-radius: 10px; animation: board-focus 1.15s ease-in-out 2; }
.math-fraction { display: inline-grid; grid-template-rows: auto auto; margin: 0 .13em; vertical-align: -.3em; text-align: center; line-height: 1; }
.math-fraction span:first-child { padding: 0 .16em .08em; border-bottom: .08em solid currentColor; }
.math-fraction span:last-child { padding: .08em .16em 0; }
.problem-prompt sup { font-size: .66em; vertical-align: super; }
.pencil-note { flex: 0 0 auto; padding: 7px 11px; border: 1px solid rgba(255,255,255,.18); border-radius: 99px; color: #dbe9e2; font-size: 12px; font-weight: 750; }
.canvas-wrap { position: relative; flex: 1 1 auto; min-height: 285px; margin: 0 14px; border-radius: 18px; overflow: hidden; background-color: var(--paper); background-image: linear-gradient(#dfe8e2 1px, transparent 1px), linear-gradient(90deg, #dfe8e2 1px, transparent 1px); background-size: 26px 26px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.06); }
#scratchpad { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.problem-visual { position: absolute; inset: 0; z-index: 1; padding: 24px; display: none; align-items: center; justify-content: center; overflow: auto; touch-action: manipulation; }
.problem-visual.active { display: flex; }
.fraction-visual { width: min(560px, 95%); display: grid; gap: 18px; }
.fraction-row { display: grid; min-height: 66px; border: 3px solid var(--forest); border-radius: 12px; overflow: hidden; }
.fraction-piece { min-width: 44px; min-height: 60px; border-right: 2px solid var(--forest); color: var(--forest); background: #fff; font-weight: 900; }
.fraction-piece:last-child { border-right: 0; }
.fraction-piece.selected { background: var(--sun); }
.visual-array { display: grid; gap: 9px; }
.visual-dot { width: 30px; height: 30px; border-radius: 50%; background: var(--sage); box-shadow: inset 0 -4px 0 rgba(23,63,53,.2); }
.visual-number-line { width: min(680px, 96%); display: flex; align-items: flex-end; justify-content: space-between; border-bottom: 4px solid var(--forest); }
.visual-number-line button { position: relative; min-width: 44px; padding: 0 3px 16px; color: var(--forest); background: transparent; font-weight: 900; }
.visual-number-line button::after { content: ""; position: absolute; left: 50%; bottom: -7px; width: 4px; height: 16px; background: var(--forest); }
.visual-number-line button.selected { color: var(--coral); transform: translateY(-7px); }
.visual-equation { padding: 24px 32px; border: 4px solid var(--forest); border-radius: 18px; color: var(--forest); background: #fff; font-size: clamp(28px, 5vw, 56px); font-weight: 900; box-shadow: 0 9px 0 var(--mint); }
.canvas-empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: #81938d; font-size: 15px; font-weight: 750; pointer-events: none; transition: opacity .2s; }
.canvas-empty.hidden { opacity: 0; }
.canvas-empty svg { width: 40px; height: 40px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.board-tools { display: flex; align-items: center; gap: 7px; padding: 12px 14px 14px; overflow-x: auto; scrollbar-width: none; }
.board-tools::-webkit-scrollbar { display: none; }
.tool-button { min-width: 86px; padding: 0 13px; display: flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid rgba(255,255,255,.13); border-radius: 13px; color: #fff; background: rgba(255,255,255,.08); font-size: 14px; font-weight: 800; white-space: nowrap; }
.tool-button.active { color: var(--forest); background: var(--sun); border-color: var(--sun); }
.tool-button.danger { margin-left: auto; color: #ffd7d4; }

.interaction-card { margin-top: clamp(14px, 2vw, 24px); padding: clamp(15px, 2vw, 23px); }
.conversation-actions { display: grid; grid-template-columns: repeat(6, minmax(105px, 1fr)); gap: 10px; }
.conversation-actions button { padding: 9px 15px; border: 2px solid var(--mint); border-radius: 15px; color: var(--forest); background: #f4f8ef; font-size: 15px; font-weight: 850; }
.conversation-actions button:active, .tool-button:active, .number-pad button:active { transform: scale(.97); }
.chat-row { margin-top: 14px; display: grid; grid-template-columns: minmax(180px, 1fr) auto auto; gap: 9px; }
.chat-row input { min-height: 52px; padding: 0 17px; border: 2px solid var(--line); border-radius: 15px; color: var(--ink); background: #fff; font-size: 16px; }
.send-button, .stop-button { padding: 0 19px; border-radius: 14px; color: #fff; background: var(--forest-2); font-weight: 850; }
.stop-button { background: var(--coral); }
.answer-zone { margin-top: 18px; }
.answer-zone > label { display: block; margin: 0 0 8px 3px; color: var(--forest-2); font-size: 13px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.answer-row { display: grid; grid-template-columns: minmax(150px, 1fr) auto; gap: 10px; }
.answer-row input { width: 100%; min-height: 58px; padding: 0 18px; border: 2px solid var(--line); border-radius: 16px; color: var(--ink); background: #fff; font-size: 22px; font-weight: 750; }
.check-button { min-width: 158px; padding: 0 22px; border-radius: 16px; color: #fff; background: var(--forest-2); font-weight: 900; }
.answer-feedback { min-height: 28px; padding: 7px 3px 0; font-size: 16px; font-weight: 800; }
.answer-feedback.correct { color: #22713c; }
.answer-feedback.try-again { color: #a64d47; }
.number-pad { display: none; }
.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0,0,0,0) !important; white-space: nowrap !important; border: 0 !important; }

.install-dialog { width: min(92vw, 480px); padding: 0; border: 0; border-radius: 24px; color: var(--ink); background: var(--paper); box-shadow: 0 24px 90px rgba(15,44,36,.36); }
.install-dialog::backdrop { background: rgba(10,35,29,.58); backdrop-filter: blur(4px); }
.install-dialog form { position: relative; padding: 30px; }
.dialog-close { position: absolute; top: 12px; right: 12px; border-radius: 50%; color: var(--forest); background: var(--mint); font-size: 28px; }
.install-wolf { width: 62px; height: 62px; font-size: 31px; }
.install-dialog h2 { margin: 17px 0 12px; font-size: 25px; }
.install-dialog ol { padding-left: 23px; line-height: 1.65; }
.install-dialog p { color: var(--muted); line-height: 1.45; }
.install-dialog .app-version { margin: 10px 0 0; text-align: center; font-size: 12px; font-weight: 750; }
.dialog-done { width: 100%; margin-top: 8px; border-radius: 14px; color: #fff; background: var(--forest-2); font-weight: 850; }
.profile-status { min-height: 21px; margin: 12px 0 2px; font-size: 14px; font-weight: 750; }
.profile-status.error { color: #a5362a; }
.profile-dialog label, .parent-unlock label { display: block; margin: 14px 0 6px; color: var(--forest); font-size: 13px; font-weight: 900; }
.profile-dialog input, .profile-dialog select, .parent-unlock input { width: 100%; min-height: 52px; padding: 0 15px; border: 2px solid var(--line); border-radius: 14px; color: var(--ink); background: #fff; font: inherit; font-size: 17px; }
.parent-dialog { width: min(94vw, 680px); }
.parent-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.parent-stats span { min-height: 80px; padding: 12px; display: flex; flex-direction: column; justify-content: center; text-align: center; border-radius: 14px; background: var(--mint); }
.parent-stats strong { font-size: 24px; }
.parent-dashboard ul { max-height: 270px; padding: 0; overflow-y: auto; list-style: none; }
.parent-dashboard li { min-height: 48px; padding: 8px 3px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); }
.parent-dashboard li strong { font-size: 13px; text-transform: capitalize; }
.settings-note { color: var(--muted); font-size: 13px; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.settings-grid label { color: var(--muted); font-size: 12px; font-weight: 850; }
.settings-grid select { width: 100%; min-height: 48px; margin-top: 4px; padding: 0 8px; border: 2px solid var(--line); border-radius: 12px; background: #fff; font: inherit; }
.voice-settings { margin-top: 8px; }
.voice-settings label { min-height: 64px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 12px; background: #f8faf6; }
.voice-settings .voice-check { display: flex; align-items: center; gap: 10px; color: var(--forest); font-size: 14px; }
.voice-settings .voice-check input { width: 24px; height: 24px; accent-color: var(--forest-2); }
.voice-settings input[type="range"] { width: 100%; min-height: 34px; accent-color: var(--forest-2); }
.dialog-done.secondary { color: var(--forest); background: var(--mint); }

@keyframes avatar-breathe { 0%,100% { transform: translateY(0) scale(1); } 50% { transform: translateY(2px) scale(1.004,.994); } }
@keyframes avatar-think { from { transform: rotate(-1.2deg) translateY(0); } to { transform: rotate(1.8deg) translateY(2px); } }
@keyframes avatar-listen { 0%,100% { transform: rotate(0); } 45% { transform: rotate(.8deg); } 52% { transform: rotate(-.6deg); } }
@keyframes avatar-speaking { 0%,100% { transform: translateY(0) rotate(0) scale(1); } 35% { transform: translateY(-2px) rotate(.35deg) scale(1.004,.996); } 70% { transform: translateY(0) rotate(-.2deg) scale(.998,1.002); } }
@keyframes avatar-celebrate { 45% { transform: translateY(-9px) rotate(-1deg); } }
@keyframes thinking-dot { 0%,100% { transform: translateY(0); opacity: .45; } 50% { transform: translateY(-5px); opacity: 1; } }
@keyframes board-focus { 50% { color: #fff8cc; text-shadow: 0 0 18px rgba(242,189,87,.95); transform: translateX(2px); } }
@keyframes coin-pop { 45% { transform: translateY(-7px) rotate(-10deg) scale(1.18); } }
@keyframes level-glow { 50% { box-shadow: 0 0 0 7px rgba(242,189,87,.28), 0 13px 30px rgba(142,96,21,.25); } }

html[data-layout="portrait"] body { overflow-y: auto; overscroll-behavior-y: auto; }
html[data-layout="portrait"] .learning-stage { grid-template-columns: 1fr; }
html[data-layout="portrait"] .wolf-card { min-height: auto; }
html[data-layout="portrait"] .wolf-scene { min-height: 225px; }
html[data-layout="portrait"] .wise-wolf-avatar { height: 310px; min-height: 260px; }
html[data-layout="portrait"] .board-card { min-height: 500px; }
html[data-layout="portrait"] .conversation-actions { grid-template-columns: repeat(3, 1fr); }
html[data-layout="portrait"] .home-screen { grid-template-columns: 1fr; align-items: start; }
html[data-layout="portrait"] .home-copy h2 { font-size: clamp(43px, 11vw, 72px); }
html[data-layout="portrait"] .lesson-toolbar { grid-template-columns: auto 1fr 1fr; align-items: end; }
html[data-layout="portrait"] .lesson-selector:first-of-type { grid-column: span 2; }
html[data-layout="portrait"] .mastery-chip { grid-column: 3; grid-row: 1; }
html[data-layout="portrait"] .game-hud { grid-template-columns: repeat(2, 1fr); }
html[data-layout="portrait"] .game-hud-title { grid-column: 1 / -1; }
html[data-layout="portrait"] .number-pad { margin-top: 14px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
html[data-layout="portrait"] .number-pad button { min-height: 52px; border: 1px solid var(--line); border-radius: 13px; color: var(--forest); background: #f5f8f2; font-size: 20px; font-weight: 850; }
html[data-layout="portrait"] .number-pad .wide-key { grid-column: span 2; }

@media (max-height: 900px) {
  html[data-layout="landscape"] .app-header { min-height: 64px; padding-top: calc(8px + env(safe-area-inset-top)); padding-bottom: 8px; }
  html[data-layout="landscape"] .brand-mark { width: 42px; height: 42px; }
  html[data-layout="landscape"] .app-shell { padding-top: 10px; padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  html[data-layout="landscape"] .lesson-toolbar { margin-bottom: 8px; padding: 7px; }
  html[data-layout="landscape"] .game-hud { margin-bottom: 8px; padding: 8px; }
  html[data-layout="landscape"] .game-hud-title, html[data-layout="landscape"] .game-stat { min-height: 56px; }
  html[data-layout="landscape"] .learning-stage { gap: 10px; }
  html[data-layout="landscape"] .wolf-card { min-height: 390px; padding: 14px; }
  html[data-layout="landscape"] .wolf-scene { min-height: 220px; }
  html[data-layout="landscape"] .wise-wolf-avatar { height: 270px; min-height: 220px; }
  html[data-layout="landscape"] .speech-bubble { min-height: 62px; padding: 12px 14px; }
  html[data-layout="landscape"] .board-card { min-height: 390px; }
  html[data-layout="landscape"] .board-heading { min-height: 78px; padding: 14px 18px 10px; }
  html[data-layout="landscape"] .canvas-wrap { min-height: 225px; }
  html[data-layout="landscape"] .interaction-card { margin-top: 10px; padding: 12px; }
  html[data-layout="landscape"] .chat-row { margin-top: 8px; }
  html[data-layout="landscape"] .answer-zone { margin-top: 10px; }
}

@media (max-width: 900px), (orientation: portrait) {
  body { overflow-y: auto; overscroll-behavior-y: auto; }
  .learning-stage { grid-template-columns: 1fr; }
  .wolf-card { min-height: auto; }
  .wolf-scene { min-height: 225px; }
  .wise-wolf-avatar { height: 310px; min-height: 260px; }
  .board-card { min-height: 500px; }
  .conversation-actions { grid-template-columns: repeat(3, 1fr); }
  .home-screen { grid-template-columns: 1fr; align-items: start; }
  .home-copy h2 { font-size: clamp(43px, 11vw, 72px); }
  .lesson-toolbar { grid-template-columns: auto 1fr 1fr; align-items: end; }
  .lesson-selector:first-of-type { grid-column: span 2; }
  .mastery-chip { grid-column: 3; grid-row: 1; }
  .game-hud { grid-template-columns: repeat(2, 1fr); }
  .game-hud-title { grid-column: 1 / -1; }
  .number-pad { margin-top: 14px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .number-pad button { min-height: 52px; border: 1px solid var(--line); border-radius: 13px; color: var(--forest); background: #f5f8f2; font-size: 20px; font-weight: 850; }
  .number-pad .wide-key { grid-column: span 2; }
}

@media (max-width: 620px) {
  .app-header { align-items: flex-start; }
  .brand-mark { width: 42px; height: 42px; }
  .eyebrow, .server-pill span:not(.status-dot) { display: none; }
  .server-pill { width: 44px; padding: 0; justify-content: center; }
  .conversation-actions { grid-template-columns: repeat(2, 1fr); }
  .mode-grid { grid-template-columns: 1fr; }
  .mode-grid button { min-height: 92px; }
  .profile-start { grid-template-columns: 1fr; }
  .profile-start label { grid-column: auto; }
  .profile-start button { min-height: 52px; }
  .lesson-toolbar { grid-template-columns: 1fr 1fr; }
  .home-button { grid-column: span 2; }
  .lesson-selector:first-of-type { grid-column: span 2; }
  .mastery-chip { grid-column: auto; grid-row: auto; }
  .game-hud { grid-template-columns: 1fr 1fr; }
  .parent-stats { grid-template-columns: 1fr 1fr; }
  .chat-row { grid-template-columns: 1fr auto; }
  .chat-row input { grid-column: span 2; }
  .answer-row { grid-template-columns: 1fr; }
  .check-button { min-height: 56px; }
  .board-heading { flex-direction: column; }
  .pencil-note { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}

/* Keep the problem, working area, and answer in one lesson viewport. */
.parent-link { display: block; text-align: center; padding: 14px; text-decoration: none; }
body:has(#appShell:not(.hidden)) { height: var(--wise-wolf-viewport-height); min-height: 0; overflow: hidden; }
body:has(#appShell:not(.hidden)) .app-header { min-height: 64px; height: 64px; padding-top: 8px; padding-bottom: 8px; }
body:has(#appShell:not(.hidden)) .brand-mark { width: 40px; height: 40px; }
body:has(#appShell:not(.hidden)) .server-pill { display: none; }
html[data-layout] body .app-shell { height: calc(var(--wise-wolf-viewport-height) - 64px); display: flex; flex-direction: column; gap: 12px; padding: 12px max(14px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left)); }
html[data-layout] body .lesson-toolbar { flex: none; margin: 0; padding: 8px; grid-template-columns: auto minmax(120px, 1fr) minmax(105px, .4fr) minmax(110px, .4fr) auto; }
html[data-layout] body .lesson-selector:first-of-type, html[data-layout] body .mastery-chip, html[data-layout] body .home-button { grid-column: auto; grid-row: auto; }
html[data-layout] body .learning-stage { flex: 1; min-height: 0; grid-template-columns: minmax(230px, .68fr) minmax(0, 1.7fr); gap: 14px; }
html[data-layout] body .wolf-card { min-height: 0; min-width: 0; padding: 16px; gap: 10px; }
html[data-layout] body .wolf-scene {
  flex: 1 1 180px;
  min-height: 70px;
  border-radius: 15px;
  background: #eee5d2 url("/static/wise-wolf/classroom.svg") center bottom / cover no-repeat;
  box-shadow: inset 0 0 0 1px rgba(94, 77, 47, .1);
}
html[data-layout] body .wise-wolf-avatar { width: 100%; height: 100%; min-height: 0; max-height: 340px; }
html[data-layout] body .speech-bubble { flex: 0 1 auto; min-height: 56px; max-height: 28%; padding: 12px 14px; font-size: 16px; overflow-y: auto; overflow-wrap: anywhere; scrollbar-width: thin; }
html[data-layout] body .speech-bubble::before { display: none; }
html[data-layout] body .speech-controls { flex: none; margin: 0; gap: 6px; }
html[data-layout] body .speech-controls button { padding: 0 10px; }
html[data-layout] body .chat-row { margin: 0; flex: none; grid-template-columns: minmax(0, 1fr) auto; gap: 7px; }
.chat-row label { grid-column: 1 / -1; font-size: 13px; font-weight: 850; }
.chat-row #retryTutorButton { grid-column: 1 / -1; grid-row: 3; justify-self: start; flex-basis: 100%; }
.chat-row:has(#retryTutorButton:not(.hidden)) { flex-wrap: wrap; }
html[data-layout] body .chat-row input { grid-column: 1; width: 100%; min-width: 0; min-height: 46px; padding: 0 10px; font-size: 16px; border-radius: 12px; }
.chat-row .stop-button:not(.hidden) { grid-column: 1; grid-row: 3; }
.chat-row .send-button { grid-column: 2; grid-row: 2; padding: 0 14px; }
.lesson-main { display: flex; flex-direction: column; min-height: 0; min-width: 0; gap: 10px; overflow-y: auto; }
.board-workspace { flex: 1; min-height: 340px; min-width: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.board-workspace:has(.board-hint:not(.hidden)) { min-height: 400px; }
.board-workspace:has(.teaching-board:not(.hidden)) { min-height: 460px; }
.board-workspace .board-card { min-width: 0; overflow: hidden; }
.drawing-instruction { margin: 6px 0 0; color: #dbe9e2; font-size: 14px; line-height: 1.35; }
.reference-wrap { background-image: none; }
.reference-question { width: 100%; text-align: center; color: var(--forest); font-size: clamp(20px, 2.5vw, 32px); font-weight: 800; overflow-wrap: anywhere; }
.model-notice { position: absolute; inset: 0; display: grid; align-content: center; margin: 0; padding: 20px; text-align: center; color: var(--forest); line-height: 1.5; }
.board-hint { flex: none; margin: 10px 14px 0; padding: 10px 12px; max-height: 110px; overflow: auto; border-radius: 12px; color: var(--forest); background: #fff0c8; font-size: 15px; line-height: 1.4; }
html[data-layout] body .board-card { flex: 1; min-height: 0; }
html[data-layout] body .board-heading { flex: none; min-height: 0; padding: 14px 18px; flex-direction: row; }
html[data-layout] body .problem-prompt { margin-top: 5px; font-size: clamp(17px, 1.65vw, 23px); }
html[data-layout] body .canvas-wrap, html[data-layout] body .canvas-wrap.lesson-visible { flex: 1 1 0; min-height: 50px !important; }
html[data-layout] body .board-tools { flex: none; padding: 9px 12px; gap: 6px; }
html[data-layout] body .tool-button { min-height: 44px; min-width: 60px; padding: 0 10px; font-size: 12px; }
html[data-layout] body .interaction-card { flex: none; position: relative; overflow: visible; margin: 0; padding: 12px 14px; border-radius: 20px; }
html[data-layout] body .answer-zone { margin: 0; }
html[data-layout] body .answer-zone > label { margin: 0 0 6px 2px; font-size: 11px; }
html[data-layout] body .answer-row { grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
html[data-layout] body .answer-row input { min-width: 0; min-height: 50px; padding: 0 12px; font-size: 20px; }
.comparison-choices { display: grid; grid-template-columns: repeat(var(--choice-count, 3), minmax(0, 1fr)); gap: 8px; min-width: 0; }
.mode-notice { margin: 0; padding: 10px; color: var(--forest); background: var(--mint); border-radius: 12px; font-size: 14px; line-height: 1.4; }
.question-model { width: 100%; max-width: 640px; padding: 14px; text-align: center; color: var(--forest); }
.question-clues { text-align: left; font-size: clamp(16px, 1.6vw, 21px); line-height: 1.5; overflow-wrap: anywhere; }
.question-clues p { margin: 0 0 14px; padding: 10px 12px; background: #e5eedf; border-radius: 10px; }
.question-flow { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px; margin: 20px 0; }
.question-flow span { padding: 10px; border-radius: 10px; background: #e5eedf; font-size: 26px; font-weight: 800; }
.question-model svg { width: 100%; max-height: 230px; }
.question-model .counter-grid { display: grid; grid-template-columns: repeat(5, minmax(28px, 44px)); justify-content: center; align-content: center; gap: 6px; min-height: 120px; padding: 14px; margin: 12px auto; border: 2px dashed #90ad9e; border-radius: 18px; background: #fff; }
.question-model .empty-counting-box { grid-template-columns: 1fr; }
.empty-counting-box p { margin: 0; color: #49685a; font-size: 18px; }
.question-model .counter-grid button { aspect-ratio: 1; width: 100%; min-width: 0; min-height: 28px; padding: 0; border-radius: 50%; background: #dfa533; border: 2px solid var(--forest); color: var(--forest); font-weight: 800; }
.question-model .counter-grid button[aria-pressed="true"] { background: #b3d5c6; }
.teaching-board.counting-lesson { padding: 8px 12px; }
.teaching-board.counting-lesson .teaching-caption { margin: 0; font-size: 16px; line-height: 1.3; text-align: center; }
.teaching-board.counting-lesson .question-model { padding: 0; }
.teaching-board.counting-lesson .counter-grid { margin: 6px auto; }
.teaching-board.foundation-lesson .question-model { padding: 0; }
.teaching-board.foundation-lesson .question-model svg { height: 140px; min-height: 0; }
@media (max-width: 700px) {
  .question-model .counter-grid { grid-template-columns: repeat(5, minmax(28px, 44px)); }
}
.question-model .model-bars { display: grid; gap: 12px; text-align: left; }
.question-model .model-bar { display: flex; align-items: center; gap: 10px; }
.question-model .model-bar span { min-width: 85px; }
.question-model .model-bar b { display: block; background: #c3dbc8; border: 1px solid var(--forest); border-radius: 6px; padding: 8px; }
@media (max-width: 699px) {
  .comparison-choices:has(.comparison-choice:nth-child(4)) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.comparison-choice { position: relative; display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 50px; padding: 3px 8px; border: 2px solid var(--line); border-radius: 13px; background: #fff; color: var(--forest); font-size: 13px; font-weight: 800; cursor: pointer; }
.comparison-symbol { font-size: 32px; line-height: 1; }
html[data-layout] body .answer-row .comparison-choice input { position: absolute; width: 1px; height: 1px; min-height: 0; margin: 0; padding: 0; border: 0; opacity: 0; clip-path: inset(50%); }
.comparison-choice:has(input:checked) { background: #dce9d8; border-color: var(--forest); }
.comparison-choice:has(input:checked)::after { content: "●"; position: absolute; top: 1px; right: 5px; font-size: 10px; }
.comparison-choice:has(input:focus-visible) { outline: 3px solid #bc7b15; outline-offset: 3px; }
.comparison-choice:has(input:disabled) { cursor: default; opacity: .65; }
@media (max-width: 699px) {
  .comparison-choices { gap: 4px; }
  .comparison-choice { flex-direction: column; gap: 1px; min-height: 50px; padding: 3px 2px; font-size: 10px; line-height: 1.1; text-align: center; }
  .comparison-symbol { font-size: 26px; }
}
html[data-layout] body .check-button { min-height: 48px; min-width: 140px; padding: 0 16px; }
html[data-layout] body .answer-feedback { min-height: 0; max-height: 55px; overflow: auto; font-size: 14px; }
.answer-feedback:empty { display: none; }
html[data-layout] body .conversation-actions { display: flex; gap: 6px; overflow-x: auto; margin-top: 9px; scrollbar-width: thin; }
html[data-layout] body .conversation-actions button { flex: 0 0 auto; min-height: 44px; padding: 6px 11px; font-size: 12px; border-width: 1px; border-radius: 10px; }
.answer-keypad { position: absolute; top: 7px; right: 15px; z-index: 8; }
.answer-keypad summary { cursor: pointer; color: var(--muted); font-size: 11px; font-weight: 750; padding: 3px 5px; }
.answer-keypad[open] summary { color: var(--forest); }
html[data-layout] body .answer-keypad .number-pad { position: absolute; bottom: 30px; right: 0; width: 235px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 0; padding: 12px; border: 1px solid var(--line); border-radius: 16px; background: var(--paper); box-shadow: var(--shadow); }
html[data-layout] body .number-pad button { min-height: 44px; border-radius: 9px; background: var(--mint); color: var(--forest); font-weight: 800; }
html[data-layout] body .number-pad .wide-key { grid-column: span 2; }
html[data-layout] body .game-hud { flex: none; margin: 0; padding: 8px; grid-template-columns: minmax(170px, 1.2fr) repeat(4, minmax(70px, 1fr)); gap: 6px; }
html[data-layout] body .game-hud-title { grid-column: auto; grid-template-columns: 34px 1fr; column-gap: 8px; }
html[data-layout] body .game-hud-title .coin-mark { width: 32px; height: 32px; font-size: 16px; border-width: 2px; }
html[data-layout] body .game-hud-title, html[data-layout] body .game-stat { min-height: 46px; }
.game-hud-title strong { font-size: 14px; }
html[data-layout] body .demand-hud { flex: none; margin: 0; padding: 10px 14px; flex-direction: row; }
.demand-hud h2 { font-size: 17px; }
.demand-hud p { font-size: 12px; }
.teaching-board svg { height: auto; min-height: 130px; max-height: 230px; }
.teaching-board.comparison-lesson { padding: 12px 16px; gap: 6px; }
.teaching-board.comparison-lesson .teaching-caption { flex: 0 0 auto; margin: 0; font-size: clamp(14px, 1.3vw, 18px); line-height: 1.4; }
.teaching-board.comparison-lesson svg { flex: 1 1 0; height: 0; min-height: 105px; max-height: 260px; }
.teaching-controls { flex: none; }
@media (min-width: 700px) and (max-width: 1000px) {
  html[data-layout] body .learning-stage { grid-template-columns: 220px minmax(0, 1fr); gap: 10px; }
  html[data-layout] body .wolf-card { padding: 12px; }
  html[data-layout] body .speech-controls button { font-size: 11px; padding: 0 8px; }
  html[data-layout] body .mastery-chip { min-width: 70px; padding: 6px; }
  .pencil-note { display: none; }
}
@media (max-height: 740px) and (min-width: 700px) {
  html[data-layout] body .app-shell { gap: 8px; padding-top: 8px; padding-bottom: 8px; }
  html[data-layout] body .wolf-card { padding: 12px; gap: 7px; }
  html[data-layout] body .board-heading { padding: 10px 14px; }
  html[data-layout] body .interaction-card { padding: 8px 12px; }
  html[data-layout] body .conversation-actions { margin-top: 6px; }
  html[data-layout] body .speech-bubble { font-size: 14px; padding: 9px 11px; }
}
@media (max-width: 699px) {
  body:has(#appShell:not(.hidden)) .app-header { height: 54px; min-height: 54px; align-items: center; padding: 5px 10px; }
  body:has(#appShell:not(.hidden)) h1 { font-size: 18px; }
  html[data-layout] body .app-shell { height: calc(var(--wise-wolf-viewport-height) - 54px); padding: 6px 8px; gap: 6px; }
  html[data-layout] body .lesson-toolbar { grid-template-columns: 54px minmax(0, 1fr) 95px; gap: 5px; padding: 5px; }
  html[data-layout] body .lesson-toolbar .home-button { padding: 0 4px; font-size: 12px; grid-row: 1 / 3; }
  html[data-layout] body .lesson-selector:first-of-type { grid-column: 2; grid-row: 1; }
  html[data-layout] body .lesson-selector:nth-of-type(2) { grid-column: 3; grid-row: 1; }
  html[data-layout] body .lesson-selector:nth-of-type(3) { grid-column: 2; grid-row: 2; }
  html[data-layout] body .mastery-chip { grid-column: 3; grid-row: 2; min-width: 0; min-height: 44px; }
  html[data-layout] body .lesson-selector label { display: none; }
  html[data-layout] body .lesson-selector select { min-height: 44px; padding: 0 20px 0 7px; font-size: 12px; border-radius: 9px; }
  html[data-layout] body .learning-stage { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); gap: 6px; }
  html[data-layout] body .wolf-card { display: grid; grid-template-columns: 66px minmax(0, 1fr); gap: 5px 8px; padding: 8px 10px; border-radius: 16px; }
  .wolf-card-heading { display: none; }
  html[data-layout] body .wolf-scene { grid-column: 1; grid-row: 1 / 3; min-height: 0; }
  html[data-layout] body .speech-bubble { grid-column: 2; max-height: 52px; min-height: 0; padding: 6px 9px; font-size: 13px; border-radius: 10px; }
  html[data-layout] body .speech-controls { grid-column: 2; gap: 5px; }
  html[data-layout] body .speech-controls button { min-height: 32px; padding: 0 8px; font-size: 11px; }
  html[data-layout] body .chat-row { grid-column: 1 / -1; display: flex; gap: 5px; }
  html[data-layout] body .chat-row label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  html[data-layout] body .chat-row input { min-height: 40px; flex: 1; }
  html[data-layout] body .chat-row button { min-height: 40px; }
  html[data-layout] body .board-heading { padding: 9px 12px; }
  .board-heading .card-label { display: none; }
  html[data-layout] body .problem-prompt { margin: 0; font-size: 17px; }
  html[data-layout] body .canvas-wrap { margin: 0 8px; border-radius: 12px; }
  html[data-layout] body .board-tools { padding: 6px 8px; }
  html[data-layout] body .tool-button { min-height: 38px; min-width: 50px; padding: 0 7px; font-size: 11px; }
  .tool-button span[aria-hidden] { display: none; }
  .lesson-main { gap: 6px; }
  html[data-layout] body .interaction-card { padding: 8px 10px; border-radius: 14px; }
  html[data-layout] body .answer-row input { min-height: 44px; font-size: 17px; }
  html[data-layout] body .answer-row .check-button { min-height: 44px; min-width: 112px; padding: 0 10px; font-size: 12px; }
  html[data-layout] body .conversation-actions { margin-top: 5px; }
  html[data-layout] body .conversation-actions button { min-height: 34px; padding: 4px 9px; }
  html[data-layout] body .game-hud { grid-template-columns: repeat(4, 1fr); padding: 5px; }
  html[data-layout] body .game-hud-title { display: none; }
  html[data-layout] body .game-stat { min-height: 40px; padding: 4px; }
  .game-stat small { font-size: 8px; }
  .game-stat strong { font-size: 13px; }
  html[data-layout] body .demand-hud { padding: 6px 10px; gap: 5px; }
  .demand-hud .card-label { display: none; }
  .demand-session-actions button { min-height: 36px; font-size: 11px; padding: 5px 8px !important; }
}
/* A keyboard or strong zoom can reduce the viewport below usable panel sizes. */
@media (max-height: 520px) {
  html[data-layout] body .wolf-card { display: block; padding: 6px 10px; }
  html[data-layout] body .wolf-card-heading, html[data-layout] body .wolf-scene,
  html[data-layout] body .speech-bubble, html[data-layout] body .speech-controls { display: none; }
  html[data-layout] body .chat-row { display: flex; }
  html[data-layout] body .chat-row label { display: none; }
  html[data-layout] body .chat-row input { flex: 1; }
  html[data-layout] body .learning-stage { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  html[data-layout] body .lesson-toolbar { display: flex; padding: 0; background: transparent; border: 0; box-shadow: none; }
  html[data-layout] body .lesson-selector, html[data-layout] body .mastery-chip { display: none; }
  html[data-layout] body .lesson-toolbar .home-button { min-height: 32px; }
  html[data-layout] body .board-tools, html[data-layout] body .conversation-actions { display: none; }
}
/* The curriculum uses the existing lesson surface and large child controls. */
.curriculum-phase { margin: 0 0 10px; padding: 10px 16px; border-radius: 14px; background: #e5eedf; color: #173f35; font-weight: 700; }
.explanation-method { margin: 0 14px 8px; color: #fff3c9; font-weight: 700; font-size: 15px; }
.recall-control { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 16px; }
.recall-control input { width: 24px; height: 24px; }
.ten-frame { display: grid; grid-template-columns: repeat(5, 48px); gap: 4px; justify-content: center; }
.ten-frame button { height: 48px; font-size: 34px; background: #fffef3; color: #dda332; border: 2px solid #24594b; }
.ten-frame button.counted { background: #dce9d8; }
.number-tiles { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.number-tiles span { min-width: 44px; min-height: 44px; padding: 8px; border-radius: 10px; border: 2px solid #24594b; font-size: 24px; }
#readQuestionButton { justify-self: start; }
.answer-order { grid-column: 1 / -1; font-size: 16px; margin: 0; }
@media (min-width: 700px) {
  html[data-course="K"] body .lesson-toolbar { grid-template-columns: auto minmax(120px, 1fr) minmax(145px, .4fr) minmax(120px, .4fr) auto; }
  html[data-course="K"] body .lesson-selector select { padding: 0 24px 0 8px; font-size: 14px; }
}
@media (max-width: 699px) {
  html[data-course="K"] body .lesson-toolbar { grid-template-columns: 54px minmax(0, 1fr) 125px; }
}

/* Reference and writing stay visible together; drawing tools only affect ink. */
html[data-layout] body .board-workspace .board-tools { flex-wrap: wrap; overflow: visible; }
html[data-layout] body .board-workspace .tool-button { flex: 1 1 50px; min-width: 44px; padding: 0 7px; gap: 4px; }
html[data-layout] body .board-workspace .reference-tools .tool-button { flex: 0 1 auto; min-width: 80px; }
.board-workspace .tool-button.danger { margin-left: 0; }
.board-workspace .problem-visual { padding: 10px; }
.board-workspace .question-model { padding: 8px; }
.board-workspace .teaching-board { padding: 12px; }
.board-workspace .teaching-caption { font-size: 17px; line-height: 1.4; }
.board-workspace .teaching-controls { flex-wrap: wrap; gap: 5px; padding: 8px 12px 0; }
.board-workspace .teaching-controls button { min-height: 44px; padding: 0 9px; font-size: 12px; }
.board-workspace .ten-frame { grid-template-columns: repeat(5, minmax(28px, 44px)); }
.board-workspace .ten-frame button { min-width: 0; height: 44px; }

@media (min-width: 700px) and (max-width: 1000px) {
  html[data-layout] body .learning-stage { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  html[data-layout] body .wolf-card { display: grid; grid-template-columns: 90px minmax(0, 1fr) minmax(210px, .85fr); gap: 8px 12px; }
  .wolf-card-heading { display: none; }
  html[data-layout] body .wolf-scene { grid-column: 1; grid-row: 1 / 3; min-height: 90px; }
  html[data-layout] body .speech-bubble { grid-column: 2; max-height: 80px; min-height: 0; }
  html[data-layout] body .speech-controls { grid-column: 2; }
  html[data-layout] body .chat-row { grid-column: 3; grid-row: 1 / 3; align-self: center; }
  html[data-layout] body .mode-notice { grid-column: 2 / -1; }
}
@media (max-width: 620px) {
  body:has(#appShell:not(.hidden)) { height: auto; min-height: var(--wise-wolf-viewport-height); overflow-y: auto; }
  html[data-layout] body .app-shell { height: auto; min-height: calc(var(--wise-wolf-viewport-height) - 54px); }
  html[data-layout] body .learning-stage { grid-template-rows: auto auto; }
  .board-workspace { grid-template-columns: minmax(0, 1fr); }
  html[data-layout] body .board-workspace .board-card { min-height: 300px; }
  html[data-layout] body .board-workspace .canvas-wrap { min-height: 180px !important; }
  .board-workspace .board-heading .card-label { display: block; }
}
