:root {
  color-scheme: light;
  font-family: "Instrument Sans", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #222c25;
  background: #f4f3ec;
  --paper: #fffef8;
  --border: #d6dace;
  --muted: #5b645b;
  --green: #2b523e;
  --across: #914223;
  --down: #27588a;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input, select { font: inherit; }
button, select {
  min-height: 36px;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--paper);
  color: inherit;
}
button:enabled, select:enabled { cursor: pointer; }
button:enabled:hover { border-color: var(--green); background: #eef3e9; }
button:disabled { color: #707a70; opacity: .68; }
:focus-visible { outline: 2px solid #35754d; outline-offset: 2px; }
.shell { width: min(100% - 40px, 1180px); margin-inline: auto; }
.masthead { background: #243c30; color: #fffef3; }
.brand { display: flex; align-items: center; gap: 14px; min-height: 78px; }
h1, h2, p { margin: 0; }
h1 { font-family: "Noto Serif CJK SC", "Songti SC", SimSun, serif; font-size: 30px; letter-spacing: .08em; }
.mark { display: grid; grid-template-columns: repeat(2, 25px); gap: 2px; transform: rotate(-5deg); }
.mark span { background: #f2eed7; color: #243c30; text-align: center; line-height: 25px; font-weight: 700; }
.mark span + span { background: #c9d8b8; }
main { padding-block: 22px 38px; }
.toolbar, .library, #navigation { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.toolbar { gap: 12px 20px; }
#number { width: 56px; height: 36px; text-align: center; border: 1px solid var(--border); border-radius: 6px; background: var(--paper); color: inherit; }
#total { white-space: nowrap; }
#notice { color: #983d28; margin-block: 10px; }
#notice:empty { margin: 0; }
.workspace { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); grid-template-areas: "puzzle clues" "bank clues"; gap: 16px; align-items: start; margin-top: 16px; }
.panel { min-width: 0; border: 1px solid var(--border); border-radius: 10px; background: var(--paper); padding: 16px; }
.puzzle { grid-area: puzzle; }
.bank { grid-area: bank; }
.clues { grid-area: clues; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.section-head span, .help, .legend { font-size: 13px; color: var(--muted); }
h2 { font-size: 17px; }
.board-frame { overflow: auto; padding: 4px; background: #e7ebdf; border-radius: 6px; }
#board {
  display: grid;
  grid-template-columns: repeat(var(--columns), minmax(0, 1fr));
  width: min(100%, calc(var(--columns) * 48px));
  min-width: calc(var(--columns) * 27px);
  margin: 4px auto;
  background: #34463b;
  gap: 1px;
  border: 1px solid #34463b;
}
.cell, .block { aspect-ratio: 1; }
.block { background: #34463b; }
.cell {
  min-height: 0;
  position: relative;
  border: 0;
  border-radius: 0;
  padding: 0;
  display: grid;
  place-items: center;
  user-select: none;
  container-type: inline-size;
  background: #fffef7;
}
.cell:focus-visible, .cell.selected { outline: 2px solid #3f8054; outline-offset: -2px; z-index: 1; }
.cell.flagged { background: #fbded6; }
.cell.flagged:hover { background: #f8d1c6; }
.cell .letter { font-size: clamp(13px, 57cqi, 29px); line-height: 1; margin-top: 18%; }
.cell.wrong .letter { color: #a12f22; }
.marker { position: absolute; top: 2px; font-size: clamp(7px, 23cqi, 12px); font-weight: 750; line-height: 1; }
.marker.long { font-size: clamp(6px, 16cqi, 10px); }
.marker.across { left: 2px; }
.marker.down { right: 2px; }
.across { color: var(--across); }
.down { color: var(--down); }
.legend { display: flex; gap: 16px; margin-top: 10px; }
.clues section + section { border-top: 1px solid var(--border); margin-top: 16px; padding-top: 16px; }
.clues ol { padding: 0; margin: 0; list-style: none; max-height: 46vh; overflow: auto; }
.clues li { display: grid; grid-template-columns: 2.75em minmax(0, 1fr); gap: 7px; padding: 8px 0; font-size: 14px; line-height: 1.55; }
.clues li + li { border-top: 1px solid #ebece4; }
.clue-text { color: #222c25; overflow-wrap: anywhere; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); gap: 6px; margin-top: 12px; }
.tile { display: grid; justify-items: center; padding: 5px 1px; gap: 2px; min-height: 44px; user-select: none; touch-action: none; }
.tile span:first-child { font-size: 19px; line-height: 1; }
.tile span + span { color: var(--muted); font-size: 11px; }
.tile[aria-pressed="true"] { background: #dcebdd; border-color: #3f8054; }
.actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }
.primary { background: var(--green); border-color: var(--green); color: white; }
.primary:enabled:hover { background: #1e3e2d; }
#feedback { min-height: 1.4em; margin-top: 10px; color: var(--muted); font-size: 14px; }
#feedback[data-result="correct"] { color: #256239; font-weight: 700; }
#feedback[data-result="incorrect"] { color: #983d28; }
.ghost { position: fixed; z-index: 5; padding: 4px 9px; background: #dcebdd; border: 1px solid #3f8054; border-radius: 5px; pointer-events: none; font-size: 22px; }
@media (max-width: 760px) {
  .shell { width: calc(100% - 24px); }
  .brand { min-height: 62px; }
  .workspace { grid-template-columns: minmax(0, 1fr); grid-template-areas: "puzzle" "bank" "clues"; }
  .panel { padding: 12px; }
}
