:root {
  color-scheme: light;
  --page: #f8f4eb;
  --surface: #fffcf5;
  --ink: #302e26;
  --muted: #625e51;
  --line: #c9c2af;
  --accent: #405744;
  --tint: #e5eadf;
  --mat: #d7bb8c;
  --light: #fff0c77d;
  --shade: #a1784d60;
  --thread: #fffcf02b;
  --thread-dark: #57411e0c;
  --caption: #fff9e9eb;
  --dot: #627144;
  --serif: "Songti SC", "Noto Serif CJK SC", SimSun, serif;
  --gap: clamp(12px, 2vw, 24px);
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  background: var(--page);
  color: var(--ink);
}
:root[data-light="moon"] {
  color-scheme: dark;
  --page: #1d2529;
  --surface: #273238;
  --ink: #f0ebdc;
  --muted: #c0c6bd;
  --line: #536065;
  --accent: #c9dab1;
  --tint: #38463b;
  --mat: #687983;
  --light: #c3d4d76b;
  --shade: #192b4082;
  --thread: #d7e2ed1f;
  --thread-dark: #101a240e;
  --caption: #273138ed;
  --dot: #c5d6a8;
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: wait; }
:is(button, a, input, .stage):focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.room { width: min(100% - 80px, 1040px); margin-inline: auto; padding: clamp(18px, 3.6vh, 42px) 0 max(12px, env(safe-area-inset-bottom)); }
.intro, .instructions, .picker-title, footer { display: flex; justify-content: space-between; align-items: center; gap: var(--gap); }
.intro { align-items: end; padding-bottom: clamp(12px, 2vh, 22px); }
.imprint { margin: 0 0 5px; color: var(--muted); font: 650 11px/1.3 ui-monospace, monospace; letter-spacing: .12em; text-transform: uppercase; }
.imprint span { margin-inline: 3px; }
h1, h2 { margin: 0; font-family: var(--serif); }
h1 { font-size: clamp(34px, 4.4vw, 58px); line-height: 1.13; letter-spacing: .045em; }
h2 { font-size: clamp(20px, 2.1vw, 26px); line-height: 1.3; }
.tools { display: flex; gap: 8px; }
.tools button { display: inline-flex; gap: 7px; align-items: center; padding: 0 13px; min-height: 44px; border: 1px solid var(--line); border-radius: 24px; background: var(--surface); font-size: 14px; }
.tools button[aria-pressed="true"] { background: var(--tint); color: var(--accent); border-color: var(--accent); }
.tools svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.stage {
  position: relative; isolation: isolate; overflow: hidden; aspect-ratio: 2.45;
  border: 1px solid var(--line); border-radius: 18px; background-color: var(--mat);
  background-image: repeating-linear-gradient(0deg, var(--thread) 0 1px, transparent 1px 3px), repeating-linear-gradient(90deg, var(--thread-dark) 0 1px, transparent 1px 3px), linear-gradient(133deg, var(--light) 8%, transparent 39%, var(--shade) 100%);
  user-select: none; -webkit-user-select: none; touch-action: none;
}
.stage[data-contact] { cursor: none; }
.scene-caption { position: absolute; z-index: 2; inset: 12px auto auto 12px; display: inline-flex; align-items: center; gap: 8px; border-radius: 18px; background: var(--caption); padding: 6px 12px; font-size: 13px; line-height: 1.4; pointer-events: none; }
.scene-caption i { width: 7px; height: 7px; border-radius: 50%; background: var(--dot); }
.scene-caption span { color: var(--muted); }
.cat-area { position: absolute; width: min(85%, 840px); aspect-ratio: 8/5; left: 50%; top: 53%; transform: translate(-50%,-50%); pointer-events: none; filter: drop-shadow(1px 9px 8px #3f301e38); }
.cat, .cat-still { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
html[data-light="moon"] .cat-area, html[data-light="moon"] .hand { filter: brightness(.85) saturate(.77) drop-shadow(0 7px 7px #15233042); }
.cat-still { object-fit: fill; transform: translate(var(--nudge-x, 0px), var(--nudge-y, 0px)) rotate(var(--tilt, 0deg)); transition: transform .14s ease-out; }
.hand { position: absolute; z-index: 1; width: clamp(62px, 14%, 134px); pointer-events: none; filter: drop-shadow(3px 5px 4px #36213d38); transform: translate(-38%, -1.4%) rotate(var(--hand-angle, 0deg)); transform-origin: 38% 1.4%; }
.stage-message { position: absolute; bottom: 12px; left: 12px; max-width: calc(100% - 24px); background: var(--surface); font-size: 14px; padding: 6px 10px; border-radius: 7px; }
.instructions { align-items: baseline; margin: 10px 1px 16px; color: var(--muted); font-size: 14px; line-height: 1.5; }
.instructions p { margin: 0; }
kbd { font: 600 12px/1.25 ui-monospace, monospace; padding: 1px 5px; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; }
.cat-picker { border-top: 1px solid var(--line); }
.picker-title { min-height: 54px; }
#share { border: 0; background: transparent; min-height: 44px; padding: 0 2px; color: var(--accent); font-size: 14px; }
#share:hover, footer a:hover { text-decoration: underline; }
.choices { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.choice { display: flex; align-items: center; gap: 6px; justify-content: center; min-height: 62px; padding: 5px 8px; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; font-size: 15px; font-weight: 620; white-space: nowrap; }
.choice:not(:disabled):hover { border-color: var(--accent); }
.choice[aria-pressed="true"] { border: 2px solid var(--accent); padding: 4px 7px; background: var(--tint); color: var(--accent); }
.portrait { display: grid; place-items: center; width: clamp(36px, 4.3vw, 55px); height: 37px; flex: none; }
.portrait img { display: block; width: 100%; height: 100%; object-fit: contain; }
.share-fallback { display: block; margin-top: 10px; color: var(--muted); font-size: 14px; }
.share-fallback input { display: block; width: 100%; margin-top: 4px; min-height: 44px; padding: 8px; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 5px; font-size: 16px; }
footer { margin-top: 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
footer a { display: inline-flex; align-items: center; min-height: 44px; color: inherit; text-underline-offset: 3px; }
@media (max-width: 800px) {
  .room { width: calc(100% - 40px); }
  .choices { display: flex; overflow-x: auto; padding: 4px 3px 7px; margin-inline: -3px; scroll-snap-type: x proximity; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
  .choice { flex: 0 0 auto; min-width: 107px; scroll-snap-align: start; }
}
@media (max-width: 575px) {
  .room { width: auto; margin-inline: max(14px, env(safe-area-inset-left)) max(14px, env(safe-area-inset-right)); padding-top: max(20px, env(safe-area-inset-top)); }
  .intro { padding-bottom: 16px; }
  .tools button { padding: 0 10px; }
  .stage { aspect-ratio: auto; height: clamp(238px, 51svh, 430px); border-radius: 13px; }
  .cat-area { width: 105%; top: 52%; }
  .instructions { display: block; margin-block: 10px 15px; }
  #keyboard-help { margin-top: 4px; font-size: 12px; }
  .choice { min-height: 55px; }
  .scene-caption { inset: 10px auto auto 10px; }
}
@media (hover: none) and (pointer: coarse) { #keyboard-help { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); } }
@media (max-height: 520px) and (orientation: landscape) { .room { padding-top: 10px; } .intro { padding-bottom: 8px; } h1 { font-size: 30px; } .stage { height: 60svh; aspect-ratio: auto; } .cat-area { width: min(68%, 105svh); } }
