:root {
  color-scheme: light;
  font: 16px/1.5 "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
  color: #432c39;
  background: #fff7f4;
}
* { box-sizing: border-box; }
body {
  --accent: #a23860;
  --tint: #fce6ee;
  --edge: #f0d9df;
  --paper: #fffdfb;
  --muted: #795d6c;
  margin: 0;
}
body[data-mode="sheep"] {
  --accent: #584784;
  --tint: #eee7fc;
  --edge: #e8def3;
  --paper: #fefcff;
  --muted: #665a77;
  min-height: 100vh;
  background: #f9f6ff;
  color: #382f49;
}
button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:focus-visible, canvas:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.app { max-width: 1000px; padding: 36px 24px 30px; margin: auto; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 24px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-icon { width: 58px; height: 58px; padding: 4px; border-radius: 20px; background: var(--tint); transform: rotate(-8deg); }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(1.65rem, 4vw, 2.45rem); line-height: 1.2; letter-spacing: .06em; }
.brand p { color: var(--muted); margin-top: 5px; font-size: .92rem; }
.modes { display: flex; gap: 4px; background: var(--paper); border: 1px solid var(--edge); padding: 5px; border-radius: 18px; }
.modes button { padding: 6px 12px; display: flex; align-items: center; justify-content: center; gap: 6px; background: none; border: 0; border-radius: 12px; font-weight: 700; white-space: nowrap; font-size: .92rem; }
.modes button[aria-pressed="true"] { color: var(--accent); background: var(--tint); }
.modes canvas { width: 27px; height: 27px; }
.game-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(240px, 280px); gap: 18px; align-items: start; }
.field, .card { background: var(--paper); border: 1px solid var(--edge); border-radius: 24px; box-shadow: 0 5px 0 var(--edge); }
.field { padding: 13px; }
.field-heading { display: flex; align-items: center; justify-content: space-between; padding: 0 9px 9px; }
.field-heading h2, .guide h2 { font-size: 1.08rem; }
.field-flower { color: var(--accent); margin-right: 3px; }
.next { display: flex; align-items: center; gap: 7px; padding: 1px 8px 1px 11px; background: var(--tint); border-radius: 12px; font-size: .85rem; font-weight: 700; color: var(--accent); }
.next canvas { width: 36px; height: 36px; }
.board { position: relative; aspect-ratio: 520 / 510; overflow: clip; border-radius: 16px; background: var(--tint); }
#playfield { display: block; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
#playfield:focus-visible { outline-offset: -4px; }
.limit { position: absolute; top: 15.686%; right: 9px; transform: translateY(-50%); padding-inline: 6px; border-radius: 6px; background: var(--paper); color: var(--accent); font-size: .8rem; font-weight: 650; pointer-events: none; }
.welcome { position: absolute; top: 27%; inset-inline: 0; display: grid; justify-items: center; gap: 5px; pointer-events: none; text-align: center; }
.welcome[hidden] { display: none; }
.welcome canvas { width: clamp(95px, 26%, 150px); height: auto; filter: drop-shadow(0 11px 0 #74354414); }
.welcome strong { font-size: clamp(1.15rem, 3.4vw, 1.8rem); letter-spacing: .04em; }
.welcome span { font-size: .92rem; color: var(--muted); }
.controls { min-height: 34px; padding: 11px 6px 0; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 5px; font-size: .84rem; color: var(--muted); }
kbd { font: inherit; padding: 1px 4px; border-radius: 4px; background: var(--tint); }
.sidebar { display: grid; gap: 17px; }
.card { padding: 17px; }
.scores { display: grid; grid-template-columns: 1fr 1fr; }
.scores > div + div { border-inline-start: 1px solid var(--edge); padding-inline-start: 15px; }
.label { color: var(--muted); font-size: .88rem; font-weight: 650; white-space: nowrap; }
.star { color: #945712; }
.scores output { display: block; font-size: 2rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.25; margin-top: 4px; overflow-wrap: anywhere; }
.scores #best { color: var(--accent); }
.guide p { color: var(--muted); font-size: .91rem; margin: 6px 0 13px; }
.guide .field-rule { font-size: .85rem; margin: 13px 0 0; }
.guide ol { list-style: none; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; padding: 0; margin: 0; }
.guide li { position: relative; text-align: center; border: 1px solid var(--edge); border-radius: 12px; padding: 4px 1px; color: var(--muted); font-size: .79rem; }
.guide li.reached { background: var(--tint); color: var(--accent); font-weight: 700; }
.guide li canvas { display: block; width: 44px; height: 44px; max-width: 100%; margin: auto; }
.actions { display: flex; gap: 8px; }
.actions button { flex: 1; padding: 10px 4px; border: 1px solid var(--edge); background: var(--paper); border-radius: 12px; font-size: .88rem; font-weight: 700; }
.actions button[aria-pressed="true"], .actions button:hover { background: var(--tint); color: var(--accent); }
.actions button span { margin-right: 3px; }
dialog { text-align: center; border: 1px solid var(--edge); border-radius: 23px; padding: 22px 35px; color: inherit; background: var(--paper); box-shadow: 0 12px 45px #3f203d38; width: min(88vw, 300px); }
dialog::backdrop { background: #3b263970; }
dialog canvas { width: 100px; height: 100px; }
dialog p { margin: 8px 0 17px; }
dialog strong { color: var(--accent); }
.primary { width: 100%; border: 0; border-radius: 12px; background: var(--accent); color: white; padding: 10px 14px; font-weight: 750; }
@media (max-width: 720px) {
  .app { padding: 18px 12px 22px; }
  .top { margin-bottom: 13px; }
  .game-layout { grid-template-columns: minmax(0, 1fr); gap: 13px; }
  .sidebar { grid-template-columns: 1fr 1fr; gap: 11px; }
  .guide { grid-column: 1 / -1; grid-row: 2; }
  .guide ol { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .actions { align-items: center; }
  .scores { padding: 10px; }
  .scores > div + div { padding-inline-start: 7px; }
  .scores output { font-size: 1.5rem; }
}
@media (max-width: 510px) {
  .top { align-items: stretch; flex-direction: column; gap: 10px; }
  .brand-icon { width: 45px; height: 45px; border-radius: 15px; }
  .brand p { margin-top: 1px; }
  .modes button { flex: 1; }
  .field { padding: 8px; }
}
@media (pointer: coarse) { .keyboard { display: none; } }
