:root {
  color-scheme: dark;
  --bg: #0d100d;
  --panel: #151a16;
  --panel-2: #1a201b;
  --line: #2a322b;
  --ink: #f4f0df;
  --muted: #92988e;
  --acid: #d8ff65;
  --blue: #68c9ff;
  --amber: #ffb45e;
  --danger: #ff716b;
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 8%, rgba(216, 255, 101, 0.055), transparent 28rem),
    radial-gradient(circle at 88% 74%, rgba(104, 201, 255, 0.05), transparent 32rem),
    var(--bg);
}
body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  content: "";
  opacity: 0.12;
  background-image: linear-gradient(#8f9b8b 1px, transparent 1px), linear-gradient(90deg, #8f9b8b 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(black, transparent 84%);
}
button { color: inherit; font: inherit; }
button:focus-visible, canvas:focus-visible { outline: 2px solid var(--acid); outline-offset: 3px; }

.shell { width: min(1180px, calc(100% - 40px)); margin: auto; padding: 24px 0 18px; }
.topbar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; min-height: 62px; }
.brand { display: flex; gap: 12px; align-items: center; width: fit-content; color: inherit; text-decoration: none; }
.brand-icon { position: relative; width: 40px; height: 40px; border: 1px solid #495347; border-radius: 11px; transform: rotate(45deg); }
.brand-icon::before, .brand-icon::after, .brand-icon i { position: absolute; content: ""; background: var(--acid); border-radius: 50%; }
.brand-icon::before { top: 7px; left: 7px; width: 7px; height: 7px; }
.brand-icon::after { right: 7px; bottom: 7px; width: 7px; height: 7px; }
.brand-icon i:first-child { top: 11px; left: 12px; width: 16px; height: 2px; transform: rotate(45deg); transform-origin: left; }
.brand-icon i:last-child { right: 12px; bottom: 11px; width: 16px; height: 2px; transform: rotate(45deg); transform-origin: right; }
.brand b, .brand small { display: block; }
.brand b { letter-spacing: -0.03em; }
.brand small { margin-top: 3px; color: var(--muted); font: 600 8px/1.2 ui-monospace, monospace; letter-spacing: 0.12em; text-transform: uppercase; }
.level-title { text-align: center; }
.level-title span, .eyebrow { color: var(--acid); font: 700 9px/1.3 ui-monospace, monospace; letter-spacing: 0.14em; text-transform: uppercase; }
.level-title strong { display: block; margin-top: 6px; font-size: 14px; }
.level-title small { display: block; margin-top: 3px; color: var(--muted); font-size: 9px; }
.icon-button { justify-self: end; padding: 10px 15px; color: #c3c8be; background: transparent; border: 1px solid var(--line); border-radius: 9px; cursor: pointer; }
.icon-button:hover { border-color: #5c6859; }

.intro-line { display: flex; align-items: end; justify-content: space-between; gap: 40px; padding: 38px 4px 24px; }
.intro-line h1 { margin: 8px 0 0; font-size: clamp(29px, 4vw, 47px); line-height: 1; letter-spacing: -0.05em; }
.intro-line > p { max-width: 380px; margin: 0; color: #aab0a7; font-size: 13px; line-height: 1.6; }

.workspace { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(360px, 0.85fr); gap: 16px; min-width: 0; }
.board-card, .program-card { background: rgba(21, 26, 22, 0.94); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 22px 60px rgba(0, 0, 0, 0.22); }
.board-card { min-width: 0; overflow: hidden; }
.board-head { display: grid; grid-template-columns: auto 1fr auto; gap: 11px; align-items: center; min-height: 68px; padding: 13px 18px; border-bottom: 1px solid var(--line); }
.board-head small, .tick-label span { display: block; color: var(--muted); font: 600 8px ui-monospace, monospace; letter-spacing: 0.14em; text-transform: uppercase; }
.board-head strong { display: block; margin-top: 4px; font-size: 13px; }
.status-dot { width: 10px; height: 10px; background: #687168; border-radius: 50%; box-shadow: 0 0 0 5px rgba(104, 113, 104, 0.1); }
.status-dot.running { background: var(--acid); box-shadow: 0 0 14px rgba(216, 255, 101, 0.6); }
.status-dot.failed { background: var(--danger); box-shadow: 0 0 14px rgba(255, 113, 107, 0.5); }
.status-dot.solved { background: var(--blue); box-shadow: 0 0 14px rgba(104, 201, 255, 0.5); }
.tick-label { min-width: 45px; text-align: right; }
.tick-label b { display: block; margin-top: 3px; font: 600 13px ui-monospace, monospace; }
.objective-card { display: grid; grid-template-columns: auto repeat(3, 1fr); gap: 14px; align-items: center; padding: 11px 18px; color: #aeb5aa; background: #121713; border-bottom: 1px solid var(--line); font-size: 9px; }
.objective-card strong { color: var(--ink); font: 700 9px ui-monospace, monospace; letter-spacing: 0.08em; text-transform: uppercase; }
.objective-card span { display: flex; gap: 7px; align-items: center; }
.objective-card i { display: inline-grid; place-items: center; flex: 0 0 auto; width: 20px; height: 20px; color: var(--acid); font: 700 8px ui-monospace, monospace; font-style: normal; }
.objective-dock { border: 1px dashed var(--blue); border-radius: 4px; }
.objective-arrow { color: var(--amber) !important; }
.objective-tick { background: #283027; border-radius: 50%; }
.canvas-wrap { position: relative; min-width: 0; overflow: hidden; aspect-ratio: 1.35 / 1; min-height: 430px; background: #111512; }
canvas { display: block; width: 100%; max-width: 100%; height: 100%; }
.collision-callout { position: absolute; right: 16px; bottom: 16px; max-width: 240px; padding: 12px 14px; background: rgba(53, 20, 18, 0.92); border: 1px solid rgba(255, 113, 107, 0.45); border-radius: 10px; }
.collision-callout b, .collision-callout span { display: block; }
.collision-callout b { color: var(--danger); font-size: 12px; }
.collision-callout span { margin-top: 3px; color: #d5aaa6; font-size: 10px; }
.timeline { display: grid; grid-template-columns: repeat(8, 1fr); gap: 5px; padding: 14px 18px 4px; }
.timeline i { position: relative; height: 5px; background: #2a322b; border-radius: 4px; }
.timeline i.past { background: #75816f; }
.timeline i.current { background: var(--acid); box-shadow: 0 0 10px rgba(216, 255, 101, 0.35); }
.timeline i:nth-child(4)::after { position: absolute; right: -3px; top: -4px; width: 1px; height: 13px; content: ""; background: #586255; }
.board-controls { display: grid; grid-template-columns: 1fr 1.8fr; gap: 9px; padding: 14px 18px 18px; }
.secondary-button, .run-button { min-height: 47px; border-radius: 10px; cursor: pointer; }
.secondary-button { color: #c3c9bf; background: #1b211c; border: 1px solid #333d34; }
.run-button { display: inline-flex; gap: 10px; align-items: center; justify-content: center; color: #10140d; font-weight: 750; background: var(--acid); border: 0; }
.run-button:hover { background: #e5ff93; }

.program-card { padding: 22px; }
.program-head { display: flex; align-items: start; justify-content: space-between; }
.program-head h2 { margin: 6px 0 0; font-size: 23px; letter-spacing: -0.04em; }
.par-chip { padding: 8px 10px; color: #9ca298; font: 600 9px ui-monospace, monospace; background: #111512; border: 1px solid var(--line); border-radius: 8px; text-transform: uppercase; }
.par-chip b { color: var(--acid); }
.instruction-key { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; margin: 20px 0; padding: 12px; color: var(--muted); font-size: 9px; background: #111512; border-radius: 9px; }
.instruction-key b { display: inline-grid; place-items: center; width: 18px; height: 18px; margin-right: 4px; color: var(--ink); font: 700 9px ui-monospace, monospace; background: #242b25; border-radius: 4px; }
.robot-program { padding: 15px 0; border-top: 1px solid var(--line); }
.robot-label { display: flex; gap: 10px; align-items: center; margin-bottom: 11px; }
.robot-swatch { display: grid; place-items: center; width: 29px; height: 29px; color: #0d1110; font: 800 11px ui-monospace, monospace; border-radius: 7px; }
.robot-a .robot-swatch { background: var(--blue); }
.robot-b .robot-swatch { background: var(--amber); }
.robot-label b, .robot-label small { display: block; }
.robot-label b { font-size: 12px; }
.robot-label small { margin-top: 2px; color: var(--muted); font-size: 9px; }
.slots { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; }
.slot { position: relative; display: grid; place-items: center; min-height: 66px; padding: 9px 4px 6px; color: var(--ink); background: #111512; border: 1px solid #303831; border-radius: 9px; cursor: pointer; }
.slot:hover { border-color: #667060; }
.slot.active { border-color: var(--acid); box-shadow: inset 0 0 0 1px rgba(216, 255, 101, 0.2); }
.slot small { position: absolute; top: 6px; left: 7px; color: #5f675f; font: 600 7px ui-monospace, monospace; }
.slot b { font: 700 20px ui-monospace, monospace; }
.slot span { color: var(--muted); font-size: 8px; }
.program-help { margin-top: 8px; padding: 12px 13px; background: rgba(216, 255, 101, 0.045); border-left: 2px solid #7b8c4c; }
.program-help p { margin: 0; color: #979e94; font-size: 10px; line-height: 1.5; }
.program-help p + p { margin-top: 3px; }
.program-help b { color: #cfd7c7; }
.aside-actions { display: flex; align-items: center; justify-content: space-between; margin-top: 16px; }
.text-button { padding: 0; color: var(--acid); font-size: 10px; background: none; border: 0; cursor: pointer; }
.aside-actions span { color: #6f776e; font: 8px ui-monospace, monospace; text-transform: uppercase; }

.result-panel { display: grid; grid-template-columns: auto 1fr auto; gap: 15px; align-items: center; margin-top: 14px; padding: 15px 18px; background: #182019; border: 1px solid #374638; border-radius: 14px; }
.result-panel[hidden] { display: none; }
.result-mark { display: grid; place-items: center; width: 42px; height: 42px; color: #0d110a; font-weight: 800; background: var(--acid); border-radius: 10px; }
.result-panel small { color: var(--acid); font: 700 8px ui-monospace, monospace; letter-spacing: 0.12em; text-transform: uppercase; }
.result-panel h2 { margin: 4px 0 0; font-size: 16px; }
.result-panel .run-button { min-height: 40px; padding: 0 18px; }
.playtest-panel { margin-top: 14px; padding: 24px; background: #182019; border: 1px solid #425442; border-radius: 14px; }
.playtest-panel[hidden] { display: none; }
.playtest-copy h2 { margin: 7px 0 6px; font-size: 23px; }
.playtest-copy > p:last-child { max-width: 720px; margin: 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.playtest-metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 18px 0; }
.playtest-metrics span { padding: 12px; color: var(--muted); font-size: 10px; background: #111512; border: 1px solid var(--line); border-radius: 8px; }
.playtest-metrics b { display: block; margin-bottom: 4px; color: var(--ink); font-size: 18px; }
.feedback-question { display: flex; flex-wrap: wrap; gap: 7px; margin: 13px 0 0; padding: 0; border: 0; }
.feedback-question legend { width: 100%; margin-bottom: 4px; color: #cfd7c7; font-size: 11px; font-weight: 700; }
.feedback-question button { min-height: 34px; padding: 0 12px; color: #aeb5aa; background: #111512; border: 1px solid #303831; border-radius: 8px; cursor: pointer; }
.feedback-question button.selected { color: #10140d; background: var(--acid); border-color: var(--acid); }
.report-output-label { display: block; margin-top: 18px; color: var(--muted); font: 700 8px ui-monospace, monospace; letter-spacing: 0.1em; text-transform: uppercase; }
.report-output { width: 100%; margin-top: 7px; padding: 12px; resize: vertical; color: #cfd7c7; font: 10px/1.45 ui-monospace, monospace; background: #0e120f; border: 1px solid var(--line); border-radius: 8px; }
.playtest-actions { display: flex; gap: 12px; align-items: center; margin-top: 10px; }
.playtest-actions .secondary-button { min-height: 38px; padding: 0 14px; }
.playtest-actions span { color: var(--muted); font-size: 9px; }
footer { display: flex; justify-content: space-between; padding: 18px 4px 0; color: #5f675e; font: 600 8px ui-monospace, monospace; letter-spacing: 0.08em; text-transform: uppercase; }

@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; }
  .program-card { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
  .program-head, .instruction-key, .program-help, .aside-actions { grid-column: 1 / -1; }
}

@media (max-width: 600px) {
  .shell { width: calc(100% - 20px); padding-top: 10px; }
  .topbar { grid-template-columns: 1fr auto; }
  .level-title { grid-column: 1 / -1; grid-row: 2; margin-top: 13px; }
  .icon-button { grid-column: 2; grid-row: 1; }
  .intro-line { display: block; padding: 27px 3px 18px; }
  .intro-line h1 { font-size: 34px; }
  .intro-line > p { margin-top: 14px; }
  .objective-card { grid-template-columns: 1fr; gap: 8px; padding: 13px 17px; }
  .objective-card strong { margin-bottom: 2px; }
  .canvas-wrap { height: 350px; min-height: 0; aspect-ratio: auto; }
  .program-card { display: block; padding: 17px; }
  .result-panel { grid-template-columns: auto 1fr; }
  .result-panel .run-button { grid-column: 1 / -1; }
  .playtest-metrics { grid-template-columns: 1fr 1fr; }
  .playtest-actions { align-items: stretch; flex-direction: column; }
  footer { gap: 12px; font-size: 7px; }
}
