/* KidCAD Arcade: the kidcad.xyz workbench at night (plum, dot grid, chunky pressed buttons), with a print-bed
   grid and blueprint cyan for the CAD parts. One fixed look for every visitor, like kidcad.xyz. */
:root {
  --bg: #1d1730; --paper: #2a2244; --paper-2: #342a55; --ink: #f7efe2; --muted: #b5a9cc; --line: #3d3460; --press: #140f24;
  --orange: #ff9a55; --green: #2fc884; --blue: #7b8fff; --purple: #a985ff; --yellow: #ffd24a; --red: #ff6b7a; --cyan: #5fd8ff;
  --display: "Nunito", "Varela Round", system-ui, sans-serif; --mono: "JetBrains Mono", ui-monospace, "DejaVu Sans Mono", monospace;
  --radius: 18px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { overflow-x: clip; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--display); font-size: 17px; line-height: 1.5; font-weight: 600;
  background-image: radial-gradient(var(--line) 1px, transparent 1px); background-size: 22px 22px; overflow-x: clip; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--bg); }
.wrap { max-width: 1240px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
h1, h2, h3 { margin: 0; font-weight: 900; line-height: 1.1; letter-spacing: -.01em; text-wrap: balance; }
h1 { font-size: clamp(30px, 4.6vw, 52px); } h2 { font-size: 26px; } h3 { font-size: 18px; }
p { margin: 0; }
a { color: var(--blue); }
:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; border-radius: 8px; }
.muted { color: var(--muted); } .small { font-size: 14px; }
.eyebrow { font-size: 13px; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; color: var(--orange); }
.lead { font-size: 20px; color: var(--muted); max-width: 58ch; }
.stack { display: grid; gap: 12px; align-content: start; min-width: 0; } .stack.tight { gap: 4px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; } .row.center { justify-content: center; }

header.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--bg); border-bottom: 2px solid var(--line); }
header.top .wrap { display: flex; align-items: center; gap: 10px 20px; flex-wrap: wrap; padding-block: 10px; }
.brand { display: flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; font-size: 24px; font-weight: 900; }
.brand b { color: var(--yellow); }
.brand .spk { width: 44px; height: 34px; }
nav.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
nav.tabs a { color: var(--ink); text-decoration: none; padding: 7px 14px; border-radius: 999px; border: 2px solid var(--line); background: var(--paper); box-shadow: 0 3px 0 var(--press); font-weight: 800; font-size: 15px; }
nav.tabs a.on { background: var(--blue); border-color: var(--blue); color: #12102a; }

.chip { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 8px 16px; border-radius: 999px;
  border: 2px solid var(--line); background: var(--paper); color: var(--ink); font: inherit; font-weight: 800; text-decoration: none; cursor: pointer;
  box-shadow: 0 3px 0 var(--press); transition: transform .08s, box-shadow .08s; }
.chip:hover { border-color: var(--purple); }
.chip:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--press); }
.chip.go { background: var(--green); border-color: var(--green); color: #082417; }
.chip.big { min-height: 54px; font-size: 19px; width: 100%; }
.chip.mini { min-height: 34px; padding: 4px 12px; font-size: 14px; }
.chip.check input { accent-color: var(--cyan); }
.chip.on { background: var(--blue); border-color: var(--blue); color: #12102a; }

main { padding-block: 28px 64px; }
.view { display: grid; gap: 22px; }
.panel { background: var(--paper); border: 2px solid var(--line); border-radius: var(--radius); box-shadow: 0 4px 0 var(--press); padding: 18px; }

/* Sparky */
.spk { display: inline-block; width: 64px; height: 50px; flex: none; }
.spk svg { width: 100%; height: 100%; display: block; }
.spk.big { width: 120px; height: 92px; }
.spk.bounce svg { animation: hop .5s ease 2; }
@keyframes hop { 50% { transform: translateY(-8px) rotate(-4deg); } }
.sparky-bar { display: flex; align-items: center; gap: 14px; background: #1f3a33; border: 2px solid #2c5a44; border-radius: var(--radius); padding: 10px 14px; box-shadow: 0 4px 0 var(--press); }
.sparky-bar { flex-wrap: wrap; }
.sparky-bar p { flex: 1 1 220px; min-width: 0; font-size: 18px; }
.sparky-bar p b { color: var(--yellow); }

/* arcade home */
.hello { display: flex; gap: 22px; align-items: center; flex-wrap: wrap; }
.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.game-card { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 18px; align-items: start; background: var(--paper); border: 2px solid var(--line);
  border-radius: var(--radius); box-shadow: 0 5px 0 var(--press); padding: 18px; color: var(--ink); text-decoration: none; }
.game-card:hover { border-color: var(--purple); transform: translateY(-2px); }
.game-card .chip { justify-self: start; }
.meta { font-size: 14px; color: var(--yellow); font-family: var(--mono); }
.art { aspect-ratio: 1; border-radius: 14px; background: #120e20; border: 2px solid var(--line); position: relative; overflow: hidden;
  background-image: linear-gradient(#2a2244 1px, transparent 1px), linear-gradient(90deg, #2a2244 1px, transparent 1px); background-size: 17px 17px; }
.art-build::before { content: ""; position: absolute; left: 24%; top: 34%; width: 52%; height: 32%; background: var(--orange); border-radius: 4px; box-shadow: 10px -10px 0 #ffb98a; }
.art-build span { position: absolute; font: 700 12px var(--mono); color: var(--cyan); }
.art-build span:nth-child(1) { left: 42%; top: 70%; } .art-build span:nth-child(2) { left: 82%; top: 36%; } .art-build span:nth-child(3) { left: 10%; top: 44%; }
.art-fix i { position: absolute; left: 22%; width: 56%; height: 9%; background: var(--green); border-radius: 3px; }
.art-fix i:nth-child(1) { bottom: 12%; } .art-fix i:nth-child(2) { bottom: 22%; } .art-fix i:nth-child(3) { bottom: 32%; } .art-fix i:nth-child(4) { bottom: 42%; width: 40%; left: 30%; }
.art-fix i:nth-child(5) { bottom: 52%; left: 28%; width: 46%; background: none; border-top: 3px dashed var(--red); height: 0; }

/* game header and level dots */
.game-head { display: flex; align-items: end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.levels { display: flex; gap: 6px; flex-wrap: wrap; }
.levels button { width: 44px; height: 44px; border-radius: 12px; border: 2px solid var(--line); background: var(--paper); color: var(--ink); font: 900 16px var(--display);
  box-shadow: 0 3px 0 var(--press); cursor: pointer; position: relative; }
.levels button.on { border-color: var(--yellow); }
.levels button.done::after { content: "★"; position: absolute; right: -4px; top: -8px; color: var(--yellow); font-size: 15px; }
.levels button:disabled { opacity: .4; cursor: not-allowed; }

/* Build It */
.build, .fix { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(300px, 1fr); gap: 18px; align-items: start; }
.stage { position: relative; background: #120e20; border: 2px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: 0 4px 0 var(--press); min-width: 0; }
#b-canvas { display: block; width: 100%; height: clamp(320px, 56vh, 560px); cursor: grab; touch-action: none; }
#b-canvas:active { cursor: grabbing; }
.stage-tools { position: absolute; top: 10px; left: 10px; display: flex; gap: 6px; flex-wrap: wrap; }
.legend { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 8px 12px; border-top: 2px solid var(--line); font-size: 13px; }
.ax { font: 700 12px var(--mono); padding: 2px 8px; border-radius: 6px; color: #12102a; }
.ax.x { background: #ff6b6b; } .ax.y { background: #5be38a; } .ax.z { background: #7b9bff; }
.side { display: grid; gap: 16px; }
.blueprint { background: #0f2238; border: 2px dashed #3b6b9a; border-radius: 12px; padding: 12px; display: grid; gap: 8px; overflow-x: auto; }
.blueprint h3 { color: var(--cyan); }
.blueprint table { border-collapse: collapse; font: 500 13.5px var(--mono); color: #cfefff; width: 100%; }
.blueprint td { padding: 4px 6px; border-bottom: 1px solid #23476b; vertical-align: top; }
.blueprint td:first-child { color: var(--cyan); font-weight: 700; white-space: nowrap; }
.parts { display: flex; gap: 6px; flex-wrap: wrap; }
.parts button { border-radius: 10px; padding: 6px 10px; border: 2px solid var(--line); background: var(--bg); color: var(--ink); font: 800 14px var(--display); cursor: pointer; }
.parts button.on { border-color: var(--orange); background: #3a2a2a; }
.parts button.cut { color: var(--red); }
.editor { display: grid; gap: 10px; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: 2px solid var(--line); border-radius: 12px; overflow: hidden; }
.seg button { border: 0; background: var(--bg); color: var(--ink); font: 800 14px var(--display); padding: 9px 6px; cursor: pointer; }
.seg button + button { border-left: 2px solid var(--line); }
.seg button.on { background: var(--orange); color: #241205; }
.slider { display: grid; grid-template-columns: minmax(0, 1fr) 76px; gap: 4px 10px; align-items: center; }
.slider label { grid-column: 1 / -1; display: flex; justify-content: space-between; font-size: 14px; }
.slider label small { color: var(--muted); font-weight: 600; }
.slider input[type=range] { width: 100%; accent-color: var(--orange); }
.slider input[type=number] { width: 76px; font: 700 15px var(--mono); background: var(--bg); color: var(--ink); border: 2px solid var(--line); border-radius: 8px; padding: 6px; }

/* Fix the Print */
.job { padding: 14px 16px; border-bottom: 2px solid var(--line); display: grid; gap: 6px; background: var(--paper); }
.job .req { display: flex; gap: 8px; flex-wrap: wrap; }
.job .req span { font: 700 13px var(--mono); padding: 3px 9px; border-radius: 999px; background: var(--bg); border: 1.5px solid var(--line); }
#f-canvas { display: block; width: 100%; height: clamp(260px, 44vh, 420px); }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 2px solid var(--line); }
.stats > div { padding: 10px 12px; display: grid; gap: 2px; }
.stats > div + div { border-left: 2px solid var(--line); }
.stats b { font: 700 18px var(--mono); }
.stats .bad { color: var(--red); } .stats .good { color: var(--green); }
.set { display: grid; gap: 4px; }
.set .seg button.on { background: var(--blue); color: #12102a; }
.set .why { font-size: 13px; color: var(--muted); }


/* Printer Care */
.care { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.care-stage .job { border-bottom: 2px solid var(--line); margin: 0; }
.printer-art { padding: 12px; }
.printer-art svg { width: 100%; height: auto; display: block; }
.tools { display: grid; gap: 8px; }
.card-step { text-align: left; border: 2px solid var(--line); background: var(--bg); color: var(--ink); font: 800 15px var(--display); padding: 10px 12px; border-radius: 12px;
  box-shadow: 0 3px 0 var(--press); cursor: pointer; }
.card-step:hover { border-color: var(--purple); }
.plan { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; counter-reset: st; min-height: 120px; }
.plan li { counter-increment: st; display: flex; justify-content: space-between; align-items: center; gap: 8px; border: 2px solid var(--line); border-radius: 12px; padding: 6px 8px 6px 10px; background: var(--bg); font-size: 15px; }
.plan li > span:first-child::before { content: counter(st) ". "; color: var(--yellow); font-family: var(--mono); }
.plan li.empty { color: var(--muted); border-style: dashed; counter-increment: none; }
.plan li.empty::before { content: none; }
.plan li.now { border-color: var(--green); }
.plan li.bad { border-color: var(--red); background: #3a1f2a; }
.plan .row { flex-wrap: nowrap; gap: 4px; } .plan .chip.mini { min-height: 30px; padding: 2px 9px; }
.art-care i { position: absolute; border-radius: 4px; }
.art-care i:nth-child(1) { left: 20%; top: 18%; width: 10%; height: 64%; background: #4a3f75; } .art-care i:nth-child(2) { left: 70%; top: 18%; width: 10%; height: 64%; background: #4a3f75; }
.art-care i:nth-child(3) { left: 24%; top: 70%; width: 52%; height: 7%; background: #9fe3ff; box-shadow: 0 -38px 0 -2px #ff9a55; }
@media (max-width: 1100px) { .care { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .care-stage { grid-column: 1 / -1; } .printer-art { max-width: 420px; margin: 0 auto; } }
@media (max-width: 640px) { .care { grid-template-columns: minmax(0, 1fr); } }

.rules { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 20px; align-items: start; background: #3a1f24; border: 3px solid #ff6b5a;
  border-radius: var(--radius); box-shadow: 0 5px 0 var(--press); padding: 22px; }
.rule-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; font-size: 17px; }
.rule-list li { background: rgb(0 0 0 / .18); border-radius: 12px; padding: 10px 14px; }
.rules .chip.big { max-width: 420px; }
@media (max-width: 640px) { .rules { grid-template-columns: minmax(0, 1fr); } }

.safety-note { background: #3a1f24; border: 2px solid #ff6b5a; border-radius: 14px; padding: 10px 14px; }

/* win */
.win { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; background: rgb(10 7 20 / .72);
  padding: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); }
.win-box { background: var(--paper); border: 3px solid var(--yellow); border-radius: 24px; box-shadow: 0 8px 0 var(--press); padding: 26px; max-width: 460px; width: 100%; display: grid; gap: 12px; justify-items: center; text-align: center; }
.stars { font-size: 44px; letter-spacing: 6px; color: var(--yellow); }
.stars .off { color: var(--line); }

@media (max-width: 900px) { .build, .fix { grid-template-columns: minmax(0, 1fr); } .cards { grid-template-columns: minmax(0, 1fr); } nav.tabs { margin-left: 0; } }
@media (max-width: 520px) { .game-card { grid-template-columns: minmax(0, 1fr); } .art { max-width: 160px; } .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats > div:nth-child(3) { border-left: 0; } .stats > div:nth-child(-n+2) { border-bottom: 2px solid var(--line); } .lead { font-size: 18px; } }
@media (prefers-reduced-motion: reduce) { .spk.bounce svg { animation: none; } .chip, .game-card { transition: none; } }
