@font-face {
  font-family: 'KleeOneTextbook';
  src: url('../fonts/KleeOne-Regular.ttf') format('truetype');
  font-weight: 400;
}
@font-face {
  font-family: 'KleeOneTextbook';
  src: url('../fonts/KleeOne-SemiBold.ttf') format('truetype');
  font-weight: 600;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  min-height: 100%;
  background: #F6FAFD;
  color: #2F2925;
  font-family: 'KleeOneTextbook', 'Hiragino Maru Gothic ProN', sans-serif;
  -webkit-tap-highlight-color: transparent;
}

.kids-app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 980px;
  margin: 0 auto;
  padding: 12px 16px 24px;
}

.kids-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid #D8D1C4;
  flex-wrap: wrap;
}

.kids-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 600;
}

.kids-brand-icon {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.kids-progress {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.prog-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid #8B8274;
  background: #FFFFFF;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: #62594F;
}
.prog-dot.is-current {
  border-color: #275F50;
  background: #E8F2EE;
  color: #275F50;
}
.prog-dot.is-done {
  border-color: #275F50;
  background: #275F50;
  color: #FFFFFF;
}

.kids-controls {
  display: flex;
  gap: 8px;
}

.kids-ctrl-btn {
  min-height: 56px;
  padding: 0 16px;
  border-radius: 8px;
  border: 1.5px solid #2F2925;
  background: #FFFFFF;
  color: #2F2925;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.kids-ctrl-btn.is-subtle {
  border-color: #8B8274;
  color: #62594F;
  font-size: 14px;
}

.kids-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 0;
}

.start-card, .finish-card, .workspace-panel {
  width: 100%;
  background: #FFFFFF;
  border: 1.5px solid #D8D1C4;
  border-radius: 8px;
  padding: 24px 20px;
}

.start-card, .finish-card {
  max-width: 640px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.start-mascot, .finish-mascot {
  width: 112px;
  height: 112px;
  object-fit: contain;
}

.start-kicker {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 6px;
  background: #F7ECC9;
  border: 1px solid #C8B476;
  font-size: 14px;
  font-weight: 600;
  color: #2F2925;
}

.start-title, .finish-title {
  font-size: 26px;
  line-height: 1.4;
}

.start-desc, .finish-desc {
  font-size: 16px;
  color: #62594F;
  line-height: 1.6;
}

.set-switcher {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 4px 0;
}

.set-switcher select {
  min-height: 56px;
  max-width: 100%;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1.5px solid #8B8274;
  background: #FFFDF7;
  color: #2F2925;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.primary-play-btn {
  min-height: 60px;
  min-width: 220px;
  padding: 12px 28px;
  border-radius: 8px;
  border: none;
  background: #2B74B3;
  color: #FFFFFF;
  font-family: inherit;
  font-size: 20px;
  font-weight: 600;
  cursor: pointer;
}

.secondary-play-btn {
  min-height: 56px;
  padding: 12px 20px;
  border-radius: 8px;
  border: 1.5px solid #8B8274;
  background: #FFFFFF;
  color: #2F2925;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

.prompt-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-bottom: 14px;
  border-bottom: 1px solid #EAE4D7;
}

.q-badge {
  padding: 6px 12px;
  border-radius: 6px;
  background: #F1C76B;
  color: #2F2925;
  font-size: 15px;
  font-weight: 600;
}

.prompt-text {
  flex: 1;
  min-width: 200px;
  font-size: 21px;
  line-height: 1.45;
}

.speak-btn {
  min-height: 56px;
  padding: 0 16px;
  border-radius: 8px;
  border: 1.5px solid #2F2925;
  background: #FFFDF7;
  color: #2F2925;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.interactive-canvas-wrap {
  margin: 18px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.tool-btn-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.tool-btn {
  min-height: 56px;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1.5px solid #2F2925;
  background: #FFFDF7;
  color: #2F2925;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}
.tool-btn.is-on {
  background: #E8F2EE;
  border-color: #275F50;
  color: #1B463B;
}

/* Clock Stage */
.clock-stage-grid {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 24px;
}
.clock-svg-holder {
  width: min(280px, 100%);
}
.clock-svg-holder svg {
  display: block;
  width: 100%;
  height: auto;
  touch-action: none;
  user-select: none;
}
.clock-helper-card {
  max-width: 300px;
  padding: 14px 16px;
  border-radius: 8px;
  border: 1px solid #D8D1C4;
  background: #FFFDF7;
  font-size: 16px;
  line-height: 1.6;
}

/* Sokuon Stage */
.sokuon-play-layout {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 24px;
  width: 100%;
}
.sokuon-pic-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.sokuon-pic-card img {
  width: 132px;
  height: 132px;
  object-fit: contain;
}
.sokuon-hint-lbl {
  font-size: 15px;
  color: #62594F;
}
.beat-pad-row {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}
.beat-pad-btn {
  width: clamp(68px, 22vw, 96px);
  min-height: 92px;
  border-radius: 8px;
  border: 2px solid #2F2925;
  background: #FFFFFF;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.beat-pad-btn.is-rest {
  background: #FAF0CE;
  border-style: dashed;
}
.beat-pad-btn.is-lit {
  outline: 4px solid #275F50;
  transform: translateY(-2px);
}
.beat-pad-sym {
  font-size: 24px;
  font-weight: 600;
}
.beat-pad-txt {
  font-size: 16px;
  font-weight: 600;
}

.quad-box-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.quad-grid {
  width: 124px;
  height: 124px;
  border: 2.5px solid #2F2925;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  background: #FFFFFF;
}
.quad-cell {
  border: 1px dashed #B8B0A2;
  background: transparent;
  font-family: inherit;
  font-size: 26px;
  font-weight: 600;
  color: #275F50;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.quad-cell.is-target-room {
  background: #FAF0CE;
}

/* Hiragana Finger Tracing Stage */
.trace-stage-layout {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 24px;
  width: 100%;
}
.trace-board-wrap {
  position: relative;
  width: min(260px, 100%);
  aspect-ratio: 1;
  border: 3px solid #4F96B5;
  border-radius: 8px;
  background: #FFFFFF;
  overflow: hidden;
  touch-action: none;
}
.trace-guide-svg, .trace-draw-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.trace-draw-canvas {
  cursor: crosshair;
  touch-action: none;
}
.trace-info-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  max-width: 290px;
  text-align: center;
}
.trace-word-img {
  width: 112px;
  height: 112px;
  object-fit: contain;
}
.trace-word-big {
  font-size: 28px;
  font-weight: 600;
}
.trace-word-extra { font-size: 19px; }
.trace-word-target {
  color: #A33232;
  border: 2px solid #A33232;
  border-radius: 4px;
  padding: 0 2px;
}
.sokuon-rhythm-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.trace-stroke-tip {
  padding: 10px 14px;
  border-radius: 8px;
  border: 1.5px solid #9AC4D6;
  background: #F4F9FC;
  font-size: 16px;
  line-height: 1.5;
}

/* Tsumiki 3D Canvas */
.tsumiki-canvas {
  width: min(360px, 100%);
  height: 250px;
  border: 1.5px solid #D8D1C4;
  border-radius: 8px;
  background: #FFFDF7;
  touch-action: none;
  cursor: grab;
}

.choices-area {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.choice-btn {
  min-height: 62px;
  padding: 12px 16px;
  border-radius: 8px;
  border: 2px solid #2F2925;
  background: #FFFFFF;
  color: #2F2925;
  font-family: inherit;
  font-size: 22px;
  font-weight: 600;
  cursor: pointer;
}
.choice-btn.is-correct {
  background: #E8F2EE;
  border-color: #275F50;
  color: #1B463B;
}
.choice-btn.is-wrong {
  background: #F9EFEA;
  border-color: #8C3B2B;
}

.feedback-bar {
  margin: 12px 0;
  padding: 14px 16px;
  border-radius: 8px;
  border: 1.5px solid #275F50;
  background: #E8F2EE;
  font-size: 18px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.feedback-bar.is-retry {
  border-color: #8C4A27;
  background: #FDF4EC;
}

.next-q-btn {
  min-height: 56px;
  padding: 10px 22px;
  border-radius: 8px;
  border: none;
  background: #275F50;
  color: #FFFFFF;
  font-family: inherit;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
}

.stamp-strip {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  width: 100%;
  max-width: 420px;
  margin: 8px 0;
}
.stamp-cell {
  aspect-ratio: 1;
  border: 1.5px solid #8B8274;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #FFFDF7;
  font-size: 14px;
  color: #8B8274;
}
.stamp-cell img {
  width: 82%;
  height: 82%;
  object-fit: contain;
}

.finish-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 8px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(47, 41, 37, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 50;
}
.modal-box {
  background: #FFFFFF;
  border: 1.5px solid #2F2925;
  border-radius: 8px;
  max-width: 460px;
  width: 100%;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.modal-note {
  font-size: 15px;
  line-height: 1.65;
  color: #62594F;
}
.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.modal-link-btn, .modal-close-btn, .modal-reset-btn {
  min-height: 56px;
  padding: 10px 16px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.modal-link-btn {
  background: #275F50;
  color: #FFFFFF;
  border: none;
}
.modal-reset-btn {
  background: #FFFDF7;
  color: #62594F;
  border: 1px solid #8B8274;
}
.modal-close-btn {
  background: #FFFFFF;
  color: #2F2925;
  border: 1.5px solid #2F2925;
}

[hidden] {
  display: none !important;
}

button, select, .modal-link-btn {
  min-width: 56px;
}

button:disabled {
  cursor: default;
}

button:focus-visible, select:focus-visible, .modal-link-btn:focus-visible {
  outline: 3px solid #235B95;
  outline-offset: 3px;
}

.kana-focus {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  width: min(100%, 520px);
  min-height: 132px;
  padding: 12px;
  border: 2px solid #9AC4D6;
  border-radius: 8px;
}
.kana-focus img {
  width: 86px;
  height: 86px;
  object-fit: contain;
}
.kana-focus-letter {
  font-size: clamp(38px, 11vw, 60px);
  line-height: 1.15;
}
.kana-row-picker {
  display: none;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
}
.kana-row-picker select {
  min-height: 56px;
  min-width: 96px;
  max-width: 100%;
  padding: 0 10px;
  color: inherit;
  background: #FFFFFF;
  border: 1.5px solid #62594F;
  border-radius: 8px;
  font: inherit;
}
.kana-chart {
  display: grid;
  gap: 6px;
  width: min(100%, 680px);
}
.kana-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(56px, 1fr));
  gap: 6px;
}
.kana-cell {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 2px;
  background: #FFFFFF;
  border-color: #9AC4D6;
  padding: 6px;
  text-align: center;
}
.kana-cell img {
  width: 36px;
  height: 36px;
  object-fit: contain;
}
.kana-cell > strong {
  font-size: 24px;
  line-height: 1.25;
}
.kana-cell-word {
  font-size: 15px;
}
.kana-cell .trace-word-target {
  border-color: transparent;
  padding: 0;
}
.kana-cell[aria-pressed="true"], .bond-number-tools [aria-pressed="true"] {
  border-color: #275F50;
  outline: 2px solid #275F50;
  outline-offset: -4px;
  background: #E8F2EE;
}
.kana-cell[aria-pressed="true"]:focus-visible, .bond-number-tools [aria-pressed="true"]:focus-visible {
  outline: 3px solid #235B95;
  outline-offset: 2px;
}
.kana-empty {
  min-width: 0;
  border: 1px dashed #D8D1C4;
  border-radius: 8px;
  background: #F6FAFD;
}

.practice-svg {
  display: block;
  width: min(100%, 390px);
  height: auto;
  border: 2px solid #9AC4D6;
  border-radius: 8px;
  background: #FFFFFF;
  user-select: none;
}
.path-trace-svg {
  touch-action: none;
  cursor: crosshair;
}
.path-trace-track, .path-trace-ink {
  fill: none;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.path-trace-track {
  stroke: #D7E9F2;
  stroke-width: 12;
}
.path-trace-ink {
  stroke: #2B74B3;
  stroke-width: 3.8;
}
.path-trace-point {
  fill: #FFFFFF;
  stroke: #4D768D;
  stroke-width: 0.85;
}
.path-trace-point.is-current-point {
  fill: #173C52;
  stroke: #FFFFFF;
  stroke-width: 1.1;
}
.path-trace-arrow, .path-trace-flag {
  fill: none;
  stroke: #173C52;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.1;
}
.path-trace-flag {
  fill: #F6E29F;
}
.practice-status {
  text-align: center;
}
.dot-order-svg {
  touch-action: manipulation;
  cursor: pointer;
}
.dot-order-line {
  fill: none;
  stroke: #2B74B3;
  stroke-linejoin: round;
  stroke-linecap: round;
  stroke-width: 1.75;
}
.dot-marker circle {
  fill: #FFFFFF;
  stroke: #2F2925;
  stroke-width: 0.8;
}
.dot-marker text {
  fill: #2F2925;
  font-size: 5.3px;
  font-weight: 600;
}
.dot-marker.is-used-dot circle {
  fill: #D7E9F2;
}
.dot-marker.is-last-dot circle {
  stroke-width: 1.8;
}
.dot-number-tools, .bond-number-tools {
  max-width: 440px;
}
.dot-number-tools button, .bond-number-tools button {
  padding-inline: 10px;
  font-size: 21px;
}

.bonds-stage {
  width: min(100%, 520px);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.bond-box {
  min-height: 98px;
  padding: 10px;
  border: 2px solid #9AC4D6;
  border-radius: 8px;
  text-align: center;
}
.bond-whole {
  grid-column: 1 / -1;
}
.bond-blocks {
  min-height: 44px;
  display: flex;
  flex-wrap: wrap;
  align-content: center;
  justify-content: center;
  gap: 6px;
  padding-top: 6px;
  font-size: 24px;
}
.bond-block {
  width: 22px;
  height: 22px;
  border: 2px solid #173C52;
  border-radius: 50%;
  background: #D7E9F2;
}
.bond-block.is-awaiting {
  border-style: dashed;
  background: #FFFFFF;
}
.bonds-stage.is-combined .bond-box:not(.bond-whole) {
  display: none;
}
.bonds-stage.is-combined .bond-whole {
  border-width: 3px;
}

@media (max-width: 560px) {
  .kana-row-picker { display: flex; }
  .kana-row {
    display: none;
    grid-template-columns: minmax(0, 1fr);
  }
  .kana-row.is-current-row { display: grid; }
  .kana-row .kana-empty { display: none; }
  .kana-cell {
    grid-template-columns: 40px 44px minmax(0, 1fr);
    justify-items: start;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
  }
  .kana-cell > strong { grid-column: 2; }
}

/* Wave 2 puzzles */
.quiz-visual, .puzzle-model, .puzzle-chart {
  max-width: 100%;
  padding: 12px 16px;
  border: 2px solid #597b91;
  border-radius: 8px;
  background: #fff;
}
.quiz-visual {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  text-align: center;
  font-size: clamp(18px, 4vw, 30px);
  font-weight: 600;
}
.puzzle-model { text-align: center; }
.puzzle-grid { display: block; width: 100%; max-width: 108px; margin: 4px auto; }
.puzzle-model .puzzle-grid { width: min(132px, 56vw); max-width: none; }
.puzzle-grid-lines { fill: none; stroke: #939da2; stroke-width: .024; }
.puzzle-outline, .puzzle-seam { fill: none; stroke: #212121; stroke-linecap: round; stroke-linejoin: round; }
.puzzle-outline { stroke-width: .1; }
.puzzle-seam { stroke-width: .06; stroke-dasharray: .14 .09; }
.puzzle-chart-row { display: flex; align-items: center; }
.puzzle-chart-key { width: 3.5em; }
.puzzle-chart-icon { width: clamp(25px, 7vw, 44px); aspect-ratio: 1; padding: 2px; border: 1px solid #777; object-fit: contain; }
.maze-board { width: min(100%, 360px); height: auto; }
.maze-walls { fill: none; stroke: #211e19; stroke-width: .075; stroke-linecap: square; }
.maze-trail { fill: none; stroke: #496986; stroke-width: .085; stroke-dasharray: .14 .08; }
.maze-player { fill: #194c73; stroke: #fff; stroke-width: .035; }
.maze-controls { max-width: 420px; }
.cherry-stage { width: min(100%, 390px); display: grid; gap: 5px; text-align: center; }
.cherry-root { justify-self: center; padding: 5px 15px; border: 2px solid #75433d; border-radius: 30px; font-size: 24px; }
.cherry-branches { position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding-top: 20px; }
.cherry-branches::before { content: ''; position: absolute; top: 2px; left: 25%; right: 25%; height: 15px; border: 2px solid #75433d; border-bottom: 0; }
.cherry-box { border: 2px solid #75433d; border-radius: 12px; padding: 6px; font-weight: 600; background: #fff; }
.cherry-dots { display: grid; grid-template-columns: repeat(5, 16px); justify-content: center; gap: 3px; padding: 4px 0; }
.cherry-dot { width: 16px; height: 16px; border: 2px solid #452f2e; border-radius: 50%; }
.cherry-dot.is-moved { background: #75433d; box-shadow: inset 0 0 0 2px white; }
.cherry-dot.is-removed { border-style: dashed; font: bold 13px/12px sans-serif; }
.cherry-caption { margin-top: 8px; }
.cherry-combine { display: flex; justify-content: center; gap: 4px; align-items: center; }
.cherry-sum { font-size: 20px; }
.cherry-choices [aria-pressed="true"] { border-width: 3px; }
