:root {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #253237;
  background: #f3f1ea;
  --ink: #253237;
  --muted: #667173;
  --line: #c9d0ce;
  --surface: #fffefa;
  --today: #cd6546;
  --past: #769ca3;
}
* { box-sizing: border-box; }
body { margin: 0; }
button, a { font: inherit; }
button { cursor: pointer; }
.page { width: min(1120px, calc(100% - 48px)); margin: 0 auto; padding-bottom: 48px; }
.site-head { height: 64px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--ink); font-size: 13px; }
.back { color: var(--ink); text-decoration: none; }
.site-name { font-weight: 700; margin-left: -36px; }
.sound { border: 0; background: none; color: var(--muted); padding: 8px 0 8px 8px; font-size: 12px; }
.intro { display: flex; align-items: end; justify-content: space-between; gap: 28px; padding: 24px 0 22px; }
.intro h1 { margin: 0; font-size: clamp(31px, 3.5vw, 41px); line-height: 1.28; letter-spacing: -.065em; font-weight: 750; }
.intro p { margin: 0 0 3px; color: #526063; font-size: 14px; line-height: 1.8; }
.game-layout { display: grid; grid-template-columns: minmax(0, 1fr) 310px; background: var(--surface); border: 1px solid var(--ink); }
.play-area { min-width: 0; }
.level-bar { min-height: 55px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 9px 23px; border-bottom: 1px solid var(--line); }
.level-id { display: flex; align-items: baseline; gap: 11px; }
.level-id span { color: var(--muted); font-size: 12px; }
.level-id strong { font-size: 16px; }
.turn-label { font-size: 12px; font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }
.board-wrap { min-height: 422px; display: grid; place-items: center; padding: 22px; }
.board { display: grid; position: relative; gap: 2px; width: min(100%, 408px); aspect-ratio: 1; background: #9ba9a9; border: 2px solid #9ba9a9; }
.cell { position: relative; display: grid; place-items: center; min-width: 0; min-height: 0; overflow: hidden; background: #f9f9f3; }
.cell.wall { background: #42585e; }
.cell.plate-a, .cell.plate-b { background: #f2e6bd; }
.cell.plate-a::before, .cell.plate-b::before { content: ''; position: absolute; inset: 18%; border: 2px solid #ad914b; border-radius: 50%; }
.cell.exit { background: #dce6db; }
.cell.exit::before { content: '▣'; color: #718a79; font-size: clamp(18px, 3vw, 30px); }
.cell.exit.open { background: #c6dfc0; }
.cell.exit.open::before { content: '▢'; color: #45794f; }
.cell.start::before { content: '·'; color: #adbab5; font-size: 27px; }
.tile-label { position: absolute; z-index: 1; top: 3px; left: 6px; font-size: 10px; font-weight: 800; color: #7d6c3a; }
.piece { position: absolute; z-index: 3; width: 55%; height: 55%; display: grid; place-items: center; border-radius: 50%; font-size: 13px; font-weight: 800; }
.piece.yours { background: var(--today); color: #fff; }
.piece.echo { border: 2px dashed #3a6872; background: #aacbd0; color: #244c55; }
.piece.both.yours { transform: translate(-15%, -15%); }
.piece.both.echo { transform: translate(20%, 20%); }
.legend { display: flex; justify-content: center; flex-wrap: wrap; gap: 20px; min-height: 45px; align-items: center; border-top: 1px solid var(--line); font-size: 11px; color: var(--muted); }
.legend span { display: flex; align-items: center; gap: 6px; }
.key { width: 12px; height: 12px; display: inline-block; border-radius: 50%; }
.key.yours { background: var(--today); }
.key.echo { background: #aacbd0; border: 1px dashed #3a6872; }
.key.plate { background: #f2e6bd; border: 1px solid #ad914b; }
.key.door { border-radius: 2px; background: #c6dfc0; border: 1px solid #718a79; }
.side-panel { display: flex; flex-direction: column; border-left: 1px solid var(--ink); padding: 17px 20px 20px; }
.day-head { display: flex; align-items: baseline; justify-content: space-between; color: var(--muted); font-size: 12px; }
.day-head #loop-label { color: var(--ink); font-weight: 700; }
.loop-hint { font-size: 11px; }
.side-panel h2 { margin: 19px 0 7px; font-size: 20px; letter-spacing: -.03em; }
.hint { margin: 0; min-height: 66px; color: #536165; font-size: 12px; line-height: 1.7; }
.tapes { margin-top: 16px; padding-top: 4px; border-top: 1px solid var(--line); }
.tape-title { display: flex; justify-content: space-between; margin: 10px 0 7px; font-size: 12px; }
.tape-title strong { color: var(--muted); font-size: 11px; font-weight: 500; }
.tape { display: grid; gap: 3px; min-height: 27px; }
.tape span { height: 27px; display: grid; place-items: center; background: #f0f2ee; color: #7a8585; font-size: 13px; font-weight: 700; }
.tape span.filled { background: #d2e2e2; color: #315a62; }
.tape.today span.filled { background: #f1d4c9; color: #99442d; }
.message { min-height: 43px; margin: 17px 0 8px; padding: 8px 0; border-top: 1px solid var(--line); color: #415659; font-size: 12px; line-height: 1.5; }
.actions { display: flex; gap: 8px; }
.actions button { min-height: 40px; border: 1px solid var(--ink); padding: 8px 12px; font-size: 12px; font-weight: 700; }
.actions #commit { flex: 1; background: var(--ink); color: #fff; }
.actions #reset { background: transparent; }
.actions button:disabled { opacity: .42; cursor: not-allowed; }
.input-area { margin-top: auto; padding-top: 20px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.controls { display: grid; grid-template-columns: repeat(3, 36px); grid-template-rows: repeat(3, 36px); gap: 3px; }
.controls button { border: 1px solid #a9b4b3; background: #f3f5f1; color: var(--ink); font-size: 18px; padding: 0; }
.controls button:active, .actions button:active { transform: translateY(1px); }
.controls button[data-move=up] { grid-column: 2; grid-row: 1; }
.controls button[data-move=left] { grid-column: 1; grid-row: 2; }
.controls button[data-move=wait] { grid-column: 2; grid-row: 2; font-size: 10px; }
.controls button[data-move=right] { grid-column: 3; grid-row: 2; }
.controls button[data-move=down] { grid-column: 2; grid-row: 3; }
.keys { margin: 0; color: #788483; font-size: 10px; line-height: 1.8; text-align: right; }
.modal { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 20px; background: #1d3036b8; }
.modal[hidden] { display: none; }
.modal-card { width: min(360px, 100%); padding: 27px; background: var(--surface); border: 1px solid var(--ink); text-align: center; }
.modal-card > span { display: block; color: var(--today); font-size: 38px; font-weight: 800; }
.modal-card h2 { margin: 6px 0; font-size: 23px; }
.modal-card p { font-size: 13px; line-height: 1.7; color: #536165; }
.modal-card button { margin-top: 8px; padding: 9px 18px; border: 0; background: var(--ink); color: #fff; font-weight: 700; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--today); outline-offset: 3px; }
@media (max-width: 820px) {
  .intro { align-items: start; }
  .intro p { max-width: 270px; }
  .game-layout { grid-template-columns: 1fr; }
  .side-panel { border-left: 0; border-top: 1px solid var(--ink); display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; }
  .day-head, .side-panel h2, .hint { grid-column: 1; }
  .tapes { grid-column: 2; grid-row: 1 / 4; margin-top: 0; }
  .message, .actions, .input-area { grid-column: 1 / 3; }
  .board-wrap { min-height: 0; }
}
@media (max-width: 560px) {
  .page { width: min(100% - 24px, 480px); }
  .site-head { height: 55px; }
  .site-name { margin-left: 0; font-size: 12px; }
  .intro { display: block; padding: 19px 0 16px; }
  .intro h1 { font-size: 30px; }
  .intro p { margin-top: 9px; font-size: 12px; }
  .board-wrap { padding: 10px; }
  .board { width: min(100%, 290px); }
  .level-bar { padding: 9px 12px; }
  .level-id { gap: 6px; }
  .level-id strong { font-size: 14px; }
  .turn-label { font-size: 10px; }
  .legend { gap: 11px; font-size: 10px; padding: 8px; }
  .side-panel { display: flex; padding: 16px; }
  .hint { min-height: 0; }
  .tapes { margin-top: 13px; }
  .message { order: -3; margin: 0 0 8px; border-top: 0; border-bottom: 1px solid var(--line); }
  .actions { order: -2; }
  .input-area { order: -1; justify-content: center; flex-direction: column; margin-top: 0; padding: 11px 0 17px; border-bottom: 1px solid var(--line); }
  .controls { grid-template-columns: repeat(3, 50px); grid-template-rows: repeat(3, 40px); }
  .keys { text-align: center; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; animation: none !important; } }
