/* 구구단·생활 문장·사회 상황(/classic) — 놀이판과 통일된 따뜻한 동화책·3D 클레이 디자인
   - 배경(#FFF8F0 + 은은한 놀이방 일러스트), 둥근 파스텔 입체 카드, 3D 클레이 삽화
   - 고정 높이·overflow:hidden 잘림 완전 해제 및 시작 버튼 화면 중앙 배치
   - CSP 준수: 인라인 스타일 없음, 외부 URL 없음 */

body {
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  background-color: #FFF8F0;
  background-image: none;
  color: #2D3436;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.5;
  background: url("./play/assets/home/bg-tablet.webp") center bottom / cover no-repeat;
}

@media (max-width: 767.98px) {
  body::before {
    background-image: url("./play/assets/home/bg-phone.webp");
  }
}

html.app-high-contrast body {
  background: #FFFFFF;
}
html.app-high-contrast body::before {
  display: none;
}

main {
  max-width: 1000px;
  margin: 0 auto;
  padding: 4px 16px calc(28px + env(safe-area-inset-bottom, 0px));
}

/* ---------- 상단 바 ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1000px;
  margin: 0 auto;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 6px;
  gap: 10px;
  flex-wrap: wrap;
}

.topbar .eyebrow {
  display: none;
}

.topbar-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-mascot {
  width: 44px;
  height: 44px;
  flex: none;
  object-fit: contain;
}

#appTitle {
  margin: 0;
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  font-size: 24px;
  font-weight: 900;
  line-height: 1.2;
  color: #2D3436;
  letter-spacing: -0.01em;
}

#appTitle::after {
  display: none;
}

.topbar-nav-group {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* M5 안전 배지 줄은 숨기고, 소리·선생님 버튼은 topbar-actions에서 항상 노출 */
.status-strip {
  display: none;
}

.topbar-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.home-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  min-width: 64px;
  min-height: 50px;
  margin-top: 0;
  box-sizing: border-box;
  padding: 0 16px;
  border-radius: 18px;
  border: 3px solid #5C4B3F;
  background: #FFFFFF;
  color: #2D3436;
  font-size: 18px;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 4px 0 #5C4B3F;
}

.home-link::before {
  content: "\2039";
  margin-right: 5px;
  font-size: 22px;
  line-height: 1;
}

.home-link.app-exit-home {
  background: #FFEDE3;
  border-color: #C2410C;
  color: #2D3436;
  box-shadow: 0 4px 0 #C2410C;
}

.home-link.app-exit-home::before {
  content: "\2302";
  font-size: 20px;
}

.sound-toggle,
.classic-teacher-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  min-height: 50px;
  min-width: 64px;
  padding: 6px 14px;
  border-radius: 18px;
  border: 3px solid #5C4B3F;
  background: #FFFFFF;
  color: #2D3436;
  font-size: 17px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 0 #5C4B3F;
}

.icon-sound::before {
  border-radius: 999px;
  border: 2px solid currentColor;
  background: rgba(251, 191, 36, 0.28);
  color: inherit;
  box-shadow: none;
}

.icon-sound[aria-pressed="true"]::before {
  background: #FFFFFF;
  border-color: #15803D;
  color: #15803D;
}

.sound-toggle.active {
  background: #E2F4E6;
  border-color: #15803D;
  color: #14532D;
  box-shadow: 0 4px 0 #15803D;
}

.classic-teacher-btn.is-open {
  background: #FFEDE3;
  border-color: #C2410C;
  color: #7C2D12;
  box-shadow: 0 4px 0 #C2410C;
}

.home-link:active,
.classic-teacher-btn:active,
.sound-toggle:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #5C4B3F;
}

.home-link:focus-visible,
.classic-teacher-btn:focus-visible,
.sound-toggle:focus-visible {
  outline: 4px solid #C2410C;
  outline-offset: 3px;
}

/* ---------- 상단 3활동 탭 + 별 지도 칩 ---------- */
.daily-routine {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  margin: 0 auto 10px;
  padding: 7px 10px;
  border: 3px solid #EADFD3;
  border-top-width: 3px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 6px 18px rgba(92, 75, 63, 0.08);
}

.routine-actions {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.routine-btn {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 54px;
  padding: 6px 10px;
  border: 3px solid #D8CBB8;
  border-radius: 18px;
  background: #FFFFFF;
  color: #2D3436;
  font-size: 17px;
  font-weight: 900;
  box-shadow: 0 4px 0 #D8CBB8;
}

.routine-clay-icon {
  width: 38px;
  height: 38px;
  flex: none;
  object-fit: contain;
}

.routine-number,
.routine-meta,
.routine-state {
  display: none;
}

.routine-btn[data-activity="math"].active {
  background: #DFEBFA;
  border-color: #1F64B8;
  color: #123D73;
  box-shadow: 0 4px 0 #1F64B8;
}

.routine-btn[data-activity="sentence"].active {
  background: #FDE5DF;
  border-color: #C2412D;
  color: #6E1D10;
  box-shadow: 0 4px 0 #C2412D;
}

.routine-btn[data-activity="social"].active {
  background: #E0F2E4;
  border-color: #2B7A42;
  color: #144923;
  box-shadow: 0 4px 0 #2B7A42;
}

.routine-btn:active {
  transform: translateY(2px);
}

/* game.css의 <=720px position:absolute 무력화 — 상단 바와 절대 겹치지 않게 고정 */
#gameChip.game-chip {
  position: static;
  top: auto;
  right: auto;
  z-index: auto;
  flex: none;
  border-radius: 18px;
  border: 3px solid #B45309;
  background: #FFF4CC;
  color: #2D3436;
  min-width: 78px;
  min-height: 54px;
  padding: 6px 12px;
  box-shadow: 0 4px 0 #B45309;
}

/* ---------- 학습 무대 공통 (고정 높이·잘림 100% 해제) ---------- */
#mathStage {
  --stage-accent: #1F64B8;
  --stage-soft: #EEF5FD;
  --stage-pill: #DFEBFA;
}

#sentenceStage {
  --stage-accent: #C2412D;
  --stage-soft: #FFF2EE;
  --stage-pill: #FDE5DF;
}

#socialStage {
  --stage-accent: #2B7A42;
  --stage-soft: #EFF9F1;
  --stage-pill: #E0F2E4;
}

.learning-stage {
  height: auto;
  min-height: 0;
  max-height: none;
  overflow: visible;
  border: 4px solid var(--stage-accent, #1F64B8);
  border-top-width: 4px;
  border-radius: 28px;
  background: #FFFFFF;
  box-shadow: 0 8px 0 var(--stage-accent, #1F64B8), 0 14px 32px rgba(45, 52, 54, 0.10);
}

.learning-stage .screen,
#introScreen,
#gameScreen,
#resultScreen,
#sentenceScreen,
#socialScreen {
  height: auto;
  min-height: 0;
  max-height: none;
  overflow: visible;
}

.screen {
  padding: 14px 18px 20px;
}

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--stage-soft, #EEF5FD);
  border-bottom: 3px solid rgba(92, 75, 63, 0.12);
  border-radius: 24px 24px 0 0;
  padding: 10px 18px;
}

.game-header .title-cell {
  flex: 0 1 auto;
  min-width: 0;
}

.stage-label,
.round-label {
  flex: 0 0 auto;
  border: 2.5px solid var(--stage-accent, #1F64B8);
  border-radius: 999px;
  padding: 5px 14px;
  background: #FFFFFF;
  color: #1F2A33;
  font-size: 16px;
  white-space: nowrap;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.06);
}

.timer-box {
  margin-left: auto;
  flex: 0 0 auto;
  text-align: right;
}

.timer-box span {
  color: #4B5563;
  font-size: 13px;
  white-space: nowrap;
}

.timer-box strong {
  color: #1F2A33;
  font-size: 26px;
  white-space: nowrap;
}

.meter {
  height: 12px;
  margin: 8px 18px 0;
  padding: 2px;
  background: #F1EAE1;
  border: 2px solid #D8CBB8;
  border-radius: 999px;
  box-shadow: none;
}

#timeFill,
#sentenceProgressFill,
#socialProgressFill {
  border-radius: 999px;
}

#timeFill {
  background: linear-gradient(90deg, #60A5FA 0%, #2563EB 100%);
}

#sentenceProgressFill {
  background: linear-gradient(90deg, #FB923C 0%, #EA580C 100%);
}

#socialProgressFill {
  background: linear-gradient(90deg, #4ADE80 0%, #16A34A 100%);
}

/* 옛 8비트 도트 미니맵·픽셀 얼굴 숨김 (DOM ID는 유지) */
#sceneMapMath,
#sceneMathTower,
#sceneSentence,
#sceneSocial {
  display: none;
}

/* ---------- 구구단 시작 화면 (시작 버튼 중앙 배치 + 미니 개념 카드) ---------- */
#introScreen .concept {
  height: auto;
  gap: 8px;
}

#introScreen .concept-kicker {
  display: none;
}

.dan-map-label {
  margin: 0 auto 2px;
  justify-content: center;
  font-size: 16px;
  color: #123D73;
}

.dan-map-label::before,
.dan-picker::before,
.dan-picker::after {
  display: none;
}

.dan-picker {
  border-radius: 22px;
  border: 2.5px solid #BFD7F6;
  background: #F4F9FF;
  padding: 10px 12px;
  margin: 0 auto;
  box-shadow: none;
}

.dan-btn,
.mode-btn,
.time-btn,
.sentence-category-btn,
.social-category-btn {
  min-height: 48px;
  border-radius: 16px;
  border: 3px solid #CFC2B2;
  background: #FFFFFF;
  color: #2D3436;
  font-weight: 900;
  box-shadow: 0 3px 0 #CFC2B2;
}

.dan-btn.active,
.mode-btn.active,
.time-btn.active,
.sentence-category-btn.active,
.social-category-btn.active {
  border-color: var(--stage-accent, #1F64B8);
  background: var(--stage-accent, #1F64B8);
  color: #FFFFFF;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.22);
}

.dan-btn.active::after {
  right: 4px;
  top: 2px;
  font-size: 12px;
  line-height: 1;
  border-radius: 999px;
}

.mode-btn.active .lv-badge {
  background: #FFFFFF;
  color: #1F2A33;
}

.lv-badge {
  border-radius: 999px;
  border-width: 1.5px;
}

.dan-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.dan-btn-icon {
  width: 24px;
  height: 24px;
  object-fit: contain;
  pointer-events: none;
  flex: none;
}

.dan-btn-label {
  line-height: 1.1;
}

.practice-summary-btn {
  display: none;
}

.question-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
}

/* Android 앱 전용: 상단 1줄 다이어트 (별 배지를 상단 바로 통합하고 중복 2층 탭 제거) */
html.android-app .daily-routine {
  display: none;
}

html.app-direct-activity .topbar a.home-link {
  display: none;
}

.topbar #gameChip.game-chip {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  min-width: 62px;
  min-height: 44px;
  padding: 0 10px;
  gap: 5px;
  border-radius: 14px;
  border: 2.5px solid #B45309;
  background: #FEF3C7;
  color: #78350F;
  font-size: 14px;
  font-weight: 900;
  box-shadow: 0 3px 0 #B45309;
}

.dan-btn:active,
.mode-btn:active,
.time-btn:active,
.answer-btn:active,
.sentence-choice-btn:active,
.social-mind-choice-btn:active,
.social-choice-btn:active,
.sentence-category-btn:active,
.social-category-btn:active {
  transform: translateY(2px) scale(0.985);
}

.practice-row {
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  width: min(760px, 100%);
  margin: 0 auto;
  padding: 8px 12px;
  border-radius: 20px;
  border: 2px solid #D6E6FB;
  background: #F8FBFF;
}

.time-picker {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.picker-label-sub {
  font-size: 11.5px;
  font-weight: 700;
  color: #475569;
}

/* 시작 버튼: 단·난이도 선택 바로 아래 화면 중앙에 큼직하고 눈에 띄게 배치 */
.intro-start-row {
  width: 100%;
  display: flex;
  justify-content: center;
  margin: 4px 0 2px;
}

#introScreen #startBtn {
  width: min(380px, 100%);
  min-height: 64px;
  margin-top: 0;
  padding: 12px 28px;
  border-radius: 999px;
  border: 3.5px solid #9A3412;
  background: linear-gradient(180deg, #EA580C 0%, #C2410C 100%);
  color: #FFFFFF;
  font-size: 25px;
  font-weight: 900;
  letter-spacing: 0.01em;
  box-shadow: 0 6px 0 #9A3412, 0 10px 20px rgba(194, 65, 12, 0.22);
}

#introScreen #startBtn:active {
  transform: translateY(3px);
  box-shadow: 0 3px 0 #9A3412;
}

/* 구구단 개념 미리보기 미니 카드 (시작 버튼 아래 한 줄 동화 카드) */
.intro-preview-card {
  width: min(760px, 100%);
  margin: 2px auto 0;
  padding: 10px 16px;
  border-radius: 22px;
  border: 2.5px solid #BFD7F6;
  background: #F4F9FF;
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
  box-sizing: border-box;
}

.intro-preview-icon {
  width: 60px;
  height: 60px;
  flex: none;
  object-fit: contain;
  padding: 6px;
  border-radius: 18px;
  background: #FFFFFF;
  border: 2px solid #D6E6FB;
}

.intro-preview-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 12px;
}

.intro-preview-top {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 12px;
}

#introScreen #conceptTitle {
  display: block;
  margin: 0;
  font-size: 18px;
  font-weight: 900;
  color: #1E3A5F;
}

#introScreen #conceptEquation {
  display: inline-block;
  margin: 0;
  padding: 2px 10px;
  border-radius: 999px;
  background: #FFFFFF;
  border: 2px solid #93C5FD;
  font-size: 20px;
  font-weight: 900;
  color: #1D4ED8;
}

#introScreen #introVisual {
  display: inline-flex;
  margin: 0;
  gap: 6px;
}

#introScreen #conceptNote {
  display: block;
  width: 100%;
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: #475569;
}

/* 묶음 점(사탕 구슬 스타일) */
.dot-group {
  border-radius: 16px;
  border: 2.5px solid #93C5FD;
  background: #FFFFFF;
  box-shadow: 0 3px 0 #BFDBFE;
  padding: 5px 8px;
}

.dot-group i,
.bundle-dot {
  border-radius: 999px;
  background: #FBBF24;
  border: 2px solid #B45309;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.65);
}

#introScreen .dot-group i {
  width: 14px;
  height: 14px;
}

/* ---------- 구구단 문제 및 결과 화면 ---------- */
#gameScreen {
  gap: 6px;
}

.question {
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  border-radius: 24px;
  border: 3px solid #1F64B8;
  background: #EEF5FD;
  color: #123D73;
  padding: 8px 26px;
  box-shadow: none;
}

.progress-step {
  border-radius: 999px;
}

.streak-reward {
  border-radius: 20px;
  border: 2.5px solid #E2D5C5;
  background: #FFFDF9;
  box-shadow: none;
}

.learning-shard {
  border-radius: 999px;
}

.classic-result-mascot {
  width: 96px;
  height: 96px;
  object-fit: contain;
  margin: 0 auto 4px;
}

.result-card {
  border-radius: 18px;
  border: 2.5px solid #BFD7F6;
  background: #F4F9FF;
  box-shadow: none;
}

/* ---------- 생활 문장 · 사회 상황 동화책 삽화 카드 ---------- */
.sentence-category-picker,
.social-category-picker {
  width: min(760px, 100%);
  margin: 0 auto 10px;
}

.story-hero-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 16px;
  width: min(820px, 100%);
  margin: 0 auto 12px;
  padding: 14px 18px;
  border-radius: 24px;
  border: 3px solid var(--stage-accent, #C2412D);
  background: var(--stage-soft, #FFF2EE);
  text-align: left;
  box-sizing: border-box;
}

.story-art-box {
  width: 100px;
  height: 100px;
  border-radius: 22px;
  border: 2.5px solid rgba(92, 75, 63, 0.16);
  background: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  box-shadow: 0 6px 14px rgba(45, 52, 54, 0.08);
}

.story-art-img {
  width: 84px;
  height: 84px;
  object-fit: contain;
}

.story-art-img.is-cheer {
  animation: story-art-bounce 0.5s ease-out;
}

@keyframes story-art-bounce {
  0%, 100% { transform: scale(1) translateY(0); }
  45% { transform: scale(1.1) translateY(-6px); }
}

.story-speech-box {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  min-width: 0;
}

.concept-kicker {
  margin: 0;
  border-radius: 999px;
  border: 2px solid var(--stage-accent, #1F64B8);
  background: #FFFFFF;
  color: #1F2A33;
  padding: 3px 12px;
  font-size: 14px;
  box-shadow: none;
}

#sentenceSituation,
#socialSituation {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: #1F2A33;
  font-size: clamp(24px, 3.8vh, 32px);
  font-weight: 900;
  line-height: 1.28;
  word-break: keep-all;
}

.sentence-target,
.social-mind {
  width: 100%;
  min-height: 46px;
  margin: 2px 0 0;
  padding: 8px 14px;
  border-radius: 16px;
  border: 2.5px solid rgba(92, 75, 63, 0.22);
  background: #FFFFFF;
  font-size: clamp(18px, 2.8vh, 24px);
  box-sizing: border-box;
  word-break: keep-all;
}

.social-mind {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px 10px;
}

.social-mind span {
  flex: 0 0 auto;
  white-space: nowrap;
}

#socialEmotion {
  word-break: keep-all;
}

.sentence-target[data-state="answered"] {
  border-color: #15803D;
  background: #E2F4E6;
  color: #14532D;
}

.social-mind[data-state="answered"] {
  border-color: #15803D;
  background: #E2F4E6;
}

/* ---------- 정답 보기 및 실행 버튼 ---------- */
.answer-btn,
.sentence-choice-btn,
.social-mind-choice-btn,
.social-choice-btn {
  min-height: 68px;
  border-radius: 22px;
  border: 3px solid #5C4B3F;
  background: #FFFDF9;
  color: #2D3436;
  box-shadow: 0 5px 0 #5C4B3F;
}

.answer-btn:active,
.sentence-choice-btn:active,
.social-mind-choice-btn:active,
.social-choice-btn:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #5C4B3F;
}

.answer-btn.correct,
.sentence-choice-btn.correct,
.social-mind-choice-btn.correct,
.social-choice-btn.correct {
  background: #E2F4E6;
  border-color: #15803D;
  color: #14532D;
  box-shadow: 0 5px 0 #15803D;
}

.primary-btn,
.secondary-btn,
.read-question-btn {
  min-height: 54px;
  border-radius: 20px;
  border-width: 3px;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.20);
}

.primary-btn {
  background: #C2410C;
  border-color: #9A3412;
  color: #FFFFFF;
}

.listen-btn,
.read-question-btn {
  background: #0F766E;
  border-color: #115E59;
  color: #FFFFFF;
}

.listen-btn::before,
.read-question-btn.icon-listen::before,
.primary-btn.action-icon::before {
  color: inherit;
}

.feedback:empty,
.result-message:empty {
  display: none;
}

.group-row,
.visual-model,
.hint-panel,
.sentence-hint,
.social-reason {
  border-radius: 18px;
}

/* 학생 화면 단순화: 교사용 문구·복사 버튼·복사 미리보기·푸터는 교사용 패널이 열렸을 때만 표시 */
.sentence-bottom-actions,
.social-bottom-actions,
#copyResultBtn,
#copyPreview,
#resultTeacherTip,
.site-footer {
  display: none;
}

body.classic-teacher-open .sentence-bottom-actions,
body.classic-teacher-open .social-bottom-actions {
  display: flex;
}

body.classic-teacher-open #copyResultBtn {
  display: inline-flex;
}

body.classic-teacher-open #copyPreview:not([hidden]),
body.classic-teacher-open #resultTeacherTip {
  display: block;
}

/* 교사용 패널: 닫혀 있을 때는 학생 화면에서 완전히 숨김, 열렸을 때만 카드형 표시 */
details.teacher-tools:not([open]) {
  display: none;
}

details.teacher-tools[open] {
  display: block;
  margin-top: 16px;
  border-radius: 24px;
  border: 3px solid #5C4B3F;
  background: #FFFFFF;
  box-shadow: 0 8px 24px rgba(45, 52, 54, 0.12);
  overflow: hidden;
}

.teacher-guide-banner {
  margin-bottom: 14px;
}

.guide-banner-link {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 54px;
  padding: 12px 20px;
  border-radius: 18px;
  border: 3px solid #0F766E;
  background: #F0FDFA;
  color: #0F766E;
  font-size: 18px;
  font-weight: 900;
  text-decoration: none;
  text-align: center;
}

.guide-banner-link:hover {
  background: #CCFBF1;
}

/* 태블릿 가로 화면: 상단 바 유지 + 잘림 없이 한 화면 안에 쾌적하게 배치 */
@media (min-width: 721px) and (max-height: 860px) and (orientation: landscape) {
  .topbar {
    display: flex;
    padding: calc(6px + env(safe-area-inset-top, 0px)) 16px 4px;
    gap: 8px;
  }
  .topbar-mascot {
    width: 36px;
    height: 36px;
  }
  #appTitle {
    font-size: 20px;
  }
  .home-link,
  .sound-toggle,
  .classic-teacher-btn {
    min-height: 44px;
    padding: 4px 12px;
    font-size: 16px;
  }
  .daily-routine {
    padding: 5px 8px;
    margin-bottom: 6px;
  }
  .routine-btn,
  #gameChip.game-chip {
    min-height: 46px;
  }
  .routine-clay-icon {
    width: 32px;
    height: 32px;
  }
  .learning-stage {
    height: auto;
    min-height: 0;
    max-height: none;
    overflow: visible;
  }
  .screen {
    padding: 10px 16px 14px;
  }
  #introScreen #startBtn {
    min-height: 56px;
    font-size: 22px;
  }
  .intro-preview-card {
    padding: 8px 14px;
  }
  .intro-preview-icon {
    width: 48px;
    height: 48px;
  }
  #introScreen #conceptTitle {
    display: block;
    font-size: 16px;
  }
  #introScreen #conceptEquation {
    display: inline-block;
    font-size: 18px;
  }
  #introScreen #introVisual {
    display: inline-flex;
  }
  #introScreen #conceptNote {
    display: none;
  }
  .story-hero-card {
    padding: 10px 14px;
    margin-bottom: 8px;
  }
  .story-art-box {
    width: 80px;
    height: 80px;
  }
  .story-art-img {
    width: 68px;
    height: 68px;
  }
}

/* 스마트폰 한 화면 완성 (360×640 보급형 세로 화면에서도 상단 메뉴판·시작·끝내기·다음 버튼까지 한 화면에 배치) */
@media (max-width: 720px) {
  .topbar {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: space-between;
    padding: calc(4px + env(safe-area-inset-top, 0px)) 8px 3px;
    gap: 5px;
  }
  .topbar > div:not(.topbar-nav-group):not(.topbar-actions) {
    display: none;
  }
  .topbar-nav-group,
  .topbar-actions {
    flex-wrap: nowrap;
    gap: 4px;
  }
  .home-link,
  .sound-toggle,
  .classic-teacher-btn {
    width: auto;
    min-width: 0;
    min-height: 44px;
    padding: 0 10px;
    border-radius: 14px;
    font-size: 14px;
    white-space: nowrap;
    box-shadow: 0 3px 0 #5C4B3F;
  }
  .home-link.app-exit-home {
    box-shadow: 0 3px 0 #C2410C;
  }
  .home-link::before {
    margin-right: 3px;
    font-size: 18px;
  }
  .icon-sound::before {
    min-width: 1.3em;
    height: 1.3em;
    margin-right: 4px;
    font-size: 0.9em;
  }
  main {
    padding: 2px 8px calc(10px + env(safe-area-inset-bottom, 0px));
  }
  .daily-routine {
    padding: 4px 5px;
    gap: 4px;
    border-radius: 16px;
    border-width: 2.5px;
    margin-bottom: 5px;
  }
  .routine-actions {
    gap: 4px;
  }
  .routine-btn {
    flex-direction: column;
    gap: 1px;
    min-height: 46px;
    padding: 3px 2px;
    border-radius: 13px;
    border-width: 2.5px;
    font-size: clamp(11px, 3.3vw, 13px);
    line-height: 1.15;
    text-align: center;
    word-break: keep-all;
    box-shadow: 0 3px 0 #D8CBB8;
  }
  .routine-clay-icon {
    width: 21px;
    height: 21px;
  }
  #gameChip.game-chip {
    min-width: 56px;
    min-height: 46px;
    padding: 3px 6px;
    gap: 4px;
    border-radius: 13px;
    border-width: 2.5px;
    font-size: 13px;
    box-shadow: 0 3px 0 #B45309;
  }
  .learning-stage {
    border-width: 2px;
    border-radius: 22px;
    box-shadow: 0 3px 0 var(--stage-accent, #1F64B8), 0 8px 20px rgba(45, 52, 54, 0.08);
  }
  .game-header {
    padding: 5px 10px;
    gap: 5px;
    border-radius: 20px 20px 0 0;
    border-bottom-width: 2px;
  }
  .stage-label,
  .round-label {
    padding: 2px 8px;
    border-width: 2px;
    font-size: 12px;
    white-space: nowrap;
  }
  .timer-box span {
    display: none;
  }
  .timer-box strong {
    margin-top: 0;
    font-size: 17px;
    white-space: nowrap;
  }
  .meter {
    height: 7px;
    margin: 4px 10px 0;
    padding: 1px;
  }
  .screen {
    padding: 6px 9px 8px;
  }
  html.android-app .screen {
    padding: 8px 10px 10px;
  }

  /* 1) 구구단 시작 화면: 3D 클레이 아이콘 카드 + 접이식 옵션 한 줄 칩 */
  #introScreen .concept {
    gap: 5px;
  }
  html.android-app #introScreen .concept {
    gap: 7px;
  }
  .dan-map-label {
    font-size: 13.5px;
    line-height: 1.2;
    margin: 0 auto;
  }
  .dan-picker {
    padding: 5px 6px;
    gap: 5px;
    border-radius: 16px;
    border-width: 2px;
  }
  .dan-btn,
  .mode-btn,
  .time-btn {
    min-height: 46px;
    padding: 3px 4px;
    border-radius: 13px;
    border-width: 2.5px;
    font-size: clamp(12.5px, 3.7vw, 14.5px);
    line-height: 1.15;
    text-align: center;
    word-break: keep-all;
    box-shadow: 0 2.5px 0 #CFC2B2;
  }
  .dan-btn {
    flex-direction: row;
    gap: 4px;
  }
  .dan-btn-icon {
    width: 19px;
    height: 19px;
  }
  html.android-app body:not(.practice-options-open) #introScreen .dan-btn {
    flex-direction: column;
    gap: 2px;
    min-height: 48px;
    padding: 3px 3px;
    font-size: 13px;
  }
  html.android-app body:not(.practice-options-open) #introScreen .dan-btn-icon {
    width: 20px;
    height: 20px;
  }
  .dan-btn.active::after {
    right: 3px;
    top: 1px;
    font-size: 10px;
  }
  #practiceSummaryBtn.practice-summary-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 44px;
    padding: 4px 10px;
    border-radius: 13px;
    border: 2px solid #93C5FD;
    background: #FFFFFF;
    color: #1E3A5F;
    font-size: 13.5px;
    font-weight: 900;
    cursor: pointer;
    box-shadow: 0 2px 0 #BFDBFE;
  }
  .practice-summary-action {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1.5px solid #1F64B8;
    background: #EFF6FF;
    color: #123D73;
    font-size: 12px;
    font-weight: 900;
    white-space: nowrap;
  }
  body:not(.practice-options-open) #introScreen .picker-group-mode {
    display: none;
  }
  .picker-group-mode > .picker-label {
    display: none;
  }
  body.practice-options-open #introScreen .intro-preview-card {
    display: none;
  }
  .practice-row {
    display: flex;
    flex-direction: column;
    padding: 5px 7px;
    gap: 5px;
    border-radius: 15px;
  }
  .picker-group {
    gap: 3px;
  }
  .picker-group + .picker-group {
    padding-left: 0;
    border-left: 0;
  }
  .picker-label {
    font-size: 11.5px;
    color: #1E3A5F;
    line-height: 1.15;
    margin: 0;
  }
  .picker-label-sub {
    font-size: 10.5px;
  }
  .mode-picker,
  .time-picker {
    gap: 5px;
  }
  .time-picker {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .dan-btn,
  .mode-btn,
  .time-btn {
    min-height: 44px;
  }
  .intro-start-row {
    margin: 1px 0 0;
    width: 100%;
  }
  #introScreen #startBtn {
    width: 100%;
    min-height: 52px;
    padding: 7px 18px;
    font-size: 20px;
    border-radius: 17px;
    box-shadow: 0 4px 0 #9A3412, 0 6px 14px rgba(194, 65, 12, 0.18);
  }
  html.android-app #introScreen #startBtn {
    min-height: 54px;
    font-size: 21px;
  }
  .intro-preview-card {
    padding: 6px 9px;
    gap: 9px;
    border-radius: 15px;
    border-width: 2px;
    margin: 0 auto;
  }
  .intro-preview-icon {
    width: 40px;
    height: 40px;
    padding: 4px;
    border-radius: 12px;
  }
  html.android-app .intro-preview-icon {
    width: 48px;
    height: 48px;
    padding: 5px;
  }
  .intro-preview-body {
    gap: 4px 8px;
  }
  .intro-preview-top {
    gap: 4px 8px;
  }
  #introScreen #conceptTitle {
    font-size: 13.5px;
    line-height: 1.2;
  }
  #introScreen #conceptEquation {
    font-size: 15px;
    padding: 2px 9px;
  }
  #introScreen #introVisual {
    gap: 4px;
  }
  #introScreen .dot-group {
    padding: 3px 5px;
    border-radius: 10px;
    border-width: 2px;
    box-shadow: 0 2px 0 #BFDBFE;
  }
  #introScreen .dot-group i {
    width: 9.5px;
    height: 9.5px;
  }
  #introScreen #conceptNote {
    display: none;
  }

  /* 2) 구구단 문제 풀이 화면: 문제+읽어주기 가로 통합 & 큼직한 게임 패드 보기 */
  #gameScreen {
    gap: 6px;
  }
  html.android-app #gameScreen {
    gap: 8px;
  }
  #gameScreen .visual-model {
    min-height: 0;
    padding: 5px 7px;
    margin: 0;
    gap: 4px;
  }
  #gameScreen .group-row {
    gap: 4px;
  }
  #gameScreen .dot-group {
    padding: 3px 5px;
    gap: 2.5px;
    border-radius: 10px;
    border-width: 2px;
    box-shadow: none;
  }
  #gameScreen .dot-group i,
  #gameScreen .bundle-dot {
    width: 8.5px;
    height: 8.5px;
    border-width: 1.5px;
  }
  #gameScreen .question-bar {
    flex-direction: row;
    align-items: stretch;
    justify-content: center;
    gap: 7px;
    width: 100%;
  }
  #gameScreen .question {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 52px;
    font-size: clamp(22px, 6.5vw, 27px);
    line-height: 1.15;
    padding: 5px 10px;
    margin: 0;
    border-radius: 16px;
    border-width: 2.5px;
    white-space: nowrap;
  }
  html.android-app #gameScreen .question {
    min-height: 54px;
    font-size: clamp(23px, 6.8vw, 28px);
  }
  #gameScreen #readQuestionBtn {
    flex: 0 0 auto;
    min-height: 52px;
    padding: 5px 12px;
    font-size: 14.5px;
    margin: 0;
    border-radius: 15px;
    white-space: nowrap;
    box-shadow: 0 3px 0 rgba(0, 0, 0, 0.18);
  }
  html.android-app #gameScreen #readQuestionBtn {
    min-height: 54px;
    font-size: 15px;
  }
  #gameScreen .progress-board {
    display: none;
  }
  #gameScreen .streak-reward {
    min-height: 28px;
    padding: 3px 9px;
    margin: 0;
    gap: 6px;
    font-size: 12.5px;
    border-radius: 14px;
  }
  #gameScreen .hint-panel {
    padding: 5px 9px;
    margin: 0;
    font-size: 13.5px;
    line-height: 1.25;
  }
  #gameScreen .answers {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    margin: 0;
    width: 100%;
  }
  #gameScreen .answer-btn {
    min-height: 52px;
    padding: 5px 8px;
    font-size: 24px;
    border-radius: 16px;
    border-width: 2.5px;
    box-shadow: 0 3.5px 0 #5C4B3F;
  }
  html.android-app #gameScreen .answer-btn {
    min-height: 58px;
    font-size: 26px;
  }
  #gameScreen .feedback {
    margin: 0;
    min-height: 0;
    padding: 2px 6px;
    font-size: 13.5px;
    line-height: 1.2;
  }
  #gameScreen #finishBtn {
    min-height: 44px;
    padding: 4px 16px;
    font-size: 14px;
    margin: 0;
    border-radius: 14px;
    box-shadow: 0 3px 0 rgba(0, 0, 0, 0.16);
  }
  #gameScreen:has(#hintPanel:not([hidden])) {
    gap: 4px;
  }
  #gameScreen:has(#hintPanel:not([hidden])) .question {
    min-height: 46px;
    font-size: 23px;
    padding: 4px 10px;
  }
  #gameScreen:has(#hintPanel:not([hidden])) #readQuestionBtn {
    min-height: 46px;
  }
  #gameScreen:has(#hintPanel:not([hidden])) .answer-btn {
    min-height: 46px;
    font-size: 21px;
  }
  #gameScreen:has(#hintPanel:not([hidden])) .streak-reward {
    display: none;
  }

  /* 3) 구구단 결과 화면 한 화면 배치 */
  #resultScreen .result-panel {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 0;
  }
  .classic-result-mascot {
    width: 52px;
    height: 52px;
    margin: 0 auto;
  }
  html.android-app .classic-result-mascot {
    width: 64px;
    height: 64px;
  }
  #resultScreen .result-kicker {
    font-size: 11.5px;
    margin: 0;
  }
  #resultScreen #resultTitle {
    font-size: 21px;
    line-height: 1.2;
    margin: 0;
  }
  #resultScreen .result-student-note {
    padding: 6px 10px;
    margin: 1px 0;
    font-size: 14.5px;
    line-height: 1.25;
    border-radius: 13px;
  }
  #resultScreen .result-stats {
    font-size: 13px;
    margin: 0;
  }
  #resultScreen .result-details {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
    margin: 2px 0;
  }
  #resultScreen .result-card {
    min-height: 0;
    padding: 5px 4px;
    border-radius: 12px;
    border-width: 2px;
  }
  #resultScreen .result-card span {
    font-size: 11px;
  }
  #resultScreen .result-card strong {
    font-size: 15.5px;
    margin-top: 1px;
  }
  body:not(.classic-teacher-open) #resultScreen .result-message {
    display: none;
  }
  #resultScreen .result-message {
    font-size: 12.5px;
    line-height: 1.25;
    margin: 0;
  }
  #resultScreen #resultActions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    width: 100%;
    margin-top: 4px;
  }
  #resultScreen #resultActions > button {
    flex: 1 1 calc(50% - 6px);
    width: auto;
    min-width: 0;
    min-height: 46px;
    padding: 5px 8px;
    font-size: 14.5px;
    margin: 0;
    border-radius: 14px;
  }
  #resultScreen #resultActions > .recommended-action {
    order: -1;
    min-height: 48px;
    border-width: 3px;
    font-size: 14.5px;
  }
  #resultScreen #resultActions:has(#nextDanBtn:not([hidden])):not(:has(#nextModeBtn:not([hidden]))) > .recommended-action,
  #resultScreen #resultActions:has(#nextModeBtn:not([hidden])):not(:has(#nextDanBtn:not([hidden]))) > .recommended-action {
    flex-basis: 100%;
  }
  #resultScreen #resultActions > .recommended-action::after {
    padding: 1px 6px;
    font-size: 11px;
  }

  /* 4) 생활 문장 · 사회 상황: 상황 그림 2배 확대 & 3중 액자 테두리 정리 */
  .sentence-panel,
  .social-panel {
    display: flex;
    flex-direction: column;
    gap: 5px;
  }
  html.android-app .sentence-panel,
  html.android-app .social-panel {
    gap: 7px;
  }
  .sentence-category-picker,
  .social-category-picker {
    margin: 0 auto;
    gap: 5px;
  }
  .sentence-category-btn,
  .social-category-btn {
    min-height: 44px;
    padding: 3px 4px;
    font-size: 14.5px;
    border-radius: 12px;
    border-width: 2px;
    box-shadow: 0 2px 0 #D8CBB8;
  }
  .story-hero-card {
    padding: 8px 10px;
    gap: 10px;
    margin: 0 auto;
    border-radius: 16px;
    border-width: 2px;
    box-shadow: 0 3px 10px rgba(45, 52, 54, 0.05);
  }
  .story-art-box {
    width: 60px;
    height: 60px;
    border-radius: 15px;
  }
  .story-art-img {
    width: 50px;
    height: 50px;
  }
  html.android-app .story-art-box {
    width: 84px;
    height: 84px;
    border-radius: 18px;
  }
  html.android-app .story-art-img {
    width: 74px;
    height: 74px;
  }
  .story-speech-box {
    gap: 3px;
  }
  .concept-kicker {
    font-size: 11.5px;
    padding: 1px 8px;
  }
  #sentenceSituation,
  #socialSituation {
    font-size: 17px;
    line-height: 1.24;
  }
  html.android-app #sentenceSituation,
  html.android-app #socialSituation {
    font-size: 18.5px;
    line-height: 1.26;
  }
  .sentence-target,
  .social-mind {
    min-height: 34px;
    padding: 5px 9px;
    margin: 0;
    font-size: 14.5px;
    line-height: 1.22;
    border-radius: 12px;
    border-width: 2px;
  }
  .social-mind {
    gap: 3px 8px;
  }
  .social-mind span {
    font-size: 11.5px;
    padding: 1px 6px;
  }
  #socialEmotion {
    font-size: 14.5px;
    line-height: 1.22;
  }
  .sentence-choices,
  .social-mind-choices,
  .social-choices {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
    margin: 0;
  }
  .sentence-choice-btn,
  .social-mind-choice-btn,
  .social-choice-btn {
    min-height: 46px;
    padding: 5px 11px;
    font-size: 16px;
    line-height: 1.2;
    border-radius: 14px;
    border-width: 2.5px;
    box-shadow: 0 3px 0 #5C4B3F;
  }
  html.android-app .sentence-choice-btn,
  html.android-app .social-mind-choice-btn,
  html.android-app .social-choice-btn {
    min-height: 50px;
    font-size: 16.5px;
  }
  /* 힌트·이유가 열릴 때는 한 화면(640px) 무스크롤을 위해 카드 높이를 부드럽게 조인다 */
  .sentence-panel:has(#sentenceHint:not([hidden])),
  .social-panel:has(#socialReason:not([hidden])) {
    gap: 4px;
  }
  .sentence-panel:has(#sentenceHint:not([hidden])) .story-art-box,
  .social-panel:has(#socialReason:not([hidden])) .story-art-box {
    width: 62px;
    height: 62px;
  }
  .sentence-panel:has(#sentenceHint:not([hidden])) .story-art-img,
  .social-panel:has(#socialReason:not([hidden])) .story-art-img {
    width: 52px;
    height: 52px;
  }
  .sentence-panel:has(#sentenceHint:not([hidden])) .sentence-choice-btn,
  .social-panel:has(#socialReason:not([hidden])) .social-mind-choice-btn,
  .social-panel:has(#socialReason:not([hidden])) .social-choice-btn {
    min-height: 45px;
    font-size: 15.5px;
  }
  .sentence-practice-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    width: 100%;
    margin: 0;
  }
  .sentence-practice-actions:has(> [hidden]),
  .sentence-practice-actions:has(> .said-btn:disabled) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .social-practice-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    width: 100%;
    margin: 0;
  }
  .sentence-practice-actions > button,
  .social-practice-actions > button {
    width: 100%;
    min-width: 0;
    min-height: 44px;
    padding: 4px 4px;
    margin: 0;
    font-size: clamp(12px, 3.5vw, 14px);
    line-height: 1.15;
    border-radius: 13px;
    border-width: 2.5px;
    text-align: center;
    word-break: keep-all;
    box-shadow: 0 3px 0 rgba(0, 0, 0, 0.18);
  }
  .sentence-practice-actions > .action-icon::before {
    display: none;
  }
  #sentenceFeedback,
  #socialFeedback {
    margin: 0;
    min-height: 0;
    padding: 2px 6px;
    font-size: 13px;
    line-height: 1.25;
  }
  .sentence-hint,
  .social-reason {
    margin: 0;
    padding: 4px 8px;
    font-size: 12.5px;
    line-height: 1.25;
    border-radius: 12px;
  }
}

/* 360~430px 초소형 스마트폰 세로 화면: 상단 바 가로 넘침 0 및 난이도 배지 정리 */
@media (max-width: 430px) {
  .topbar {
    padding-left: 8px;
    padding-right: 8px;
    gap: 4px;
  }
  .topbar-nav-group,
  .topbar-actions {
    gap: 4px;
  }
  .home-link,
  .sound-toggle,
  .classic-teacher-btn,
  .topbar #gameChip.game-chip {
    width: auto;
    min-width: 44px;
    min-height: 44px;
    padding: 0 7px;
    border-width: 2.5px;
    font-size: 12.5px;
  }
  html:not(.app-direct-activity) .topbar #gameChip .chip-badge {
    display: none;
  }
  html.android-app:not(.app-direct-activity) .topbar .home-link,
  html.android-app:not(.app-direct-activity) .topbar .sound-toggle,
  html.android-app:not(.app-direct-activity) .topbar .classic-teacher-btn,
  html.android-app:not(.app-direct-activity) .topbar #gameChip.game-chip {
    padding: 0 5px;
    font-size: 12px;
  }
  html.android-app:not(.app-direct-activity) .topbar .home-link::before {
    display: none;
  }
  .icon-sound::before {
    display: none;
  }
  .mode-btn .lv-badge {
    display: none;
  }
}

/* 스마트폰 가로 모드(높이 500px 이하): 상단 메뉴판·시작 버튼까지 한 화면에 정렬 */
@media (max-height: 500px) and (orientation: landscape) {
  .topbar {
    padding: calc(2px + env(safe-area-inset-top, 0px)) 10px 2px;
    gap: 6px;
  }
  .topbar > div:not(.topbar-nav-group):not(.topbar-actions) {
    display: none;
  }
  .home-link,
  .sound-toggle,
  .classic-teacher-btn,
  .topbar #gameChip.game-chip {
    width: auto;
    min-height: 44px;
    padding: 0 10px;
    font-size: 14px;
  }
  main {
    padding: 2px 10px 6px;
  }
  .daily-routine {
    padding: 3px 6px;
    margin-bottom: 4px;
  }
  .routine-btn,
  #gameChip.game-chip {
    flex-direction: row;
    min-height: 44px;
    padding: 2px 8px;
    font-size: 13px;
  }
  .game-header {
    padding: 3px 12px;
  }
  .meter {
    height: 6px;
    margin: 3px 12px 0;
  }
  .screen {
    padding: 5px 10px 6px;
  }
  #introScreen .concept {
    gap: 4px;
  }
  .dan-map-label,
  .picker-label,
  .intro-preview-card,
  #practiceSummaryBtn.practice-summary-btn {
    display: none;
  }
  .dan-picker {
    grid-template-columns: repeat(8, minmax(0, 1fr));
    padding: 4px 6px;
    gap: 4px;
  }
  .dan-btn {
    flex-direction: row;
    gap: 3px;
  }
  .dan-btn-icon {
    width: 16px;
    height: 16px;
  }
  body #introScreen .picker-group-mode,
  body:not(.practice-options-open) #introScreen .picker-group-mode {
    display: flex;
  }
  body #introScreen .practice-row,
  body:not(.practice-options-open) #introScreen .practice-row {
    display: grid;
    grid-template-columns: 1.15fr 1fr;
    gap: 8px;
    padding: 4px 6px;
  }
  .dan-btn,
  .mode-btn,
  .time-btn {
    min-height: 44px;
    font-size: 13px;
    padding: 2px 4px;
  }
  .mode-btn .lv-badge {
    display: none;
  }
  .intro-start-row {
    margin: 0;
  }
  #introScreen #startBtn {
    min-height: 46px;
    padding: 4px 20px;
    font-size: 18px;
  }
  #gameScreen .question-bar {
    flex-direction: row;
    justify-content: center;
  }
}

/* ---------- v2.7 보상 손맛 연출 (날아가는 별 & 완주 색종이 팡파르 & 블록이 숨쉬기) ---------- */
.classic-result-mascot,
.topbar-mascot {
  cursor: pointer;
}

@media (prefers-reduced-motion: no-preference) {
  .classic-result-mascot {
    animation: classic-mascot-breathe 2.6s ease-in-out infinite;
  }
}

.classic-result-mascot.is-cheer,
.topbar-mascot.is-cheer {
  animation: classic-mascot-hop 0.48s ease-out;
}

@keyframes classic-mascot-breathe {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-4px) scale(1.04, 0.97); }
}

@keyframes classic-mascot-hop {
  0%, 100% { transform: translateY(0) scale(1); }
  40% { transform: translateY(-10px) scale(1.08); }
  75% { transform: translateY(1px) scale(0.97); }
}

.classic-fx-layer {
  position: fixed;
  inset: 0;
  z-index: 68;
  pointer-events: none;
  overflow: hidden;
}

.classic-star-flyer {
  position: fixed;
  bottom: 24vh;
  width: 32px;
  height: 32px;
  pointer-events: none;
  filter: drop-shadow(0 3px 6px rgba(180, 83, 9, 0.35));
}

.classic-star-flyer.from-left {
  left: 24vw;
  animation: fly-star-left 0.7s cubic-bezier(0.22, 0.8, 0.36, 1) forwards;
}
.classic-star-flyer.from-center {
  left: 48vw;
  animation: fly-star-center 0.7s cubic-bezier(0.22, 0.8, 0.36, 1) forwards;
}
.classic-star-flyer.from-right {
  left: 72vw;
  animation: fly-star-right 0.7s cubic-bezier(0.22, 0.8, 0.36, 1) forwards;
}

@keyframes fly-star-left {
  0% { opacity: 0; transform: translate(0, 12px) scale(0.5) rotate(-20deg); }
  20% { opacity: 1; transform: translate(6vw, -10vh) scale(1.22) rotate(12deg); }
  100% { opacity: 0; transform: translate(54vw, -68vh) scale(0.45) rotate(140deg); }
}

@keyframes fly-star-center {
  0% { opacity: 0; transform: translate(0, 12px) scale(0.5) rotate(-15deg); }
  20% { opacity: 1; transform: translate(4vw, -12vh) scale(1.22) rotate(15deg); }
  100% { opacity: 0; transform: translate(32vw, -68vh) scale(0.45) rotate(140deg); }
}

@keyframes fly-star-right {
  0% { opacity: 0; transform: translate(0, 12px) scale(0.5) rotate(-10deg); }
  20% { opacity: 1; transform: translate(-2vw, -12vh) scale(1.22) rotate(18deg); }
  100% { opacity: 0; transform: translate(10vw, -68vh) scale(0.45) rotate(140deg); }
}

.classic-confetti-burst {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.classic-confetti {
  position: fixed;
  top: 42vh;
  left: 50vw;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  opacity: 0;
}

.classic-confetti.cc-1  { background: #F59E0B; animation: cc-pop-1 1.05s ease-out forwards; }
.classic-confetti.cc-2  { background: #10B981; border-radius: 50%; animation: cc-pop-2 1.05s ease-out forwards; }
.classic-confetti.cc-3  { background: #3B82F6; animation: cc-pop-3 1.05s ease-out forwards; }
.classic-confetti.cc-4  { background: #EC4899; border-radius: 50%; animation: cc-pop-4 1.05s ease-out forwards; }
.classic-confetti.cc-5  { background: #F97316; animation: cc-pop-5 1.05s ease-out forwards; }
.classic-confetti.cc-6  { background: #8B5CF6; border-radius: 50%; animation: cc-pop-6 1.05s ease-out forwards; }
.classic-confetti.cc-7  { background: #14B8A6; animation: cc-pop-7 1.05s ease-out forwards; }
.classic-confetti.cc-8  { background: #EAB308; border-radius: 50%; animation: cc-pop-8 1.05s ease-out forwards; }
.classic-confetti.cc-9  { background: #EF4444; animation: cc-pop-9 1.05s ease-out forwards; }
.classic-confetti.cc-10 { background: #22C55E; border-radius: 50%; animation: cc-pop-10 1.05s ease-out forwards; }
.classic-confetti.cc-11 { background: #0EA5E9; animation: cc-pop-11 1.05s ease-out forwards; }
.classic-confetti.cc-12 { background: #F43F5E; border-radius: 50%; animation: cc-pop-12 1.05s ease-out forwards; }

@keyframes cc-pop-1  { 0% { opacity: 1; transform: translate(0,0) scale(0.6) rotate(0deg); } 100% { opacity: 0; transform: translate(-32vw,-28vh) scale(1.1) rotate(220deg); } }
@keyframes cc-pop-2  { 0% { opacity: 1; transform: translate(0,0) scale(0.6) rotate(0deg); } 100% { opacity: 0; transform: translate(-22vw,-34vh) scale(1.1) rotate(-180deg); } }
@keyframes cc-pop-3  { 0% { opacity: 1; transform: translate(0,0) scale(0.6) rotate(0deg); } 100% { opacity: 0; transform: translate(-10vw,-36vh) scale(1.1) rotate(200deg); } }
@keyframes cc-pop-4  { 0% { opacity: 1; transform: translate(0,0) scale(0.6) rotate(0deg); } 100% { opacity: 0; transform: translate(10vw,-36vh) scale(1.1) rotate(-210deg); } }
@keyframes cc-pop-5  { 0% { opacity: 1; transform: translate(0,0) scale(0.6) rotate(0deg); } 100% { opacity: 0; transform: translate(22vw,-34vh) scale(1.1) rotate(190deg); } }
@keyframes cc-pop-6  { 0% { opacity: 1; transform: translate(0,0) scale(0.6) rotate(0deg); } 100% { opacity: 0; transform: translate(32vw,-28vh) scale(1.1) rotate(-220deg); } }
@keyframes cc-pop-7  { 0% { opacity: 1; transform: translate(0,0) scale(0.6) rotate(0deg); } 100% { opacity: 0; transform: translate(-34vw,-10vh) scale(1.0) rotate(160deg); } }
@keyframes cc-pop-8  { 0% { opacity: 1; transform: translate(0,0) scale(0.6) rotate(0deg); } 100% { opacity: 0; transform: translate(-18vw,14vh) scale(1.0) rotate(-150deg); } }
@keyframes cc-pop-9  { 0% { opacity: 1; transform: translate(0,0) scale(0.6) rotate(0deg); } 100% { opacity: 0; transform: translate(-6vw,20vh) scale(1.0) rotate(170deg); } }
@keyframes cc-pop-10 { 0% { opacity: 1; transform: translate(0,0) scale(0.6) rotate(0deg); } 100% { opacity: 0; transform: translate(8vw,20vh) scale(1.0) rotate(-170deg); } }
@keyframes cc-pop-11 { 0% { opacity: 1; transform: translate(0,0) scale(0.6) rotate(0deg); } 100% { opacity: 0; transform: translate(20vw,14vh) scale(1.0) rotate(150deg); } }
@keyframes cc-pop-12 { 0% { opacity: 1; transform: translate(0,0) scale(0.6) rotate(0deg); } 100% { opacity: 0; transform: translate(34vw,-10vh) scale(1.0) rotate(-160deg); } }

html.app-reduce-motion .classic-result-mascot,
body.game-calm .classic-result-mascot {
  animation: none;
}

/* 동화책 테마에 맞춘 정답 축하 팝업 및 결과 블록이 맞춤 색상 */
#celebration.celebration {
  border-radius: 26px;
  border: 4px solid #16A34A;
  background: #FFFDF5;
  color: #14532D;
  box-shadow: 0 10px 28px rgba(21, 128, 61, 0.22);
}

.classic-result-mascot.clay-tint-yellow {
  filter: hue-rotate(-72deg) saturate(1.42) brightness(1.14);
}
.classic-result-mascot.clay-tint-blue {
  filter: hue-rotate(88deg) saturate(1.16) brightness(1.03);
}
.classic-result-mascot.clay-tint-pink {
  filter: hue-rotate(195deg) saturate(1.2) brightness(1.04);
}
.classic-result-mascot.clay-tint-mint {
  filter: hue-rotate(48deg) saturate(1.18) brightness(1.06);
}
.classic-result-mascot.clay-tint-purple {
  filter: hue-rotate(155deg) saturate(1.22) brightness(1.04);
}
.classic-result-mascot.clay-tint-coral {
  filter: hue-rotate(232deg) saturate(1.30) brightness(1.06);
}
.classic-result-mascot.clay-tint-gold {
  filter: hue-rotate(-84deg) saturate(1.75) brightness(1.12) contrast(1.04);
}

/* v3.0 배경 테마 (/classic 적용, 고대비 모드 시 자동 비활성화) */
html:not(.app-high-contrast) body[data-baeum-bg="sakura"] { background-color: #FFF0F6; }
html:not(.app-high-contrast) body[data-baeum-bg="sakura"]::before { filter: hue-rotate(290deg) saturate(1.15) brightness(1.03); }
html:not(.app-high-contrast) body[data-baeum-bg="ocean"] { background-color: #EBF8FF; }
html:not(.app-high-contrast) body[data-baeum-bg="ocean"]::before { filter: hue-rotate(155deg) saturate(1.18) brightness(1.02); }
html:not(.app-high-contrast) body[data-baeum-bg="sunset"] { background-color: #FFF3E0; }
html:not(.app-high-contrast) body[data-baeum-bg="sunset"]::before { filter: hue-rotate(-28deg) saturate(1.25) brightness(1.01); }
html:not(.app-high-contrast) body[data-baeum-bg="space"] { background-color: #EEF2FF; }
html:not(.app-high-contrast) body[data-baeum-bg="space"]::before { filter: hue-rotate(195deg) saturate(1.12) brightness(0.98); }
html:not(.app-high-contrast) body[data-baeum-bg="rainbow"] { background-color: #FAF5FF; }
html:not(.app-high-contrast) body[data-baeum-bg="rainbow"]::before { filter: hue-rotate(245deg) saturate(1.22) brightness(1.03); }

/* ---------- v2.8 생활 문장 노래방 따라 읽기 리듬 가이드 바 ---------- */
.sentence-target.is-karaoke {
  background: linear-gradient(90deg, #FEF9C3 0%, #FFFDF5 100%);
  border-color: #D97706 !important;
  color: #78350F !important;
}

.sentence-karaoke-bar {
  width: 100%;
  height: 7px;
  margin-top: 5px;
  border-radius: 999px;
  background: #F3E8D2;
  border: 1.5px solid #D9C39E;
  overflow: hidden;
  box-sizing: border-box;
}

.sentence-karaoke-bar[hidden] {
  display: none !important;
}

.sentence-karaoke-fill {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #F59E0B 0%, #FBBF24 100%);
  transition: width 0.08s linear;
}

.sentence-karaoke-bar.is-done {
  border-color: #16A34A;
  background: #DCFCE7;
}

.sentence-karaoke-bar.is-done .sentence-karaoke-fill {
  background: linear-gradient(90deg, #22C55E 0%, #16A34A 100%);
}

#saidSentenceBtn.is-ready:not(:disabled) {
  border-color: #D97706;
  background: #FEF3C7;
  color: #78350F;
  box-shadow: 0 4px 0 #D97706;
}


/* v3.1 클래식 활동 오늘의 배움 기차 진행 바 */
.classic-course-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 14px;
  margin: 0 0 12px;
  padding: 10px 16px;
  border-radius: 20px;
  border: 3px solid #166534;
  background: #ECFDF5;
  color: #064E3B;
  box-shadow: 0 4px 0 #166534;
}
.classic-course-status {
  font-size: 18px;
  font-weight: 900;
  line-height: 1.3;
}
.classic-course-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.classic-course-next-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 8px 18px;
  border-radius: 999px;
  border: 3px solid #052E16;
  background: #166534;
  color: #FFFFFF;
  font-size: 18px;
  font-weight: 900;
  text-decoration: none;
  box-shadow: 0 3px 0 #052E16;
}
.classic-course-board-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 2.5px solid #166534;
  background: #FFFFFF;
  color: #064E3B;
  font-size: 16px;
  font-weight: 800;
  text-decoration: none;
}
html.app-high-contrast .classic-course-bar,
html.app-high-contrast .classic-course-board-link {
  background: #FFFFFF !important;
  color: #000000 !important;
  border-color: #000000 !important;
  box-shadow: none !important;
}
html.app-high-contrast .classic-course-next-btn {
  background: #000000 !important;
  color: #FFFFFF !important;
  border-color: #000000 !important;
  box-shadow: none !important;
}


/* ---------- v3.7 연산·구구단 (구구단 · 덧셈 · 뺄셈 탭 & 단계 선택 & 점 모형) ---------- */
.dan-picker[hidden],
.math-step-picker[hidden] {
  display: none !important;
}

.math-op-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  width: min(760px, 100%);
  margin: 0 auto;
}

.math-op-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 46px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 2.5px solid #C8B8A2;
  background: #FFFDF9;
  color: #2D3436;
  font-size: 16px;
  font-weight: 900;
  line-height: 1.15;
  cursor: pointer;
  box-shadow: 0 3px 0 #D8CBB8;
  transition: transform 0.12s ease, background 0.15s ease, color 0.15s ease;
}

.math-op-btn.active {
  border-color: #1F64B8;
  background: #1F64B8;
  color: #FFFFFF;
  box-shadow: 0 3px 0 #123D73;
}

.math-op-btn:active,
.math-step-btn:active {
  transform: translateY(2px) scale(0.985);
}

.math-step-picker {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.math-step-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 52px;
  padding: 8px 10px;
  border-radius: 16px;
  border: 3px solid #D8CBB8;
  background: #FFFFFF;
  color: #2D3436;
  font-size: 17px;
  font-weight: 900;
  line-height: 1.15;
  cursor: pointer;
  box-shadow: 0 3px 0 #CFC2B2;
}

.math-step-btn.active {
  border-color: #1F64B8;
  background: #1F64B8;
  color: #FFFFFF;
  box-shadow: 0 3px 0 #123D73;
}

.math-step-btn.cleared:not(.active) {
  border-color: #16A34A;
  background: #F0FDF4;
  color: #14532D;
}

.math-step-btn-icon {
  width: 24px;
  height: 24px;
  object-fit: contain;
  pointer-events: none;
  flex: none;
}

.math-step-btn-label {
  line-height: 1.15;
  word-break: keep-all;
}

.math-vis-op {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  font-size: 22px;
  font-weight: 900;
  color: #1D4ED8;
  line-height: 1;
}

.dot-group.add-group-b {
  border-color: #7DD3FC;
  box-shadow: 0 3px 0 #BAE6FD;
}

.dot-group.add-group-b i {
  background: #38BDF8;
  border-color: #0369A1;
}

.dot-group.sub-group {
  border-color: #FDA4AF;
  box-shadow: 0 3px 0 #FECDD3;
}

.dot-group i.is-taken {
  position: relative;
  background: #F1F5F9;
  border: 2px dashed #64748B;
  box-shadow: none;
}

.dot-group i.is-taken::after {
  content: "";
  position: absolute;
  left: -3px;
  right: -3px;
  top: 50%;
  height: 2px;
  border-radius: 999px;
  background: #DC2626;
  transform: translateY(-50%) rotate(-35deg);
}

@media (max-width: 720px) {
  .math-op-tabs {
    gap: 5px;
  }
  .math-op-btn {
    min-height: 44px;
    padding: 3px 6px;
    border-width: 2px;
    font-size: clamp(12.5px, 3.6vw, 14.5px);
    box-shadow: 0 2px 0 #CFC2B2;
  }
  .math-op-btn.active {
    box-shadow: 0 2px 0 #123D73;
  }
  .math-step-picker {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .math-step-btn {
    min-height: 48px;
    padding: 4px 6px;
    border-radius: 13px;
    border-width: 2.5px;
    font-size: clamp(13px, 3.8vw, 15px);
    box-shadow: 0 2.5px 0 #CFC2B2;
  }
  .math-step-btn-icon {
    width: 20px;
    height: 20px;
  }
  .math-vis-op {
    font-size: 16px;
    padding: 0 2px;
  }
  #gameScreen .dot-group.add-group-b,
  #gameScreen .dot-group.sub-group {
    box-shadow: none;
  }
}

@media (max-height: 500px) and (orientation: landscape) {
  .math-op-btn,
  .math-step-btn {
    min-height: 44px;
    font-size: 13px;
    padding: 2px 6px;
  }
  .math-step-picker {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    padding: 4px 6px;
    gap: 4px;
  }
  .math-step-btn-icon {
    width: 16px;
    height: 16px;
  }
}

html.app-high-contrast #practiceSummaryBtn.practice-summary-btn,
html.app-high-contrast .practice-summary-action,
html.app-high-contrast .math-op-btn,
html.app-high-contrast .math-step-btn {
  background: #FFFFFF !important;
  color: #000000 !important;
  border-color: #000000 !important;
  box-shadow: none !important;
}

html.app-high-contrast .math-op-btn.active,
html.app-high-contrast .math-step-btn.active {
  background: #000000 !important;
  color: #FFFFFF !important;
  border-color: #000000 !important;
}

html.app-high-contrast .dot-group.add-group-b i {
  background: #000000 !important;
  border-color: #000000 !important;
}

html.app-high-contrast .dot-group i.is-taken {
  background: #FFFFFF !important;
  border: 2px dashed #000000 !important;
}

html.app-high-contrast .dot-group i.is-taken::after {
  background: #000000 !important;
}
