:root {
  color-scheme: dark;
  color: #f4f4dc;
  background: #13251e;
  font-family: system-ui, "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  font-synthesis: none;
  --panel: #20382d;
  --soil: #152d23;
  --slot: #294438;
  --lime: #d3ea91;
  --muted: #bbceb6;
  --tray-tile: clamp(10px, 3.32vw, 18px);
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 280px; padding: max(10px, env(safe-area-inset-top)) clamp(10px, 3vw, 28px) max(12px, env(safe-area-inset-bottom)); -webkit-tap-highlight-color: transparent; }
a, button { font: inherit; color: inherit; }
button:not(:disabled) { cursor: pointer; }
a:focus-visible, button:focus-visible { outline: 3px solid #eae89e; outline-offset: 3px; }
.garden { max-width: 830px; margin: 0 auto; }
.masthead, .tools { display: flex; align-items: center; justify-content: space-between; gap: 7px; }
.masthead { margin-bottom: 9px; }
.back { display: inline-flex; align-items: center; min-height: 42px; gap: 7px; color: #dbe8ce; font-size: .86rem; font-weight: 710; white-space: nowrap; text-decoration: none; }
.back img { border-radius: 23%; }
.tool { min-height: 40px; padding: 5px 12px; border: 1px solid transparent; border-radius: 10px; background: #314a3c; color: #e8efd9; font-size: .85rem; font-weight: 720; line-height: 1.15; white-space: nowrap; touch-action: manipulation; }
.tool:hover:not(:disabled) { background: #3d5948; }
.tool:disabled { opacity: .55; }
.sound[aria-pressed="true"] { border-color: #9cbb75; color: #e5f1b5; }
.cover {
  position: relative;
  isolation: isolate;
  display: flex;
  align-items: flex-end;
  min-height: clamp(74px, 12vw, 120px);
  margin-bottom: 10px;
  padding: 12px clamp(13px, 3vw, 26px);
  border-radius: 18px;
  overflow: hidden;
  background: #35593a url("../../media/block-garden.webp") 54% 58% / cover no-repeat;
}
.cover::after { position: absolute; inset: 0; z-index: -1; background: linear-gradient(90deg,#10271aee,#17392365 55%,#17392319); content: ""; }
h1 { margin: 0; color: #fcf2d4; font-size: clamp(1.85rem, 5vw, 3.1rem); font-weight: 850; line-height: 1.06; letter-spacing: -.085em; }
.modes { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); padding: 4px; gap: 4px; margin-bottom: 11px; border-radius: 12px; background: #253d31; }
.modes button { min-height: 41px; border: 0; border-radius: 8px; padding: 4px; background: transparent; color: #cedcc4; font-size: .94rem; font-weight: 760; touch-action: manipulation; }
.modes button[aria-pressed="true"] { background: #d3ea91; color: #23391c; }
.game { display: grid; gap: 9px; border-radius: 19px; padding: clamp(9px, 2vw, 16px); background: var(--panel); }
.game[data-world="sunny"] { --panel: #413c29; --soil: #322e1d; --slot: #4c462c; --faint:#685638; }
.game[data-world="pond"] { --panel: #223c40; --soil: #162e36; --slot: #2b464e; --faint:#395a65; }
.game[data-world="moon"] { --panel: #343247; --soil: #25253a; --slot: #3b3951; --faint:#57526b; }
.world { display: flex; justify-content: space-between; align-items: center; min-height: 33px; gap: 8px; margin-bottom: 6px; color: #f6ebbb; }
.world strong { font-size: .9rem; letter-spacing: -.015em; }
.world .tool { min-height: 34px; }
.progress { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; margin: 0; text-align: center; }
.stat { min-width: 0; padding: 5px 2px 6px; border-radius: 9px; background: #ffffff0b; }
.stat dt { color: var(--muted); font-size: .73rem; font-weight: 690; }
.stat dd { margin: 2px 0 0; color: #f5efcd; font-size: clamp(.98rem, 3.7vw, 1.17rem); font-weight: 820; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.board-frame { position: relative; min-width: 0; width: 100%; padding: clamp(5px, 1.6vw, 11px); border-radius: 15px; background: var(--soil); border: 1px solid #ffffff14; }
.board { display: grid; gap: clamp(3px, .9vw, 6px); --side: 8; }
.board-row { display: grid; grid-template-columns: repeat(var(--side), minmax(0, 1fr)); gap: inherit; }
.cell { position: relative; display: block; width: 100%; min-width: 0; aspect-ratio: 1; padding: 0; border: 1px solid #ffffff0c; border-radius: clamp(5px, 1.6vw, 9px); background: var(--slot); touch-action: manipulation; }
.cell:focus-visible { z-index: 2; outline-offset: -2px; }
:where(.board-row:nth-child(even)) .cell:nth-child(odd),
:where(.board-row:nth-child(odd)) .cell:nth-child(even) { background: var(--faint, #304c3d); }
.cell::after, .unit::after { position: absolute; inset: 0; margin: auto; width: 33%; height: 30%; border-radius: 75% 25% 70% 25%; transform: rotate(-14deg); background: #fff5; content: ""; }
.cell::after { opacity: 0; }
.cell[data-tone]::after { opacity: 1; }
[data-tone="leaf"] { --tile: #a8d773; --tile-edge: #6f9e4b; }
[data-tone="sun"] { --tile: #ffd074; --tile-edge: #cb8c3b; }
[data-tone="berry"] { --tile: #f1a4ba; --tile-edge: #c5728c; }
[data-tone="sky"] { --tile: #8dcce3; --tile-edge: #5694ae; }
[data-tone="plum"] { --tile: #bea8e5; --tile-edge: #9078bd; }
[data-tone="peach"] { --tile: #f6a888; --tile-edge: #cc7958; }
[data-tone="bloom"] { --tile: #f9d15a; --tile-edge: #c88e32; }
.cell[data-tone], .unit { border: 1px solid var(--tile-edge); background: var(--tile); box-shadow: inset 0 2px 0 #fff7, inset 0 -3px 0 var(--tile-edge); }
.cell[data-tone="bloom"]::after {
  width: 61%; height: 61%; transform: none; background: #fff4bd; border-radius: 0;
  clip-path: polygon(50% 0%,61% 35%,98% 36%,69% 57%,79% 94%,50% 73%,21% 94%,31% 57%,2% 36%,39% 35%);
}
.cell.preview { background: #648b67; box-shadow: inset 0 0 0 1px #b7e5aa; }
.cell.hint-cell { border: 2px dashed #ffe699; background: #67794e; }
.cell.hint-cell::after { width: 15%; height: 15%; border-radius: 25%; background: #ffe699; opacity: 1; transform: rotate(45deg); }
.cell.preview-line { outline: 1px solid #c7dc9a; outline-offset: -2px; }
.message { min-height: 1.34em; margin: 0; align-self: center; text-align: center; color: #e5efcf; font-size: clamp(.84rem, 3.5vw, .98rem); font-weight: 730; line-height: 1.4; word-break: keep-all; }
.tray { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 5px; }
.piece { display: grid; position: relative; place-items: center; min-width: 0; min-height: calc(var(--tray-tile) * 5 + 11px); padding: 3px; border: 1px solid #ffffff0a; border-radius: 13px; background: #ffffff0a; touch-action: none; user-select: none; }
.piece:disabled { opacity: .53; }
.piece[aria-pressed="true"] { outline: 2px solid #a9cb79; outline-offset: -2px; background: #9baa641d; }
.game[data-mode="practice"] .tray { --tray-tile: clamp(23px, 6.7vw, 33px); }
.game[data-mode="practice"] .piece { min-height: calc(var(--tray-tile) * 2 + 14px); }
.shape { display: grid; grid-template-columns: repeat(var(--columns), var(--tray-tile)); grid-template-rows: repeat(var(--rows), var(--tray-tile)); gap: var(--shape-gap, 2px); pointer-events: none; }
.unit { position: relative; display: block; border-radius: clamp(3px, 1vw, 6px); }
.drag-piece { position: fixed; z-index: 5; pointer-events: none; filter: drop-shadow(0 4px 5px #07140c9c); }
.controls, .dialog-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.tool.hint { min-width: 69px; background: #c8e47e; color: #26391e; }
.tool.hint:hover:not(:disabled) { background: #d8ed9a; }
.tool.next { flex: 1 1 100%; order: -1; max-width: 235px; color: #3c3013; background: #ffdc89; }
.board-fx { position: absolute; z-index: 3; inset: 0; overflow: hidden; border-radius: inherit; pointer-events: none; }
.fx-tile, .fx-leaf { display: block; position: absolute; }
.fx-tile { border-radius: 20%; background: #fff0a8; animation: dissolve .62s ease-out forwards; }
.fx-leaf { z-index: 1; width: var(--size); height: var(--size); border-radius: 70% 18% 65% 22%; background: var(--tone); animation: shower .68s cubic-bezier(.14,.46,.44,1) forwards; }
.cell.placed { animation: settle .22s ease-out both; }
.board-frame.blocked { animation: missed .25s ease-out; }
@keyframes dissolve { from { opacity: .88; transform: scale(.96); } to { opacity: 0; transform: scale(.2) rotate(12deg); } }
@keyframes shower { from { opacity: 1; transform: scale(.72); } to { opacity: 0; transform: translate(var(--x),var(--y)) rotate(var(--rotate)) scale(.28); } }
@keyframes settle { 0% { scale: .87; } 63% { scale: 1.04; } 100% { scale: 1; } }
@keyframes missed { 33% { box-shadow: inset 0 0 0 2px #e6a785; } }
dialog { width: min(470px, calc(100% - 30px)); max-height: 82vh; padding: 18px; color: #f4f4dc; border: 1px solid #6e8765; border-radius: 17px; background: #233c32; }
dialog::backdrop { background: #07140dbb; }
dialog h2 { margin: 0; font-size: 1.25rem; }
dialog p { margin: 7px 0 17px; }
.map-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 9px; }
.stage-list details { border-radius: 10px; margin-bottom: 5px; padding: 7px; background: #304b3a; }
.stage-list summary { cursor: pointer; min-height: 32px; padding: 4px; font-weight: 760; }
.stage-grid { display: grid; grid-template-columns: repeat(6,minmax(0,1fr)); gap: 4px; margin-top: 5px; }
.stage-grid .tool { min-width: 0; padding: 3px; }
.stage-grid .tool[aria-current="step"] { color: #24381c; background: #c8e47e; }
@media (min-width: 700px) {
  .game { grid-template-columns: minmax(0, 1fr) 258px; grid-template-rows: auto auto 1fr auto; gap: 9px 15px; }
  .dashboard { grid-area: 1 / 2; }
  .board-frame { grid-area: 1 / 1 / 5 / 2; align-self: start; max-width: min(100%, calc(100svh - 231px)); justify-self: center; }
  .message { grid-area: 2 / 2; }
  .tray { grid-area: 3 / 2; grid-template-columns: 1fr; grid-template-rows: repeat(3,minmax(0,1fr)); --tray-tile: 15px; }
  .piece { min-height: 64px; }
  .controls { grid-area: 4 / 2; }
  .modes { max-width: none; }
}
@media (max-width: 699px) {
  .garden { max-width: 450px; }
  .board-frame { width: min(100%, max(235px, calc(100svh - 286px))); justify-self: center; }
  .tool, .modes button { min-height: 39px; }
}
@media (max-width: 390px) {
  .masthead { gap: 4px; }
  .tools { gap: 4px; }
  .back { font-size: .76rem; }
  .back img { width: 27px; height: 27px; }
  .tool { padding-inline: 8px; }
  .cover { min-height: 65px; }
  .modes, .cover { margin-bottom: 7px; }
  .game { gap: 6px; }
  .stat dt { font-size: .69rem; }
}
@media (prefers-reduced-motion: reduce) {
  .fx-tile, .fx-leaf, .cell.placed, .board-frame.blocked { animation: none; }
}

