:root {
  color-scheme: light;
  --bg: #f4efe4;
  --ink: #1c2430;
  --muted: #3a4a5e;
  --card: #fffaf3;
  --line: #cbb892;
  --header: #0f5132;
  --header-ink: #f3fff6;
  --header-btn: #f3fff6;
  --header-btn-ink: #0c3b24;
  --btn: #0f5132;
  --btn-ink: #ffffff;
  --gold: #6a3e00;
  --focus: #0b3f91;
  --meter: #e4d3b0;
  --fill: #c47d00;
  --sail: #f7fbff;
  --cloud: #d5e3ee;
  --tongue: #c45252;
  --lip: #b83b5e;
  --tooth: #fffdf8;
  --good: #e7f6ee;
  --shadow: 0 8px 24px rgba(28, 36, 48, 0.08);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121a22;
  --ink: #f6f1e6;
  --muted: #e4d9c8;
  --card: #1c2833;
  --line: #466078;
  --header: #08261c;
  --header-ink: #f6f1e6;
  --header-btn: #d9fff0;
  --header-btn-ink: #06241a;
  --btn: #8ee0c2;
  --btn-ink: #06241a;
  --gold: #ffd36a;
  --focus: #ffd36a;
  --meter: #2a3b4a;
  --fill: #ffd36a;
  --sail: #d5e7f2;
  --cloud: #c5d5e2;
  --tongue: #e08080;
  --lip: #e07a96;
  --tooth: #fffdf8;
  --good: #163528;
  --shadow: none;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 1.125rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -48px;
  background: var(--btn);
  color: var(--btn-ink);
  padding: 12px 16px;
  z-index: 3;
}

.skip-link:focus { top: 12px; }

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--header);
  color: var(--header-ink);
  position: static;
}

.topbar h1 {
  margin: 0;
  flex: 1 1 8rem;
  font-size: clamp(1.05rem, 2.4vw, 1.4rem);
  line-height: 1.2;
}

.topbar button[hidden] { display: none; }

.topbar a,
.topbar button {
  min-width: 64px;
  min-height: 64px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  background: var(--header-btn);
  color: var(--header-btn-ink);
  border-radius: 12px;
  text-decoration: none;
  border: 3px solid transparent;
  font: inherit;
  font-weight: 700;
}

main {
  width: min(40rem, 100%);
  margin: 0 auto;
  padding: 16px 16px 48px;
}

.stack { display: flex; flex-direction: column; gap: 12px; }

.card, .banner {
  background: var(--card);
  border: 3px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  box-shadow: var(--shadow);
}

.banner { background: var(--good); }

.quiet { color: var(--muted); margin: 0; }

h2, h3 { line-height: 1.25; margin: 0; }

p { margin: 0; }

button, .text-link, input, select, label {
  touch-action: manipulation;
  font: inherit;
  color: var(--ink);
}

button, .text-link {
  min-width: 64px;
  min-height: 64px;
  padding: 12px 16px;
  border-radius: 14px;
  border: 3px solid var(--line);
  background: var(--card);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

button.xl, a.text-link.xl { min-height: 88px; background: var(--btn); color: var(--btn-ink); border-color: transparent; font-weight: 700; }

.stack > button,
.stack > .text-link,
.card > button,
form > button,
dialog > button { width: 100%; }

dialog[open] {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

button.is-closed { background: var(--card); color: var(--ink); }

button.is-on { outline: 3px solid var(--focus); }

.choice-row { display: flex; flex-wrap: wrap; gap: 12px; }

.choice-row button { flex: 1 1 9rem; }

input, select {
  min-height: 64px;
  width: 100%;
  padding: 8px 12px;
  border-radius: 12px;
  border: 3px solid var(--line);
  background: var(--card);
  font-size: 1.05rem;
}

.inline {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 64px;
}

.inline input[type="radio"],
.inline input[type="checkbox"] {
  width: 64px;
  height: 64px;
  min-width: 64px;
  min-height: 64px;
  accent-color: var(--btn);
}

.inline label { min-height: 64px; display: flex; align-items: center; }

label { font-weight: 700; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

/* Nothing looks selected on load: script-focused headings, the notice and
   mouse/touch focus show no ring. Keyboard focus keeps :focus-visible. */
:focus:not(:focus-visible) { outline: none; }
[tabindex="-1"]:focus, dialog:focus, dialog:focus-visible { outline: none; }

.picture { font-size: 4.5rem; text-align: center; line-height: 1.2; }

.word { font-size: 2rem; text-align: center; font-weight: 800; }

#scorer-line { font-size: 1.7rem; font-weight: 800; text-align: center; margin: 4px 0 0; }

#scorer-again { text-align: center; font-weight: 700; }

.ship { display: flex; align-items: flex-end; gap: 12px; min-height: 96px; }

.cub { font-size: 3rem; margin: 0; }

.sails { display: flex; align-items: flex-end; gap: 8px; height: 88px; }

.sail {
  display: block;
  width: 36px;
  height: 24px;
  background: var(--sail);
  border: 3px solid var(--ink);
  border-radius: 8px 8px 0 0;
  transform-origin: bottom center;
}

.sail.is-up { height: 72px; }

.meter {
  height: 28px;
  background: var(--meter);
  border-radius: 999px;
  overflow: hidden;
  border: 3px solid var(--line);
}

#roar-fill { display: block; height: 100%; width: 0; background: var(--fill); }

.ribbon { display: flex; align-items: flex-end; gap: 6px; height: 64px; }

.ribbon span {
  display: block;
  width: 12px;
  height: 10px;
  background: var(--gold);
  border-radius: 6px;
}

.hold {
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.hold.is-holding { box-shadow: inset 0 0 0 4px var(--gold); }

.sky {
  position: relative;
  min-height: 18rem;
  background: var(--card);
  border-radius: 16px;
  overflow: hidden;
  border: 3px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding-bottom: 0.75rem;
}

.cloud {
  width: 140px;
  height: 52px;
  margin: 24px;
  border-radius: 40px;
  background: var(--cloud);
  transition: transform 1.2s ease;
}

.mic-wiggle { animation: mic-wiggle 0.2s ease 1; }

@keyframes mic-wiggle {
  from { transform: translateX(-2px); }
  to { transform: translateX(0); }
}

.cloud.is-leaving, .cloud.is-aside { transform: translate(150px, -28px); }

.mouth-svg, .front-svg, canvas, .mouth-photo { width: min(100%, 40rem); height: auto; display: block; border-radius: 16px; }

.mouth-sky { fill: var(--card); }
.palate, .jaw { fill: none; stroke: var(--ink); stroke-width: 6; }
.tongue { fill: var(--tongue); }
.lips, .front-lips { fill: var(--lip); }
.tooth { fill: var(--tooth); stroke: var(--ink); }

.mouth-figure { margin: 0; }

.sticker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(7rem, 1fr));
  gap: 12px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.sticker {
  min-height: 88px;
  border: 3px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 8px;
}

.sticker.have { background: var(--good); }

table { width: 100%; border-collapse: collapse; }

th, td { border: 2px solid var(--line); padding: 8px; text-align: left; }

td.practiced { background: var(--good); font-weight: 800; }

dialog {
  width: min(40rem, calc(100vw - 24px));
  max-height: min(40rem, calc(100dvh - 24px));
  margin-block: auto;
  overflow: auto;
  border: 3px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  color: var(--ink);
  padding: 16px;
}

dialog::backdrop { background: rgba(18, 26, 34, 0.62); }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

ul { margin: 0; padding-left: 1.2rem; }

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

@media (forced-colors: active) {
  button, a, input, select { border: 2px solid ButtonText; }
}

@media print {
  body * { visibility: hidden; }
  #print-root, #print-root * { visibility: visible; }
  #print-root { position: absolute; left: 0; top: 0; width: 100%; }
}

/* DR MGG-3 2026-11-16: keep the grown-ups note button visible (sticky footer) */
#note-dialog .note-actions { position: sticky; bottom: -16px; margin: 0 -16px -16px; padding: 12px 16px 16px; background: var(--card); border-top: 1px solid var(--line); z-index: 1; }
#note-dialog .note-actions > button { width: 100%; }


/* r7: end-of-voyage trophy and sticker moments */
.sky .cloud { align-self: flex-start; }
.sky .cub { align-self: flex-start; margin-left: 16px; }
.trophy {
  font-size: clamp(4.5rem, 22vw, 7rem);
  line-height: 1;
  text-align: center;
  margin: 4px auto 8px;
  transform-origin: 50% 80%;
  filter: drop-shadow(0 2px 0 rgba(90, 60, 0, 0.35));
  align-self: center;
}
.trophy.is-visible { transform: scale(1); }
.trophy.is-pop { animation: trophy-pop 0.9s ease both; }
@keyframes trophy-pop {
  0% { transform: scale(0.2) rotate(-14deg); opacity: 0; }
  60% { transform: scale(1.16) rotate(6deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .trophy.is-pop { animation: none; transform: scale(1); }
  .cloud { transition: none; }
}
.sticker-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0;
  margin: 0;
  list-style: none;
  font-weight: 700;
}
#sticker-toast { text-align: center; }
#roar-practice-tips { margin: 0; padding-left: 1.2em; }
#rory-trophy { min-height: 6rem; }

/* r5 2026-11-22: sequel continue link on the trophy / finished-map screens only */
a.sequel-link { box-sizing: border-box; }
