:root {
  --paper: #f3ece4;
  --ink: #241c18;
  --muted: #4e433d;
  --line: rgba(36, 28, 24, 0.14);
  --sheet: #faf6f1;
  --cream: #fffaf7;
  --mark: #7a3140;
  --clay: #8a4b12;
  --clay-soft: #f3e7da;
  --orange: #ef9b28;
  --pen: "HanziPen SC", "Hannotate SC", "Kaiti SC", "STKaiti", "KaiTi", "Songti SC", serif;
  --drive: #f6d0c8;
  --drive-ink: #641f30;
  --pursue: #f3e7a2;
  --pursue-ink: #5c4010;
  --drive-name: #1d6a3a;
  --pursue-name: #8d2f2a;
  --serif: "Songti SC", "STSong", "Noto Serif SC", "Iowan Old Style", Palatino, serif;
  --sans: "PingFang SC", "Hiragino Sans GB", "Avenir Next", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html {
  scrollbar-color: #b7a79b transparent;
}

html, body { margin: 0; min-height: 100%; overflow-x: clip; }

body {
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  background:
    linear-gradient(180deg, rgba(255, 252, 248, 0.7), transparent 280px),
    var(--paper);
}

button, a { font: inherit; }

button { color: inherit; cursor: pointer; }

a { color: inherit; }

::selection { background: #edd5d4; color: var(--ink); }

:focus-visible {
  outline: 2px solid var(--clay);
  outline-offset: 3px;
}

h1:focus { outline: none; }

h1:focus-visible {
  outline: 2px solid var(--clay);
  outline-offset: 4px;
}

.frame {
  width: min(980px, calc(100% - 32px));
  margin: 0 auto;
  padding: 48px 0 80px;
}

.sheet {
  background: var(--sheet);
  border: 1px solid rgba(36, 28, 24, 0.08);
  border-radius: 6px 28px 6px 28px;
  padding: 44px 40px 32px;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.8) inset,
    0 18px 40px rgba(72, 42, 32, 0.07);
}

h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(34px, 5vw, 52px);
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1.12;
  text-wrap: balance;
}

h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.25;
  text-wrap: balance;
}

.lead {
  max-width: 62ch;
  margin: 16px 0 0;
  font-size: 17px;
  line-height: 1.7;
  text-wrap: pretty;
}

.fine,
.hint,
.status,
.about {
  color: var(--muted);
}

.fine {
  margin: 22px 0 0;
  font-size: 14px;
  line-height: 1.65;
}

.intro {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 28px 36px;
  align-items: center;
  margin-top: 28px;
}

.mini {
  margin: 0;
}

.mini .mark {
  display: block;
  width: 100%;
  height: auto;
}

.mini figcaption {
  display: grid;
  gap: 4px;
  margin-top: 8px;
  font-size: 14px;
  line-height: 1.4;
}

.drive-name { color: var(--drive-name); font-weight: 560; }

.pursue-name { color: var(--pursue-name); font-weight: 560; }

.steps {
  margin: 0;
  padding-left: 1.25em;
}

.steps li {
  margin-top: 14px;
  padding-left: 0.2em;
}

.steps li::marker {
  color: var(--mark);
  font-family: var(--serif);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 26px;
}

.primary,
.ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 999px;
  text-decoration: none;
}

.primary {
  border: none;
  background: var(--clay);
  color: var(--cream);
}

.primary:disabled {
  background: #e4d5c8;
  color: #5c463c;
  cursor: not-allowed;
}

.ghost {
  border: 1px solid var(--line);
  background: transparent;
}

.ghost:hover,
.word:hover,
.tag:hover {
  background: rgba(122, 49, 64, 0.06);
}

.primary:hover:not(:disabled) { background: #6f3c0e; }

.bar {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px 20px;
}

.bar h1 { font-size: clamp(28px, 4vw, 40px); }

.about {
  margin: 12px 0 0;
  max-width: 68ch;
  font-size: 15px;
  line-height: 1.65;
}

.kept {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 16px 0 0;
  font-size: 14px;
}

.kept b {
  font-weight: 560;
}

.chip {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 3px;
  background: var(--drive);
  color: var(--drive-ink);
  line-height: 1.4;
}

.cols {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.col {
  border: 1px solid rgba(122, 49, 64, 0.35);
  background: var(--cream);
  padding: 6px 4px;
}

.col:empty { display: none; }

.word {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  border: 0;
  background: transparent;
  color: var(--mark);
  font-size: 16px;
  line-height: 1.45;
  text-align: left;
}

.word.on {
  background: rgba(36, 28, 24, 0.05);
}

.word.on span {
  color: #5c463c;
  text-decoration-line: line-through;
  text-decoration-thickness: 2px;
  text-decoration-color: var(--ink);
}

.board.revive .word:not(.back) {
  background: rgba(36, 28, 24, 0.05);
}

.board.revive .word:not(.back) span {
  color: #5c463c;
  text-decoration-line: line-through;
  text-decoration-thickness: 2px;
  text-decoration-color: var(--ink);
}

.word.back,
.word.back:hover {
  background: var(--pursue);
  color: var(--pursue-ink);
}

.word.back span { text-decoration: none; }

.dock {
  position: sticky;
  bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px 18px;
  margin-top: 18px;
  padding: 12px 14px;
  background: var(--cream);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 12px 28px rgba(72, 42, 32, 0.1);
}

.count {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin: 0;
  font-variant-numeric: tabular-nums;
  line-height: 1.35;
}

.count b {
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 500;
  letter-spacing: -0.03em;
}

.count span {
  color: var(--muted);
  font-size: 14px;
}

.status {
  margin: 4px 0 0;
  font-size: 14px;
  line-height: 1.5;
}

.status.warn {
  color: var(--mark);
  font-weight: 560;
}

.dock .actions { margin-top: 0; }

.capture {
  margin-top: 8px;
}

.plate {
  position: relative;
  width: 100%;
  min-width: 0;
  aspect-ratio: 4 / 3.15;
  margin: 0;
  background-color: #f7f8f6;
  background-image:
    linear-gradient(to right, rgba(168, 180, 172, 0.55) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(168, 180, 172, 0.55) 1px, transparent 1px);
  background-size: 22px 22px;
  overflow: hidden;
}

.sky {
  position: absolute;
  inset: 0;
}

.sky .mark {
  position: absolute;
  width: 42%;
  height: auto;
  aspect-ratio: 1;
  left: 56%;
  top: 46%;
  transform: translate(-50%, -50%);
  overflow: visible;
}

.mark polygon {
  fill: none;
  stroke: var(--orange);
  stroke-width: 1.7;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.mark.draw polygon {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: draw 0.9s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.mark.draw polygon.down { animation-delay: 0.32s; }

@keyframes draw {
  to { stroke-dashoffset: 0; }
}

.tag,
.tag:hover {
  position: absolute;
  max-width: 5.6em;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--orange);
  font-family: var(--pen);
  font-size: clamp(12px, 3.1vw, 24px);
  font-weight: 500;
  line-height: 1.35;
  text-align: center;
  text-wrap: balance;
}

.tag .ink {
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
  padding: 0.02em 0.18em 0.06em;
  border-radius: 3px;
  background: #f7cfc8;
}

.tag.pursue .ink { background: #e4f3a2; }

.tag.is-picked .ink {
  outline: 1.5px solid var(--orange);
  outline-offset: 3px;
}

.at-top { left: 56%; top: 4%; transform: translateX(-50%); max-width: 6.2em; }
.at-bot { left: 56%; bottom: 9%; transform: translateX(-50%); max-width: 4.6em; }
.at-ul { left: 23%; top: 22%; }
.at-ur { right: 11%; top: 22%; }
.at-ll { left: 22%; top: 56%; }
.at-lr { right: 12%; top: 56%; }

.aside,
.spine {
  position: absolute;
  z-index: 1;
  margin: 0;
  font-family: var(--pen);
  font-weight: 500;
  background: transparent;
}

.aside {
  font-size: clamp(13px, 3.5vw, 26px);
  line-height: 1.2;
}

.aside.drive {
  left: 3%;
  top: 18%;
  color: #2f9a45;
}

.aside.pursue {
  left: 3%;
  bottom: 16%;
  color: #d23b3b;
}

.spine {
  right: 1.5%;
  top: 50%;
  transform: translateY(-50%);
  color: var(--orange);
  font-size: clamp(13px, 3.4vw, 28px);
  letter-spacing: 0.22em;
  writing-mode: vertical-rl;
}

.roster {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 28px;
  margin-top: 22px;
}

.roster h2 {
  margin: 0;
  font-size: 22px;
}

.roster ul {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}

.roster li {
  margin-top: 4px;
  line-height: 1.5;
}



@media (min-width: 720px) {
  .plate { aspect-ratio: 16 / 9.2; background-size: 28px 28px; }
  .tag { font-size: clamp(16px, 2vw, 24px); }
  .aside,
  .spine { font-size: clamp(18px, 2.2vw, 28px); }
  .spine { letter-spacing: 0.36em; }
}

@media (max-width: 860px) {
  .cols { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .intro { grid-template-columns: 1fr; }
  .mini { max-width: 220px; }
}

@media (max-width: 560px) {
  .frame {
    width: min(100% - 20px, 980px);
    padding-top: 28px;
  }

  .sheet { padding: 28px 16px 22px; }

  .cols,
  .roster { grid-template-columns: 1fr; }

  .plate {
    aspect-ratio: 1 / 1.12;
    background-size: 16px 16px;
  }

  .sky .mark { width: 54%; left: 48%; top: 50%; }

  .at-top { left: 48%; top: 16%; }
  .at-bot { left: 48%; bottom: 16%; max-width: 5.2em; }
  .at-ul { left: 2%; top: 30%; }
  .at-ur { right: 8%; top: 30%; }
  .at-ll { left: 2%; top: 54%; }
  .at-lr { right: 8%; top: 54%; }

  .aside.drive { top: 5%; }
  .aside.pursue { bottom: 6%; }
  .spine { right: 0.2%; letter-spacing: 0.1em; }

  .dock {
    flex-direction: column;
    align-items: stretch;
  }

  .dock .actions { width: 100%; }

  .dock .primary,
  .dock .ghost { flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .mark.draw polygon {
    animation: none;
    stroke-dashoffset: 0;
  }
}

@media print {
  body { background: white; }
  .sheet { box-shadow: none; }
  .dock,
  .actions,
  .hint { display: none; }
}
