:root {
  color-scheme: light;
  --ink: #2d4134;
  --muted: #657662;
  --green: #315d47;
  --green-deep: #244a37;
  --line: #d7dfd0;
  --paper: #f8f7ed;
  --serif: "Noto Serif SC", "Songti SC", "STSong", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  font-family: var(--sans);
  color: var(--ink);
  background: #e8eee2;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-tap-highlight-color: transparent;
}

* { box-sizing: border-box; }
html, body { width: 100%; min-width: 320px; height: 100%; margin: 0; }
body { min-height: 100svh; overflow: hidden; background: #e8eee2; }
button { color: inherit; font: inherit; }
button:disabled { cursor: default; }
[hidden] { display: none !important; }

.app-shell {
  position: relative;
  display: grid;
  grid-template-rows: 46px minmax(0, 1fr) auto;
  width: min(100%, 540px);
  height: 100dvh;
  min-height: 520px;
  margin-inline: auto;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  overflow: hidden;
  background-color: #dfe8d8;
  background-image:
    linear-gradient(180deg, #183c2e5c 0%, #183c2e36 13%, #edf1e2ad 23%, #edf1e2a2 70%, #e7eee14d 87%, #183f2e71 100%),
    url("assets/courtyard.webp");
  background-position: center, center;
  background-size: 100% 100%, auto 100%;
  box-shadow: 0 0 30px #34482c16;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
  padding: 0 14px;
  border-bottom: 1px solid #fff3;
  background: linear-gradient(180deg, #173d2eb0, #21473478);
}
.brand { display: flex; align-items: center; gap: 8px; min-width: 0; color: #fff9e8; font: 700 clamp(19px, 5vw, 24px)/1 var(--serif); letter-spacing: .04em; text-shadow: 0 1px 4px #102c20b3; }
.brand-mark { display: grid; place-items: center; width: 25px; height: 25px; border: 1px solid #c6d3bd; border-radius: 50%; color: #bb8f49; font: 17px/1 Georgia, serif; background: #f7f3df; }
.top-actions { display: flex; align-items: center; gap: 7px; }
.icon-button, .close-button {
  display: grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 50%;
  background: transparent;
  color: #49654d;
  cursor: pointer;
}
.icon-button:hover, .close-button:hover { border-color: #d7dfd0; background: #edf2e8; }
.icon-button [data-symbol] { width: 19px; height: 19px; }
.top-actions .icon-button [data-symbol] { filter: brightness(0) invert(1); opacity: .94; }
.icon-button img, .dock-button img, .actions [data-symbol] img { display: block; width: 100%; height: 100%; object-fit: contain; }
#sound[data-muted="true"] [data-symbol] { opacity: .64; }

.game-main {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  justify-items: center;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: clamp(8px, 1.6dvh, 15px) 10px;
  background: linear-gradient(180deg, #edf1e2a8 0%, #f2f0e3a0 50%, #e7eee1a1 100%);
  scrollbar-width: thin;
  scrollbar-color: #bdc9b8 transparent;
}
.play-card {
  container-type: inline-size;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: clamp(5px, 1.2dvh, 11px);
  width: 100%;
  max-width: 504px;
  min-height: 0;
}
.play-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 43px; padding: 0 3px; }
.level-heading { flex: 1; min-width: 0; }
.eyebrow { display: flex; align-items: center; gap: 6px; min-height: 17px; color: #3e5542; font: 700 14px/1.2 ui-monospace, "SFMono-Regular", Consolas, monospace; letter-spacing: .06em; }
.live-dot { width: 6px; height: 6px; border-radius: 50%; background: #7e9b69; box-shadow: 0 0 0 3px #dce7d3; }
.play-heading h1 { margin: 3px 0 0; color: #243e2d; font: 700 clamp(22px, 6.4vw, 32px)/1.48 var(--serif); letter-spacing: .015em; text-shadow: 0 1px 4px #fffc; overflow-wrap: anywhere; }
.flower-status { display: flex; align-items: center; gap: 7px; flex: none; min-width: 82px; padding: 5px 9px; border: 1px solid #d8e1d2; border-radius: 18px; background: #f1f5e9; color: #476149; }
.flower-status-flower { color: #b78342; font-size: 17px; line-height: 1; }
.flower-status > span:last-child { display: grid; gap: 2px; justify-items: start; }
.flower-status b { color: #314d37; font: 750 17px/1 ui-monospace, "SFMono-Regular", Consolas, monospace; }
.flower-status small { color: #495d48; font-size: 13px; font-weight: 600; line-height: 1.1; }

.plot {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
  place-self: center;
  height: 100%;
  max-height: 125cqw;
  width: auto;
  max-width: 100%;
  min-width: 0;
  min-height: 0;
  aspect-ratio: 6 / 7;
  margin: 0;
  padding: clamp(10px, 1.7dvh, 16px);
  overflow: visible;
  border: 1px solid #aebba4;
  border-radius: 17px;
  background-color: #dce4d5;
  background-image:
    linear-gradient(180deg, #f5f6e757 0%, #eef0e41c 36%, #d8e0ce26 100%),
    url("assets/courtyard-board.webp");
  background-position: center;
  background-size: cover;
  box-shadow: inset 0 0 0 4px #f8f5e9c9, 0 5px 14px #344a311e;
}
.plot::before { position: absolute; z-index: -1; inset: 6px; border: 1px solid #fff9; border-radius: 11px; content: ""; pointer-events: none; }
#board-wrap { position: relative; z-index: 1; align-self: center; width: 100%; min-width: 0; isolation: isolate; border-radius: 14px; }
#board {
  --cols: 3;
  --rows: 3;
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  gap: clamp(3px, 1.25vw, 6px);
  width: 100%;
  touch-action: none;
  user-select: none;
}
#flow { position: absolute; z-index: 8; inset: 0; width: 100%; height: 100%; pointer-events: none; }

.cell {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  width: 100%;
  aspect-ratio: 1;
  padding: 2px;
  border: 1px solid #9eae98;
  border-radius: clamp(7px, 2.3vw, 12px);
  background: linear-gradient(148deg, #fffef5f5 5%, #e8ebd7ed 100%);
  box-shadow: 0 2px 0 #82937b, 0 4px 7px #24372025;
  isolation: isolate;
  overflow: visible;
  text-align: center;
  touch-action: none;
  transition: transform .14s ease, box-shadow .14s ease, background .16s ease;
}
.cell[data-type="empty"]:not(.bloomed-plot) {
  border-color: #8f9b7db3;
  background: linear-gradient(145deg, #f1efd298, #cdd2b484);
  box-shadow: inset 0 1px 2px #fff9, 0 1px 2px #43564040;
}
.tile-icon { display: flex; align-items: center; justify-content: center; width: 83%; height: 65%; min-height: 0; pointer-events: none; }
.tile-icon img, .legend img, .help-rows i img { display: block; width: 100%; height: 100%; object-fit: contain; }
.tile-label { max-width: 100%; color: #405746; font-size: clamp(11px, 3.3vw, 16px); font-weight: 700; line-height: 1.1; letter-spacing: .02em; pointer-events: none; }
.cell:has(.under) .tile-icon { width: 74%; height: 54%; margin-top: 5px; }
.cell.return-channel .tile-label { font-size: clamp(10px, 2.8vw, 14px); white-space: nowrap; }
.cell .under { position: absolute; z-index: 4; top: 2px; right: 2px; display: grid; place-items: center; min-width: 27px; min-height: 16px; max-width: calc(100% - 3px); padding: 2px 3px; overflow: hidden; border: 1px solid #a9bca5; border-radius: 6px; background: #f5fff0; box-shadow: 0 1px 3px #233b2933; color: #274b35; font-size: clamp(7px, 2vw, 9px); font-weight: 750; line-height: 1; letter-spacing: -.04em; white-space: nowrap; }
.cell .under img { width: 11px; height: 11px; object-fit: contain; }
.cell .under[data-type="K"] { min-width: 30px; padding-inline: 2px; letter-spacing: 0; }
.cell.selected { z-index: 6; outline: 3px solid #41917c; outline-offset: 0; box-shadow: 0 0 0 4px #dff2d6a8, 0 4px 9px #163c2c4a; }
.cell.suggested { z-index: 5; outline: 3px dashed #bd8732; outline-offset: 1px; }
.cell.blocked { outline: 2px dashed #ba694d; outline-offset: -2px; background-color: #fbe8d2; }
.cell.return-channel { border: 2px solid #4b8d76; box-shadow: inset 0 0 0 2px #e1f0dc, 0 2px 0 #39745f, 0 4px 7px #21483330; }
.cell.bloomed-plot { border-color: #c8b778; background: radial-gradient(ellipse at 50% 72%, #f5edc9 0, #ece9d2 50%, #e3e8d6 100%); box-shadow: inset 0 0 0 2px #fff9, 0 2px 4px #4d593223; }
.cell.bloomed-plot::after { position: absolute; z-index: 3; top: 3px; right: 3px; display: grid; place-items: center; width: 14px; height: 14px; border: 1px solid #b6b98d; border-radius: 50%; background: #fbf8e7; color: #50663c; content: "✓"; font: 700 9px/1 var(--sans); }
.cell.bloomed-plot .tile-label { display: none; }
.planted-bloom { display: grid; place-items: center; width: 74%; height: 74%; }
.planted-bloom img { display: block; max-width: 100%; max-height: 100%; object-fit: contain; }
.cell.first-source-guide, .cell.revealed-source-guide { z-index: 7; outline: 3px solid #d39a37; outline-offset: 2px; box-shadow: 0 0 0 6px #fff3c789, 0 4px 10px #513c1340; animation: spring-pulse 1.6s ease-in-out infinite; }
.cell.first-source-guide::before, .cell.revealed-source-guide::before, .cell.coach-next::before { position: absolute; z-index: 10; top: -25px; left: 50%; padding: 4px 7px; transform: translateX(-50%); border: 1px solid #a16c28; border-radius: 999px; background: #fff5d6; box-shadow: 0 2px 5px #2a321e35; color: #503d21; content: "从这里开始"; font: 700 12px/1.1 var(--sans); white-space: nowrap; pointer-events: none; }
.cell.revealed-source-guide::before { content: "新泉眼"; }
.cell.coach-next { z-index: 8; outline: 3px dashed #d39a37; outline-offset: 2px; }
.cell.coach-next::before { content: attr(data-coach); }
.cell.first-source-guide.coach-next::before { content: attr(data-coach); }
.cell.wish-target { outline: 2px solid #ce9b49; outline-offset: 2px; }
.wish-target-mark { position: absolute; z-index: 6; top: -7px; left: -7px; display: grid; place-items: center; width: 19px; height: 19px; border: 1px solid #a7712c; border-radius: 50%; background: #fff1c7; box-shadow: 0 1px 4px #30281555; color: #67431c; font: 800 10px/1 var(--sans); }
@keyframes spring-pulse { 50% { box-shadow: 0 0 0 8px #fff0c876, 0 4px 10px #513c1340; } }
@media (hover: hover) { .cell:not([data-type="empty"]):hover { transform: translateY(-1px); filter: brightness(1.025); } }

.wish-panel:not([hidden]) { display: grid; grid-template-columns: minmax(0, 1fr); gap: 3px; min-height: 44px; padding: 5px 9px; border: 1px solid #d8cfab; border-radius: 11px; background: #fff8e7ee; box-shadow: 0 2px 6px #62543612; }
.wish-goal-row, .wish-order-row { display: flex; align-items: center; gap: 7px; min-width: 0; }
.wish-kicker { flex: none; min-width: 32px; color: #725021; font-size: 13px; font-weight: 800; letter-spacing: .07em; }
#wish-goal { min-width: 0; margin: 0; color: #4c533d; font-size: 15px; font-weight: 650; line-height: 1.25; }
#wish-order { display: flex; align-items: center; gap: 4px; min-width: 0; margin: 0; padding: 0; list-style: none; }
.wish-flower { display: inline-flex; align-items: center; justify-content: center; min-width: 40px; min-height: 22px; padding: 1px 5px; border: 1px solid #e2dac5; border-radius: 999px; background: #f3f0e7; color: #999582; font-size: 13px; line-height: 1; white-space: nowrap; }
.wish-flower.pending { border-style: dashed; background: #fffdf6; color: #766c56; }
.wish-flower.opened { border-color: #dfbd7a; background: #fff0c9; color: #785127; font-weight: 750; }

.message { display: flex; align-items: center; justify-content: center; gap: 7px; min-height: 38px; margin: 0; padding: 5px 10px; border-radius: 9px; background: #fffbedee; color: #304735; font-size: clamp(15px, 4.1vw, 18px); font-weight: 600; line-height: 1.4; text-align: center; }
.message-mark { flex: none; color: #b78b43; font: 17px/1 Georgia, serif; }
.play-card:has(.first-source-guide) .message, .play-card:has(.revealed-source-guide) .message { background: #fff8df; }
.play-card:has(#board-wrap.won) .message { color: #365e43; font-weight: 650; }
.actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; padding-top: 2px; }
.actions button, .primary, .next, .rest {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 0;
  min-height: 46px;
  padding: 7px 8px;
  border: 1px solid #d4dccd;
  border-radius: 10px;
  background: #fafbf4;
  box-shadow: 0 2px 0 #e2e6da;
  color: #4b5d48;
  cursor: pointer;
  font-size: clamp(15px, 4.1vw, 18px);
  font-weight: 700;
  line-height: 1.1;
  text-align: center;
  transition: transform .12s, background .15s, box-shadow .15s;
  touch-action: manipulation;
}
.actions [data-symbol] { width: 17px; height: 17px; flex: none; }
.actions .primary, .primary { border-color: #2f6149; background: linear-gradient(145deg, #3c7757, #2b5b43); box-shadow: 0 2px 0 #1d4935; color: #fffef2; }
.actions .next, .next { border-color: #805926; background: linear-gradient(145deg, #a2763e, #79542d); box-shadow: 0 2px 0 #644220; color: #fffaf0; }
.actions .rest, .rest { border-color: #2f6149; background: linear-gradient(145deg, #3c7757, #2b5b43); box-shadow: 0 2px 0 #1d4935; color: #fffef2; }
.actions button:active, .primary:active { transform: translateY(1px); box-shadow: none; }
.actions button:disabled { opacity: 1; border-color: #cfd6c8; background: #e5e8dc; color: #5b6756; box-shadow: none; }
.actions:has(#next:not([hidden])) { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
.actions:has(#next:not([hidden])) #next { grid-row: 1; grid-column: 1 / span 3; min-height: 43px; }
.actions:has(#next:not([hidden])) #rest { grid-row: 1; grid-column: 4 / span 3; min-height: 43px; }
.actions:has(#next:not([hidden])) #hint { grid-row: 2; grid-column: 1 / span 2; min-height: 37px; }
.actions:has(#next:not([hidden])) #undo { grid-row: 2; grid-column: 3 / span 2; min-height: 37px; }
.actions:has(#next:not([hidden])) #reset { grid-row: 2; grid-column: 5 / span 2; min-height: 37px; }

.app-dock {
  position: relative;
  z-index: 3;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: center;
  min-height: 54px;
  padding: 4px 14px max(4px, env(safe-area-inset-bottom));
  border-top: 1px solid #fff3;
  background: linear-gradient(0deg, #163c2fea, #284a35d9);
  box-shadow: 0 -4px 12px #203e2e17;
}
.dock-button { display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 4px 7px; border: 1px solid transparent; border-radius: 12px; background: #ffffff12; color: #fffbed; cursor: pointer; text-shadow: 0 1px 3px #142d23a8; touch-action: manipulation; }
.dock-button [data-symbol] { display: block; width: 18px; height: 18px; flex: none; }
.dock-button [data-symbol] { filter: brightness(0) invert(1); opacity: .93; }
.dock-button b { font-size: clamp(15px, 4vw, 18px); font-weight: 700; white-space: nowrap; }
.dock-button:hover:not(:disabled) { border-color: #ffffff55; background: #ffffff25; }
.dock-button:disabled { color: #f3f0df; }
.side-entry:disabled b::after { display: block; content: "2关后开放"; margin-top: 2px; color: #f5e4bb; font-size: 12px; font-weight: 500; }

.sr { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }

dialog {
  position: fixed;
  inset: auto 8px max(8px, env(safe-area-inset-bottom));
  width: min(480px, calc(100vw - 16px));
  max-width: min(480px, calc(100vw - 16px));
  max-height: min(86dvh, 760px);
  margin: 0 auto;
  padding: 16px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid #bac7b2;
  border-radius: 20px 20px 16px 16px;
  background: linear-gradient(160deg, #fcfbf4, #f0f2e8);
  box-shadow: 0 16px 70px #18312658;
  color: var(--ink);
  scrollbar-width: thin;
  scrollbar-color: #bdc9b8 transparent;
}
dialog::backdrop { background: #18372db4; backdrop-filter: blur(3px); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: -2px 0 12px; padding-bottom: 10px; border-bottom: 1px solid #dce3d6; }
.modal-head h2 { margin: 0; color: #36543e; font: 700 22px/1.2 var(--serif); }
.close-button { width: 40px; height: 40px; border-color: #dce2d5; background: #eff2e8; font-size: 24px; line-height: 1; }
.map-group { margin: 0 0 12px; }
.map-group h3, .challenge-stamps h3, .side-stamps-heading h3, .stamp-heading h3 { margin: 0; color: #3c5944; font: 700 14px/1.3 var(--serif); }
.map-group > h3 { margin-bottom: 7px; }
.map-group p { margin: 5px 0 7px; color: #697563; font-size: 14px; }
#level-list, #side-list, #wish-list { display: grid; gap: 6px; }
#level-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
#side-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
#wish-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.level-option { display: flex; align-items: center; gap: 5px; min-width: 0; min-height: 44px; padding: 6px 7px; border: 1px solid var(--line); border-radius: 9px; background: #fffdf5; color: #435541; cursor: pointer; text-align: left; }
.level-option:disabled { opacity: .55; cursor: default; }
.level-option.current, .level-option.is-current { border-color: #a8bd9e; background: #e8f0e1; }
.level-option.passed { border-color: #ddc58e; background: #fff3d6; }
.level-number { flex: none; color: #75826e; font: 650 12px/1 ui-monospace, "SFMono-Regular", Consolas, monospace; }
.level-name { min-width: 0; overflow: hidden; font-size: 14px; font-weight: 700; line-height: 1.2; text-overflow: ellipsis; }
.level-state { margin-left: auto; color: #596751; font-size: 12px; line-height: 1.1; white-space: nowrap; }
.side-map-group { padding-top: 9px; border-top: 1px solid #dce3d6; }
.map-group-heading { display: flex; align-items: center; justify-content: space-between; gap: 9px; margin-bottom: 7px; }
.wish-entry { display: inline-flex; align-items: center; gap: 5px; min-height: 34px; padding: 5px 10px; border: 1px solid #cbb98b; border-radius: 999px; background: #fff5d8; color: #76582b; cursor: pointer; font-size: 14px; font-weight: 750; }
.wish-entry:disabled { border-color: #dedac9; background: #f2f0e6; color: #8b8a7d; cursor: default; }
#wish-list .level-option { display: grid; grid-template-columns: 1fr; justify-items: center; align-content: center; gap: 3px; min-height: 59px; padding: 5px 3px; text-align: center; }
#wish-list .level-name { width: 100%; text-overflow: clip; white-space: normal; }
#wish-list .level-state { margin: 0; font-size: 12px; }
#side-list .level-option { display: grid; grid-template-columns: auto 1fr; justify-items: start; align-content: center; gap: 3px 4px; min-height: 52px; padding: 5px; }
#side-list .level-name { grid-column: 1 / -1; width: 100%; white-space: normal; }
#side-list .level-state { grid-column: 1 / -1; margin: 0; }

.journal { overflow: hidden; margin-bottom: 13px; border: 1px solid #d5ddce; border-radius: 14px; background: #fffef8; box-shadow: 0 3px 12px #42503c07; }
.journal-top { display: flex; align-items: center; gap: 8px; padding: 10px 13px 8px; }
.journal-top h2 { margin: 0; color: #385642; font: 700 17px/1.2 var(--serif); }
.journal-icon { display: block; width: 17px; height: 17px; }
.journal-icon img { display: block; width: 100%; height: 100%; }
.bloom-art { position: relative; height: 112px; margin: 0 10px; overflow: hidden; border: 1px solid #e5d8b8; border-radius: 10px; background: #f1e5c7; }
.bloom-art img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: 72% 46%; }
.bloom-art figcaption { position: absolute; bottom: 7px; left: 8px; display: grid; gap: 2px; padding: 4px 8px; border: 1px solid #e9d7ad; border-radius: 6px; background: #fff6dded; box-shadow: 0 1px 5px #48381e20; color: #584e38; }
.bloom-art figcaption span { font-size: 8px; letter-spacing: .08em; }
.bloom-art figcaption strong { font: 700 16px/1.1 var(--serif); }
.bloom-art.is-variety { background: radial-gradient(ellipse at 48% 55%, #fffdf2 0, #f3ead4 72%, #eadfc6 100%); }
.bloom-art.is-variety img { object-fit: contain; padding: 3px; background: linear-gradient(145deg, #fbf8ec, #efe6d1); }
.bloom-art.is-variety figcaption { right: 7px; bottom: 7px; left: auto; background: #fff9e9ed; }
.journal-bottom { padding: 10px 13px 12px; }
.collection-line { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: #52644f; font-size: 14px; }
.collection-line b { font: 700 12px/1 ui-monospace, "SFMono-Regular", Consolas, monospace; }
.progress { height: 5px; margin: 7px 0 10px; overflow: hidden; border-radius: 8px; background: #e5e8d9; }
.progress i { display: block; width: 0; height: 100%; border-radius: inherit; background: #7a9363; transition: width .35s ease; }
.stats { display: grid; grid-template-columns: 1fr 1fr; padding-top: 8px; border-top: 1px solid #e2e5d7; }
.stats > div { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.stats > div + div { padding-left: 14px; border-left: 1px solid #e1e4d6; }
.stats span { color: #5e715b; font-size: 13px; }
.stats strong { font: 700 17px/1.2 Georgia, serif; }
#flower-marks { display: flex; gap: 2px; }
.flower-mark { display: grid; place-items: center; width: 21px; height: 21px; }
.flower-mark img { max-width: 20px; max-height: 20px; }
.is-closed { filter: grayscale(1); opacity: .52; }
.stamp-section, .challenge-stamps, .wish-stamps-section, .side-stamps-section { margin-top: 12px; padding-top: 10px; border-top: 1px solid #dce3d6; }
.stamp-heading, .side-stamps-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.stamp-heading span, .side-stamps-heading span { color: #637453; font: 600 10px/1 ui-monospace, Consolas, monospace; }
.book-note { margin: 5px 0 8px; color: #697563; font-size: 14px; line-height: 1.45; }
#stamps, #wish-stamps, #side-stamps { display: grid; margin: 0; padding: 0; list-style: none; }
#stamps { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; }
#stamps li, #wish-stamps li { display: grid; justify-items: center; align-content: center; gap: 4px; min-height: 72px; padding: 6px 2px; border: 1px dashed #c5c9b6; border-radius: 10px; background: #efeee3; color: #636b5f; text-align: center; }
#stamps li.earned, #wish-stamps li.earned { border-style: solid; border-color: #d9c095; background: #fff2d8; color: #77532b; }
#stamps i, #wish-stamps i { display: block; width: 27px; height: 27px; filter: grayscale(1); opacity: .36; }
#stamps .earned i, #wish-stamps .earned i { filter: none; opacity: 1; }
#stamps img, #wish-stamps img { display: block; width: 100%; height: 100%; object-fit: contain; }
#stamps b, #wish-stamps b { font: 700 14px/1.2 var(--serif); }
#stamps small, #wish-stamps small { color: inherit; font-size: 12px; line-height: 1.15; }
.challenge-stamps h3 { margin-bottom: 6px; }
.challenge-stamps p { margin: 5px 0; padding: 7px 9px; border: 1px solid #d8dccb; border-radius: 8px; background: #f0f0e4; color: #5a684f; font-size: 14px; line-height: 1.4; }
.challenge-stamps p.earned { border-color: #d7bb86; background: #fff2d8; color: #805b2e; font-weight: 700; }
#wish-stamps { grid-template-columns: repeat(1, minmax(0, 1fr)); }
#wish-stamps:empty::before { padding: 9px 10px; border: 1px dashed #d7cda9; border-radius: 9px; background: #fff9e9; color: #76694d; content: "让萱草最后开，就能留下这一枚花愿印。"; font-size: 10px; line-height: 1.4; }
#side-stamps { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; margin-top: 7px; }
#side-stamps li { display: grid; justify-items: center; align-content: start; gap: 3px; min-height: 69px; padding: 6px 3px; border: 1px dashed #c9cbb8; border-radius: 9px; background: #f0efe4; color: #656b5e; text-align: center; }
#side-stamps li.earned { border-style: solid; border-color: #d4ba8c; background: #fff2d8; color: #74552e; }
#side-stamps i { width: 25px; height: 25px; filter: grayscale(1); opacity: .35; }
#side-stamps .earned i { filter: none; opacity: 1; }
#side-stamps img { width: 100%; height: 100%; }
#side-stamps b { font: 700 14px/1.2 var(--serif); }
#side-stamps small { font-size: 12px; }

.rest-summary { margin: 6px 0 14px; color: #53684e; font-size: 16px; line-height: 1.65; }
.rest-art { display: flex; justify-content: center; gap: 12px; padding: 8px 0 18px; color: #c3924c; font-size: 30px; }
.rest-art span:nth-child(2) { color: #bf7c72; font-size: 37px; }
.rest-back, .help-done { width: 100%; min-height: 46px; }
.help-rows > div { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.help-rows i { display: block; flex: none; width: 40px; height: 38px; }
.help-rows p { margin: 0; color: #54654f; font-size: 15px; line-height: 1.55; }
.help-rows b { display: block; margin-bottom: 1px; color: #334d39; font-size: 16px; }
.help-done { margin-top: 9px; }

button:focus-visible { outline: 3px solid #cb8b30; outline-offset: 2px; z-index: 12; }
.cell:focus-visible { outline: 3px solid #cb8b30; outline-offset: 2px; }

@media (min-width: 720px) {
  body { display: grid; place-items: center; background: #d9e1d4 url("assets/courtyard.webp") center / cover fixed; }
  body::before { position: fixed; inset: 0; background: #e7ecdfaa; content: ""; pointer-events: none; }
  .app-shell { z-index: 1; width: min(540px, 100vw); height: min(100dvh, 900px); border-inline: 1px solid #ced8c8; }
  .game-main { padding-inline: 18px; }
  .play-heading { min-height: 52px; }
  .app-dock { min-height: 58px; }
  dialog { inset: 50% auto auto 50%; width: min(480px, calc(100vw - 32px)); max-width: min(480px, calc(100vw - 32px)); max-height: min(84dvh, 760px); border-radius: 20px; transform: translate(-50%, -50%); }
}

@media (max-height: 620px) {
  .app-shell { grid-template-rows: 42px minmax(0, 1fr) auto; }
  .game-main { padding-block: 3px 5px; }
  .play-card { gap: 3px; }
  .play-heading { min-height: 38px; }
  .play-heading h1 { margin-top: 2px; }
  .plot { padding: 9px; border-radius: 14px; }
  .message { min-height: 30px; padding-block: 3px; }
  .actions button { min-height: 38px; padding-block: 5px; }
  .actions:has(#next:not([hidden])) #next, .actions:has(#next:not([hidden])) #rest { min-height: 39px; }
  .actions:has(#next:not([hidden])) #hint, .actions:has(#next:not([hidden])) #undo, .actions:has(#next:not([hidden])) #reset { min-height: 34px; }
  .app-dock { min-height: 48px; padding-top: 2px; }
  .dock-button { min-height: 40px; }
}

@media (max-width: 360px) {
  .topbar { padding-inline: 10px; }
  .top-actions { gap: 3px; }
  .icon-button { width: 38px; height: 38px; }
  .game-main { padding-inline: 8px; }
  .flower-status { min-width: 76px; padding-inline: 7px; }
  .actions { gap: 4px; }
  .actions button { gap: 3px; padding-inline: 4px; }
  .dock-button { gap: 4px; padding-inline: 3px; }
  dialog { inset-inline: 6px; width: calc(100vw - 12px); max-width: calc(100vw - 12px); padding: 13px; }
  #level-list { gap: 5px; }
  .level-option { gap: 4px; min-height: 42px; padding-inline: 5px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .001ms !important; animation-duration: .001ms !important; animation-iteration-count: 1 !important; }
  .cell.first-source-guide, .cell.revealed-source-guide { animation: none !important; }
}
