:root { color-scheme: dark; --bg: #20212b; --text: #eeedf2; --muted: #aaa9bb; --blue: #9ebfce; --yellow: #d8c58e; --red: #d49f99; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", sans-serif; touch-action: manipulation; }
button, a { touch-action: manipulation; }
button { font: inherit; cursor: pointer; }
#app { width: min(100%, 580px); margin: auto; padding: max(16px, env(safe-area-inset-top)) 14px max(20px, env(safe-area-inset-bottom)); text-align: center; }
header { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
.header-left { display: flex; align-items: center; gap: 2px; }
.title { display: flex; align-items: baseline; gap: 6px; }
#version { font-size: 10px; color: var(--muted); }
header a { color: var(--muted); text-decoration: none; font-size: 28px; padding: 4px 6px; }
h1 { margin: 0; font: 24px Georgia, serif; letter-spacing: .09em; }
h1 small { display: block; margin-top: 5px; font: 10px sans-serif; color: var(--muted); letter-spacing: .25em; }
#ranking, #restart { border: 0; background: none; color: var(--muted); font-size: 11px; padding: 12px 2px; min-height: 44px; }
.scores { display: flex; justify-content: center; gap: 36px; margin: 16px 0 12px; color: var(--muted); font-size: 11px; letter-spacing: .06em; }
.scores strong { display: block; font-size: 27px; line-height: 1.3; color: var(--text); font-variant-numeric: tabular-nums; }
#best { color: #edda96; }
#forecast { display: grid; place-items: center; height: 78px; margin-top: 18px; position: relative; z-index: 3; pointer-events: none; }
.preview { width: 64px; height: 64px; }
.preview .seed { display: block; width: 64px; height: 64px; filter: drop-shadow(0 1px 0 #ffffff22); }
#board { display: grid; grid-template-columns: repeat(var(--size, 4), 1fr); gap: 0; width: min(100%, 52dvh, 440px); position: relative; isolation: isolate; margin: auto; }
.soil { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.soil path { stroke: var(--bg); stroke-width: 7px; stroke-linejoin: round; }
.land-0 { fill: var(--blue); }
.land-1 { fill: var(--yellow); }
.land-2 { fill: var(--red); }
.soil-fading { animation: land-change var(--grow-ms) ease-in-out forwards; }
.tile { display: grid; place-items: center; position: relative; min-width: 0; padding: 0; aspect-ratio: 1; border: 0; border-radius: 12px; background: transparent; user-select: none; }
.tile:disabled { opacity: 1; cursor: default; }
.tile:focus-visible, button:focus-visible, a:focus-visible { outline: 3px solid white; outline-offset: 2px; z-index: 1; }
.seed { width: 65%; height: 65%; overflow: visible; pointer-events: none; }
.planted .seed { animation: plant 160ms ease-out; }
.growing .seed { animation: sprout var(--grow-ms) ease forwards; }
@keyframes plant { from { transform: translateY(-7px) scale(.7); opacity: .2; } to { transform: none; opacity: 1; } }
@keyframes land-change { 0%, 15% { opacity: 1; } 100% { opacity: 0; } }
@keyframes sprout { 35% { transform: translateY(-3px) scale(1.16); opacity: 1; } to { transform: translateY(-9px) scale(.4); opacity: 0; } }
#status { min-height: 24px; margin-top: 14px; color: #edda96; font-size: 15px; }
#again { background: #edda96; border: 0; border-radius: 30px; color: #30291d; padding: 10px 28px; margin: 8px; }
@media (max-width: 360px) { #app { padding-inline: 10px; } }
@media (prefers-reduced-motion: reduce) { .planted .seed, .growing .seed, .soil-fading { animation: none; } }

#restart { justify-self: end; }
#ranking-dialog { width: min(320px, calc(100% - 32px)); max-height: calc(100dvh - 40px); padding: 24px; border: 1px solid #565765; border-radius: 18px; color: var(--text); background: var(--bg); text-align: center; }
#ranking-dialog::backdrop { background: #0009; }
#ranking-dialog h2 { margin: 0 0 18px; font-size: 18px; font-weight: 500; }
#ranking-list { margin: 0; padding-left: 32px; text-align: left; }
#ranking-list li { padding: 7px 0 7px 8px; color: var(--muted); }
#ranking-list strong { color: #edda96; font-size: 24px; font-variant-numeric: tabular-nums; }
#ranking-list span { margin-left: 12px; font-size: 11px; }
#ranking-empty { color: var(--muted); font-size: 13px; }
#ranking-dialog hr { margin: 20px 0; border: 0; border-top: 1px solid #565765; }
.legacy-record { display: grid; gap: 8px; font-size: 12px; color: var(--muted); }
#legacy-best { color: var(--text); font-size: 22px; font-variant-numeric: tabular-nums; }
#storage-note { font-size: 12px; color: var(--muted); }
#ranking-close { margin-top: 20px; padding: 10px 22px; min-height: 44px; background: #edda96; color: #30291d; border: 0; border-radius: 24px; }
