:root {
  color-scheme: light;
  --canvas: #f1f7f6;
  --surface: #fffdf9;
  --surface-soft: #e6f3f1;
  --ink: #202b3d;
  --ink-soft: #40536a;
  --muted: #5d6d7f;
  --line: #c6d8d5;
  --teal: #147c75;
  --teal-dark: #0d5f5a;
  --teal-soft: #d9efec;
  --peach: #e7816d;
  --peach-soft: #f9e7e2;
  --gold: #a66b00;
  --danger: #a13b3b;
  --success: #17693a;
  --shadow: 0 8px 20px rgba(24, 58, 66, 0.1);
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --jp: "Noto Sans JP", "Yu Gothic", "Hiragino Kaku Gothic ProN", sans-serif;
}

[hidden] { display: none !important; }

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font: 1rem/1.55 var(--font);
}

html:lang(ja) { --font: "Noto Sans JP", "Yu Gothic UI", "Hiragino Kaku Gothic ProN", sans-serif; }
html:lang(zh-Hans) { --font: "Noto Sans SC", "Microsoft YaHei UI", "PingFang SC", sans-serif; }
html:lang(zh-Hant) { --font: "Noto Sans TC", "Microsoft JhengHei UI", "PingFang TC", sans-serif; }
html:lang(ko) { --font: "Noto Sans KR", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif; }
html:lang(th) { --font: "Noto Sans Thai", "Leelawadee UI", "Th Sarabun New", sans-serif; }
html:lang(hi) { --font: "Noto Sans Devanagari", "Nirmala UI", "Mangal", sans-serif; }
[lang="ja"] { font-family: var(--jp); }

button, input, summary { font: inherit; }
button, summary, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: var(--teal-dark); text-underline-offset: 0.18em; }
a:hover { color: var(--ink); }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { line-height: 1.12; text-wrap: balance; }
p { text-wrap: pretty; }

:focus-visible {
  outline: 3px solid #0a5f94;
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  left: 1rem;
  top: -5rem;
  z-index: 100;
  padding: 0.8rem 1rem;
  color: white;
  background: var(--ink);
  border-radius: 0.5rem;
}
.skip-link:focus { top: 1rem; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  min-height: 4.5rem;
  padding: 0.65rem max(1rem, calc((100vw - 72rem) / 2));
  border-bottom: 1px solid var(--line);
  background: rgba(241, 247, 246, 0.96);
}

.spark-home-button {
  width: 3rem;
  height: 3rem;
  flex: 0 0 3rem;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(24, 91, 89, 0.2);
  border-radius: 0.8rem;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 8px 22px rgba(29, 74, 72, 0.12);
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.spark-home-button img { width: 90%; height: 90%; object-fit: contain; }
.spark-home-button:hover,
.spark-home-button:focus-visible {
  transform: translateY(-2px);
  border-color: var(--teal);
  box-shadow: 0 12px 28px rgba(29, 74, 72, 0.18);
  outline: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  color: var(--ink);
  text-decoration: none;
}
.brand-mark {
  display: grid;
  width: 2.65rem;
  height: 2.65rem;
  place-items: center;
  color: white;
  background: var(--teal);
  border-radius: 0.65rem;
  font: 800 1.45rem/1 var(--jp);
}
.brand strong, .brand small { display: block; }
.brand strong { font-size: 0.98rem; }
.brand small { color: var(--muted); font-size: 0.76rem; }

.header-progress {
  display: grid;
  grid-template-columns: auto auto auto auto;
  align-items: baseline;
  gap: 0.2rem 0.4rem;
  margin-left: auto;
  color: var(--muted);
  font-size: 0.76rem;
}
.header-progress strong { color: var(--teal-dark); font-size: 1rem; }
.language-slot:empty { display: none; }
.language-slot { flex: 0 1 13rem; }
.mofuna-language-picker {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 0.45rem;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
}
.mofuna-language-picker select {
  min-width: 0;
  min-height: 2.75rem;
  padding: 0 2rem 0 0.65rem;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 0.65rem;
  background: var(--surface);
  font: 700 0.82rem/1 var(--font);
}

.tools { position: relative; }
.tools > summary {
  min-height: 2.75rem;
  display: flex;
  align-items: center;
  padding: 0 0.85rem;
  border: 1px solid var(--line);
  border-radius: 0.65rem;
  background: var(--surface);
  cursor: pointer;
  font-weight: 700;
  list-style: none;
}
.tools > summary::-webkit-details-marker { display: none; }
.tools-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 0.55rem);
  width: min(20rem, calc(100vw - 2rem));
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.tools-menu p { margin: 0.8rem 0; color: var(--muted); font-size: 0.82rem; }
.toggle-row { display: flex; align-items: center; gap: 0.6rem; font-weight: 700; }
.toggle-row input { width: 1.2rem; height: 1.2rem; accent-color: var(--teal); }
kbd { padding: 0.12rem 0.38rem; border: 1px solid var(--line); border-radius: 0.3rem; background: #fff; }

main, footer {
  width: min(72rem, calc(100% - 2rem));
  margin-inline: auto;
}

.intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 18rem;
  gap: 2rem;
  align-items: end;
  padding: 2.1rem 0 1.4rem;
}
.human-note, .section-label {
  color: var(--teal-dark);
  font-size: 0.78rem;
  font-weight: 800;
}
.human-note { display: inline-block; margin-bottom: 0.55rem; padding: 0.28rem 0.58rem; border-radius: 999px; background: var(--teal-soft); }
.intro h1 { max-width: 21ch; margin-bottom: 0.55rem; font-size: clamp(2.1rem, 4vw, 2.8rem); letter-spacing: -0.035em; }
.intro-copy { max-width: 72ch; color: var(--ink-soft); font-size: 0.98rem; line-height: 1.55; }
.primary-link {
  display: inline-flex;
  min-height: 2.75rem;
  align-items: center;
  justify-content: center;
  margin-top: 0.25rem;
  padding: 0 1rem;
  color: white;
  background: var(--teal);
  border-radius: 0.65rem;
  font-weight: 800;
  text-decoration: none;
}
.primary-link span { margin-inline-start: 0.2em; }
.primary-link:hover { color: white; background: var(--teal-dark); }
.intro-facts { display: grid; gap: 0.45rem; padding: 0.7rem 0; border-block: 1px solid var(--line); }
.intro-facts span { display: flex; justify-content: space-between; color: var(--ink-soft); }
.intro-facts strong { color: var(--ink); font-size: 1.25rem; }

.practice {
  scroll-margin-top: 5.5rem;
  padding: 1.5rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.practice-header, .practice-grid, .row-heading, .row-actions, .voice-credit {
  display: flex;
  align-items: center;
}
.practice-header { justify-content: space-between; gap: 1rem; padding-bottom: 1.2rem; border-bottom: 1px solid var(--line); }
.section-label { margin-bottom: 0.35rem; }
.practice-header h2 { margin-bottom: 0; font-size: 1.7rem; }
.row-progress { flex: none; color: var(--muted); font-size: 0.84rem; font-weight: 700; }

.practice-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(18rem, 0.9fr);
  gap: 2rem;
  align-items: stretch;
  padding: 2rem 0;
}
.sound-lesson { padding-right: 2rem; border-right: 1px solid var(--line); }
.sound-heading { display: flex; justify-content: space-between; gap: 1rem; align-items: center; }
.sound-number { color: var(--muted); font-size: 0.82rem; font-weight: 700; }
.human-badge { padding: 0.3rem 0.55rem; color: var(--success); background: #e1f3e7; border-radius: 999px; font-size: 0.74rem; font-weight: 800; }
.kana-display { display: flex; align-items: baseline; gap: 1rem; margin: 1.6rem 0 0.9rem; }
.kana-display span:first-child { font: 800 7.2rem/0.85 var(--jp); }
.kana-display span:last-child { color: var(--teal-dark); font-size: 2rem; font-weight: 850; }
.pronunciation-hint { max-width: 50ch; min-height: 3.2rem; color: var(--ink-soft); font-size: 1.05rem; }
.audio-status { min-height: 1.6rem; margin-bottom: 0.5rem; color: var(--muted); font-size: 0.82rem; }
.audio-status.error { color: var(--danger); font-weight: 700; }
.hear-button, .hear-next-button, .autoplay-button, .next-button, .secondary-button, .recall-button, .hear-again, .row-arrow, .library-controls button, .sound-button, .recall-option, .text-button {
  min-height: 2.75rem;
  border: 0;
  border-radius: 0.6rem;
  cursor: pointer;
  font-weight: 750;
}
.audio-actions { display: flex; flex-wrap: wrap; gap: 0.55rem; }
.hear-button, .hear-next-button, .autoplay-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  flex: 1 1 8.75rem;
  min-width: 0;
  padding: 0 0.75rem;
  color: white;
  background: var(--teal);
}
.particle-button {
  --particle-a: 66, 215, 236;
  --particle-b: 98, 243, 220;
  position: relative;
  isolation: isolate;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.42);
  background:
    radial-gradient(circle at 18% 18%, rgba(255,255,255,0.24), transparent 30%),
    linear-gradient(135deg, #137f78, #1a9b8f 54%, #35a99b);
  box-shadow:
    0 8px 20px rgba(19,127,120,0.16),
    inset 0 1px 0 rgba(255,255,255,0.32);
  transition: filter 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}
.particle-button::before,
.particle-button::after {
  content: "" !important;
  position: absolute;
  inset: -35%;
  pointer-events: none;
  border-radius: inherit;
  background:
    linear-gradient(115deg, transparent 0 42%, rgba(255,255,255,0.72) 43%, transparent 45% 100%),
    radial-gradient(circle, rgba(255,255,255,0.9) 0 2px, transparent 3px),
    radial-gradient(circle, rgba(var(--particle-a),0.72) 0 1px, transparent 2px),
    radial-gradient(circle, rgba(var(--particle-b),0.86) 0 1px, transparent 2px);
  background-size: 100% 100%, 92px 74px, 67px 58px, 112px 91px;
  mix-blend-mode: screen;
  opacity: 0.36;
  animation: wcV2SparkDrift 5.8s ease-in-out infinite !important;
}
.particle-button::after {
  opacity: 0.24;
  transform: rotate(180deg);
  animation-duration: 7.2s !important;
  animation-delay: -1.4s !important;
}
.particle-button .button-label { position: relative; z-index: 1; white-space: nowrap; }
.hear-next-button {
  --particle-a: 112, 185, 240;
  --particle-b: 126, 218, 232;
  background:
    radial-gradient(circle at 18% 18%, rgba(255,255,255,0.22), transparent 30%),
    linear-gradient(135deg, #24314b, #28506a 54%, #2d6878);
  box-shadow: 0 8px 20px rgba(36,49,75,0.17), inset 0 1px 0 rgba(255,255,255,0.28);
}
.autoplay-button {
  --particle-a: 225, 163, 214;
  --particle-b: 255, 205, 227;
  background:
    radial-gradient(circle at 18% 18%, rgba(255,255,255,0.22), transparent 30%),
    linear-gradient(135deg, #684d6f, #7b5c7d 54%, #8b687f);
  box-shadow: 0 8px 20px rgba(104,77,111,0.17), inset 0 1px 0 rgba(255,255,255,0.28);
}
.autoplay-button[aria-pressed="true"] { box-shadow: 0 0 0 3px rgba(139,104,127,0.2), 0 8px 20px rgba(104,77,111,0.22); }
.particle-button:not(:disabled):hover { filter: brightness(0.92) saturate(1.08); transform: translateY(-1px); }
.next-button:hover, .recall-button:hover, .hear-again:hover { background: var(--teal-dark); }
.hear-button:disabled, .hear-next-button:disabled, .autoplay-button:disabled, .hear-again:disabled { cursor: progress; opacity: 0.65; }
.say-prompt { margin: 0.75rem 0 1rem; color: var(--gold); font-size: 0.86rem; font-weight: 800; }
.lesson-navigation { display: flex; gap: 0.65rem; }
.secondary-button { padding: 0 0.9rem; border: 1px solid var(--line); background: transparent; }
.secondary-button:hover { background: var(--surface-soft); }
.next-button { padding: 0 1rem; color: white; background: var(--ink); }
.next-button:hover { background: var(--teal-dark); }

.mascot-stage { display: grid; place-items: center; min-height: 25rem; }
.sprite-pair { display: flex; align-items: end; justify-content: center; width: 100%; }
.mofuna-sprite, .mokomoko-sprite { aspect-ratio: 1; }
.mofuna-sprite { position: relative; width: min(18rem, 60vw); filter: drop-shadow(0 8px 8px rgba(25, 57, 62, 0.13)); }
.mofuna-sprite-layer {
  position: absolute;
  inset: 0;
  opacity: 0;
  background-repeat: no-repeat;
  background-size: 400% 400%;
  background-position: 0 0;
  image-rendering: auto;
  transition: opacity 140ms ease-out;
  will-change: opacity;
}
.mofuna-sprite-layer.is-visible { opacity: 1; }
.mofuna-sprite.instant-swap .mofuna-sprite-layer { transition: none; }
.mokomoko-sprite { background-repeat: no-repeat; background-size: 400% 400%; background-position: 0 0; image-rendering: auto; }
.mokomoko-sprite { width: min(8.5rem, 28vw); margin-left: -3.2rem; }
.mascot-stage p { max-width: 32ch; margin: -1rem 0 0; color: var(--muted); text-align: center; }

.row-practice { padding: 1.25rem 0 0; border-top: 1px solid var(--line); }
.row-heading { justify-content: center; gap: 1rem; }
.row-heading > div { min-width: 10rem; text-align: center; }
.row-heading span { color: var(--muted); font-size: 0.75rem; font-weight: 700; }
.row-heading h3 { margin: 0.2rem 0 0; font-family: var(--jp); }
.row-arrow { width: 2.75rem; padding: 0; border: 1px solid var(--line); background: transparent; }
.row-arrow:hover { background: var(--surface-soft); }
.row-sounds { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.55rem; margin: 1rem 0; }
.sound-button { min-width: 4.4rem; padding: 0.45rem 0.65rem; border: 1px solid var(--line); background: transparent; }
.sound-button strong, .sound-button small { display: block; }
.sound-button strong { font: 750 1.45rem/1.1 var(--jp); }
.sound-button small { color: var(--muted); }
.sound-button:hover { background: var(--surface-soft); }
.sound-button.active { color: white; border-color: var(--teal); background: var(--teal); }
.sound-button.active small { color: white; }
.sound-button-heard { display: block; color: var(--success); font-size: 0.62rem; }
.sound-button.active .sound-button-heard { color: white; }
.row-actions { justify-content: space-between; gap: 1rem; padding-top: 0.8rem; }
.row-actions p { margin: 0; color: var(--muted); font-size: 0.84rem; }
.recall-button, .hear-again { padding: 0 1rem; color: white; background: var(--teal); }

.recall { display: grid; grid-template-columns: 1fr auto; gap: 1rem; align-items: center; margin-top: 1.2rem; padding: 1.25rem; border-radius: 0.85rem; background: var(--teal-soft); }
.recall h3, .recall p { margin-bottom: 0.35rem; }
.recall-options { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 0.65rem; }
.recall-option { min-width: 5rem; padding: 0.55rem 0.9rem; border: 1px solid #81b9b3; background: white; font: 800 1.45rem/1 var(--jp); }
.recall-option:hover { border-color: var(--teal); background: #f5fffd; }
.recall-option.correct { color: white; background: var(--success); }
.recall-option.wrong { color: white; background: var(--danger); }
.text-button { width: fit-content; min-height: 2.4rem; padding: 0; color: var(--teal-dark); background: transparent; text-decoration: underline; text-underline-offset: 0.18em; }

.sound-library { margin-top: 1.3rem; border-top: 1px solid var(--line); }
.sound-library > summary { min-height: 3.5rem; display: flex; align-items: center; cursor: pointer; font-weight: 800; }
.library-controls { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1rem; }
.library-controls button { padding: 0 0.8rem; border: 1px solid var(--line); background: transparent; }
.library-controls button[aria-pressed="true"] { color: white; border-color: var(--teal); background: var(--teal); }
.sound-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(4.3rem, 1fr)); gap: 0.45rem; padding-bottom: 1rem; }
.sound-grid .sound-button { min-width: 0; }

.learning-guide, .voice-credit, .faq { margin-top: 4rem; }
.guide-intro { max-width: 48rem; }
.guide-intro h2, .voice-credit h2, .faq h2 { font-size: 2rem; }
.guide-intro p { color: var(--ink-soft); }
.guide-columns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2rem; margin-top: 2rem; }
.guide-columns article { padding-top: 1.2rem; border-top: 3px solid var(--teal); }
.guide-columns article:nth-child(2) { border-top-color: var(--peach); }
.guide-columns article:nth-child(3) { border-top-color: var(--gold); }
.guide-columns p { color: var(--ink-soft); }
.guide-columns a { font-weight: 750; }

.voice-credit { gap: 1.5rem; padding: 1.5rem 0; border-block: 1px solid var(--line); }
.voice-mark { display: grid; flex: 0 0 4.5rem; height: 4.5rem; place-items: center; color: white; background: var(--teal); border-radius: 50%; font: 800 2rem/1 var(--jp); }
.voice-credit h2 { margin-bottom: 0.6rem; }
.voice-credit p:last-child { max-width: 65ch; margin-bottom: 0; color: var(--ink-soft); }

.faq { max-width: 54rem; }
.faq > details { border-top: 1px solid var(--line); }
.faq > details:last-child { border-bottom: 1px solid var(--line); }
.faq summary { min-height: 3.8rem; display: flex; align-items: center; cursor: pointer; font-weight: 750; }
.faq details p { max-width: 68ch; color: var(--ink-soft); }

footer { margin-top: 4rem; padding: 2rem 0 3rem; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.84rem; }
footer p { margin-bottom: 0.25rem; }
footer a { display: inline-block; margin-top: 0.6rem; font-weight: 700; }
noscript { display: block; padding: 1rem; color: white; background: var(--danger); text-align: center; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

@media (max-width: 800px) {
  .site-header { flex-wrap: wrap; }
  .header-progress { order: 3; width: 100%; margin-left: 3.35rem; }
  .language-slot { margin-left: auto; }
  .intro { grid-template-columns: 1fr; gap: 0.9rem; padding: 1.4rem 0 1.1rem; }
  .intro h1 { font-size: 2.15rem; }
  .intro-facts { max-width: 30rem; }
  .practice-grid { grid-template-columns: 1fr; }
  .sound-lesson { padding-right: 0; padding-bottom: 1.5rem; border-right: 0; border-bottom: 1px solid var(--line); }
  .mascot-stage { min-height: 18rem; }
  .mofuna-sprite { width: 14rem; }
  .mokomoko-sprite { width: 7rem; }
  .guide-columns { grid-template-columns: 1fr; gap: 1.4rem; }
}

@media (max-width: 520px) {
  main, footer { width: min(100% - 1rem, 72rem); }
  .site-header { padding-inline: 0.5rem; }
  .spark-home-button { width: 2.75rem; height: 2.75rem; flex-basis: 2.75rem; }
  .brand small { display: none; }
  .tools { margin-left: auto; }
  .tools > summary { font-size: 0.78rem; }
  .header-progress { margin-left: 3.35rem; }
  .language-slot { order: 4; width: 100%; margin-left: 0; flex-basis: 100%; }
  .intro { padding: 1.1rem 0 0.9rem; }
  .intro h1 { font-size: 1.9rem; }
  .practice { padding: 1rem 0.75rem; }
  .practice-header { align-items: flex-start; }
  .practice-header h2 { font-size: 1.35rem; }
  .row-progress { white-space: nowrap; }
  .sound-heading { align-items: flex-start; }
  .kana-display span:first-child { font-size: 5.7rem; }
  .kana-display span:last-child { font-size: 1.65rem; }
  .audio-actions { flex-direction: column; }
  .hear-button, .hear-next-button, .autoplay-button { flex: 0 0 auto; width: 100%; }
  .lesson-navigation > button { flex: 1; }
  .mascot-stage { min-height: 14rem; }
  .mofuna-sprite { width: 11rem; }
  .mokomoko-sprite { width: 5.5rem; margin-left: -2.2rem; }
  .row-actions, .voice-credit { align-items: flex-start; flex-direction: column; }
  .recall { grid-template-columns: 1fr; }
  .recall-options { grid-column: auto; }
  .hear-again { width: 100%; }
  .guide-intro h2, .voice-credit h2, .faq h2 { font-size: 1.65rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.001ms !important; animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; }
  .particle-button::before, .particle-button::after { animation: none !important; transform: none !important; }
}

@keyframes wcV2SparkDrift {
  0%, 100% { transform: translate3d(-6%, -3%, 0) rotate(0deg); }
  48% { transform: translate3d(7%, 4%, 0) rotate(2deg); }
  70% { transform: translate3d(2%, -1%, 0) rotate(-1deg); }
}
