:root {
  color-scheme: light;
  --paper: #f8f1e9;
  --card: #fffdf8;
  --ink: #35273b;
  --muted: #635460;
  --plum: #5a416c;
  --plum-soft: #efe7f2;
  --line: #e7ddcb;
  --red: #aa4a55;
  --gold: #f4ca71;
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
body { margin: 0; }
button, select { font: inherit; }
button, canvas[tabindex] { -webkit-tap-highlight-color: transparent; }
button:focus-visible, select:focus-visible, canvas:focus-visible, [tabindex="-1"]:focus-visible {
  outline: 3px solid #249675;
  outline-offset: 3px;
}
[hidden] { display: none !important; }
.page-width { width: min(1120px, calc(100% - 56px)); margin-inline: auto; }
main { padding-bottom: 22px; }

.site-header { border-bottom: 1px solid var(--line); background: #fdf8ef; }
.header-inner { min-height: 69px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: flex; align-items: center; gap: 11px; font-size: 19px; font-weight: 800; color: var(--plum); letter-spacing: 0.1em; white-space: nowrap; }
.brand-icon { position: relative; display: grid; place-items: center; width: 37px; height: 37px; border-radius: 12px; background: var(--plum); }
.brand-icon i { position: relative; width: 14px; height: 11px; margin-top: 8px; border-radius: 65% 65% 55% 55%; background: #fff3dc; }
.brand-icon i::before { content: ""; position: absolute; left: -4px; top: -5px; width: 5px; height: 6px; border-radius: 50%; background: #fff3dc; box-shadow: 6px -5px #fff3dc, 13px -5px #fff3dc, 19px 0 #fff3dc; }
.header-controls { display: flex; align-items: center; gap: 16px; }
.header-controls select { min-height: 37px; padding: 4px 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--plum); font-size: 14px; font-weight: 700; cursor: pointer; }
.total-progress { width: 155px; }
.total-label { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; color: var(--muted); }
.total-label strong { color: var(--plum); font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
progress { appearance: none; display: block; height: 6px; width: 100%; margin-top: 7px; overflow: hidden; border: 0; border-radius: 20px; background: #e8e0d0; }
progress::-webkit-progress-bar { background: #e8e0d0; }
progress::-webkit-progress-value { background: #8e6ea3; border-radius: 20px; }
progress::-moz-progress-bar { background: #8e6ea3; border-radius: 20px; }

.intro { min-height: 151px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 11px 13px 2px; }
.intro h1 { margin: 0; font-size: clamp(34px, 5.4vw, 64px); font-weight: 900; line-height: 1.05; color: var(--plum); }
.intro h1 span:last-child { color: var(--red); }
.intro p { margin: 12px 0 0; color: var(--muted); font-size: clamp(14px, 2vw, 17px); line-height: 1.55; }
.intro-art { display: block; width: clamp(112px, 24vw, 229px); height: auto; }
.level-picker { margin-block: 0 17px; }
.level-picker ol { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 8px; padding: 0; margin: 0; list-style: none; }
.level-picker button { position: relative; display: block; width: 100%; height: 44px; border-radius: 11px; border: 1px solid var(--line); background: var(--card); color: var(--muted); font-weight: 750; cursor: pointer; font-variant-numeric: tabular-nums; }
.level-picker button:hover { background: #f3ebef; color: var(--plum); }
.level-picker button.complete { color: var(--plum); background: var(--plum-soft); border-color: #e0d3e7; }
.level-picker button[aria-current="step"] { border-color: var(--plum); background: var(--plum); color: #fffef3; }
.level-check { position: absolute; top: 5px; right: 7px; font-size: 11px; }

.game { background: var(--card); border: 1px solid var(--line); border-radius: 22px; box-shadow: 0 8px 24px #5440230a; padding: 20px; }
.game-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 15px; }
.scene-heading, .score { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.level-number { flex: none; padding: 5px 9px; color: #8f404d; background: #f9e8e7; border-radius: 8px; font-size: 13px; font-weight: 750; white-space: nowrap; }
.scene-heading h2, .celebration h2, dialog h2 { margin: 0; font-size: clamp(19px, 2.6vw, 27px); letter-spacing: 0.02em; }
.score { flex: none; justify-content: flex-end; color: var(--muted); font-size: 13px; gap: 8px; }
.score strong { color: var(--plum); font-size: 15px; font-variant-numeric: tabular-nums; }
.score-dots { display: inline-flex; gap: 4px; }
.score-dot { display: block; width: 9px; height: 9px; border-radius: 50%; background: #ede4d3; }
.score-dot.filled { background: #916bad; }

.pictures { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.picture { margin: 0; min-width: 0; overflow: hidden; background: #fbf5e9; border: 1px solid #e8dcc8; border-radius: 15px; }
.picture figcaption { min-height: 41px; display: flex; align-items: center; gap: 8px; padding: 5px 11px; font-size: 15px; color: #584b3c; font-weight: 750; }
.picture figcaption b { display: grid; place-items: center; flex: 0 0 24px; height: 24px; border-radius: 6px; background: #e9dfcf; color: #584b3c; font-size: 13px; }
.answer-picture { border-color: var(--plum); }
.answer-picture figcaption { background: var(--plum); color: #fffdf8; }
.answer-picture figcaption b { background: #fffaf0; color: var(--plum); }
.board { position: relative; isolation: isolate; }
.board canvas { display: block; width: 100%; height: auto; aspect-ratio: 16 / 11; background: #ead5b4; }
.answer-picture canvas { cursor: crosshair; }
.board canvas:focus-visible { z-index: 1; position: relative; outline-offset: -4px; }
.marks { position: absolute; z-index: 2; inset: 0; pointer-events: none; }
.mark { position: absolute; display: grid; place-items: center; transform: translate(-50%, -50%); border-radius: 50%; width: var(--mark-width); aspect-ratio: 1; }
.mark.found { border: 3px solid #14765a; background: #50c29335; box-shadow: 0 0 0 2px #fff8dd; }
.mark.found::after { position: absolute; right: 0; bottom: 0; display: grid; place-items: center; height: 20px; width: 20px; content: "✓"; border-radius: 50%; background: #14765a; color: white; font-weight: 800; font-size: 13px; }
.mark.clue { border: 3px dashed #865106; background: #ffdf9480; box-shadow: 0 0 0 2px #fff4c4; animation: clue 1.4s ease-in-out infinite alternate; }
.mark.miss { width: 24px; border: 2px solid #8a4939; box-shadow: 0 0 0 2px #fff8dd; animation: fade 0.55s ease-out forwards; }
.mark.cursor { width: 22px; border: 2px solid #23382f; outline: 2px solid #fffef5; }
@keyframes clue { to { opacity: 0.55; } }
@keyframes fade { to { opacity: 0; transform: translate(-50%, -50%) scale(1.6); } }

.game-footer { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; margin-top: 16px; }
.button { min-height: 43px; display: inline-flex; justify-content: center; align-items: center; gap: 7px; border-radius: 10px; padding: 7px 13px; border: 1px solid transparent; font-weight: 750; font-size: 14px; cursor: pointer; white-space: nowrap; }
.hint-button { color: #61471f; background: #fcf1d8; border-color: #eedbae; }
.hint-button:hover:not(:disabled) { background: #f8e8bd; }
.hint-icon { color: #986315; font-size: 18px; }
.next-button { background: var(--plum); color: #fffef3; }
.next-button:hover:not(:disabled) { background: #473155; }
.button:disabled { cursor: default; }
.hint-button:disabled { opacity: 0.5; }
.next-button:disabled { background: #efe8ef; color: #655569; }
.feedback { text-align: center; margin: 0; font-size: 14px; line-height: 1.5; color: var(--muted); }
.feedback.success { color: var(--plum); font-weight: 750; }
.celebration { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 17px; padding: 19px 20px; border: 1px solid #e0d3e7; border-radius: 17px; background: var(--plum-soft); color: var(--plum); }
.celebration p { margin: 6px 0 0; }
dialog { width: min(420px, calc(100% - 32px)); padding: 24px; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 16px; }
dialog::backdrop { background: #28392b66; }
dialog form { display: flex; justify-content: flex-end; gap: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

@media (min-width: 821px) and (max-height: 820px) {
  .page-width { width: min(1020px, calc(100% - 56px)); }
  .header-inner { min-height: 55px; }
  .intro { min-height: 118px; padding-block: 10px; }
  .intro h1 { font-size: clamp(34px, 5.1vw, 57px); }
  .intro p { margin-top: 8px; }
  .intro-art { width: 178px; }
  .level-picker { margin-bottom: 12px; }
  .level-picker button { height: 38px; }
  .game { padding: 15px; }
  .game-header { margin-bottom: 10px; }
  .game-footer { margin-top: 11px; }
}

@media (max-width: 680px) {
  .page-width { width: calc(100% - 24px); }
  .header-inner { min-height: 59px; gap: 12px; }
  .brand { font-size: 16px; gap: 8px; }
  .brand-icon { width: 32px; height: 32px; }
  .header-controls { gap: 9px; }
  .header-controls select { font-size: 13px; padding-inline: 4px; }
  .total-progress { width: 88px; }
  .total-label { gap: 4px; font-size: 11px; }
  .intro { min-height: 113px; padding: 14px 0 11px; }
  .intro p { margin-top: 7px; }
  .intro-art { width: clamp(89px, 24vw, 150px); }
  .level-picker ol { gap: 4px; }
  .level-picker button { height: 39px; border-radius: 8px; font-size: 13px; }
  .level-check { top: 1px; right: 2px; font-size: 9px; }
  .game { padding: 11px; border-radius: 15px; }
  .game-header { margin-bottom: 10px; }
  .scene-heading { gap: 6px; }
  .level-number { font-size: 11px; }
  .score { gap: 5px; font-size: 12px; }
  .score strong { font-size: 13px; }
  .score-dots { display: none; }
  .pictures { gap: 8px; }
  .picture { border-radius: 10px; }
  .picture figcaption { min-height: 36px; padding: 4px 8px; font-size: 14px; }
  .game-footer { margin-top: 11px; gap: 7px; }
  .feedback { font-size: 13px; }
  .button { padding-inline: 8px; }
}

@media (max-width: 500px) {
  .pictures { grid-template-columns: minmax(0, 1fr); }
  .game-footer { grid-template-columns: 1fr 1fr; }
  .feedback { grid-column: 1 / -1; grid-row: 1; min-height: 1.5em; }
  .hint-button { justify-self: start; }
  .next-button { justify-self: end; }
  .celebration { align-items: flex-start; flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) {
  .mark.clue { animation: none; }
  .mark.miss { animation-name: fade-opacity; }
  @keyframes fade-opacity { to { opacity: 0; } }
}
