:root {
  color-scheme: light;
  --bg: #f7f4e9;
  --bg-dot: #e6e0cf;
  --surface: #fffdf4;
  --surface-soft: #f1ecdf;
  --border: #d5d1c5;
  --border-strong: #a39d90;
  --ink: #34313e;
  --muted: #67616e;
  --soft: #736d7a;
  --lavender: #ded4f1;
  --lavender-edge: #b6a3d2;
  --lavender-deep: #6f5a9a;
  --mint: #c5e7d8;
  --mint-edge: #8ab7a3;
  --coral: #ffb7a5;
  --coral-edge: #d28f7f;
  --focus: #b11f4b;
  --commit-1: #c8ecd2;
  --commit-2: #92d6a8;
  --commit-3: #5fb884;
  --commit-4: #3d8f62;
  --conflict: #c9c2d4;
  --floor: #fffdf4;
  --floor-dot: #e4dccb;
  --ball: #7a62b8;
  --panel: rgba(255, 253, 244, 0.92);
  --shadow: 0 16px 40px rgba(52, 49, 62, 0.12);
}
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #25232f;
  --bg-dot: #312e3c;
  --surface: #302d3c;
  --surface-soft: #3a3647;
  --border: #514b62;
  --border-strong: #7d7591;
  --ink: #f4efe2;
  --muted: #c9c1d6;
  --soft: #b9b1c6;
  --lavender: #5c4f7a;
  --lavender-edge: #9c89c4;
  --lavender-deep: #cbbcf0;
  --mint: #3f6a5a;
  --mint-edge: #8fcfb4;
  --coral: #8a5448;
  --coral-edge: #ffb7a5;
  --focus: #fd8ea1;
  --commit-1: #3d6b52;
  --commit-2: #4f9a6c;
  --commit-3: #72c58f;
  --commit-4: #a9e8bd;
  --conflict: #6a6180;
  --floor: #3b3645;
  --floor-dot: #4a4456;
  --ball: #d8cbff;
  --panel: rgba(48, 45, 60, 0.94);
  --shadow: 0 16px 40px rgba(10, 8, 16, 0.4);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--bg) radial-gradient(var(--bg-dot) 1px, transparent 1.4px) 0 0 / 22px 22px;
  font-family: "Mona Sans", "Segoe UI", -apple-system, BlinkMacSystemFont, Aptos, sans-serif;
  overflow-x: hidden;
}
[hidden] { display: none !important; }
button { font: inherit; color: var(--ink); background: var(--surface); border: 2px solid var(--ink); border-radius: 10px; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:hover:not(:disabled) { background: var(--lavender); }
button:disabled { opacity: 0.5; cursor: default; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.stage:focus-visible { outline: 3px solid var(--lavender-deep); outline-offset: -3px; }
kbd { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; padding: 0 5px; border: 1.5px solid var(--ink); border-bottom-width: 3px; border-radius: 6px; background: var(--surface); font: 700 11px ui-monospace, Consolas, monospace; color: var(--ink); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.eyebrow, .label { font: 700 10px/1.2 ui-monospace, Consolas, "Courier New", monospace; letter-spacing: 1.4px; color: var(--soft); margin: 0; }

.app { max-width: 1180px; margin: 0 auto; padding: 0 24px 20px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 64px; border-bottom: 2px solid var(--border); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 750; font-size: 18px; letter-spacing: -0.4px; }
.brand svg { width: 28px; height: 28px; }
.brand-sub { font-weight: 400; color: var(--muted); }
.top-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.chip { padding: 6px 11px; font-size: 12px; font-weight: 650; border-width: 1.5px; background: var(--surface); }
.chip[aria-pressed="false"]:is(#music, #sound) { color: var(--muted); border-style: dashed; }
.chip.round { width: 32px; padding: 6px 0; }

.heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin: 18px 0 14px; }
h1 { margin: 6px 0 0; font-size: clamp(28px, 4vw, 44px); line-height: 1.05; letter-spacing: -1.6px; font-weight: 800; }
h1 span { color: var(--lavender-deep); }
.edition { margin-left: 10px; padding: 3px 7px; vertical-align: middle; font: 700 11px ui-monospace, monospace; letter-spacing: 0; color: var(--ink); background: var(--mint); border: 1.5px solid var(--ink); border-radius: 6px; }
.controls-hint { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.controls-hint span { margin-right: 6px; }

.game-shell { background: var(--surface); border: 2px solid var(--ink); border-radius: 18px; overflow: hidden; box-shadow: var(--shadow); }
.game-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 12px 18px; border-bottom: 2px solid var(--ink); background: var(--surface-soft); flex-wrap: wrap; }
.repo { display: flex; align-items: center; gap: 10px; min-width: 0; }
.repo strong { display: block; font-size: 15px; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.branch-icon { font-size: 26px; color: var(--lavender-deep); }
.branch-tag { font: 11px ui-monospace, monospace; padding: 3px 7px; border-radius: 6px; border: 1.5px solid var(--mint-edge); background: var(--mint); color: var(--ink); white-space: nowrap; max-width: 200px; overflow: hidden; text-overflow: ellipsis; }
.scoreboard { display: flex; gap: 26px; }
.scoreboard strong { display: block; margin-top: 3px; font: 700 20px ui-monospace, Consolas, monospace; letter-spacing: 1px; }
.scoreboard .lives { color: var(--coral-edge); letter-spacing: 2px; }

.stage { position: relative; height: clamp(400px, 66vh, 640px); background: var(--bg); overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
#scene { display: block; width: 100%; height: 100%; cursor: none; }
.stage[data-status="ready"] #scene, .stage[data-status="paused"] #scene, .stage[data-status="over"] #scene { cursor: default; }
.stage-buttons { position: absolute; top: 12px; right: 12px; display: flex; gap: 6px; z-index: 2; }
.stage-buttons button { height: 34px; min-width: 34px; padding: 0 10px; font-size: 13px; font-weight: 650; background: var(--panel); border-width: 1.5px; }
.serve-hint { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 1; padding: 7px 12px; border: 1.5px solid var(--ink); border-radius: 999px; background: var(--panel); font-size: 12px; font-weight: 600; white-space: nowrap; pointer-events: none; }
.message { position: absolute; inset: 0; margin: auto; z-index: 3; width: min(360px, calc(100% - 32px)); height: fit-content; padding: 22px; text-align: left; background: var(--panel); border: 2px solid var(--ink); border-radius: 16px; box-shadow: var(--shadow); }
.message h2 { margin: 8px 0 8px; font-size: 26px; line-height: 1.1; letter-spacing: -0.8px; }
.message p:not(.eyebrow) { margin: 0 0 16px; font-size: 14px; line-height: 1.5; color: var(--muted); }
.primary { display: inline-flex; align-items: center; justify-content: space-between; gap: 28px; padding: 11px 16px; font-weight: 700; font-size: 14px; background: var(--lavender); }
.primary:hover:not(:disabled) { background: var(--mint); }
.error-notice { position: absolute; inset: 20px; margin: auto; height: fit-content; max-width: 420px; padding: 18px; background: var(--panel); border: 2px solid var(--coral-edge); border-radius: 14px; z-index: 4; font-size: 14px; line-height: 1.5; }

.effects { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 16px; border-top: 2px solid var(--ink); }
.effect { display: inline-flex; align-items: center; gap: 7px; padding: 5px 9px; border: 1.5px dashed var(--border-strong); border-radius: 9px; font-size: 12px; font-weight: 650; color: var(--muted); }
.effect small { font-weight: 400; }
.effect b { font: 700 11px ui-monospace, monospace; min-width: 32px; text-align: right; }
.effect i { width: 12px; height: 12px; border: 1.5px solid var(--ink); border-radius: 4px; }
.effect[data-type="copilot"] i, .swatch.copilot { background: var(--lavender); }
.effect[data-type="dependabot"] i, .swatch.dependabot { background: var(--mint); }
.effect[data-type="actions"] i, .swatch.actions { background: var(--coral); }
.effect[data-type="regression"] i, .swatch.bug { background: var(--coral-edge); border-radius: 50%; }
.effect[data-active="true"] { color: var(--ink); border-style: solid; border-color: var(--ink); background: var(--surface-soft); }

.progress-row { display: flex; align-items: center; gap: 14px; padding: 10px 16px; border-top: 2px solid var(--border); font-size: 13px; color: var(--muted); }
.progress-row b { color: var(--ink); }
.live-dot { display: inline-block; width: 8px; height: 8px; margin-right: 8px; border-radius: 50%; background: var(--commit-3); border: 1.5px solid var(--ink); vertical-align: -1px; }
.progress-track { flex: 1; height: 10px; border: 1.5px solid var(--ink); border-radius: 999px; overflow: hidden; background: var(--surface-soft); }
.progress-track i { display: block; height: 100%; width: 0; background: var(--commit-3); }
#percentage { font: 700 12px ui-monospace, monospace; color: var(--ink); min-width: 38px; text-align: right; }

.legend { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; margin: 14px 2px; font-size: 12px; color: var(--muted); }
.legend-title { font: 700 10px ui-monospace, monospace; letter-spacing: 1.4px; color: var(--soft); }
.legend span { display: inline-flex; align-items: center; gap: 4px; }
.swatch { display: inline-block; width: 12px; height: 12px; border: 1.5px solid var(--ink); border-radius: 3px; }
.swatch.c1 { background: var(--commit-1); } .swatch.c2 { background: var(--commit-2); }
.swatch.c3 { background: var(--commit-3); } .swatch.c4 { background: var(--commit-4); }
.swatch.conflict { background: repeating-linear-gradient(45deg, var(--conflict) 0 3px, var(--surface) 3px 6px); }
footer { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-top: 12px; border-top: 2px solid var(--border); font: 10px ui-monospace, monospace; letter-spacing: 1px; color: var(--soft); }

dialog { width: min(560px, calc(100% - 24px)); max-height: min(460px, calc(100% - 24px)); margin: 12px auto auto; overflow: auto; overscroll-behavior: contain; padding: 24px; color: var(--ink); background: var(--surface); border: 2px solid var(--ink); border-radius: 18px; box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(37, 35, 47, 0.45); }
dialog h2 { margin: 6px 0 10px; font-size: 26px; letter-spacing: -0.8px; }
dialog h3 { margin: 16px 0 6px; font-size: 15px; }
dialog p, dialog li { font-size: 14px; line-height: 1.55; color: var(--muted); }
dialog b { color: var(--ink); }
.dialog-close { position: sticky; float: right; margin: -10px -10px 0 0; top: 0; width: 32px; height: 32px; font-size: 18px; line-height: 1; border-width: 1.5px; }
.help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.help-grid > div { padding: 2px 14px; border: 1.5px solid var(--border); border-radius: 12px; }
.help-list { padding-left: 0; list-style: none; }
.help-list li { margin: 6px 0; }
#got-it { position: sticky; bottom: 0; box-shadow: 0 -10px 0 var(--surface); }
.help-list .swatch { margin-right: 6px; vertical-align: -1px; }

@media (max-width: 760px) {
  .app { padding: 0 10px 14px; }
  .topbar { min-height: 54px; }
  .brand { font-size: 16px; }
  .brand-sub { display: none; }
  .brand > span { display: none; }
  .controls-hint { display: none; }
  .heading { margin: 12px 0 10px; }
  .game-toolbar { padding: 10px 12px; gap: 10px; }
  .scoreboard { gap: 14px; width: 100%; justify-content: space-between; }
  .scoreboard strong { font-size: 16px; }
  .stage { height: clamp(380px, 118vw, 560px); }
  .effects { padding: 8px 10px; gap: 6px; }
  .effect small { display: none; }
  .progress-row { padding: 8px 10px; font-size: 12px; }
  .help-grid { grid-template-columns: 1fr; }
  footer span:last-child { display: none; }
}
@media (max-width: 360px) {
  .chip { padding: 5px 8px; font-size: 11px; }
  .repo strong { font-size: 14px; }
  .branch-tag { max-width: 120px; }
  .message { padding: 16px; }
  .message h2 { font-size: 22px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
