:root {
  color-scheme: light;
  --paper: #fbf6e8;
  --ink: #253726;
  --muted: #4e6043;
  --pale: #fffdf5;
  --line: #ded8be;
  --green: #2f5031;
  font: 100%/1.5 ui-rounded, "Arial Rounded MT Bold", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100svh; }
button, input { font: inherit; }
button { color: inherit; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; }
a { color: var(--green); text-underline-offset: .17em; }
:focus-visible { outline: 3px solid #a13d20; outline-offset: 3px; }
.wrap { width: min(1080px, 100%); margin-inline: auto; padding-inline: max(24px, env(safe-area-inset-left)) max(24px, env(safe-area-inset-right)); }
.bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-block: max(20px, env(safe-area-inset-top)) 22px; }
.brand, .bar-actions { display: flex; align-items: center; gap: 12px; }
.brand { font-weight: 850; letter-spacing: -.04em; font-size: 1.4rem; }
.brand img { border-radius: 12px; flex: none; }
.network { font-size: .8rem; color: var(--muted); text-align: right; }
.network.ready::before { content: ""; display: inline-block; vertical-align: .12em; width: 7px; height: 7px; border-radius: 50%; background: #547748; margin-right: .4em; }
.pill, .primary {
  display: inline-flex; align-items: center; justify-content: center; gap: .65em; min-height: 46px;
  padding: .57em 1em; border-radius: 999px; font-size: .92rem; font-weight: 750;
  border: 1px solid #c6c9ae; background: var(--pale); transition: background .16s;
}
.pill:hover { background: #ecefd8; }
.primary { background: var(--green); border-color: var(--green); color: white; }
.primary:hover { background: #416342; }
.primary:disabled { opacity: .65; }
.lock-icon { position: relative; width: 14px; height: 10px; flex: none; margin-top: 5px; border: 1.6px solid currentColor; border-radius: 3px; }
.lock-icon::before { content: ""; position: absolute; left: 2px; right: 2px; bottom: 8px; height: 6px; border: 1.6px solid currentColor; border-bottom: 0; border-radius: 5px 5px 0 0; }
.hero { display: grid; grid-template-columns: 1fr 1.18fr; border-radius: 32px; overflow: hidden; background: #f8e4a3; box-shadow: 0 4px 0 #e8d69d; }
.hero-copy { display: grid; align-content: center; padding: clamp(24px, 5vw, 64px); }
h1, h2, h3, p { margin: 0; }
.hero h1 { font-size: clamp(3rem, 6.7vw, 6rem); letter-spacing: -.08em; line-height: .96; font-weight: 900; }
.hero h1 em { display: block; color: #526137; font-style: normal; }
.hero p { margin-top: 1.25rem; color: #445238; font-size: clamp(1rem, 2vw, 1.22rem); max-width: 29ch; }
.hero-art { display: block; width: 100%; height: 100%; min-height: 310px; max-height: 460px; object-fit: cover; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 26px; }
.choice {
  display: grid; grid-template-columns: 100px 1fr auto; align-items: center; gap: 18px; text-align: left;
  padding: 16px; border: 1px solid #d8d8b8; border-radius: 24px; background: #e9edd3;
  box-shadow: 0 3px 0 #d9dfbf; transition: transform .16s, box-shadow .16s;
}
.choice.pairs { background: #f8e3d4; border-color: #ecd1bb; box-shadow: 0 3px 0 #edceb5; }
.choice:hover { transform: translateY(-2px); }
.choice:active { transform: translateY(2px); box-shadow: none; }
.picture { position: relative; display: grid; place-items: center; aspect-ratio: 1; background: #f6f5e2; border-radius: 24px; }
.picture img { display: block; width: 86%; height: 86%; object-fit: contain; }
.stack { background: #f9f0dd; }
.stack img { width: 73%; height: 73%; background: #fffff4; border: 2px solid #dca985; border-radius: 14px; transform: rotate(9deg); box-shadow: -5px 4px #edbf9b; }
.choice-copy { display: grid; min-width: 0; }
.age { font-size: .77rem; font-weight: 780; color: #4d5d3d; }
.choice strong { font-size: clamp(1.3rem, 2.8vw, 1.9rem); letter-spacing: -.045em; line-height: 1.12; margin-block: .13em; }
.choice-copy > :last-child { font-size: .9rem; color: #47573c; }
.arrow { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: #fffaf0; font-size: 1.2rem; }
.footer { text-align: center; color: var(--muted); font-size: .8rem; padding-block: 25px max(16px, env(safe-area-inset-bottom)); }
.hold { position: relative; isolation: isolate; overflow: hidden; -webkit-touch-callout: none; user-select: none; touch-action: none; }
.hold::before { position: absolute; inset: 0; z-index: -1; content: ""; background: #dbe8b8; transform: scaleX(0); transform-origin: left; }
.hold.holding::before { transform: scaleX(1); transition: transform 2s linear; }
body.playing { background: #f3f0dd; }
.game { padding-bottom: max(16px, env(safe-area-inset-bottom)); text-align: center; }
.game-head { margin-bottom: clamp(12px, 3vh, 24px); }
.game-head h1 { font-size: clamp(2.1rem, 7vw, 4rem); font-weight: 880; line-height: 1.08; letter-spacing: -.06em; }
.game-head p { color: var(--muted); margin-top: 5px; }
.board { margin-inline: auto; display: grid; gap: clamp(9px, 2.1vw, 18px); }
.board.animals { max-width: 580px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.board.memory { max-width: 670px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.tile {
  position: relative; display: grid; place-items: center; min-width: 0; min-height: 52px; padding: 9%;
  aspect-ratio: 1.12; border: 2px solid #d4ceaa; background: #fff9e9; border-radius: clamp(15px, 4vw, 28px);
  box-shadow: 0 4px 0 #ddd5b0; transition: transform .16s, background .16s, border-color .16s;
}
.tile img { display: block; width: 100%; height: 100%; max-height: 175px; object-fit: contain; pointer-events: none; }
.tile:active { transform: translateY(3px); }
.animals .tile:nth-child(1) { background: #f9dec5; }
.animals .tile:nth-child(2) { background: #f9edbd; }
.animals .tile:nth-child(3) { background: #e7e3f2; }
.animals .tile:nth-child(4) { background: #e0eace; }
.animals .tile.tapped { border-color: var(--green); animation: hop .42s ease-out; }
@keyframes hop { 35% { transform: translateY(-6px) scale(1.035); } }
.memory .tile { aspect-ratio: 1; }
.memory .tile.covered { background: #dce7bc; border-color: #b4c798; box-shadow: 0 4px 0 #b4c798; color: #47643b; }
.memory .tile.covered i { display: grid; place-items: center; font: 850 clamp(1.5rem, 5vw, 3rem)/1 system-ui, sans-serif; font-style: normal; }
.memory .tile.matched { background: #eaf0d8; border-color: #789363; box-shadow: 0 4px 0 #c4d2a4; }
.matched::after { position: absolute; right: 6px; top: 2px; content: "✓"; font-weight: 900; color: #305830; }
.feedback { min-height: 1.5em; margin-block: 14px 8px; font-weight: 770; font-size: clamp(1rem, 3.8vw, 1.4rem); }
.replay { margin: 0 auto 12px; }
dialog { margin: auto; padding: 0; border: 1px solid var(--line); border-radius: 25px; color: var(--ink); background: var(--pale); width: min(100% - 28px, 490px); max-height: 90dvh; box-shadow: 0 18px 64px #18271a55; }
dialog::backdrop { background: #222e23a8; }
.sheet { padding: clamp(19px, 5vw, 30px); }
.sheet h2 { font-size: clamp(1.45rem, 6vw, 2rem); line-height: 1.15; letter-spacing: -.04em; }
.sheet h3 { margin-bottom: .25em; }
.sheet p { margin-block: .5em; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sheet label { display: block; font-weight: 720; margin-block: .7em .25em; }
.sheet input:not([type=checkbox]) { display: block; width: 100%; min-height: 48px; border: 1px solid #87967d; border-radius: 12px; background: #fff; padding: 8px 12px; color: var(--ink); font-size: 1.1rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.settings-part { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 13px; }
.pin-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.pin-fields > div { min-width: 0; }
.sheet .check, summary { min-height: 44px; display: flex; gap: 10px; align-items: center; cursor: pointer; font-weight: 720; margin: 0; }
.check input { width: 22px; height: 22px; accent-color: var(--green); }
summary::before { content: "›"; font-size: 1.5rem; line-height: 1; }
details[open] > summary::before { transform: rotate(90deg); }
.error { color: #9b2e1d; font-weight: 690; }
.settings-status { color: var(--green); }
@media (max-width: 690px) {
  .wrap { padding-inline: max(15px, env(safe-area-inset-left)) max(15px, env(safe-area-inset-right)); }
  .bar { padding-bottom: 13px; gap: 6px; }
  .hero { grid-template-columns: 1fr; border-radius: 24px; }
  .hero-copy { padding: 22px; }
  .hero h1 { font-size: clamp(2.6rem, 10vw, 4rem); }
  .hero h1 em { display: inline; }
  .hero p { margin-top: .65rem; }
  .hero-art { min-height: 0; height: auto; max-height: 285px; aspect-ratio: 1.95; object-position: 50% 25%; }
  .choices { grid-template-columns: 1fr; gap: 11px; margin-top: 19px; }
  .choice { grid-template-columns: 68px 1fr auto; padding: 10px 12px; gap: 12px; border-radius: 19px; }
  .picture { border-radius: 16px; }
}
@media (max-width: 390px) {
  .bar-actions, .brand { gap: 6px; }
  .brand { font-size: 1.2rem; }
  .brand img { width: 34px; height: 34px; }
  .network { max-width: 11ch; font-size: .73rem; }
  .bar .pill { padding-inline: .65em; }
}
@media (orientation: landscape) and (max-height: 560px) {
  .bar { padding-block: max(4px, env(safe-area-inset-top)) 9px; }
  .board.animals, .board.memory { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .board.memory { max-width: min(560px, calc((100dvh - 145px) * 1.9)); }
  .game-head { margin-bottom: 9px; }
  .game-head h1 { font-size: 2rem; }
  .feedback { margin-block: 8px 4px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
