:root {
  color-scheme: light;
  --ink: #232638;
  --muted: #55566a;
  --paper: #fbf8ef;
  --white: #fffdfa;
  --line: #ded9ca;
  --yellow: #ffd455;
  --lilac: #eee9ff;
  --pink: #ffdedc;
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  background: var(--paper);
  color: var(--ink);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { opacity: .55; cursor: default; }
a { color: inherit; }
:focus-visible { outline: 3px solid #6b49ba; outline-offset: 4px; }
.site-header {
  max-width: 1060px; margin: 0 auto; padding: max(15px, env(safe-area-inset-top)) 28px 15px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 850; letter-spacing: -.03em; font-size: 21px; }
.brand img { width: 41px; height: 41px; }
.brand-note { display: block; color: var(--muted); letter-spacing: .11em; font-size: 9px; line-height: 1.4; }
main { max-width: 1060px; margin: 0 auto; padding: 10px 28px 32px; }
.tabs { width: fit-content; display: flex; gap: 4px; background: #efeadf; padding: 4px; border-radius: 13px; }
.tabs button, .ghost { border: 1px solid transparent; border-radius: 10px; background: transparent; color: var(--ink); font-weight: 700; min-height: 44px; padding: 7px 15px; }
.tabs button[aria-current=page] { background: var(--white); border-color: var(--line); box-shadow: 0 1px 2px #23263817; }
.ghost { border-color: var(--line); background: var(--white); }
.intro { margin: 27px 0 20px; }
.intro h1 { font-size: clamp(32px, 7vw, 56px); font-weight: 900; line-height: 1.12; letter-spacing: -.065em; margin: 0 0 10px; }
.intro h1 br { display: none; }
.intro p, dialog p, #libraryStatus { font-size: 14px; line-height: 1.65; color: var(--muted); margin: 0; }
.section-intro h1 { font-size: clamp(31px, 6vw, 44px); }
.workbench { display: grid; grid-template-columns: minmax(0,1.45fr) minmax(0,1fr); gap: 16px; align-items: stretch; }
.board, .controls, .card, .invite-banner { background: var(--white); border: 1px solid var(--line); border-radius: 17px; }
.board { overflow: hidden; }
.board-title, .board-footer { padding: 13px 16px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.board-title h2, .controls h2 { font-size: 16px; margin: 0; }
.board-title output, .board-footer { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.preview-space {
  min-height: min(62vw, 340px); display: grid; place-items: center; padding: 14px;
  background-color: var(--lilac); background-image: radial-gradient(#9c8abe54 1px, transparent 1px);
  background-size: 13px 13px;
}
.preview-space canvas { display: block; width: auto; height: auto; max-width: 100%; max-height: min(58vw,310px); object-fit: contain; }
.swatches { display: flex; align-items: center; gap: 4px; height: 20px; }
.swatches svg { width: 15px; height: 15px; }
.controls { padding: 16px; display: grid; align-content: start; gap: 15px; }
.upload { display: flex; align-items: center; gap: 11px; min-height: 70px; padding: 8px 11px; border: 1px dashed #8272af; border-radius: 12px; background: #f5f1ff; cursor: pointer; }
.upload:has(+ input:focus-visible) { outline: 3px solid #6b49ba; outline-offset: 3px; }
.upload-symbol { display: grid; place-items: center; width: 35px; height: 35px; border-radius: 10px; background: var(--white); font-size: 23px; flex: 0 0 auto; }
.upload strong, .upload small { display: block; }
.upload small { color: var(--muted); font-size: 11px; line-height: 1.4; margin-top: 3px; }
fieldset { border: 0; padding: 0; margin: 0; min-inline-size: 0; }
legend { padding: 0; width: 100%; font-size: 14px; font-weight: 700; }
legend output { float: right; color: #524191; font-variant-numeric: tabular-nums; }
input[type=range] { display: block; width: 100%; min-height: 36px; margin: 0; accent-color: #705bb1; }
.range-labels { color: var(--muted); display: flex; justify-content: space-between; font-size: 11px; }
.button {
  display: inline-flex; align-items: center; justify-content: center; min-height: 45px; border-radius: 11px; border: 1px solid var(--ink);
  padding: 9px 15px; font-weight: 750; font-size: 14px; color: var(--ink); text-align: center; text-decoration: none;
}
.primary { background: var(--yellow); }
.primary:active { background: #f2c147; }
.quiet { background: var(--white); border-color: var(--line); }
.quiet-link { color: #51418a; font-size: 13px; }
.full { width: 100%; }
.micro { color: var(--muted); margin: 0; font-size: 12px; line-height: 1.6; }
.cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit,minmax(min(100%,230px),1fr)); }
.card { overflow: hidden; }
.card-image { width: 100%; height: 180px; display: block; object-fit: contain; padding: 13px; background: var(--lilac); }
.card:nth-child(2) .card-image { background: #e9f5f5; }
.card:nth-child(3) .card-image { background: var(--pink); }
.card-body { padding: 12px; }
.card h2 { font-size: 15px; margin: 0 0 5px; }
.card p { margin: 0 0 9px; color: var(--muted); font-size: 12px; }
#libraryStatus:not(:empty) { margin: 8px 0 12px; }
dialog { width: min(480px,calc(100% - 28px)); max-height: calc(100vh - 30px); max-height: calc(100dvh - 30px); border: 1px solid var(--line); border-radius: 17px; background: var(--white); color: var(--ink); padding: 16px; }
dialog::backdrop { background: #232638a8; }
dialog:not([open]) { display: none; }
.legacy-modal-active { overflow: hidden; }
.legacy-modal-active::before { content: ""; position: fixed; inset: 0; background: #232638a8; z-index: 10; }
dialog.legacy-modal { position: fixed; inset: 0; height: max-content; margin: auto; z-index: 11; overflow: auto; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.dialog-head h2 { font-size: 19px; margin: 0; }
.close { border: 0; background: transparent; min-width: 44px; min-height: 44px; font-size: 27px; line-height: 1; color: var(--muted); }
dialog img { width: 100%; max-height: min(53vh, 470px); max-height: min(53dvh, 470px); object-fit: contain; margin: 10px 0; display: block; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 8px; }
.actions > * { flex: 1 1 138px; }
#inviteLinkText { border: 1px solid var(--line); padding: 9px; border-radius: 8px; }
.invite-banner { margin-bottom: 10px; padding: 12px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.invite-banner div { flex: 1 1 155px; }
.invite-banner p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.visually-hidden { position: absolute; overflow: hidden; height: 1px; width: 1px; white-space: nowrap; clip-path: inset(50%); }
#toast { position: fixed; z-index: 20; bottom: max(20px,env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); max-width: calc(100% - 28px); width: max-content; }
#toast:not(:empty) { padding: 10px 13px; border-radius: 11px; background: var(--ink); color: white; font-size: 13px; }
footer { text-align: center; min-height: 48px; padding-bottom: env(safe-area-inset-bottom); color: var(--muted); font-size: 12px; }
@media (max-width: 650px) {
  .site-header { padding-left: 15px; padding-right: 15px; }
  main { padding: 3px 14px 24px; }
  .tabs { width: 100%; }
  .tabs button { flex: 1; padding: 5px 7px; }
  .intro { margin: 22px 0 14px; }
  .intro h1 br { display: initial; }
  .workbench { grid-template-columns: minmax(0,1fr); gap: 10px; }
  .preview-space { min-height: 185px; padding: 9px; }
  .preview-space canvas { max-height: 44vw; }
  .controls { padding: 12px; gap: 12px; }
  .cards { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
  .card-image { height: 120px; padding: 8px; }
  .card-body { padding: 9px; }
  .card .button { padding: 6px; }
  .dialog-head h2 { font-size: 17px; }
}

.play-intro { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin: 24px 0 16px; }
.play-intro h1 { font-size: clamp(31px,5vw,47px); line-height: 1.1; margin: 0 0 6px; letter-spacing: -.045em; }
.play-intro p { color: var(--muted); font-size: 14px; line-height: 1.55; margin: 0; }
.play-layout { display: grid; grid-template-columns: minmax(0,1.75fr) minmax(0,1fr); gap: 16px; align-items: start; }
.play-stage, .play-shelf { min-width: 0; background: var(--white); border: 1px solid var(--line); border-radius: 17px; padding: 14px; }
.play-header { display: flex; align-items: center; justify-content: space-between; gap: 9px; margin-bottom: 9px; }
.play-header h2, .play-shelf h2 { font-size: 18px; margin: 0; }
.play-header p, #playRemaining { font-size: 12px; color: var(--muted); margin: 3px 0 0; }
#playCount { color: #51418a; font-size: 13px; font-weight: 800; white-space: nowrap; font-variant-numeric: tabular-nums; }
#playProgress { display: block; width: 100%; height: 6px; margin: 0 0 10px; border: 0; border-radius: 10px; background: #eee8f9; appearance: none; accent-color: #705bb1; }
#playProgress::-webkit-progress-bar { background: #eee8f9; border-radius: 10px; }
#playProgress::-webkit-progress-value { background: #705bb1; border-radius: 10px; }
#playProgress::-moz-progress-bar { background: #705bb1; border-radius: 10px; }
.play-viewport { position: relative; overflow: auto; max-height: min(69vh,460px); border-radius: 12px; background: var(--lilac); overscroll-behavior: contain; }
.play-board-mat { min-width: 100%; width: max-content; min-height: 100%; display: flex; justify-content: center; align-items: center; padding: 10px; }
#playBoard { display: block; border-radius: 3px; cursor: crosshair; touch-action: none; }
.is-panning #playBoard { cursor: grab; }
.is-panning #playBoard:active { cursor: grabbing; }
.play-palette { display: flex; gap: 6px; overflow: auto; padding: 4px 4px 6px; margin: 0 -4px; }
.play-color { flex: 0 0 auto; min-height: 49px; display: grid; grid-template-columns: 13px auto; gap: 2px 5px; align-items: center; padding: 5px 8px; border: 1px solid var(--line); border-radius: 9px; background: var(--white); color: var(--ink); font-size: 12px; }
.play-color[aria-pressed=true] { border-color: #705bb1; background: #f5efff; }
.play-color small { grid-column: 2; color: var(--muted); text-align: left; }
.play-swatch { display: block; width: 13px; height: 13px; border: 1px solid #23263845; border-radius: 50%; }
.play-palette-bar { display: grid; gap: 5px; margin-top: 8px; }
.play-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.play-zoom { display: flex; align-items: center; gap: 5px; padding: 0 4px 0 0; }
.play-zoom output { min-width: 24px; text-align: center; font-size: 13px; }
.play-toolbar button, .play-text-button { min-height: 44px; border: 1px solid var(--line); border-radius: 8px; background: var(--white); color: var(--ink); font-size: 12px; font-weight: 700; padding: 4px 10px; }
.play-zoom button { min-width: 44px; font-size: 18px; }
.play-toolbar button[aria-pressed=true] { background: var(--lilac); border-color: #705bb1; }
.play-shelf h2 { margin-bottom: 10px; }
.play-tiles { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; margin-bottom: 12px; }
.play-tile { min-width: 0; border: 1px solid var(--line); border-radius: 10px; background: #f6f1ff; color: var(--ink); padding: 8px; font-size: 13px; font-weight: 700; }
.play-tile:nth-child(2) { background: #f0f8f7; }
.play-tile:nth-child(3) { background: #eef3fb; }
.play-tile:nth-child(4) { background: #fdf0ed; }
.play-tile[aria-pressed=true] { border-color: #705bb1; box-shadow: inset 0 0 0 1px #705bb1; }
.play-tile canvas { display: block; width: min(100%,72px); height: auto; margin: 0 auto 4px; }
.play-shelf summary { min-height: 44px; display: list-item; padding: 10px 0; font-weight: 800; cursor: pointer; }
#guideMaterialList { list-style: none; padding: 0; margin: 8px 0 0; }
#guideMaterialList li { display: flex; justify-content: space-between; align-items: center; gap: 7px; padding: 7px 0; border-top: 1px solid var(--line); font-size: 13px; }
.play-finish { margin-top: 12px; padding: 11px; background: #f8edc2; border: 1px solid #ede1b4; border-radius: 12px; }
.play-finish h3 { margin: 0; font-size: 17px; }
.play-finish .actions { margin-top: 8px; }
.play-text-button { min-height: 44px; background: transparent; border: 0; text-decoration: underline; }
.board-reveal::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: #fff9; animation: lift-paper 500ms ease-out both; }
.just-completed { animation: finish-in 250ms ease-out both; }
@keyframes lift-paper { to { transform: translateY(-100%); opacity: 0; } }
@keyframes finish-in { from { opacity: 0; transform: translateY(6px); } }
@media (max-width: 650px) {
  .tabs button { font-size: 14px; white-space: nowrap; padding-inline: 4px; }
  .play-intro { align-items: start; margin: 15px 0 10px; gap: 7px; }
  .play-intro h1 { font-size: 28px; }
  .play-intro p { font-size: 13px; }
  .play-intro .button { font-size: 12px; padding-inline: 8px; }
  .play-layout { grid-template-columns: minmax(0,1fr); gap: 10px; }
  .play-stage, .play-shelf { padding: 10px; }
  .play-toolbar { gap: 4px; }
  .play-zoom { gap: 2px; }
  .play-tiles { grid-template-columns: repeat(4,minmax(0,1fr)); }
  .play-tile { font-size: 11px; padding: 5px 2px; }
  #guideMaterials { margin-top: 2px; }
}
@media (prefers-reduced-motion: reduce) {
  .board-reveal::after { display: none; }
  .just-completed { animation: none; }
}
