:root {
  color-scheme: dark;
  --ink: #13151c;
  --panel: #20232a;
  --rim: #41454f;
  --paper: #f5f3ec;
  --dim: #c3c6cc;
  --accent: #b4eed1;
  --deep: #1b3533;
  --mono: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; color: var(--paper); background: var(--ink); font: 1rem/1.6 system-ui, "Yu Gothic", sans-serif; }
body.ghost { --accent: #c9b6ff; --deep: #342b49; }
body.cafe { --accent: #ffce96; --deep: #422f2b; }
.game-wrap { width: min(1120px, calc(100% - clamp(32px, 8vw, 112px))); margin: 0 auto; min-height: calc(100svh - 128px); padding: clamp(24px, 4vw, 54px) 0; }
.game-heading { margin-bottom: clamp(18px, 2.7vw, 32px); }
h1,h2,p,figure,ol { margin: 0; }
.game-heading h1 { font-size: clamp(2rem, 5.2vw, 3.9rem); line-height: 1.16; letter-spacing: -.055em; }
.game-heading h1 span { color: var(--accent); }
.game-heading p { margin-top: 10px; color: var(--dim); }
.workbench { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(290px, .9fr); gap: clamp(16px, 2.3vw, 30px); align-items: start; }
.monitor,.console,.review { border: 1px solid var(--rim); border-radius: 9px; background: var(--panel); box-shadow: 0 4px 0 #0c0e13; }
.monitor { overflow: hidden; }
.rail,.screen-foot,.panel-heading,.scoreline { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.rail { min-height: 43px; padding: 7px 15px; border-bottom: 2px solid var(--accent); background: var(--deep); font-size: .9rem; font-weight: 750; }
.rail > :last-child, .counter-size { font: 700 .87rem/1.5 var(--mono); color: var(--accent); }
.scene { display: block; width: 100%; height: auto; aspect-ratio: 2 / 1; object-fit: contain; background: #171d25; image-rendering: pixelated; }
.screen-foot { min-height: 58px; padding: 12px 16px; background: #191c22; border-top: 1px solid var(--rim); }
.screen-foot > span,.scoreline span,.stats span { color: var(--dim); font-size: .9rem; }
.screen-foot strong { text-align: right; }
.sample-pair { display: grid; grid-template-columns: 1fr 1fr; background: #172327; gap: 2px; }
.sample-pair figure { min-width: 0; text-align: center; }
.sample-pair canvas { width: 100%; display: block; aspect-ratio: 2/1; image-rendering: pixelated; }
.sample-pair figcaption { padding: 10px 5px; font-size: .9rem; background: #202c2c; }
.sample-pair strong { display: block; color: var(--accent); font: 750 1.1rem/1.6 var(--mono); }
.console,.review { padding: clamp(15px, 2.4vw, 27px); }
.console { display: grid; gap: 15px; }
.console h2,.review h2 { font-size: clamp(1.12rem, 2vw, 1.45rem); letter-spacing: -.03em; line-height: 1.4; }
.console > p:not(.feedback) { color: var(--dim); }
button { appearance: none; color: var(--paper); background: #2a2e37; border: 1px solid #555a66; border-radius: 5px; padding: 8px 12px; min-height: 44px; line-height: 1.4; font-family: inherit; font-size: 1rem; font-weight: 700; cursor: pointer; touch-action: manipulation; }
button:enabled:hover { border-color: var(--accent); }
button:focus-visible,summary:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
button:disabled { cursor: default; }
button.primary { background: var(--accent); color: #172329; border: 1px solid var(--accent); padding: 11px 16px; box-shadow: 0 3px 0 #0c1016; }
button.primary:hover:enabled { filter: brightness(1.08); }
button.primary:active:enabled { transform: translateY(2px); box-shadow: none; }
button.primary:disabled { background: #383d47; color: #b1b5bc; border-color: #4a505b; box-shadow: none; }
.choice-pair,.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.choice { min-height: 78px; line-height: 1.5; font-size: .88rem; }
.choice b { display: block; color: var(--accent); font: 800 1.3rem/1.4 var(--mono); }
.choice.correct { border: 2px solid #9be7b7; background: #253e34; }
.choice.wrong { border: 2px solid #f5a69a; background: #402c30; }
.feedback { background: #181b22; border-left: 3px solid var(--accent); padding: 10px 13px; color: var(--paper); font-size: .98rem; }
.scoreline,.stats { padding-top: 12px; border-top: 1px solid var(--rim); }
.scoreline strong,.stats strong { font: 750 1.1rem var(--mono); color: var(--accent); }
.marks { display: flex; gap: 5px; }
.marks i { flex: 1; text-align: center; border-radius: 2px; background: #363c45; height: 18px; font: 800 14px/18px var(--mono); }
.marks .right { background: #a6dfb4; color: #163122; }
.marks .miss { background: #f0aaa2; color: #392222; }
.review { margin-top: 20px; }
.review ul { padding-left: 1.4em; margin-bottom: 0; }
.review li + li { margin-top: 7px; }
.quiet { padding: 5px 9px; font-size: .86rem; }
.code-list { list-style:none; padding:0; border:1px solid var(--rim); background:#171a22; border-radius:6px; overflow:hidden; }
.code-list li { display:grid; grid-template-columns:2.7rem minmax(0,1fr) auto; gap:10px; align-items:center; padding:3px 8px; min-height:49px; }
.code-list li + li { border-top:1px solid #373a45; }
.code-list .line-number { font:700 .85rem var(--mono); color:var(--dim); }
.code-list li > div { display:grid; justify-items:start; }
.code-list button { font-size:.87rem; padding:5px 9px; background:#302d3d; border-color:#61576d; }
.code-list .old-command { color:var(--dim); font-size:.82rem; text-decoration:line-through; }
.code-list strong { color:#a2eed0; }
.code-list li.changed { border-left:3px solid #a2eed0; background:#202f30; }
.code-list li.executing { box-shadow:inset 0 0 0 2px #f5cf83; }
.ghost-playback { display:flex; flex-wrap:wrap; align-items:center; gap:6px 14px; padding:10px 16px 0; }
.ghost-playback span { font-size:.94rem; color:var(--accent); }
.ghost dialog { width:min(380px,calc(100% - 32px)); padding:22px; color:var(--paper); background:var(--panel); border:2px solid #9785b2; border-radius:8px; box-shadow:0 16px 60px #0009; }
.ghost dialog::backdrop { background:#0b0d17c9; }
.ghost dialog h2 { margin:0 0 5px; font-size:1.35rem; }
.ghost dialog > p { color:var(--dim); }
.replacement { margin:16px 0; padding:0; border:none; }
.replacement legend { margin-bottom:8px; color:var(--accent); font-weight:700; }
.replacement div { display:grid; grid-template-columns:1fr 1fr; gap:8px; }
.replacement button:disabled { border-style:dashed; color:var(--dim); background:var(--ink); font-weight:500; }
#edit-note { margin-bottom:12px; }
.legend { justify-content: center; flex-wrap: wrap; gap: 8px 18px; }
.legend i { display: inline-block; width: 10px; height: 10px; margin-right: 6px; }
.robot-key { background: #9dffde; }
.ghost-key { background: #bba2f8; }
.goal-key { background: #ffd487; }
.board-text { padding: 9px 16px; color: var(--dim); font-size: .88rem; }
.board-text summary { cursor: pointer; }
.board-text pre { white-space: pre-wrap; line-height: 1.7; }
.order-ticket strong { color:var(--accent); font-size:1.22rem; }
.memo-book { border-radius:5px; padding:12px; color:#3e302b; border-left:5px solid #a97c63; background:repeating-linear-gradient(#fff0cf 0 24px,#e5d2b7 24px 25px); }
.memo-book p { padding:10px 3px; }
.memo-book ul { list-style:none; display:flex; flex-wrap:wrap; gap:7px; margin:0; padding:0; }
.memo-book li { background:#fffae9; border:1px solid #b69b7b; border-radius:3px; display:inline-flex; align-items:center; gap:4px; padding:4px 7px; font-size:.88rem; font-weight:700; }
.memo-book canvas { width:26px; height:26px; image-rendering:pixelated; }
.memo-book li.active-memo { border:2px solid #4a7365; background:#f2ffeb; }
.memo-book small { color:#315b49; }
.console h3 { font-size:1.12rem; margin:0; line-height:1.45; }
.receipt { background:#2d342e; border-left:3px solid #aed4a8; padding:10px 13px; }
.receipt > strong { color:#c2edbd; }
.receipt p { margin-top:3px; }
.stats strong,.stats span { display:block; }
.stats strong { margin-top:5px; }
.comparison figcaption { border-bottom:1px solid var(--rim); color:var(--dim); font-weight:700; }
.comparison figure:last-child figcaption { background:var(--deep); color:var(--accent); }
.sample-pair canvas { object-fit:cover; height:auto; }
@media (max-width: 780px) {
  .workbench { grid-template-columns: 1fr; gap: 14px; }
  .game-wrap { max-width: 620px; }
  .console { gap: 11px; }
}
@media (max-width: 440px) {
  .game-wrap { width: calc(100% - 24px); padding-top: 19px; }
  .rail,.screen-foot { padding-inline: 11px; }
  .screen-foot { min-height: 46px; }
  .console { padding: 13px; }
  .sample-pair figcaption { font-size: .8rem; }
  .inspection .sample-pair canvas { aspect-ratio: 1.45; }
  .code-list li { gap:6px; }
  .memo-book { padding:8px; }
  .cafe .game-heading { margin-bottom:12px; }
  .cafe #shop { max-height:145px; object-fit:cover; }
}

