:root {
  color-scheme: light;
  --paper: #f3eee4;
  --ink: #1c2421;
  --muted: #5c574e;
  --card: #fffdf8;
  --line: #e3d8c6;
  --teal: #0e5c57;
  --teal-2: #14756e;
  --on-teal: #f4fffd;
  --coral: #b64032;
  --moss: #2a6844;
  --sand: #e7f3f1;
  --focus: #0b57d0;
  --shadow: 0 16px 40px rgba(40, 32, 20, 0.08);
  --serif: Palatino, "Palatino Linotype", "Iowan Old Style", Georgia, serif;
  --sans: "Segoe UI", system-ui, sans-serif;
  --max: 46rem;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #121918;
    --ink: #f4efe6;
    --muted: #c3bbb0;
    --card: #1c2523;
    --line: #31403c;
    --teal: #8fd9d1;
    --teal-2: #1c6e68;
    --on-teal: #06211f;
    --coral: #ffb4a8;
    --moss: #9ddeaf;
    --sand: #243330;
    --focus: #9ec1ff;
    --shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #121918;
  --ink: #f4efe6;
  --muted: #c3bbb0;
  --card: #1c2523;
  --line: #31403c;
  --teal: #8fd9d1;
  --teal-2: #1c6e68;
  --on-teal: #06211f;
  --coral: #ffb4a8;
  --moss: #9ddeaf;
  --sand: #243330;
  --focus: #9ec1ff;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
}

:root[data-theme="light"] {
  color-scheme: light;
  --paper: #f3eee4;
  --ink: #1c2421;
  --muted: #5c574e;
  --card: #fffdf8;
  --line: #e3d8c6;
  --teal: #0e5c57;
  --teal-2: #14756e;
  --on-teal: #f4fffd;
  --coral: #b64032;
  --moss: #2a6844;
  --sand: #e7f3f1;
  --focus: #0b57d0;
  --shadow: 0 16px 40px rgba(40, 32, 20, 0.08);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background:
    radial-gradient(900px 280px at 10% -10%, rgba(20, 117, 110, 0.16), transparent 60%),
    var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.05rem;
  line-height: 1.5;
}
img { max-width: 100%; height: auto; }
a { color: var(--teal); }
a:hover { text-decoration-thickness: 2px; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.15; letter-spacing: -0.02em; }
h1 { font-size: clamp(2.1rem, 6vw, 3.4rem); margin: 0 0 0.6rem; }
h2 { font-size: 1.55rem; margin: 1.4rem 0 0.4rem; }
h3 { font-size: 1.15rem; margin: 1rem 0 0.3rem; }
p { margin: 0.4rem 0 0.8rem; }

.skip {
  position: absolute;
  left: 0.5rem;
  top: -3rem;
  background: var(--card);
  padding: 0.5rem 0.8rem;
  z-index: 5;
}
.skip:focus { top: 0.5rem; }

.top, .foot, main { width: min(100% - 1.5rem, var(--max)); margin-inline: auto; }
.top {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 0;
}
.brand { font-family: var(--serif); font-size: 1.6rem; color: var(--ink); text-decoration: none; min-height: 44px; display: inline-flex; align-items: center; }
nav { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; }
nav a, .theme-btn, button, .btn {
  font: inherit;
  min-height: 48px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  padding: 0.45rem 0.9rem;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.btn.primary, button.primary {
  background: var(--teal);
  color: var(--on-teal);
  border-color: transparent;
}
.btn.ghost { background: transparent; }
.btn.danger { color: var(--coral); border-color: var(--coral); background: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
.theme-btn { min-width: 48px; }

.hero { display: grid; gap: 1rem; align-items: center; }
@media (min-width: 760px) {
  .hero { grid-template-columns: 1.3fr 0.7fr; }
}
.kicker { text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.78rem; color: var(--teal); margin: 0; font-weight: 700; }
.lede { font-size: 1.15rem; }
.row { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.8rem 0; }
.mascot { width: min(100%, 280px); border-radius: 1.5rem; justify-self: center; box-shadow: var(--shadow); }
.card, .note, .word-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 1.1rem;
  padding: 1rem 1.05rem;
  box-shadow: var(--shadow);
}
.grid { display: grid; gap: 0.75rem; }
@media (min-width: 700px) { .grid.two { grid-template-columns: 1fr 1fr; } }
.muted { color: var(--muted); }
.banner {
  background: var(--sand);
  border-radius: 1rem;
  padding: 0.8rem 1rem;
  margin: 0.6rem 0 1rem;
}
.banner strong { font-family: var(--serif); }
fieldset {
  border: 1px solid var(--line);
  border-radius: 1rem;
  margin: 0 0 1rem;
  padding: 0.8rem 1rem 1rem;
}
legend { font-family: var(--serif); padding: 0 0.3rem; }
label { display: block; font-weight: 650; margin-bottom: 0.25rem; }
.choice { display: flex; gap: 0.6rem; align-items: flex-start; font-weight: 500; margin: 0.35rem 0; min-height: 48px; }
.choice input { width: 1.2rem; height: 1.2rem; margin-top: 0.2rem; accent-color: var(--teal-2); }
input:not([type]), input[type="text"], input[type="password"], textarea, select {
  width: 100%;
  font: inherit;
  font-size: 1rem;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  padding: 0.7rem 0.8rem;
  min-height: 48px;
}
textarea { min-height: 7rem; resize: vertical; }
.hint { display: block; color: var(--muted); font-weight: 450; margin: 0.15rem 0 0.45rem; }
.field { margin-bottom: 1rem; }
.error { color: var(--coral); font-weight: 650; }

.say-btn {
  width: 100%;
  min-height: 5.6rem;
  border-radius: 1.4rem;
  border: 0;
  background: var(--teal);
  color: var(--on-teal);
  font-size: 1.45rem;
  font-weight: 700;
  touch-action: none;
  user-select: none;
}
.say-btn:active { transform: scale(0.98); }
.reaction {
  font-family: var(--serif);
  font-size: clamp(1.8rem, 5vw, 2.6rem);
  text-align: center;
  margin: 0.2rem 0 0.6rem;
}
.word {
  font-family: var(--serif);
  font-size: clamp(2.4rem, 8vw, 4rem);
  text-align: center;
  margin: 0.2rem 0;
}
.stones { display: flex; gap: 0.4rem; justify-content: center; margin: 0.4rem 0 0.8rem; }
.stone {
  width: 0.9rem;
  height: 0.9rem;
  border-radius: 50%;
  background: var(--line);
}
.stone.on { background: var(--teal); }
.rate {
  display: grid;
  gap: 0.5rem;
}
@media (min-width: 700px) { .rate { grid-template-columns: 1fr 1fr 1fr; } }
.rate button { width: 100%; border-radius: 1rem; min-height: 64px; }
.draw { width: min(100%, 220px); display: block; margin: 0.4rem auto; }
.bars { display: grid; gap: 0.45rem; }
.bar { height: 0.7rem; background: var(--line); border-radius: 99px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--teal); }
table { width: 100%; border-collapse: collapse; font-size: 0.98rem; }
th, td { text-align: left; padding: 0.45rem 0.3rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
.foot { padding: 2rem 0 3rem; color: var(--muted); font-size: 0.95rem; }
dialog {
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--card);
  color: var(--ink);
  max-width: 28rem;
  padding: 1.2rem;
}
dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
audio, video { width: 100%; margin: 0.4rem 0; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation: none !important; transition: none !important; }
}
.deck { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.6rem; list-style: none; padding: 0; margin: 0.8rem 0 1rem; }
.deck li, .play-card { background: var(--card); border: 1px solid var(--line); border-radius: 1rem; padding: 0.6rem; text-align: center; }
.pic-svg { width: 4.5rem; height: 4.5rem; display: block; margin: 0 auto; }
.play-card { padding: 1rem 0.8rem 1.1rem; margin-bottom: 0.8rem; }
.mouth-demo { margin: 0.4rem auto 0.8rem; max-width: 16rem; }
.mouth-svg { width: 100%; height: auto; overflow: visible; }
.tongue-body, .tip, .sound-bar, .helper { transform-box: fill-box; transform-origin: center; }
.mouth-demo.bunched .tongue-body { transform: translateY(-6px) scale(1.05, 0.82); }
.mouth-demo.retroflex .tip { transform: rotate(-48deg); transform-origin: 0% 80%; }
.mouth-demo.anchor_er .sound-bar { transform: scaleX(1); }
.mouth-demo.facilitator .helper { opacity: 1; }
.mouth-demo.slow .sound-bar { transform: scaleX(1.15); }
.mouth-demo.is-playing.bunched .tongue-body { animation: rora-hill 1.3s ease forwards; }
.mouth-demo.is-playing.retroflex .tip { animation: rora-tip 1.3s ease forwards; }
.mouth-demo.is-playing.anchor_er .sound-bar { animation: rora-hold 1.4s ease forwards; }
.mouth-demo.is-playing.facilitator .k-bit { animation: rora-pop 1.4s ease forwards; }
.mouth-demo.is-playing.slow .sound-bar { animation: rora-stretch 1.4s ease forwards; }
@keyframes rora-hill { from { transform: translateY(10px) scale(1, 1); } to { transform: translateY(-6px) scale(1.05, 0.82); } }
@keyframes rora-tip { from { transform: rotate(8deg); } to { transform: rotate(-48deg); } }
@keyframes rora-hold { from { transform: scaleX(0.25); } to { transform: scaleX(1); } }
@keyframes rora-pop { from { opacity: 0.2; } to { opacity: 1; } }
@keyframes rora-stretch { from { transform: scaleX(0.4); } to { transform: scaleX(1.15); } }

@media print {
  .top, .foot, .row, button { display: none !important; }
  body { background: white; color: black; }
  .card { box-shadow: none; }
}

main#app { min-height: 100vh; min-height: 100svh; }
