:root {
  color-scheme:light;
  --paper:#f8f4eb;
  --ink:#243e3a;
  --green:#276858;
  --muted:#63736b;
  --orange:#bd5837;
  font-family:ui-rounded,"Avenir Next",system-ui,sans-serif;
  color:var(--ink);
  background:var(--paper);
  font-synthesis:none;
}
* {
  box-sizing:border-box;
}
body {
  margin:0;
  background-image:radial-gradient(#d9d7c8 .8px,transparent .8px);
  background-size:22px 22px;
  min-height:100dvh;
}
button,a {
  -webkit-tap-highlight-color:transparent;
  touch-action:manipulation;
}
button {
  font:inherit;
  cursor:pointer;
}
a {
  color:inherit;
}
button:focus-visible,a:focus-visible {
  outline:4px solid var(--orange);
  outline-offset:5px;
}
button:disabled {
  cursor:default;
}
button[hidden],[hidden] {
  display:none!important;
}
.shell {
  max-width:1000px;
  margin:auto;
  padding:32px 28px 24px;
}
.back {
  display:inline-flex;
  align-items:center;
  min-height:48px;
  text-decoration:none;
  font-weight:650;
  font-size:.95rem;
}
.eyebrow {
  font-size:.75rem;
  font-weight:800;
  text-transform:uppercase;
  letter-spacing:.17em;
  color:var(--green);
  margin:40px 0 16px;
}
h1 {
  font-size:clamp(3rem,8vw,5.8rem);
  letter-spacing:-.065em;
  line-height:1.04;
  margin:0;
  font-weight:800;
}
.menu h1 {
  font-size:clamp(2.1rem,8vw,5.8rem);
}
h1 span {
  color:var(--orange);
}
.intro {
  font-size:1.1rem;
  color:var(--muted);
  line-height:1.6;
  margin:20px 0 30px;
}
.games {
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(260px,360px));
  gap:24px;
  margin-top:38px;
}
.game-tile {
  --pebble-bg:#e3eddf;
  --pebble-ink:#276858;
  --pebble-edge:#b9ccb2;
  background:#fffdf8;
  border:1px solid #dcdccd;
  border-radius:26px;
  overflow:hidden;
  text-decoration:none;
  box-shadow:0 5px 0 #e4e2d7;
  transition:transform .2s;
}
@media(hover:hover) {
  .game-tile:hover {
    transform:translateY(-4px);
  }
}
.reading-tile,.counting-tile {
  --pebble-bg:#f4dfc9;
  --pebble-ink:#984327;
  --pebble-edge:#ddbaa0;
}
.light-tile {
  --pebble-bg:#e8e3f0;
  --pebble-ink:#514368;
  --pebble-edge:#c6bad8;
}
.river-tile {
  --pebble-bg:#d7ecf5;
  --pebble-ink:#28646f;
  --pebble-edge:#a7ccdc;
}
.preview {
  height:185px;
  background:#e3eddf;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:25px;
}
.mini-card {
  display:grid;
  place-items:center;
  background:var(--green);
  color:#d0e5bd;
  width:90px;
  height:110px;
  border:5px solid #fffdf8;
  border-radius:15px;
  font-size:3.7rem;
  font-weight:800;
  transform:rotate(-12deg);
  box-shadow:0 5px 10px #243e3a18;
}
.mini-card.face {
  background:#fff2d7;
  color:var(--orange);
  transform:rotate(7deg);
  margin-left:-12px;
}
.mini-card:last-child {
  transform:rotate(18deg);
}
.tile-content {
  padding:25px;
}
.tag {
  font-size:.7rem;
  text-transform:uppercase;
  letter-spacing:.1em;
  color:var(--green);
  font-weight:800;
}
h2 {
  font-size:1.8rem;
  letter-spacing:-.04em;
  margin:12px 0;
}
.tile-content p {
  color:var(--muted);
  line-height:1.5;
}
.play-label {
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-height:48px;
  min-width:88px;
  padding:10px 24px;
  margin-top:24px;
  border:1px solid var(--pebble-edge);
  border-radius:48% 52% 46% 54% / 50% 46% 54% 50%;
  background:var(--pebble-bg);
  color:var(--pebble-ink);
  box-shadow:0 3px 0 var(--pebble-edge);
  font-weight:750;
  transition:transform .15s,box-shadow .15s;
}
.game-tile:active .play-label {
  transform:translateY(3px);
  box-shadow:0 0 0 var(--pebble-edge);
}
.footer-note {
  text-align:center;
  color:var(--muted);
  font-size:.8rem;
  margin:45px 0 12px;
}
.menu .footer-note {
  text-align:left;
}
.memory {
  max-width:850px;
}
.toolbar {
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px;
}
.quiet {
  border:1px solid #d0d5c9;
  border-radius:30px;
  background:var(--paper);
  padding:12px 17px;
  min-height:48px;
  font-weight:650;
  color:var(--ink);
}
.quiet:disabled {
  opacity:.45;
}
.game-header {
  text-align:center;
}
.game-header .eyebrow {
  margin-top:30px;
}
.game-header h1 {
  font-size:clamp(2.8rem,7vw,4.6rem);
}
.game-header .intro {
  margin:14px 0 26px;
}
.progress {
  display:flex;
  flex-wrap:wrap;
  justify-content:space-between;
  align-items:center;
  gap:14px;
  margin:0 auto;
  max-width:620px;
}
.progress ol {
  display:flex;
  gap:8px;
  list-style:none;
  padding:0;
  margin:0;
}
.progress li {
  width:34px;
  height:34px;
  display:grid;
  place-items:center;
  border-radius:50%;
  border:1px solid #bccaba;
  font-weight:700;
  color:var(--muted);
}
.progress li[aria-current] {
  background:var(--green);
  border-color:var(--green);
  color:white;
}
.progress li.done {
  background:#dce8d7;
  color:var(--green);
}
.progress p {
  font-size:.9rem;
  color:var(--muted);
}
.status {
  text-align:center;
  color:var(--green);
  font-weight:650;
  min-height:1.5em;
  margin:12px 0 18px;
}
.board {
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:14px;
  max-width:620px;
  margin:auto;
}
.board[data-pairs="6"],
.board[data-pairs="7"],
.board[data-pairs="8"],
.board[data-pairs="4"] {
  grid-template-columns:repeat(4,minmax(0,1fr));
}
.board[data-pairs="5"] {
  grid-template-columns:repeat(5,minmax(0,1fr));
}
.card {
  aspect-ratio:1/1.06;
  min-width:0;
  border:4px solid #fffdf8;
  border-radius:19px;
  box-shadow:0 4px 0 #bccdbd;
  background:var(--green);
  color:#d5e8bf;
  font-size:clamp(2rem,7vw,4rem);
  font-weight:750;
  display:grid;
  place-items:center;
  padding:12%;
  transition:transform .16s,background .16s,box-shadow .16s;
}
.card:not(:disabled):hover {
  transform:translateY(-3px);
}
.card.revealed {
  background:#fffdf8;
  box-shadow:0 4px 0 #dedbcd;
}
.card.matched {
  background:#e5efdc;
  border-color:#d1e2c5;
  box-shadow:0 3px 0 #b7cfac;
}
.card svg {
  width:100%;
  height:100%;
  overflow:visible;
}
.result {
  text-align:center;
  border-radius:22px;
  background:#e5efdc;
  padding:24px;
  margin:28px auto 0;
  max-width:620px;
}
.result h2 {
  margin-top:0;
}
.result p {
  color:var(--muted);
}
.primary {
  background:var(--green);
  color:white;
  border:0;
  border-radius:30px;
  padding:15px 28px;
  min-height:50px;
  font-weight:750;
}
.primary:hover {
  background:#1f5548;
}
@media(max-width:550px) {
  .shell {
    padding:18px 16px;
  }
  .toolbar {
    font-size:.8rem;
  }
  .quiet {
    padding:10px 12px;
    font-size:.8rem;
  }
  .board {
    gap:10px;
  }
  .board[data-pairs="5"] {
    grid-template-columns:repeat(3,minmax(0,1fr));
  }
  .board[data-pairs="6"],
.board[data-pairs="7"],
.board[data-pairs="8"],
.board[data-pairs="4"] {
    grid-template-columns:repeat(4,minmax(0,1fr));
  }
  .card {
    border-width:3px;
    border-radius:14px;
  }
  .game-header .eyebrow {
    margin-top:24px;
  }
  .footer-note {
    margin-top:28px;
  }
  .progress {
    gap:8px;
  }
}
@media(prefers-reduced-motion:reduce) {
  *,*::before,*::after {
    transition:none!important;
    animation:none!important;
  }
}
.reading-preview {
  background:#f4dfc9;
}
.illustrated-preview {
  padding:0;
}
.illustrated-preview img {
  display:block;
  width:100%;
  height:100%;
  object-fit:cover;
}
.reading {
  max-width:900px;
}
.reading-options {
  display:flex;
  justify-content:space-between;
  align-items:end;
  gap:18px;
  margin:30px 0 20px;
}
.reading-options label {
  display:block;
  font-size:.85rem;
  font-weight:750;
  margin-bottom:8px;
}
.reading-options select {
  font:inherit;
  min-height:48px;
  padding:12px 38px 12px 14px;
  border:1px solid #c9cebf;
  border-radius:12px;
  background:#fffdf8;
  color:var(--ink);
  max-width:100%;
}
.reading-options select:focus-visible {
  outline:3px solid var(--orange);
  outline-offset:3px;
}
.poem {
  background:#fffdf8;
  border:1px solid #dedbce;
  box-shadow:0 5px 0 #e7e3d8;
  border-radius:24px;
  padding:36px clamp(20px,5vw,50px);
}
.poem-heading {
  border-bottom:1px solid #e6e2d7;
  padding-bottom:18px;
  margin-bottom:24px;
}
.poem-heading h2 {
  font-size:2rem;
  margin:12px 0 8px;
}
.poem-heading p {
  color:var(--muted);
  font-size:.8rem;
  margin:0;
}
#poem-body {
  white-space:pre-wrap;
  font-size:1.4rem;
  line-height:1.95;
  letter-spacing:.025em;
  overflow-wrap:break-word;
}
.large-text #poem-body {
  font-size:1.8rem;
}
.timer-panel {
  text-align:center;
  background:#e5efdc;
  padding:25px 20px;
  border-radius:24px;
  margin:26px 0;
}
.timer-panel h2 {
  font-size:1.3rem;
  margin:0;
}
.timer-panel p {
  color:var(--muted);
  line-height:1.5;
  font-size:.9rem;
}
.timer-panel output {
  display:block;
  font-size:clamp(3rem,10vw,4.5rem);
  font-variant-numeric:tabular-nums;
  font-weight:750;
  letter-spacing:.03em;
  margin:14px 0;
}
.timer-actions {
  display:flex;
  justify-content:center;
  gap:12px;
  flex-wrap:wrap;
}
.timer-panel #reading-status {
  min-height:1.5em;
  margin:20px 0 0;
  color:var(--green);
  font-weight:650;
}
.history {
  margin:40px 0;
}
.history h2 {
  font-size:1.5rem;
}
.history-note,#empty-history {
  color:var(--muted);
  font-size:.9rem;
}
.history ol {
  list-style:none;
  margin:22px 0;
  padding:0;
}
.history li {
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:16px;
  padding:18px 0;
  border-bottom:1px solid #dedbce;
}
.history time {
  display:block;
  font-size:.8rem;
  color:var(--muted);
  margin-top:6px;
}
.history-duration {
  font-variant-numeric:tabular-nums;
  font-size:1.3rem;
  font-weight:750;
  white-space:nowrap;
}
#storage-warning {
  padding:14px;
  background:#f4dfc9;
  border-radius:12px;
  line-height:1.5;
}
@media(max-width:550px) {
  .reading-options {
    align-items:stretch;
    flex-direction:column;
    gap:12px;
  }
  .reading-options select {
    width:100%;
  }
  .reading-options .quiet {
    align-self:flex-start;
  }
  #poem-body {
    font-size:1.15rem;
  }
  .large-text #poem-body {
    font-size:1.45rem;
  }
  .poem-heading h2 {
    font-size:1.6rem;
  }
  .poem {
    padding:25px 20px;
  }
}

/* Keep the compact reading action anchored to the visible viewport. */
.reading {
  padding-bottom:calc(100px + env(safe-area-inset-bottom, 0px));
}
.reading-controls {
  position:fixed;
  top:var(--controls-top, auto);
  bottom:var(--controls-bottom, 0);
  left:var(--controls-left, 0);
  width:var(--controls-width, 100%);
  transform:var(--controls-transform, none);
  z-index:10;
  display:flex;
  justify-content:center;
  padding:12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  pointer-events:none;
}
.reading-controls .primary {
  min-width:144px;
  max-width:100%;
  pointer-events:auto;
  box-shadow:0 3px 12px #243e3a26;
}
#poem {
  scroll-margin-top:16px;
}
#reading-status {
  color:var(--green);
  text-align:center;
}
.toolbar {
  flex-wrap:wrap;
}
#share-status {
  color:var(--green);
  overflow-wrap:anywhere;
}
#share-status input {
  display:block;
  width:100%;
  min-height:48px;
  margin-top:8px;
  font:inherit;
}

.reading-clock {
  text-align:center;
  color:var(--muted);
  margin:24px 0 12px;
}
.reading-clock output {
  display:inline-block;
  color:var(--green);
  font-variant-numeric:tabular-nums;
  font-weight:750;
  min-width:5.5em;
}

/* The welcome artwork is scoped to the selection page. */
.menu .welcome {
  display:grid;
  grid-template-columns:minmax(0,340px) minmax(0,1fr);
  align-items:center;
  gap:40px;
  margin:24px 0;
}
.menu .welcome-brand { margin:0; line-height:0; }
.welcome-brand img { display:block; width:100%; height:auto; }
.welcome-copy .eyebrow { margin:0 0 16px; }
.welcome-copy h2 { font-size:clamp(1.6rem,3vw,2.3rem); margin:0; }
.welcome-copy .intro { margin:16px 0 24px; }
.welcome-link { display:inline-flex; align-items:center; gap:18px; text-decoration:none; }
.menu #games { scroll-margin-top:20px; }
@media(max-width:650px) {
  .menu .welcome { grid-template-columns:minmax(0,1fr); gap:12px; margin:12px 0 24px; text-align:center; }
  .menu .welcome-brand { width:min(260px,100%); margin:auto; }
  .welcome-copy .eyebrow,.welcome-link { display:none; }
  .welcome-copy .intro { margin:8px 0 0; font-size:.95rem; }
  .menu .games { margin-top:24px; }
}
