:root {
  color-scheme: light;
  --paper: #f4efe3;
  --panel: #fffdf7;
  --ink: #1e2c25;
  --muted: #545b4f;
  --border: #d8cebb;
  --ridge: #e8decb;
  --accent: #a33723;
  --accent-hover: #802c1c;
  --signal: #a7442d;
  --green: #345238;
  --code: ui-monospace, 'SFMono-Regular', Consolas, monospace;
  --serif: Georgia, 'Times New Roman', serif;
  font: 16px/1.52 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: 100vh; }
button, textarea { font: inherit; color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: default; }
a { color: inherit; text-underline-offset: .2em; }
:where(a, button, summary, textarea, [tabindex]):focus-visible { outline: 3px solid #8f3c26; outline-offset: 3px; }

.sr-only, .skip-link:not(:focus) {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link:focus {
  position: absolute;
  z-index: 5;
  margin: .5rem;
  padding: .6rem 1rem;
  color: var(--ink);
  background: white;
}

.shell { width: min(100% - 48px, 976px); margin-inline: auto; }
.site-header { color: #fffdf5; background: #212b25; }
.header-inner { display: flex; align-items: center; justify-content: space-between; min-height: 54px; }
.brand { display: inline-flex; gap: .6rem; align-items: center; font: 750 .78rem/1 var(--code); letter-spacing: .12em; text-decoration: none; }
.brand-mark { display: block; position: relative; width: 21px; height: 17px; }
.brand-mark i { position: absolute; top: 4px; width: 13px; height: 10px; background: #ecc8a2; clip-path: polygon(0 100%, 50% 4%, 100% 100%, 81% 100%, 50% 40%, 19% 100%); }
.brand-mark i + i { left: 8px; top: 6px; opacity: .55; }
.modes { display: flex; gap: .2rem; }
.modes a { min-height: 44px; display: grid; place-items: center; padding: .35rem .8rem; font-size: .8rem; text-decoration: none; border-bottom: 2px solid transparent; }
.modes a:hover { color: #f2c19e; }
.modes a[aria-current] { color: #f6cba8; border-color: #f1bf93; }
.language-link, #language-link { min-width: 44px; white-space: nowrap; }
.site-header :focus-visible { outline-color: #efc2a2; }

.intro { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin: clamp(1.4rem, 3vw, 2rem) 0 1.3rem; }
.puzzle-label { margin: 0; color: var(--accent); font: 750 .7rem/1.3 var(--code); letter-spacing: .16em; }
.intro h1 { margin: .18em 0 .1em; font: 500 clamp(2.75rem, 7.2vw, 4.65rem)/.98 var(--serif); letter-spacing: -.06em; }
.intro-copy { margin: .75rem 0 0; color: var(--muted); font-size: clamp(.88rem, 2vw, 1rem); }
.date-controls { display: grid; grid-template-columns: 2.75rem max-content 2.75rem; align-items: center; gap: .2rem; }
.date-controls[data-practice] { grid-template-columns: max-content; }
.date-stamp { min-width: max-content; padding: .38rem .55rem; border: 1px solid var(--border); font: 650 .73rem/1.25 var(--code); color: var(--muted); }
.date-controls:not([data-practice]) .date-stamp { grid-column: 2; grid-row: 1; }
.day-step { grid-row: 1; min-height: 44px; display: grid; place-items: center; border-radius: .25rem; font: 500 1.5rem/1 var(--serif); text-decoration: none; }
.day-step:hover { background: #ede4d3; }
#next-day { grid-column: 3; }

.workbench { display: grid; grid-template-columns: minmax(0, 1fr) minmax(14rem, 17.25rem); gap: 1rem; align-items: start; margin-bottom: 1.65rem; }
.panel { min-width: 0; border: 1px solid var(--border); background: var(--panel); border-radius: .55rem; }
.board-panel { padding: clamp(.8rem, 2.6vw, 1.4rem); }
.panel-heading { display: flex; align-items: baseline; justify-content: space-between; gap: .65rem; max-width: 31rem; margin: 0 auto .88rem; }
.panel h2 { margin: 0; font: 500 clamp(1.42rem, 3.5vw, 1.75rem)/1.1 var(--serif); letter-spacing: -.04em; }
.progress { white-space: nowrap; font: 650 .76rem/1.15 var(--code); color: var(--muted); }
.board-layout {
  display: grid;
  grid-template-columns: clamp(1.3rem, 5vw, 2.7rem) minmax(0, 1fr) clamp(2.1rem, 8vw, 3.8rem);
  gap: .35rem;
  max-width: 31rem;
  margin-inline: auto;
}
.column-guide, .columns, .rows, .quotas { font-family: var(--code); }
.column-guide { display: grid; align-items: center; justify-items: center; color: var(--muted); font-size: clamp(.48rem, 1.4vw, .62rem); font-weight: 750; }
.columns, .rows, .quotas { display: grid; gap: 0; }
.columns { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.rows, .quotas { grid-template-rows: repeat(6, minmax(0, 1fr)); }
.column-label, .row-label, .quota { display: grid; place-items: center; }
.column-label, .row-label { min-height: .95rem; color: var(--muted); font-size: .73rem; font-weight: 700; }
.quota { align-self: center; justify-self: center; min-width: clamp(1.5rem, 5.5vw, 2.7rem); padding: .2rem .16rem; border: 1px solid #ded7c7; border-radius: .28rem; font-size: clamp(.7rem, 2vw, .91rem); background: #f3eee4; white-space: nowrap; }
.quota.is-met { color: #284b31; border-color: #b9c7a9; background: #e6eddd; }
.quota.is-over { color: #8b2f1e; border-color: #e5bdac; background: #fae5dc; }
.terrain-window { position: relative; min-width: 0; overflow: visible; aspect-ratio: 1; }
.terrain {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template: repeat(6, minmax(0, 1fr)) / repeat(6, minmax(0, 1fr));
  border: 1px solid #b6a88d;
  background: var(--ridge);
  background-image: repeating-radial-gradient(ellipse at 9% 105%, transparent 0 16px, #b79e732e 17px 18px, transparent 19px 30px), repeating-radial-gradient(ellipse at 106% -9%, transparent 0 12px, #ab93652c 13px 14px, transparent 15px 27px);
  border-radius: .27rem;
}
.tile {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  position: relative;
  padding: 0;
  border: 0;
  border-bottom: 1px solid #766c5480;
  border-right: 1px solid #766c5480;
  border-radius: 0;
  background: transparent;
  color: #404b3b;
}
.tile:nth-child(6n) { border-right: 0; }
.tile:nth-last-child(-n + 6) { border-bottom: 0; }
.tile:not(:disabled):hover { background: #faf1dfd9; }
.tile:focus-visible { z-index: 3; outline: 3px solid #733a29; outline-offset: -3px; border-radius: .15rem; }
.tile.rock { background: repeating-linear-gradient(145deg, #8e785425 0 2px, transparent 2px 9px), #5d5a4718; }
.tile:disabled:not(.rock):not(.fixed) { background: #5d5a4715; }
.tile.fixed { background: #fcf0db84; }
.tile.selected { background-color: #fff0db9c; }
.tile.invalid { background-color: #f1b8a277; }
.tile-mark { display: inline-block; width: .75rem; height: .75rem; --marker: #394c38; position: relative; flex: none; }
.tile .tile-mark { z-index: 2; width: clamp(.65rem, 2vw, 1rem); height: clamp(.65rem, 2vw, 1rem); }
.mark-base { background: #39553c; border: 2px solid #fff6dd; outline: 1px solid #39553c; border-radius: 2px; }
.mark-tower { background: #996021; clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); }
.mark-finish { background: #a23923; clip-path: polygon(50% 0, 100% 92%, 0 92%); }
.mark-rock { background: #6e664e; clip-path: polygon(0 92%, 25% 42%, 43% 68%, 70% 15%, 100% 92%); }
.mark-selected { background: var(--signal); border: 2px solid #fff7e7; outline: 1px solid var(--signal); border-radius: 50%; }
.route-lines { position: absolute; z-index: 1; inset: 1px; pointer-events: none; }
.route-line { position: absolute; height: 3px; border-radius: 20px; background: var(--signal); transform-origin: 0 center; transform: translateY(-50%) rotate(var(--angle)); }
.route-line.is-broken { height: 2px; background: repeating-linear-gradient(to right, #973924 0 4px, transparent 4px 8px); }
.legend { display: flex; flex-wrap: wrap; gap: .48rem 1rem; justify-content: center; margin: .85rem 0 1rem; padding: 0; list-style: none; color: var(--muted); font-size: .75rem; }
.legend li { display: inline-flex; align-items: center; gap: .3rem; }
.actions { display: flex; flex-wrap: wrap; justify-content: center; gap: .55rem; }
.button { border: 1px solid transparent; border-radius: .28rem; min-height: 44px; padding: .5rem .9rem; font-size: .85rem; font-weight: 700; }
.button-primary { background: var(--accent); color: #fffdf8; }
.button-primary:hover { background: var(--accent-hover); }
.button-quiet { background: transparent; border-color: #cbbda5; }
.button-quiet:hover { background: #f6efe1; }
.feedback { max-width: 31rem; margin: .85rem auto 0; padding: .55rem .75rem; border-radius: .25rem; background: #f6efdf; color: #514f3c; font-size: .83rem; }
.feedback.is-error { background: #faebe3; color: #7a3022; }
.feedback.is-success { background: #e8eee1; color: #2b5235; }
.feedback p { margin: 0; }
.feedback ul { margin: .35rem 0 0; padding-inline-start: 1.12rem; }

.side { display: grid; gap: 1rem; }
.rules, .signal { padding: 1.1rem; }
.rules { background-color: #f9f4e7; background-image: repeating-radial-gradient(ellipse at 113% -30%, transparent 0 22px, #d1baa52b 23px 24px, transparent 25px 33px); }
.rules summary { display: none; }
.rules dl { margin: .8rem 0 0; }
.rules dl div { padding: .72rem 0; border-top: 1px solid #e2d6c1; }
.rules dl div:last-child { padding-bottom: .16rem; }
.rules dt { font-size: .86rem; font-weight: 750; }
.rules dd { margin: .22rem 0 0; color: var(--muted); font-size: .8rem; }
.signal { background: #e9efe0; border-color: #c4d0b8; }
.signal h2 { color: #294b32; }
.signal p { margin: .55rem 0 .7rem; font-size: .82rem; }
.signal-actions { display: flex; flex-wrap: wrap; gap: .45rem; }
.button-share { color: #fffdf8; background: #34543b; }
.button-share:hover { background: #24432d; }
.signal .share-status:empty { margin: 0; }
.board-panel .share-status { margin: .5rem 0 0; text-align: center; font-size: .82rem; color: var(--green); }
.board-panel .share-status:empty { margin: 0; }
.copy-fallback { display: grid; gap: .35rem; margin-top: .6rem; font-size: .78rem; }
.copy-fallback textarea { width: 100%; min-width: 0; background: white; border: 1px solid #b7c7b0; border-radius: .25rem; resize: vertical; font-family: var(--code); }
.archive summary { padding: .75rem 1rem; cursor: pointer; font-size: .88rem; font-weight: 750; }
.archive-streak { float: inline-end; color: var(--green); font: 700 .69rem/1.8 var(--code); }
.archive-note { margin: 0 1rem .5rem; color: var(--muted); font-size: .75rem; }
.archive-days { margin: 0; padding: 0 1rem .55rem; list-style: none; }
.archive-days li { display: flex; align-items: center; justify-content: space-between; gap: .35rem; border-top: 1px solid var(--border); }
.archive-days a { min-height: 44px; display: flex; align-items: center; font-size: .84rem; }
.archive-days a[aria-current] { color: var(--accent); font-weight: 750; }
.archive-days time { white-space: nowrap; }
.archive-days .day-solved { color: var(--green); font-size: .75rem; }
.error { color: #7a3022; background: #faebe3; padding: .7rem 1rem; }
.footer { display: flex; align-items: baseline; flex-wrap: wrap; gap: .35rem 1rem; border-top: 1px solid var(--border); padding: .85rem 0 1.3rem; color: var(--muted); font-size: .73rem; }
.footer > span { font-family: var(--code); font-weight: 750; letter-spacing: .09em; }
.footer p { margin: 0; }
.footer-links { display: flex; flex-wrap: wrap; gap: .35rem 1rem; margin-left: auto; }
:root:lang(zh-CN) { --serif: 'Songti SC', SimSun, serif; }
:root:lang(zh-CN) :is(.brand, .intro h1, .panel h2) { letter-spacing: 0; }

@media (max-width: 720px) {
  .workbench { grid-template-columns: minmax(0, 1fr); }
  .signal { grid-row: 1; }
  .side { gap: .75rem; }
}

@media (max-width: 450px) {
  .shell { width: calc(100% - 24px); }
  .brand { gap: .35rem; letter-spacing: .07em; white-space: nowrap; }
  .modes a { min-width: 44px; padding-inline: .48rem; }
  .game-header .header-inner { flex-wrap: wrap; }
  .game-header .brand { font-size: .7rem; letter-spacing: .04em; }
  .game-header .brand-mark { display: none; }
  .game-header .modes a { padding-inline: .3rem; }
  .intro { align-items: start; flex-direction: column; gap: .55rem; margin-bottom: .9rem; }
  .intro-copy { margin-top: .45rem; }
  .date-controls:not([data-practice]) {
    max-width: 100%;
    grid-template-columns: 2.75rem minmax(0, max-content) 2.75rem;
  }
  .date-stamp { min-width: 0; padding: .28rem .42rem; }
  .board-panel { padding: .65rem .48rem .9rem; }
  .panel-heading { padding: 0 .22rem; }
  .board-layout { gap: .25rem; }
  .legend { gap: .4rem .65rem; }
  .actions { gap: .4rem; }
  .footer-links { margin-left: 0; }
}

[data-embed] .shell { width: min(100% - 1rem, 37rem); }
[data-embed] .header-inner { min-height: 44px; }
[data-embed] .intro { justify-content: center; align-items: center; margin: .3rem 0 .45rem; }
[data-embed] .intro > :first-child {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
[data-embed] .workbench { grid-template-columns: minmax(0, 1fr); gap: .6rem; margin-bottom: .65rem; }
[data-embed] .board-panel { padding-block: .65rem .75rem; }
[data-embed] .panel-heading { margin-bottom: .45rem; }
[data-embed] .legend { margin-block: .6rem .7rem; }
[data-embed] .side { gap: .5rem; }
[data-embed] .signal { grid-row: 1; }
[data-embed] .rules { padding: 0 1rem; }
[data-embed] .rules h2, [data-embed] .footer > :not(#full-game-link) { display: none; }
[data-embed] .rules summary { display: list-item; min-height: 44px; padding-block: .7rem; font-size: .88rem; font-weight: 750; cursor: pointer; }
[data-embed] .rules dl { margin-top: 0; padding-bottom: .7rem; }
[data-embed] .footer { justify-content: center; padding: 0; }
[data-embed] #full-game-link { display: inline-flex; align-items: center; gap: .3rem; min-height: 44px; }
