:root {
  color-scheme: light;
  font-family: "Atkinson Hyperlegible Next", "Noto Sans", system-ui, sans-serif;
  color: #241c29;
  background: #f8f4ed;
  --paper: #fffdf9;
  --purple: #552476;
  --ink: #241c29;
  --muted: #5e5265;
  --border: #a99ab2;
  --lavender: #f0e5f7;
  --red: #9d192a;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font-size: 1rem; line-height: 1.55; }
button { font: inherit; cursor: pointer; color: inherit; }
button:disabled { cursor: default; opacity: .68; }
button:focus-visible, summary:focus-visible {
  outline: 3px solid #71309b;
  outline-offset: 3px;
}
h1:focus { outline: none; }
h1, p, figure { margin: 0; }
.bar {
  background: var(--paper);
  border-bottom: 1px solid #e5dce8;
  padding: calc(8px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left));
}
.brand {
  display: flex; align-items: center; gap: 10px;
  min-height: 48px; border: 0; background: transparent; padding: 4px 10px;
  border-radius: 10px; margin: auto; color: var(--purple); font-weight: 750;
}
.home-icon { flex: none; }
.brand span { border: 1px solid #b899c5; background: var(--lavender); border-radius: 9px; padding: 3px 7px; }
main, footer {
  width: min(100%, 990px); margin: auto;
  padding-inline: max(12px, env(safe-area-inset-left)) max(12px, env(safe-area-inset-right));
}
main { padding-top: clamp(20px, 4vw, 40px); }
footer { text-align: center; color: var(--muted); font-size: .93rem; padding-top: 26px; padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
#offline { margin-bottom: 10px; }
.hero, .section-heading { text-align: center; }
.hero .section-heading { margin: 0; }
.logo { display: block; margin: 0 auto 10px; border-radius: 32px; width: clamp(140px, 27vw, 180px); height: auto; }
h1 { font-size: clamp(1.85rem, 5.5vw, 2.85rem); letter-spacing: -.035em; line-height: 1.14; }
.hero h1 { color: var(--purple); font-size: clamp(2.4rem, 7vw, 3.5rem); }
.tagline { color: var(--muted); font-size: clamp(1rem, 3vw, 1.22rem); margin-top: 8px; }
.section-heading { margin-bottom: 20px; }
.context { color: var(--purple); font-weight: 700; margin-bottom: 6px; }
.activity-list, .menu { width: min(100%, 480px); margin: 24px auto 12px; display: grid; gap: 12px; }
.activity-card {
  display: flex; justify-content: space-between; align-items: center; text-align: left; gap: 12px;
  background: var(--purple); color: #fff; border: 1px solid var(--purple);
  border-radius: 18px; padding: 16px clamp(16px, 4vw, 24px); min-height: 92px;
}
.activity-card + .activity-card { background: var(--paper); color: var(--purple); border-color: #9274a2; }
.activity-card strong { display: block; font-size: 1.35rem; }
.activity-card small { display: block; font-size: 1rem; }
.activity-card > span:last-child { font-size: 2rem; line-height: 1; }
.activity-card:hover { box-shadow: 0 0 0 2px #b899c5; }
.button {
  display: inline-flex; justify-content: center; align-items: center; text-align: center;
  border: 1px solid #9274a2; border-radius: 12px; min-height: 48px;
  padding: 8px 15px; background: var(--paper); color: var(--purple); font-weight: 720;
}
.button:hover:not(:disabled) { box-shadow: inset 0 0 0 1px currentColor; }
.button.primary { background: var(--purple); color: white; border-color: var(--purple); }
.button.quiet { background: transparent; border-color: transparent; text-decoration: underline; text-underline-offset: .2em; }
.button[aria-disabled="true"] { background: #eee8ef; color: #54495a; border-color: #a99ab2; }
.menu .button { min-height: 60px; font-size: 1.12rem; }
#install-area { max-width: 480px; margin: 16px auto 0; text-align: center; }
.note { margin-top: 8px; padding: 14px; text-align: left; background: var(--paper); border: 1px solid var(--border); border-radius: 12px; }
.note p + p { margin-top: 10px; }
.picture { background: var(--paper); border: 1px solid #c8b9ce; border-radius: 18px; overflow: hidden; width: min(100%, 430px); margin: auto; }
.object-photo { display: block; width: 100%; aspect-ratio: 5 / 4; object-fit: contain; background: #faf6ee; }
.intro-photo { width: min(100%, 440px); }
.intro-photo .object-photo { max-height: 370px; }
.name-layout { display: grid; gap: 18px; width: min(100%, 520px); margin: auto; }
.name-layout .picture .object-photo { max-height: 230px; }
.practice { min-width: 0; }
.size-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0 12px; }
.size-row p { color: var(--muted); }
.size[aria-pressed="true"] { background: var(--lavender); border: 2px solid var(--purple); }
.grid {
  display: grid; grid-template-columns: repeat(var(--size), minmax(0, 1fr));
  gap: clamp(2px, .7vw, 6px); touch-action: none; user-select: none; -webkit-user-select: none;
}
.cell {
  display: grid; place-items: center; padding: 0; aspect-ratio: 1;
  min-width: 0; background: var(--paper); border: 1px solid #ac9ab6;
  border-radius: clamp(4px, 1vw, 9px); font-size: clamp(1rem, 4vw, 1.46rem); font-weight: 730;
}
.cell:focus-visible { outline-offset: -3px; }
.cell.selected { background: var(--lavender); box-shadow: inset 0 0 0 2px var(--purple); }
.cell.preview { box-shadow: inset 0 0 0 2px var(--purple); }
.cell.hint { background: #f9edc1; outline: 2px dashed #67491b; outline-offset: -4px; }
.actions { display: flex; justify-content: center; align-items: center; gap: 8px; margin-top: 14px; }
.wrap { flex-wrap: wrap; }
.feedback { text-align: center; color: var(--purple); font-weight: 700; min-height: 1.55em; margin-top: 10px; }
.answer { padding: 12px 0 0; }
.answer-line { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px; }
.answer-word { font-size: clamp(2.2rem, 9vw, 3.3rem); line-height: 1.12; font-weight: 800; color: #000; }
.syllable-word { color: #000; }
.syllable-word .red { color: var(--red); }
.audio-status { margin: 6px 0; color: var(--muted); }
.audio-status:empty { margin: 0; }
.answer .primary { margin-top: 8px; }
.aid { font-size: 1.65rem; font-weight: 750; text-align: center; margin-top: 6px; }
.prompt { margin: 0 auto 16px; text-align: center; }
#companion { margin-top: 8px; }
summary { display: inline list-item; cursor: pointer; color: var(--purple); padding-block: 9px; }
.choices { display: grid; gap: 12px; max-width: 700px; margin: auto; }
.photo-choice {
  display: block; min-width: 0; border: 2px solid #9878aa; border-radius: 16px;
  overflow: hidden; padding: 0; background: var(--paper);
}
.photo-choice .object-photo { max-height: 300px; }
.photo-choice.picked { outline: 3px solid var(--purple); outline-offset: 2px; }
.media-error { display: block; text-align: center; padding: 20px; }
@media (min-width: 390px) { .choices { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.activity-card small { font-size: .88rem; }
[lang="en"] { color: #22576b; }
.activity-card:first-child [lang="en"], .button.primary [lang="en"] { color: #c4edf9; }
.guide, .guide-note { max-width: 530px; margin-inline: auto; }
.guide { padding-left: 1.6rem; }
.guide li + li { margin-top: 12px; }
.guide-note { padding: 12px; border-radius: 12px; background: var(--lavender); }
.round-settings fieldset { border: 1px solid var(--border); border-radius: 12px; }
.round-settings label { display: inline-flex; align-items: center; min-height: 44px; padding-inline: 8px; }
.round-settings input { accent-color: var(--purple); }
main[data-screen="play"] { padding-top: 8px; }
[data-screen="play"] .section-heading { margin-bottom: 8px; }
[data-screen="play"] h1 { font-size: clamp(1.4rem, 5vw, 2rem); }
[data-screen="play"] .context { font-size: .85rem; margin-bottom: 2px; }
body:has([data-screen="play"]) .bar { padding-block: env(safe-area-inset-top) 0; }
body:has([data-screen="play"]) .brand { min-height: 42px; }
footer:has(#offline[hidden]) { display: none; }
.name-layout { gap: 8px; }
.name-layout .section-heading { margin-bottom: 0; }
.puzzle-buttons { display: contents; }
.name-layout .picture { width: min(100%, 110px); }
.name-layout .picture .object-photo { max-height: 84px; }
#puzzle-actions { margin-top: 4px; }
#puzzle-actions .button, .choice-layout .button, .answer .button { padding: 4px 10px; min-height: 44px; }
#puzzle-tools { text-align: center; }
#puzzle-size { justify-content: center; margin: 0; }
.grid { width: min(100%, 430px); margin-inline: auto; }
.answer-space { min-height: 104px; }
.answer { padding-block: 4px; }
.answer-line { justify-content: center; }
.answer .primary { display: flex; margin-inline: auto; }
.feedback { margin-top: 4px; }
.puzzle-side .feedback:empty { display: none; }
.choice-layout { width: min(100%, 760px); margin: auto; padding-bottom: env(safe-area-inset-bottom); }
.choice-layout .prompt { margin-bottom: 6px; }
.choice-target { font-weight: 800; font-size: 1.45rem; }
#choice-hint .object-photo { max-height: 68px; margin: 2px auto; }
.choices { gap: 7px; }
.photo-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.photo-options .object-photo {
  height: clamp(54px, calc((100dvh - 245px) / 3), 164px);
  aspect-ratio: auto;
}
.word-options { grid-template-columns: minmax(0, 1fr); max-width: 480px; }
.word-choice.picked { outline: 3px solid var(--purple); outline-offset: -3px; background: var(--lavender); }
.choice-footer {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  min-height: 48px; margin-top: 3px;
}
.choice-footer .feedback { margin: 0; text-align: left; }
@media (orientation: landscape) {
  .intro-layout, .choice-layout {
    display: grid; grid-template-columns: minmax(0, .72fr) minmax(0, 1.5fr);
    align-items: center; gap: 12px; width: min(100%, 840px); margin-inline: auto;
  }
  .intro-photo .object-photo { max-height: min(370px, calc(100dvh - 90px)); }
  .name-layout {
    grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr) minmax(0, 1.45fr);
    grid-template-areas: "controls photo grid" "size photo grid" "hints photo grid";
    grid-template-rows: auto auto 1fr;
    align-items: start;
    gap: 8px 12px;
    width: 100%;
  }
  .bar:has(> .section-heading) {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    grid-template-areas: "progress brand title";
    align-items: center;
    column-gap: 8px;
  }
  .bar > .section-heading { display: contents; }
  .bar:has(> .section-heading) .brand { grid-area: brand; white-space: nowrap; }
  .bar > .section-heading .context {
    grid-area: progress;
    margin: 0;
    text-align: left;
    font-size: clamp(.66rem, 1.65vw, .95rem);
    line-height: 1.2;
  }
  .bar > .section-heading h1 {
    grid-area: title;
    text-align: right;
    font-size: clamp(.94rem, 2.5vw, 1.5rem);
  }
  .name-layout .puzzle-side, #puzzle-actions { display: contents; }
  .name-layout .picture {
    grid-area: photo; align-self: center; margin: 0 auto 44px;
    width: min(100%, 208px);
  }
  .name-layout .picture .object-photo { max-height: min(145px, 28dvh); }
  .puzzle-buttons { grid-area: controls; display: flex; gap: 6px; align-items: stretch; }
  #puzzle-actions .puzzle-buttons .button {
    min-width: 0;
    padding-inline: clamp(4px, 1vw, 10px);
    font-size: clamp(.76rem, 1.85vw, 1rem);
    line-height: 1.2;
  }
  #puzzle-actions [data-action="skip"] {
    grid-area: photo; align-self: center; justify-self: center;
    margin-top: calc(min(145px, 28dvh) + 4px);
  }
  #puzzle-tools { grid-area: hints; text-align: left; }
  #puzzle-size { grid-area: size; justify-content: start; }
  #puzzle-tools .actions { justify-content: start; }
  .name-layout .aid, .name-layout .audio-status, .name-layout .feedback { grid-column: 1; }
  .name-layout .practice { grid-area: grid; }
  .name-layout .grid {
    width: min(100%, 430px, max(120px, calc(100dvh - 58px - env(safe-area-inset-top) - env(safe-area-inset-bottom))));
    aspect-ratio: 1;
    grid-template-rows: repeat(var(--size), minmax(0, 1fr));
    gap: clamp(2px, .6dvh, 5px);
  }
  .name-layout .cell { width: 100%; height: 100%; font-size: clamp(.8rem, 5dvh, 1.46rem); line-height: 1; }
  .name-layout .answer-space { min-height: 0; }
  .choice-layout .prompt { margin: 0; }
  .photo-options[data-count="6"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .photo-options .object-photo { height: clamp(55px, calc((100dvh - 165px) / 2), 215px); }
  .word-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (orientation: portrait) and (max-height: 680px) {
  .name-layout .picture .object-photo { max-height: 60px; }
  .name-layout .grid { width: min(100%, max(232px, calc(100dvh - 300px))); }
}

.button > [lang="en"] { margin-inline-start: .28em; }

/* Each atlas cell stays square even in short landscape choice cards. */
.atlas-photo { display: flex; align-items: center; justify-content: center; overflow: hidden; container-type: size; }
.atlas-window { display: block; position: relative; flex: none; width: min(100cqw, 100cqh); height: min(100cqw, 100cqh); aspect-ratio: 1; overflow: hidden; }
.atlas-window img { position: absolute; max-width: none; object-fit: fill; }


.privacy-note { max-width: 620px; margin: 24px auto 12px; padding: 12px 16px; color: #675d70; font-size: .9rem; line-height: 1.6; }
.privacy-note summary { cursor: pointer; }
.privacy-note p { margin: 10px 0; }
.privacy-note [lang=en] { color: #76658d; }
.privacy-note label { display: flex; align-items: center; gap: 10px; }
.privacy-note input { width: 20px; height: 20px; }

/* Persistent drag instructions: the example is separate from the puzzle. */
.drag-guide { max-width: 430px; margin: 0 auto 12px; padding: 12px 14px; border: 1px solid #d7c3e9; border-radius: 12px; background: #f8f3fc; }
.drag-guide p { margin: 0; color: var(--purple); font-weight: 700; line-height: 1.35; }
.drag-guide p[lang="en"] { margin-top: 4px; color: #375b82; font-weight: 400; font-size: .9rem; }
.drag-mouse { display: none; }
@media (hover: hover) and (pointer: fine) { .drag-touch { display: none; } .drag-mouse { display: block; } }
.drag-example { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 10px; padding-bottom: 9px; }
.example-label { color: var(--purple); font-size: .85rem; font-weight: 700; }
.example-word { position: relative; display: flex; border-radius: 8px; background: #e4cef6; color: var(--purple); }
.example-word > span { display: grid; place-items: center; width: 30px; height: 30px; border: 1px solid #b99ccd; font-weight: 750; }
.example-word::after { content: '➜'; position: absolute; left: 4px; right: 3px; bottom: -15px; height: 12px; border-bottom: 2px solid var(--purple); text-align: right; line-height: 22px; font-size: 18px; }
