:root {
  color-scheme: light;
  --paper: #fff3dc;
  --grain: url("/assets/paper-grain.svg");
  --card: #fffaf0;
  --ink: #35472e;
  --muted: #5f624b;
  --line: #dfcba7;
  --green: #45623d;
  --peach: #f8ddbd;
  --leaf: #e9edda;
  --board-ink: #614535;
  --r0: #f2b1a2;
  --r1: #a9cfdf;
  --r2: #f8dc82;
  --r3: #d5b5e7;
  --r4: #bcd38d;
  --r5: #f5c095;
  --r6: #a8d6c4;
  --r7: #b9d2ae;
  --r8: #e9bad7;
  --r9: #e7dfa1;
  --r10: #a9c0ef;
  --r11: #e8b593;
  font-family: ui-rounded, "Nunito", system-ui, sans-serif;
  font-size: 15px;
  background: var(--paper);
  color: var(--ink);
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  position: relative;
  isolation: isolate;
  background: var(--grain) var(--paper);
}
body::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  /* 四角按原比例缩放，纸纹纵向平铺。 */
  border-image: url("/assets/garden-paper.webp") 310 360 fill /
    min(20.18vw, 310px) min(23.44vw, 360px) / 0 stretch round;
}
button,
input,
button,
input,
summary {
  cursor: pointer;
}
button,
a,
input,
button {
  color: inherit;
}
a {
  color: inherit;
  text-decoration: none;
}
button {
  border: 0;
  background: none;
}
button:disabled {
  opacity: 0.35;
  cursor: default;
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--green);
  outline-offset: 4px;
}
svg {
  width: 24px;
  height: 24px;
}
button svg {
  display: block;
}
.svg-library {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}
.wrap {
  max-width: 1160px;
  margin: auto;
  padding-inline: 40px;
}
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 50px;
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex;
  gap: 9px;
  align-items: center;
  font-size: clamp(18px, 4.8vw, 27px);
  font-weight: bold;
}
.brand-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 35px;
  height: 35px;
  border-radius: 10px;
  background: var(--green);
  color: #f7eed5;
}
.brand-icon svg {
  width: 25px;
  height: 25px;
}
.site-header nav {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 13px;
}
.site-header .brand,
.site-header nav {
  background: #fff7e7ed;
  border-radius: 999px;
  padding: 3px 10px;
}
.site-header nav a {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  white-space: nowrap;
}
.site-header nav a span {
  margin-left: 7px;
}
.header-label {
  font-size: 10px;
  color: var(--muted);
}
.intro {
  padding: 4px 0 8px;
  text-align: center;
}
.intro h1 {
  margin: 0;
  font-size: clamp(20px, 3.2vw, 32px);
  line-height: 1.2;
}
.intro p {
  max-width: 56ch;
  margin: 6px auto 0;
  color: var(--muted);
}
.garden-title {
  display: block;
  width: min(100%, 650px);
  height: 142px;
  object-fit: contain;
  margin-inline: auto;
  color: var(--green);
}
.eyebrow {
  font-size: 10px;
  font-weight: 600;
  line-height: 1.6;
  display: flex;
  align-items: center;
  gap: 8px;
}
.play-layout {
  display: grid;
  grid-template-columns: minmax(0, 490px) minmax(280px, 380px);
  justify-content: center;
  grid-template-areas: "board setup" "board tools";
  grid-template-rows: auto 1fr;
  gap: 12px 24px;
  align-items: start;
  padding-bottom: 32px;
}
.puzzle-setup,
.play-tools,
.game-area {
  min-width: 0;
  border: 2px solid var(--line);
  border-radius: 24px 21px 23px 19px;
  background: var(--grain) #fff7e5;
  box-shadow: inset 0 0 0 2px #fffcf0, 0 3px 0 #9a703417;
  padding: 16px;
}
.puzzle-setup {
  grid-area: setup;
}
.play-tools {
  grid-area: tools;
}
.mode-tabs {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--grain) var(--leaf);
  padding: 4px;
  gap: 4px;
}
.mode-tabs a {
  flex: 1;
  display: grid;
  place-items: center;
  min-height: 44px;
  font-weight: 700;
  padding: 8px 4px;
  font-size: 13px;
  border-radius: 999px;
  color: var(--muted);
}
.mode-tabs a[aria-current] {
  background: var(--grain) var(--green);
  color: white;
}
.puzzle-info {
  padding: 12px 0 10px;
}
.puzzle-info .eyebrow {
  color: var(--muted);
  margin: 0 0 10px;
}
h2 {
  font-family: Georgia, serif;
  font-weight: 400;
}
.puzzle-info h2 {
  font-size: 29px;
  margin: 0 0 4px;
}
.date-line {
  font-size: 12px;
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 6px;
  color: var(--muted);
}
.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}
.stats > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--peach);
}
.stat-label {
  font-size: 10px;
  font-weight: 700;
}
.stats strong {
  font-size: 20px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.stats strong span {
  font-weight: 400;
}
.saved-note,
.hint-help {
  font-size: 12px;
  color: var(--muted);
  margin: 8px 0 0;
}
.game-area {
  grid-area: board;
  width: 100%;
  background: var(--grain) #f9eacb;
}
.board-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0 0 6px;
  font-size: 10px;
  color: var(--muted);
}
.board-top > span {
  font-weight: 600;
}
.region-toggle {
  display: flex;
  gap: 6px;
  align-items: center;
  font-size: 13px;
  min-height: 32px;
}
.board {
  touch-action: none;
  display: grid;
  grid-template-columns: repeat(var(--size, 8), 1fr);
  border: 1px solid #808080;
  border-radius: 9px 7px 10px 7px;
  overflow: hidden;
  background: var(--board-ink);
  aspect-ratio: 1;
  width: 100%;
  isolation: isolate;
}
.cell {
  background: var(--grain) var(--region);
  border-right: 1px solid #808080;
  border-bottom: 1px solid #808080;
  aspect-ratio: 1;
  position: relative;
  padding: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  min-width: 0;
  color: var(--board-ink);
  user-select: none;
  -webkit-user-select: none;
}
.cell.last-column {
  border-right: 0;
}
.cell.last-row {
  border-bottom: 0;
}
.cell svg {
  width: 58%;
  height: 58%;
  pointer-events: none;
}
.cell .cross {
  font-size: clamp(16px, 3vw, 27px);
  line-height: 1;
  opacity: 0.85;
  font-weight: 300;
  pointer-events: none;
}
.cell.wrong-crown .cross {
  color: #a52029;
  font-weight: 750;
  opacity: 1;
}
.cell:hover {
  filter: brightness(0.96);
}
.cell:focus-visible {
  outline: 3px solid #1a3b30;
  outline-offset: -5px;
  z-index: 1;
}
.cell.hinted {
  outline: 2px dashed var(--board-ink);
  outline-offset: -5px;
}
.region-letter {
  position: absolute;
  top: 3px;
  left: 4px;
  color: #332419;
  font-size: 9px;
  pointer-events: none;
}
.board-instructions {
  font-size: 13px;
  text-align: center;
  color: var(--muted);
  margin: 10px 0 0;
  line-height: 1.5;
}
.utilities {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.utilities button,
.round-action {
  flex: 1 0 auto;
  min-height: 44px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 13px 11px 14px 10px;
  background: var(--grain) #fff7e6;
  font-size: 13px;
  font-weight: 750;
}
.round-action {
  width: 100%;
  margin-top: 8px;
  background: var(--grain) var(--green);
  color: white;
}
.completion .round-action {
  background: var(--grain) var(--green);
  color: white;
}
#hearts {
  color: #a4423b;
  letter-spacing: 0.12em;
}
.cell:disabled {
  opacity: 1;
}
.utilities #hint {
  background: var(--grain) #f9dd9c;
  border-color: #bd9253;
}
.utilities button span {
  font-size: 18px;
}
input[type="checkbox"] {
  accent-color: var(--green);
  width: 14px;
  height: 14px;
  margin: 0;
}
.status {
  font-size: 12px;
  line-height: 1.6;
  min-height: 34px;
  color: var(--muted);
  margin: 4px 0 0;
}
.status.error {
  color: #9a3434;
}
.completion {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  background: #e8eee3;
  border: 1px solid #c6d2c0;
  border-radius: 9px;
  padding: 18px;
  margin-top: 16px;
}
.completion[hidden] {
  display: none;
}
.completion-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff9e8;
  border-radius: 50%;
}
.completion h2 {
  font-size: 21px;
  margin: 0 0 6px;
}
.completion p {
  font-size: 11px;
  margin: 0;
  color: var(--muted);
}
.completion button {
  padding: 9px 10px;
  font-size: 12px;
  border: 1px solid #b4c6b0;
  border-radius: 5px;
}
.learn {
  border-top: 1px solid var(--line);
  padding: 55px 0 50px;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 64px;
}
.learn-heading .eyebrow {
  font-size: 9px;
  color: var(--muted);
  max-width: 220px;
}
.learn-heading h2 {
  font-size: 32px;
  line-height: 1.2;
  margin: 18px 0;
}
.learn-heading > p:last-child {
  font-size: 13px;
  line-height: 1.8;
  color: var(--muted);
}
.learn-cards {
  display: grid;
  gap: 14px;
}
.learn-cards article {
  padding: 19px 23px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
}
.lesson-number {
  font-size: 9px;
  color: var(--muted);
}
.learn-cards h3 {
  font:
    21px Georgia,
    serif;
  margin: 10px 0;
}
.learn-cards p {
  font-size: 12px;
  line-height: 1.7;
  color: var(--muted);
  margin: 0;
}
.faq {
  border-top: 1px solid var(--line);
  padding: 36px 0 50px;
}
.faq h2 {
  font-size: 30px;
  margin: 0 0 20px;
}
.faq details {
  border-bottom: 1px solid var(--line);
  padding: 17px 0;
}
.faq summary {
  font-size: 14px;
}
.faq details p {
  font-size: 13px;
  line-height: 1.8;
  max-width: 720px;
  color: var(--muted);
}
.site-footer {
  border-top: 1px solid var(--line);
  padding-block: 25px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
}
.site-footer .brand {
  font-size: 25px;
}
.site-footer p,
.site-footer > span {
  font-size: 11px;
  color: var(--muted);
}
.footer-links {
  display: flex;
  flex: 0 0 100%;
  flex-wrap: wrap;
  gap: 8px 18px;
  font-size: 13px;
}
.footer-links a {
  text-decoration: underline;
  text-underline-offset: 3px;
}
dialog {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  color: var(--ink);
  padding: 30px;
  max-width: 430px;
  margin: auto;
}
dialog::backdrop {
  background: #182e2660;
}
dialog h2 {
  font-size: 28px;
}
dialog p:not(.eyebrow) {
  font-size: 14px;
  line-height: 1.6;
  color: var(--muted);
}
.dialog-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 24px;
}
.dialog-actions button {
  padding: 11px 15px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 13px;
}
.dialog-actions .primary {
  background: var(--green);
  color: white;
}
button[hidden] {
  display: none;
}

@media (max-width: 760px) {
  .wrap {
    padding-inline: clamp(12px, 4vw, 26px);
  }
  .header-label {
    display: none;
  }
  .site-header .brand {
    padding: 3px 7px 3px 0;
  }
  .site-header nav {
    padding-inline: 8px;
  }
  .site-header nav a span {
    display: none;
  }
  .intro {
    padding-block: 2px 4px;
  }
  .garden-title {
    height: clamp(74px, 22vw, 120px);
  }
  .play-layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "setup" "board" "tools";
    max-width: 560px;
    margin-inline: auto;
    gap: 10px;
  }
  .puzzle-setup,
  .play-tools,
  .game-area {
    padding: 10px;
    border-radius: 14px;
  }
  .puzzle-setup {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(115px, 0.85fr);
    align-items: center;
    column-gap: 10px;
  }
  .mode-tabs,
  .stats,
  #energy-recovery,
  #start {
    grid-column: 1 / -1;
  }
  .puzzle-info {
    padding-block: 10px 0;
  }
  .puzzle-info h2 {
    font-size: 22px;
    margin-bottom: 4px;
  }
  .puzzle-info .eyebrow {
    display: none;
  }
  .stats {
    margin-top: 8px;
  }
  .board-top {
    margin: 0;
  }
  .board-instructions {
    margin-top: 6px;
    font-size: 12px;
  }
  .learn {
    grid-template-columns: 1fr;
    gap: 12px;
    padding-block: 30px;
  }
}
@media (max-width: 510px) {
  .stats strong {
    font-size: 16px;
  }
  .stats > div {
    gap: 4px;
    padding-inline: 6px;
  }
}
