:root {
  --paper: #f4eedf;
  --paper-deep: #e9dec6;
  --ink: #26372f;
  --muted: #6c6a5f;
  --accent: #b36b32;
  --accent-soft: #f1c75b;
  --line: rgba(38, 55, 47, 0.2);
  --card: rgba(255, 253, 246, 0.78);
  --shadow: 0 18px 55px rgba(61, 48, 29, 0.1);
  --serif: Iowan Old Style, Baskerville, "Times New Roman", serif;
  --sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html[data-site="esperanto"] {
  --paper: #eaf3e9;
  --paper-deep: #d5e8d4;
  --ink: #143d2d;
  --muted: #52665b;
  --accent: #14764b;
  --accent-soft: #a9d8b7;
  --line: rgba(20, 61, 45, 0.2);
  --card: rgba(252, 255, 250, 0.82);
}

html[data-site="toki"] {
  --paper: #fff6c8;
  --paper-deep: #f6e88f;
  --ink: #242318;
  --muted: #68644a;
  --accent: #d34f35;
  --accent-soft: #f4be32;
  --line: rgba(36, 35, 24, 0.2);
  --card: rgba(255, 254, 239, 0.86);
}

html[data-site="solresol"] {
  --paper: #eef2fb;
  --paper-deep: #d8e2f7;
  --ink: #18294e;
  --muted: #5d6780;
  --accent: #3159a6;
  --accent-soft: #f0c84b;
  --line: rgba(24, 41, 78, 0.2);
  --card: rgba(252, 253, 255, 0.86);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.6;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 14% 7%, color-mix(in srgb, var(--accent-soft) 24%, transparent) 0 8rem, transparent 8.1rem),
    linear-gradient(115deg, transparent 0 78%, color-mix(in srgb, var(--paper-deep) 60%, transparent) 78% 100%),
    var(--paper);
}

body::before {
  background-image: repeating-linear-gradient(0deg, rgba(60, 45, 20, 0.025) 0 1px, transparent 1px 4px);
  content: "";
  inset: 0;
  pointer-events: none;
  position: fixed;
  z-index: -1;
}

a {
  color: var(--ink);
  text-decoration-color: color-mix(in srgb, var(--accent) 65%, transparent);
  text-decoration-thickness: 0.09em;
  text-underline-offset: 0.18em;
}

a:hover {
  color: var(--accent);
}

.skip-link {
  background: var(--ink);
  color: var(--paper);
  left: 1rem;
  padding: 0.55rem 0.8rem;
  position: fixed;
  top: -5rem;
  z-index: 20;
}

.skip-link:focus {
  top: 1rem;
}

.site-header {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr auto 1fr;
  margin: 0 auto;
  max-width: 1180px;
  padding: 1rem 2rem;
}

.site-header nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.site-header nav a {
  border-radius: 999px;
  padding: 0.3rem 0.7rem;
  text-decoration: none;
}

.site-header nav a[aria-current="page"] {
  background: var(--ink);
  color: var(--paper);
}

.garden-mark {
  font-family: var(--serif);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-decoration: none;
}

.garden-mark:first-letter {
  color: var(--accent);
}

.utility-nav {
  justify-self: end;
  font-size: 0.83rem;
}

main {
  margin: 0 auto;
  max-width: 1050px;
  padding: 0 2rem 5rem;
}

.word-hero,
.simple-hero {
  padding: clamp(4rem, 10vw, 8rem) 0 clamp(3rem, 7vw, 5rem);
}

.word-hero {
  min-height: 70vh;
  position: relative;
}

.word-hero::after {
  color: color-mix(in srgb, var(--accent) 13%, transparent);
  content: "*";
  font-family: var(--serif);
  font-size: clamp(15rem, 40vw, 31rem);
  line-height: 0.8;
  pointer-events: none;
  position: absolute;
  right: -0.02em;
  top: 0.12em;
  z-index: -1;
}

html[data-site="esperanto"] .word-hero::after {
  content: "★";
  font-size: clamp(10rem, 25vw, 21rem);
  top: 0.5em;
}

html[data-site="toki"] .word-hero::after {
  content: "☀";
  font-size: clamp(10rem, 25vw, 21rem);
  top: 0.45em;
}

html[data-site="solresol"] .word-hero::after {
  content: "♪";
  font-family: var(--sans);
  font-size: clamp(11rem, 30vw, 24rem);
  top: 0.3em;
}

.eyebrow {
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  margin: 0 0 0.5rem;
  text-transform: uppercase;
}

.cadence-title {
  font-family: var(--serif);
  font-size: clamp(1.4rem, 3vw, 2.3rem);
  margin: 0.6rem 0 1.2rem;
}

.cadence-swap {
  display: inline-flex;
  gap: 0.38em;
}

.cadence-swap s {
  color: var(--muted);
  text-decoration-color: var(--accent);
  text-decoration-thickness: 0.11em;
}

.cadence-swap ins {
  color: var(--accent);
  font-family: var(--sans);
  font-size: 0.55em;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-decoration: none;
  text-transform: uppercase;
  transform: rotate(-4deg) translateY(-0.1em);
}

h1,
h2,
h3,
blockquote {
  font-family: var(--serif);
  text-wrap: balance;
}

.word-hero h1 {
  font-size: clamp(4.8rem, 16vw, 11.5rem);
  font-weight: 500;
  letter-spacing: -0.055em;
  line-height: 0.78;
  margin: 0 0 1.6rem;
  max-width: 9ch;
}

.pronunciation {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  margin: 0 0 1.4rem;
}

.meaning-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.meaning-chips li {
  background: var(--ink);
  border-radius: 999px;
  color: var(--paper);
  font-size: 0.82rem;
  font-weight: 700;
  padding: 0.35rem 0.75rem;
}

.lede {
  font-family: var(--serif);
  font-size: clamp(1.3rem, 3vw, 2rem);
  line-height: 1.35;
  margin: 2.4rem 0 0;
  max-width: 28em;
}

.section-block {
  border-top: 1px solid var(--line);
  padding: clamp(3rem, 7vw, 5rem) 0;
}

.section-heading {
  display: grid;
  gap: 0 2rem;
  grid-template-columns: minmax(8rem, 0.35fr) 1fr;
  margin-bottom: 2rem;
}

.section-heading h2 {
  font-size: clamp(2rem, 5vw, 3.8rem);
  font-weight: 500;
  line-height: 1;
  margin: 0;
}

.lineage figure {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 1rem;
  box-shadow: var(--shadow);
  margin: 0;
  overflow-x: auto;
  padding: 1rem;
}

.lineage figure img {
  display: block;
  height: auto;
  margin: 0 auto;
  max-height: 35rem;
  min-width: min(42rem, 100%);
  width: 100%;
}

figcaption {
  color: var(--muted);
  font-size: 0.78rem;
  padding: 0.7rem 0.5rem 0;
}

.descendant-cards {
  display: grid;
  gap: 0.7rem;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  list-style: none;
  margin: 1.5rem 0 0;
  padding: 0;
}

.descendant-cards li {
  border-left: 3px solid var(--accent);
  padding: 0.4rem 0.8rem;
}

.descendant-cards span,
.descendant-cards small,
.descendant-cards strong {
  display: block;
}

.descendant-cards span,
.descendant-cards small {
  color: var(--muted);
  font-size: 0.72rem;
}

.descendant-cards strong {
  font-family: var(--serif);
  font-size: 1.45rem;
}

.kerfuffle {
  background: color-mix(in srgb, var(--accent-soft) 30%, var(--card));
  border: 1px solid var(--line);
  border-radius: 1rem;
  margin-top: 2rem;
  padding: clamp(1.2rem, 3vw, 2rem);
}

.kerfuffle h3 {
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  font-weight: 500;
  margin: 0 0 0.8rem;
}

.kerfuffle > p:last-child {
  margin-bottom: 0;
  max-width: 55rem;
}

.kerfuffle-pair {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  font-family: var(--serif);
  font-size: 1.3rem;
  gap: 0.8rem;
  margin: 0.6rem 0;
}

.kerfuffle-pair span {
  color: var(--accent);
}

.origin-route {
  align-items: center;
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr auto 1fr;
  margin: 1.5rem 0;
}

.origin-route > span:not(.route-arrow) {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 1rem;
  box-shadow: var(--shadow);
  padding: clamp(1.2rem, 4vw, 2.5rem);
  text-align: center;
}

.origin-route small,
.origin-route strong {
  display: block;
}

.origin-route small {
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
}

.origin-route strong {
  font-family: var(--serif);
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 1.1;
}

.route-arrow {
  color: var(--accent);
  font-size: 2.5rem;
}

.comparison-list {
  color: var(--muted);
  columns: 2;
}

.note-sequence {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  list-style: none;
  margin: 1.5rem 0;
  padding: 0;
}

.note {
  background: var(--note-colour);
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 1rem;
  box-shadow: var(--shadow);
  color: white;
  display: grid;
  min-width: 7rem;
  padding: 1rem 1.2rem;
  text-align: center;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.28);
}

.note span {
  font-family: var(--serif);
  font-size: 2rem;
  line-height: 1;
}

.note small {
  font-size: 0.7rem;
  margin-top: 0.45rem;
  text-transform: uppercase;
}

.note-do { --note-colour: #ce3f46; }
.note-re { --note-colour: #d86b28; }
.note-mi { --note-colour: #e2b923; color: #2d2a14; text-shadow: none; }
.note-fa { --note-colour: #388452; }
.note-sol { --note-colour: #3269b3; }
.note-la { --note-colour: #4e4a91; }
.note-si { --note-colour: #79428d; }

.play-word {
  margin: 0 0 1.4rem;
}

.play-word:disabled {
  cursor: wait;
  opacity: 0.72;
}

.note.is-playing {
  box-shadow: 0 0 0 4px var(--paper), 0 0 0 7px var(--accent);
}

.music-score {
  background: rgba(255, 255, 255, 0.58);
  border: 1px solid var(--line);
  border-radius: 1rem;
  margin: 0 0 1.4rem;
  max-width: 50rem;
  overflow-x: auto;
  padding: 0.8rem 1rem 0.6rem;
}

.music-score svg {
  display: block;
  height: auto;
  width: 100%;
}

.music-score figcaption {
  color: var(--muted);
  font-size: 0.75rem;
  text-align: right;
}

.staff-lines line,
.music-note line {
  stroke: var(--ink);
  stroke-linecap: round;
  stroke-width: 1.8;
}

.treble-clef {
  fill: var(--ink);
  font-family: "Bravura Text", "Noto Music", "Apple Symbols", serif;
  font-size: 74px;
}

.music-note ellipse {
  fill: var(--ink);
}

.music-note text {
  fill: var(--muted);
  font: 700 10px/1 var(--sans);
  text-anchor: middle;
}

.music-note.is-playing ellipse {
  fill: var(--accent);
}

.music-note.is-playing .note-stem,
.music-note.is-playing .ledger-line {
  stroke: var(--accent);
  stroke-width: 2.8;
}

.notation-hat {
  background: color-mix(in srgb, var(--paper-deep) 58%, white);
  border: 1px dashed var(--accent);
  border-radius: 1rem;
  margin: 0 0 1.5rem;
  max-width: 50rem;
  padding: 1.15rem;
}

.notation-hat-heading {
  align-items: center;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
}

.notation-hat h3,
.notation-hat p {
  margin: 0;
}

.notation-hat h3 {
  font-family: var(--serif);
  font-size: clamp(1.4rem, 4vw, 2rem);
  font-weight: 500;
  line-height: 1.1;
}

.shuffle-notation {
  background: transparent;
  color: var(--ink);
  flex: 0 0 auto;
}

.notation-display {
  align-items: center;
  display: flex;
  min-height: 6.6rem;
}

.alt-notation small,
.alt-notation strong {
  display: block;
}

.alt-notation small {
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.alt-notation strong {
  font-family: var(--serif);
  font-size: clamp(2.2rem, 8vw, 4.5rem);
  font-weight: 500;
  letter-spacing: 0.04em;
  line-height: 1;
}

.notation-lights {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin-top: 0.65rem;
}

.notation-light {
  background: var(--note-colour);
  border: 2px solid rgba(0, 0, 0, 0.16);
  border-radius: 50%;
  box-shadow: inset 0 0 0 0.23rem rgba(255, 255, 255, 0.25), 0 0.25rem 0.8rem rgba(0, 0, 0, 0.12);
  display: inline-block;
  height: 2.9rem;
  width: 2.9rem;
}

.notation-source {
  color: var(--muted);
  font-size: 0.74rem;
}

.solresol-spelling > p:not(.caveat) {
  font-family: var(--serif);
  font-size: 1.2rem;
  max-width: 48rem;
}

.sentence blockquote {
  font-size: clamp(2.2rem, 7vw, 5.5rem);
  line-height: 1.05;
  margin: 2rem 0 1rem;
}

.word-gloss {
  border-top: 1px dashed var(--line);
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.82rem;
  max-width: 55rem;
  padding-top: 0.7rem;
}

.translation {
  font-family: var(--serif);
  font-size: 1.35rem;
}

.caveat {
  color: var(--muted);
  font-size: 0.82rem;
  max-width: 50rem;
}

.weather {
  align-items: center;
  background: var(--ink);
  border-radius: 0.8rem;
  color: var(--paper);
  display: flex;
  gap: 1.3rem;
  margin: 1rem 0 3rem;
  padding: 1.1rem 1.4rem;
}

.weather > span {
  color: var(--accent-soft);
  font-size: 2.4rem;
}

.weather p {
  margin: 0;
}

.weather .eyebrow {
  color: var(--accent-soft);
}

.sources > p,
.sources > ul {
  margin-left: calc(35% + 1.3rem);
}

.sources li {
  margin-bottom: 0.45rem;
}

.end-nav {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 1.2rem;
  padding-bottom: 3rem;
}

.button,
button {
  background: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 999px;
  color: var(--paper);
  cursor: pointer;
  display: inline-block;
  font: 700 0.9rem/1 var(--sans);
  padding: 0.8rem 1.1rem;
  text-decoration: none;
}

.button:hover,
button:hover {
  background: var(--accent);
  color: white;
}

.simple-hero h1 {
  font-size: clamp(3.2rem, 10vw, 7rem);
  font-weight: 500;
  letter-spacing: -0.04em;
  line-height: 0.95;
  margin: 0.3rem 0 1rem;
}

.simple-hero > p:last-child {
  font-family: var(--serif);
  font-size: 1.4rem;
  max-width: 40rem;
}

.archive-list {
  border-top: 1px solid var(--line);
  list-style: none;
  margin: 0 0 5rem;
  padding: 0;
}

.archive-list a {
  align-items: baseline;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  padding: 1.1rem 0;
  text-decoration: none;
}

.archive-list span {
  font-family: var(--serif);
  font-size: 1.6rem;
}

.archive-list small {
  color: var(--muted);
  text-align: right;
}

.prose {
  font-family: var(--serif);
  font-size: 1.15rem;
  margin: 0 auto 5rem;
  max-width: 43rem;
}

.prose h2 {
  font-size: 2rem;
  margin-top: 2.5rem;
}

footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.8rem;
  margin: 0 auto;
  max-width: 1180px;
  padding: 2rem;
}

footer p {
  margin: 0.3rem 0;
}

.rootle-intro {
  padding-bottom: 2rem;
}

.game {
  margin: 0 auto 5rem;
  max-width: 35rem;
}

.rootle-intro {
  padding: 3rem 0 1.5rem;
}

.game-meta,
.game-actions {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin: 0.7rem 0;
}

.game-meta span {
  color: var(--muted);
  font-size: 0.8rem;
}

.game-meta button,
.game-actions button {
  background: transparent;
  color: var(--ink);
  padding: 0.55rem 0.8rem;
}

.hint {
  background: var(--card);
  border-left: 3px solid var(--accent);
  margin: 1rem 0;
  padding: 0.8rem 1rem;
}

.board {
  display: grid;
  gap: 0.4rem;
  grid-template-columns: repeat(var(--word-length, 5), minmax(2.5rem, 1fr));
  margin: 1.5rem auto;
  max-width: calc(var(--word-length, 5) * 4.3rem);
}

.tile {
  align-items: center;
  aspect-ratio: 1;
  background: color-mix(in srgb, var(--card) 55%, transparent);
  border: 2px solid var(--line);
  display: flex;
  font-size: clamp(1.3rem, 5vw, 2rem);
  font-weight: 800;
  justify-content: center;
  text-transform: uppercase;
}

.tile.filled {
  border-color: var(--muted);
}

.tile.correct,
.key.correct {
  background: #3d8057;
  border-color: #3d8057;
  color: white;
}

.tile.present,
.key.present {
  background: #b98a26;
  border-color: #b98a26;
  color: white;
}

.tile.absent,
.key.absent {
  background: #686b66;
  border-color: #686b66;
  color: white;
}

.keyboard {
  display: grid;
  gap: 0.35rem;
  margin-top: 1.4rem;
}

.keyboard-row {
  display: flex;
  gap: 0.3rem;
  justify-content: center;
}

.key {
  background: color-mix(in srgb, var(--paper-deep) 70%, white);
  border: 0;
  border-radius: 0.25rem;
  color: var(--ink);
  flex: 1;
  font-size: clamp(0.68rem, 2.3vw, 0.86rem);
  height: 3.2rem;
  max-width: 2.8rem;
  min-width: 1.35rem;
  padding: 0;
}

.key.wide {
  flex: 1.5;
  max-width: 4.4rem;
}

.piano {
  display: flex;
  height: 11rem;
  position: relative;
  border: 6px solid #182033;
  border-radius: 0.5rem;
  background: #182033;
}

.piano .piano-key {
  align-items: flex-end;
  background: linear-gradient(#eee, #fff 65%);
  border: 1px solid #7b8290;
  border-radius: 0 0 0.25rem 0.25rem;
  box-shadow: inset 0 -5px 0 #cbd0da;
  color: #18294e;
  display: flex;
  font-size: clamp(0.85rem, 3vw, 1.1rem);
  height: 100%;
  justify-content: center;
  max-width: none;
  min-width: 0;
  padding-bottom: 1rem;
}

.piano .piano-key.correct { background: #3d8057; color: white; }
.piano .piano-key.present { background: #b98a26; color: white; }
.piano .piano-key.absent { background: #686b66; color: white; }
.piano .piano-key.pressed,
.piano .piano-key:active { box-shadow: inset 0 4px 12px #18203388; transform: translateY(2px); }
.piano .piano-key:focus-visible { outline: 3px solid var(--accent); outline-offset: -5px; }

.piano-black-key {
  background: linear-gradient(90deg, #111827, #343c4b, #111827);
  border: 1px solid #080e18;
  border-radius: 0 0 0.25rem 0.25rem;
  box-shadow: 0 4px 3px #0006;
  height: 58%;
  pointer-events: none;
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  width: 8%;
}

.piano-controls { justify-content: space-between; margin-top: 0.5rem; }
.piano-controls .key.wide { max-width: 9rem; }
.guess-meanings { padding-left: 1.5rem; }
.guess-meanings li { margin: 0.4rem 0; }

html[data-site="solresol"] .tile { text-transform: none; font-size: 1.3rem; }

.game-status {
  font-weight: 700;
  min-height: 1.6em;
  text-align: center;
}

.game details {
  border-top: 1px solid var(--line);
  margin-top: 2rem;
  padding-top: 1rem;
}

.game summary {
  cursor: pointer;
  font-weight: 700;
}

.visually-hidden {
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  height: 1px;
  overflow: hidden;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

@media (max-width: 760px) {
  .site-header {
    grid-template-columns: 1fr;
    padding: 0.8rem 1rem;
  }

  .site-header > nav:first-of-type {
    gap: 0.1rem;
    justify-content: center;
    justify-self: stretch;
  }

  .site-header > nav:first-of-type a {
    font-size: 0.87rem;
    padding-left: 0.45rem;
    padding-right: 0.45rem;
  }

  .garden-mark,
  .site-header .utility-nav {
    display: none;
  }

  main {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .word-hero {
    min-height: auto;
    padding-top: 4rem;
  }

  .word-hero h1 {
    font-size: clamp(4rem, 19vw, 7rem);
  }

  .section-heading {
    display: block;
  }

  .section-heading .eyebrow {
    margin-bottom: 0.7rem;
  }

  .sources > p,
  .sources > ul {
    margin-left: 0;
  }

  .origin-route {
    grid-template-columns: 1fr;
  }

  .route-arrow {
    line-height: 0.8;
    text-align: center;
    transform: rotate(90deg);
  }

  .comparison-list {
    columns: 1;
  }

  .note {
    min-width: 5.6rem;
    padding: 0.8rem;
  }

  .notation-hat-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .archive-list a {
    align-items: flex-start;
    flex-direction: column;
    gap: 0;
  }

  .archive-list small {
    text-align: left;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .tile.correct,
  .tile.present,
  .tile.absent {
    animation: reveal 260ms ease-out;
  }

  @keyframes reveal {
    0% { transform: rotateX(0); }
    50% { transform: rotateX(90deg); }
    100% { transform: rotateX(0); }
  }
}
