:root {
  color-scheme: light;
  --paper: #f6f3e9;
  --ink: #21473e;
  --muted: #687970;
  --teal: #174e46;
  --gold: #b68b48;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  background: var(--paper);
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); min-height: 100vh; }
#penrose { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 0; pointer-events: none; }
.site-header, .game-layout, .site-footer { position: relative; z-index: 1; }
button { font: inherit; -webkit-tap-highlight-color: transparent; }
button:focus-visible { outline: 3px solid #c59139; outline-offset: 4px; }
[hidden] { display: none !important; }
.svg-definitions { position: absolute; width: 0; height: 0; overflow: hidden; }
.site-header { max-width: 1180px; margin: auto; padding: 24px 36px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #234c3d20; }
.brand { display: inline-flex; align-items: center; gap: 10px; font: bold 21px Georgia, serif; letter-spacing: 2px; }
.brand svg { width: 40px; height: 40px; color: var(--gold); }
.brand { color: inherit; text-decoration: none; }
.home-link { display: inline-flex; align-items: center; min-height: 44px; color: var(--ink); font-size: 12px; text-decoration: none; }
.home-link:hover { text-decoration: underline; }
a:focus-visible { outline: 3px solid #c59139; outline-offset: 4px; border-radius: 4px; }
.header-note { font-size: 12px; color: var(--muted); letter-spacing: .5px; }
.game-layout { max-width: 1100px; margin: 24px auto 18px; padding: 0 32px; display: grid; grid-template-columns: 290px minmax(0, 1fr); gap: 60px; align-items: center; }
.eyebrow { font-size: 10px; font-weight: 700; letter-spacing: 2px; margin: 0; }
.introduction > .eyebrow { color: #89662d; }
h1 { margin: 18px 0; font: normal clamp(50px, 6vw, 76px)/.97 Georgia, "Times New Roman", serif; letter-spacing: -3px; }
h1 span { color: var(--gold); }
.intro-copy { color: var(--muted); font-size: 16px; line-height: 1.7; margin: 24px 0; }
.instructions { padding: 0; margin: 30px 0 0; list-style: none; counter-reset: step; }
.instructions li { counter-increment: step; position: relative; padding-left: 34px; margin: 20px 0; font-size: 13px; line-height: 1.7; color: var(--muted); }
.instructions li::before { content: "0" counter(step); position: absolute; top: 1px; left: 0; font-size: 10px; font-weight: 700; letter-spacing: 1px; color: #946e32; }
.instructions span { display: block; color: var(--ink); font-size: 14px; font-weight: 600; }
.botanical-note { display: flex; align-items: center; margin: 16px 0 0 -12px; }
.botanical-note img { width: 110px; height: 120px; object-fit: contain; transform: rotate(-12deg); }
.botanical-note span { font: italic 13px/1.7 Georgia, serif; color: #758272; }
.game-panel { min-width: 0; padding: 24px; background: #fffdf7cc; border: 1px solid #fff; border-radius: 24px; box-shadow: 0 12px 45px #354c3510; }
.game-toolbar { display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap; }
.score-box .eyebrow { color: var(--muted); font-size: 9px; }
.two-player-score { display: flex; align-items: stretch; gap: 8px; flex-wrap: wrap; }
.player-score, .target-score { min-width: 72px; padding: 8px 10px; border: 1px solid #d6c9a980; border-radius: 14px; background: #fffaf0a8; }
.player-score.is-active { border-color: var(--teal); box-shadow: 0 0 0 2px #174e4620 inset; background: #eef6ef; }
.player-score p, .target-score p { margin: 4px 0 0; }
.player-score strong { font: normal 28px/1 Georgia, serif; }
.target-score span { font-size: 13px; color: var(--muted); }
.turn-note { margin: 10px 0 0; color: var(--teal); font-size: 13px; font-weight: 700; }
.score-box p { margin: 5px 0 0; }
.score-box strong { font: normal 30px/1 Georgia, serif; }
.score-box p span { font-size: 13px; color: var(--muted); }
.category-control, .timer-control, .preview-control, .size-control { display: grid; gap: 5px; min-width: 150px; }
.category-control { min-width: 190px; }
.category-control .eyebrow, .timer-control .eyebrow, .preview-control .eyebrow, .size-control .eyebrow { color: var(--muted); font-size: 9px; }
.category-control select, .timer-control select, .preview-control select, .size-control select { min-height: 44px; border: 1px solid #d6c9a9; border-radius: 999px; background-color: #fffaf0; color: var(--ink); padding: 0 96px 0 18px; font: 600 13px/1 "Avenir Next", "Segoe UI", sans-serif; cursor: pointer; appearance: none; -webkit-appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink) 50%), linear-gradient(135deg, var(--ink) 50%, transparent 50%); background-position: calc(100% - 45px) 50%, calc(100% - 36px) 50%; background-size: 9px 9px, 9px 9px; background-repeat: no-repeat; }
.category-control select:focus-visible, .timer-control select:focus-visible, .preview-control select:focus-visible, .size-control select:focus-visible { outline: 3px solid #c59139; outline-offset: 3px; }
.category-note, .timer-note, .preview-note, .size-note { margin: 7px 0 0; color: var(--muted); font-size: 11px; }
.timer-note, .preview-note, .size-note { margin-top: 4px; }
.game-timer { flex: 0 0 auto; min-width: 54px; height: 30px; display: grid; place-content: center; border-radius: 999px; background: #174e46; color: #fffaf0; font-weight: 800; font-size: 12px; padding: 0 11px; letter-spacing: .3px; }
.game-timer.is-warning { background: #a94722; }

.primary-button { background: var(--teal); color: #fffaf0; border: 1px solid var(--teal); border-radius: 40px; padding: 12px 22px; min-height: 44px; font-size: 13px; font-weight: 600; cursor: pointer; transition: background .15s; }
.primary-button:hover { background: #286356; }
.primary-button:disabled { opacity: .6; cursor: wait; }
.status-bar { min-height: 56px; display: flex; align-items: center; gap: 12px; justify-content: space-between; }
#status { margin: 12px 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.countdown { flex: 0 0 30px; height: 30px; display: grid; place-content: center; border-radius: 50%; background: #eee5d0; color: #78551e; font-weight: 700; font-size: 12px; }
.board { display: grid; grid-template-columns: repeat(var(--board-size, 4), minmax(0, 1fr)); gap: clamp(5px, 1.1vw, 10px); }
.card { position: relative; padding: 0; width: 100%; aspect-ratio: 1; border: 0; border-radius: 10px; background: transparent; cursor: pointer; touch-action: manipulation; }
.card[aria-disabled="true"] { cursor: default; }
.card-face { position: absolute; inset: 0; border-radius: inherit; overflow: hidden; display: grid; place-items: center; }
.card-back { color: #cfb77a; background: linear-gradient(140deg, #235b50, #133f39); border: 1px solid #164a40; box-shadow: 0 3px 5px #163d3914; }
.card-back::before { content: ""; position: absolute; inset: 7px; border: 1px solid #d8bc743d; border-radius: 6px; }
.card-back::after { content: ""; position: absolute; inset: 12px; border: 1px solid #d8bc741a; border-radius: 3px; }
.card-back svg { width: 59%; height: 59%; opacity: .85; }
.card-front { display: none; background: #f5f0e3; border: 1px solid #ded8c6; }
.card-front img { display: block; width: 91%; height: 91%; object-fit: contain; pointer-events: none; }
body[data-category="butterflies"] .card-front img, body[data-category="fossils"] .card-front img, body[data-category="mushrooms"] .card-front img, body[data-category="gemstones"] .card-front img { width: 94%; height: 94%; }
.card.is-up .card-back { display: none; }
.card.is-up .card-front { display: grid; }
.card.is-matched .card-front { background: #eef3e8; border-color: #9fb59a; }
.card.is-matched::after { content: "✓"; position: absolute; top: 5px; right: 5px; width: 17px; height: 17px; display: grid; place-content: center; border-radius: 50%; background: #39614d; color: white; font-size: 10px; }
@media (hover: hover) { .card[aria-disabled="false"]:hover .card-back { background: #2b6558; } }
.board-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 15px; color: var(--muted); font-size: 10px; letter-spacing: .4px; }
.footer-flower { color: var(--gold); font-size: 19px; }
.site-footer { text-align: center; padding: 10px 24px 24px; color: var(--muted); font: italic 12px Georgia, serif; }
@media (min-width: 850px) {
  .game-panel { width: 100%; max-width: max(360px, calc(100svh - 320px)); justify-self: center; }
}
@media (min-width: 850px) and (max-height: 820px) {
  .site-header { padding-top: 12px; padding-bottom: 12px; }
  .game-layout { margin-top: 22px; max-width: 1000px; gap: 45px; }
  .card { aspect-ratio: 1 / 1.02; }
  .game-panel { padding: 20px; }
  .botanical-note { display: none; }
}
@media (max-width: 849px) {
  .site-header { padding: 15px 24px; }
  .game-layout { display: block; max-width: 650px; margin-top: 26px; padding: 0 20px; }
  .introduction { margin-bottom: 22px; text-align: center; }
  .introduction > .eyebrow { font-size: 9px; }
  h1 { font-size: 46px; letter-spacing: -2px; margin: 12px 0; }
  h1 br { display: none; }
  .intro-copy, .botanical-note { display: none; }
  .instructions { display: flex; gap: 14px; margin: 18px 0 0; }
  .instructions li { flex: 1; padding: 0; margin: 0; font-size: 11px; line-height: 1.6; }
  .instructions li::before { display: none; }
  .instructions span { font-size: 12px; margin-bottom: 3px; }
  .card { aspect-ratio: 1 / 1.05; }
}
@media (max-width: 620px) {
  .category-control, .timer-control, .preview-control, .size-control { order: 3; width: 100%; }
  .category-control select, .timer-control select, .preview-control select, .size-control select { width: 100%; }
}
@media (max-width: 450px) {
  .header-note { display: none; }
  .site-header { padding: 10px 20px; }
  .brand { font-size: 16px; }
  .brand svg { width: 30px; height: 30px; }
  .game-layout { margin-top: 20px; padding: 0 12px; }
  h1 { font-size: 40px; }
  .game-panel { padding: 14px; border-radius: 18px; }
  .board { gap: 7px; }
  .card { border-radius: 7px; aspect-ratio: 1 / 1.13; }
  .card-back::before { inset: 5px; }
  .card-back::after { inset: 8px; }
  .primary-button { padding: 11px 17px; }
  .status-bar { min-height: 53px; }
  .site-footer { padding-bottom: 18px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

.premium-access { position: relative; z-index: 1; max-width: 520px; margin: 48px auto; padding: 24px; background: #fffdf7; border-radius: 24px; }
.premium-access a { color: var(--teal); }
