:root {
  color-scheme: light;
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  color: #483435;
  background: #f5eee3;
  font-synthesis: none;
  --paper: #fffbf5;
  --line: #e9ddce;
  --ink: #483435;
  --muted: #826c65;
  --rose: #9c4c60;
  --rose-pale: #f8e5e7;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(ellipse at 12% 0%, #ffe9df 1%, transparent 42%),
              radial-gradient(ellipse at 100% 100%, #eee5d5, transparent 57%),
              #f7f0e6;
}
button { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, .stage:focus-visible {
  outline: 2px solid var(--rose);
  outline-offset: 3px;
}
.shell { width: min(1224px, calc(100% - 64px)); margin: 0 auto; padding: 38px 0 40px; }
.masthead { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 0 0 26px; }
.brand { display: flex; align-items: center; gap: 16px; }
.brand-icon {
  display: grid; place-items: center; width: 60px; height: 60px; border-radius: 20px;
  font-size: 33px; color: #fff8f2; background: #9f5665;
  box-shadow: inset 0 0 0 1px #ae6877, 0 8px 16px #9c4c601c;
  text-shadow: 0 1px 0 #773948;
}
h1, h2, p { margin: 0; }
h1 { font-family: "DM Serif Text", "Songti SC", SimSun, Georgia, serif; font-size: clamp(28px, 3.8vw, 41px); letter-spacing: -.04em; font-weight: 700; line-height: 1.15; }
.brand p { font-size: 13px; line-height: 1.5; margin-top: 5px; color: var(--muted); }
.ready {
  display: flex; align-items: center; gap: 8px; padding: 9px 12px;
  border-radius: 999px; border: 1px solid #eddccf; background: #fff9f2;
  color: #5a5543; font-size: 12px; font-weight: 650; white-space: nowrap;
}
.ready i { width: 7px; height: 7px; border-radius: 50%; background: #a48a59; box-shadow: 0 0 0 3px #a48a5929; }
.ready[data-state="ready"] i { background: #59864e; box-shadow: 0 0 0 3px #59864e1e; }
.ready[data-state="error"] i { background: #aa5060; box-shadow: 0 0 0 3px #aa506024; }

.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 270px; gap: 20px; align-items: start; }
.game-card, .panel {
  background: var(--paper); border-radius: 18px;
  border: 1px solid #eadccf; box-shadow: 0 6px 22px #754c2b10, 0 1px 2px #754c2b0d;
}
.game-card { overflow: hidden; }
.game-bar { min-height: 53px; display: flex; justify-content: space-between; align-items: center; padding: 0 16px; }
.location { font-weight: 650; color: #62454a; font-size: 14px; display: flex; gap: 8px; align-items: center; }
.location-mark { color: #a35b70; font-size: 19px; line-height: 1; }
.reset {
  background: #fbf0ea; color: #7a514d; padding: 5px 10px; border: 1px solid #f1dfd5;
  border-radius: 8px; font-size: 12px; font-weight: 600; white-space: nowrap;
}
.reset:hover { background: #f8e7df; }
.reset span { font-size: 17px; line-height: .8; vertical-align: -1px; margin-right: 2px; }

.stage {
  position: relative; width: 100%; aspect-ratio: 16 / 9; background: #b8be96;
  overflow: hidden; outline-offset: -3px; border-block: 1px solid #d4c7aa;
}
.stage canvas { display: block; width: 100%; height: 100%; image-rendering: pixelated; }
.scene-badge {
  position: absolute; left: 12px; bottom: 11px; display: flex; gap: 8px; align-items: center;
  padding: 5px 9px; color: #fff7e8; background: #413636de;
  border-radius: 4px; border: 1px solid #eee0c951; font-size: 10px; letter-spacing: .08em;
  pointer-events: none;
}
.scene-badge i { width: 3px; height: 3px; background: #f2a6a6; }
.scene-note {
  position: absolute; inset: 50% auto auto 50%; z-index: 1; transform: translate(-50%, -50%);
  max-width: calc(100% - 30px); width: max-content; padding: 12px 18px; color: var(--ink);
  background: #fff9eeec; border: 1px solid #e2cbb7; border-radius: 8px; text-align: center; font-size: 13px;
}

.game-foot { display: flex; align-items: center; justify-content: center; gap: 12px; min-height: 52px; padding: 8px; }
.keyboard-tip { display: flex; align-items: center; gap: 4px; color: var(--muted); }
.keyboard-tip span { margin: 0 4px; font-size: 12px; }
kbd {
  min-width: 22px; height: 23px; padding: 0 4px; display: inline-grid; place-items: center; border-radius: 5px;
  background: #f8f0e6; color: #68524e; border: 1px solid #e8d9c8; border-bottom-width: 2px;
  font: 650 12px/1 "IBM Plex Mono", Consolas, monospace;
}
.foot-label { color: #795d55; white-space: nowrap; font-size: 12px; }
.panel { padding: 19px 17px 16px; display: grid; gap: 16px; }
.setting + .setting { padding-top: 15px; border-top: 1px solid #f0e5d8; }
.setting h2 { color: #5d4143; font-size: 13px; font-weight: 700; }
.segmented button:hover, .frames button:hover { background: #faece6; }
.view-setting, .pad-setting { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.segmented { display: flex; border-radius: 8px; border: 1px solid #eddfd0; padding: 3px; background: #f8f0e6; }
.segmented button, .frames button {
  border: 0; border-radius: 5px; background: transparent; color: #755a55; font-weight: 650; font-size: 12px;
}
.segmented button { padding: 4px 10px; }
.segmented button[aria-pressed="true"], .frames button[aria-pressed="true"] { background: #efd8db; color: #753b4b; }
.pad-copy p { margin-top: 4px; font-size: 11px; color: var(--muted); }
.d-pad { display: grid; grid-template-columns: repeat(3, 30px); grid-template-rows: repeat(3, 26px); gap: 3px; }
.d-pad button {
  border: 1px solid #e8d6c3; border-bottom-width: 2px; background: #fcf4e7; color: #805d53;
  border-radius: 5px; display: grid; place-items: center; font-size: 16px; line-height: 1; font-weight: 750;
  touch-action: none; user-select: none;
}
.d-pad button:hover, .d-pad button[data-active="true"] { background: #f1d9da; border-color: #dfb9b8; color: #8a4053; }
.d-pad [data-direction="up"] { grid-area: 1 / 2; }
.d-pad [data-direction="left"] { grid-area: 2 / 1; }
.d-pad [data-direction="right"] { grid-area: 2 / 3; }
.d-pad [data-direction="down"] { grid-area: 3 / 2; }
.d-pad-center { grid-area: 2 / 2; display: grid; place-items: center; color: #c28d8d; font-size: 12px; }
.frames-setting { display: grid; gap: 8px; }
.freeze { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; color: #5d4143; width: fit-content; cursor: pointer; }
.freeze input { margin: 0; accent-color: var(--rose); }
.frames { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 3px; border-radius: 8px; border: 1px solid #eddfd0; padding: 3px; background: #f8f0e6; }
.frames button { min-height: 26px; }

@media (max-width: 850px) {
  .shell { width: calc(100% - 34px); padding: 25px 0; }
  .workspace { grid-template-columns: minmax(0, 1fr); gap: 15px; }
  .panel { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 15px; }
  .panel:not(:has(.wardrobe-setting:not([hidden]))) .view-setting { border-top: none; padding-top: 0; }
}
@media (max-width: 465px) {
  .shell { width: calc(100% - 24px); padding-top: 19px; }
  .masthead { margin-bottom: 17px; gap: 8px; }
  .brand { gap: 9px; }
  .brand-icon { width: 44px; height: 44px; border-radius: 13px; font-size: 27px; }
  .brand p { font-size: 10px; }
  .ready { font-size: 10px; padding: 7px 8px; }
  .panel { padding: 13px; gap: 10px; }
  .view-setting { grid-column: 1 / -1; }
  .panel .view-setting { padding-top: 10px; border-top: 1px solid #f0e5d8; }
  .d-pad { grid-template-columns: repeat(3, 27px); }
  .pad-copy p { display: none; }
  h1 { font-size: 28px; }
  .game-foot { gap: 6px; }
  .keyboard-tip { gap: 3px; }
  kbd { min-width: 19px; padding: 0 3px; }
}

@media (max-width: 465px) { .pad-setting, .frames-setting { grid-column: 1 / -1; } .d-pad { grid-template-columns: repeat(3, 40px); grid-template-rows: repeat(3, 34px); } }

.d-pad button[hidden], .frames button[hidden] { display: none; }
.d-pad [data-direction="up-left"] { grid-area: 1 / 1; }
.d-pad [data-direction="up-right"] { grid-area: 1 / 3; }
.d-pad [data-direction="down-left"] { grid-area: 3 / 1; }
.d-pad [data-direction="down-right"] { grid-area: 3 / 3; }
.frames button { min-width: 0; padding-inline: 2px; }
.frames button[data-frame="0"] { min-width: 37px; }
.outfit-select {
  max-width: 110px; padding: 5px 8px;
  border-radius: 8px; border: 1px solid #eddfd0;
  color: #755a55; background: #f8f0e6;
  font-family: inherit; font-size: 12px; font-weight: 650;
}
.outfit-select:focus-visible { outline: 2px solid var(--rose); outline-offset: 3px; }

.wardrobe-setting[hidden] { display: none; }
.wardrobe-fields { display: grid; gap: 6px; margin-top: 8px; }
.wardrobe-field { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.wardrobe-field label { font-size: 12px; color: #745b57; }
.wardrobe-field .outfit-select { min-width: 99px; }
@media (max-width: 465px) { .wardrobe-setting { grid-column: 1 / -1; } }

@media (max-width: 410px) { .foot-label { display: none; } }
