/* Game kit F – "bugjagd" (Bug-Jagd): real code with line numbers, a preview/console with the symptom, tap the faulty line, pick the fix.
   The editor and the console are always dark (like a real code editor); the preview page is a light "browser" page in every theme.
   Everything is scoped under .gk-bugjagd. Horizontal overflow stays INSIDE the editor (.bj-scroll), never the page. */
.gk-bugjagd{--bj-ed:#0B1D24;--bj-ed-2:#0F2830;--bj-edge:#21495A;--bj-ink:#D4E6EA;--bj-ln:#5F8590;--bj-bug:#FF8A6B;--bj-ok:#C9F27A;
  --bj-k:#C9F27A;--bj-s:#FFC94A;--bj-c:#6F96A1;--bj-n:#FF9E80;--bj-f:#8FD3F4;--bj-p:#CFE3E8;--bj-a:#B7E38A;--bj-g:#8FD3F4;--bj-o:#9DB7BF;
  --bj-fs:14px;--bj-lh:34px}
.gk-bugjagd.young{--bj-fs:17px;--bj-lh:46px}
@media (pointer:coarse){.gk-bugjagd{--bj-lh:44px}.gk-bugjagd.young{--bj-lh:48px}}

/* progress dots: one per bug */
.gk-bugjagd .bj-dots{list-style:none;margin:0;padding:0;display:flex;gap:8px;flex-wrap:wrap}
.gk-bugjagd .bj-dots li{width:34px;height:34px;border-radius:10px;display:grid;place-items:center;font:800 14px/1 var(--mono);background:var(--soft);color:var(--muted);border:2px solid var(--line-2)}
.gk-bugjagd .bj-dots li.on{border-color:var(--sky);color:var(--ink);box-shadow:0 0 0 3px color-mix(in srgb,var(--sky) 25%,transparent)}
.gk-bugjagd .bj-dots li.done{background:var(--surface);color:var(--ink-2)}
.gk-bugjagd .bj-dots li.star{background:var(--sun);border-color:var(--sun-shadow);color:var(--sun-ink)}

/* layout: phone = stacked (preview → editor → card); wide = editor left, preview + card right */
.gk-bugjagd .bj-play{display:grid;gap:14px;min-width:0;grid-template-columns:minmax(0,1fr)}
.gk-bugjagd .bj-play>*{min-width:0}
@media (min-width:1000px){
  .gk-bugjagd .bj-play{grid-template-columns:minmax(0,1.35fr) minmax(300px,1fr);grid-template-areas:"ed pv" "ed card";align-items:start}
  .gk-bugjagd .bj-ed{grid-area:ed}
  .gk-bugjagd .bj-pv{grid-area:pv}
  .gk-bugjagd .bj-card{grid-area:card}
}

/* ---------- the editor ---------- */
.gk-bugjagd .bj-ed{background:var(--bj-ed);color:var(--bj-ink);border:1px solid var(--bj-edge);border-radius:14px;overflow:hidden;box-shadow:0 12px 30px rgba(0,0,0,.28)}
.gk-bugjagd .bj-ed-h{display:flex;align-items:center;gap:10px;padding:9px 12px;background:var(--bj-ed-2);border-bottom:1px solid var(--bj-edge);font:700 13px/1.2 var(--mono)}
.gk-bugjagd .bj-win{display:flex;gap:5px;flex:none}
.gk-bugjagd .bj-win i{width:9px;height:9px;border-radius:50%;background:#2F6175;display:block}
.gk-bugjagd .bj-file{color:#fff;background:var(--bj-ed);border:1px solid var(--bj-edge);border-bottom-color:var(--bj-ed);border-radius:7px 7px 0 0;padding:5px 10px;margin:-9px 0 -10px;line-height:1.5;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.gk-bugjagd .bj-st{margin-left:auto;font-size:11.5px;color:var(--bj-bug);border:1px solid currentColor;border-radius:6px;padding:2px 7px;white-space:nowrap}
.gk-bugjagd[data-ph="done"] .bj-st{color:var(--bj-ok)}
.gk-bugjagd .bj-scroll{overflow-x:auto;overscroll-behavior-x:contain;-webkit-overflow-scrolling:touch;padding:8px 0;scrollbar-width:thin;scrollbar-color:#2F6175 transparent}
.gk-bugjagd .bj-line{display:flex;align-items:center;min-width:100%;width:max-content;min-height:var(--bj-lh);margin:0;padding:0 14px 0 0;border:0;background:none;color:inherit;text-align:left;font:500 var(--bj-fs)/1.5 var(--mono);border-radius:0;cursor:default;position:relative;-webkit-tap-highlight-color:transparent}
.gk-bugjagd .bj-ln{flex:none;width:3.2em;padding-right:1em;text-align:right;color:var(--bj-ln);user-select:none;font-variant-numeric:tabular-nums}
.gk-bugjagd .bj-code{white-space:pre;font:inherit;background:none;padding:0;color:inherit;tab-size:2}
.gk-bugjagd .bj-ed.live button.bj-line{cursor:pointer}
.gk-bugjagd .bj-ed.live button.bj-line:hover{background:rgba(143,211,244,.08)}
.gk-bugjagd .bj-ed.live button.bj-line:hover .bj-ln{color:var(--bj-f)}
.gk-bugjagd button.bj-line:focus-visible{outline:2px solid var(--bj-f);outline-offset:-2px;background:rgba(143,211,244,.10)}
.gk-bugjagd .bj-line.nope{opacity:.55}
.gk-bugjagd .bj-line.nope .bj-code{text-decoration:line-through;text-decoration-color:rgba(157,183,191,.45)}
.gk-bugjagd .bj-line.bug{background:rgba(255,138,107,.16);box-shadow:inset 3px 0 0 var(--bj-bug)}
.gk-bugjagd .bj-line.bug .bj-ln{color:#2B0E05;font-weight:900}
.gk-bugjagd .bj-line.bug .bj-ln,.gk-bugjagd .bj-line.new .bj-ln{background:linear-gradient(90deg,transparent 0 4px,var(--bj-bug) 4px calc(100% - 6px),transparent calc(100% - 6px));border-radius:0 8px 8px 0;align-self:stretch;display:flex;align-items:center;justify-content:flex-end}
.gk-bugjagd .bj-line.new{background:rgba(201,242,122,.13);box-shadow:inset 3px 0 0 var(--bj-ok);animation:bjIn .6s ease}
.gk-bugjagd .bj-line.new .bj-ln{color:#123D2F;font-weight:900;background:linear-gradient(90deg,transparent 0 4px,var(--bj-ok) 4px calc(100% - 6px),transparent calc(100% - 6px))}
.gk-bugjagd .bj-tag{display:none!important;position:sticky;right:6px;margin-left:auto;padding-left:14px;flex:none;font:800 11px/1 var(--body);font-style:normal;letter-spacing:.04em;text-transform:uppercase}
.gk-bugjagd .bj-tag::before{content:"";position:absolute;inset:-5px -8px -5px 6px;border-radius:999px;background:var(--bj-bug);z-index:-1}
.gk-bugjagd .bj-tag{color:#2B0E05;z-index:0;isolation:isolate}
.gk-bugjagd .bj-tag.ok{color:#123D2F}
.gk-bugjagd .bj-tag.ok::before{background:var(--bj-ok)}
.gk-bugjagd .bj-line.empty{min-height:calc(var(--bj-lh) * .62)}
.gk-bugjagd .bj-line.needs{animation:bjGlow 1.1s ease 3}
@keyframes bjGlow{0%,100%{background:transparent}50%{background:rgba(255,201,74,.25);box-shadow:inset 3px 0 0 var(--sun)}}
@keyframes bjIn{from{background:rgba(201,242,122,.35)}}
/* tokens */
.gk-bugjagd .t-k{color:var(--bj-k)}.gk-bugjagd .t-s{color:var(--bj-s)}.gk-bugjagd .t-c{color:var(--bj-c);font-style:italic}.gk-bugjagd .t-n{color:var(--bj-n)}
.gk-bugjagd .t-f{color:var(--bj-f)}.gk-bugjagd .t-p{color:var(--bj-p)}.gk-bugjagd .t-a{color:var(--bj-a)}.gk-bugjagd .t-g{color:var(--bj-g)}.gk-bugjagd .t-o{color:var(--bj-o)}

/* ---------- the preview: a light browser page (app) or a dark terminal (term) ---------- */
.gk-bugjagd .bj-pv{border-radius:14px;overflow:hidden;border:1px solid var(--line-2);background:#F6F8F5;color:#173327;box-shadow:0 10px 26px rgba(0,0,0,.18);transition:box-shadow .25s}
.gk-bugjagd .bj-pv-h{display:flex;align-items:center;gap:8px;padding:8px 10px;background:#E3EAE5;border-bottom:1px solid #CBD8CF;font:700 12.5px/1.2 var(--body);color:#3E5B4C;flex-wrap:wrap}
.gk-bugjagd .bj-pv-t{font-weight:900;text-transform:uppercase;letter-spacing:.06em;font-size:11.5px}
.gk-bugjagd .bj-url{font:600 12px/1.2 var(--mono);background:#fff;border:1px solid #CBD8CF;border-radius:999px;padding:4px 10px;min-width:0;flex:1 1 120px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:#3E5B4C}
.gk-bugjagd .bj-state{margin-left:auto;font:900 11.5px/1 var(--body);padding:5px 9px;border-radius:999px;white-space:nowrap}
.gk-bugjagd .bj-pv.bad .bj-state{background:#FFE3DA;color:#8A2B16}
.gk-bugjagd .bj-pv.ok .bj-state{background:#D9F5B0;color:#1E4D16}
.gk-bugjagd .bj-pv.ok{box-shadow:0 0 0 3px rgba(201,242,122,.45),0 10px 26px rgba(0,0,0,.18)}
.gk-bugjagd .bj-pv.flash{animation:bjFlash .6s ease}
@keyframes bjFlash{30%{box-shadow:0 0 0 4px rgba(255,138,107,.6)}}
.gk-bugjagd .bj-page{position:relative;padding:14px 16px 16px;display:flex;flex-direction:column;align-items:flex-start;gap:8px;min-height:96px;background:#FFFFFF;transition:background .3s;font-family:Georgia,'Times New Roman',serif;color:#111}
.gk-bugjagd .bj-h1{font:700 26px/1.15 Georgia,'Times New Roman',serif;margin:0;overflow-wrap:anywhere}
.gk-bugjagd .bj-p{font-size:16px;margin:0}
.gk-bugjagd .bj-out{font:700 18px/1.3 var(--body);margin:0;color:#173327}
.gk-bugjagd .bj-err{font:800 14px/1.3 var(--body);margin:0;color:#8A2B16;background:#FFE3DA;border-radius:8px;padding:6px 10px}
.gk-bugjagd .bj-list{margin:0;padding-left:20px;font:600 15px/1.45 var(--body)}
.gk-bugjagd .bj-btn,.gk-bugjagd .bj-fakebtn{font:500 16px/1.2 system-ui,-apple-system,'Segoe UI',sans-serif;color:#111;background:#EFEFEF;border:1px solid #767676;border-radius:4px;padding:10px 16px;min-height:44px;min-width:44px;cursor:pointer}
.gk-bugjagd .bj-fakebtn{display:inline-block;margin-right:6px}
.gk-bugjagd .bj-btn:active{background:#E0E0E0}
.gk-bugjagd .bj-btn:focus-visible{outline:3px solid #2F7A55;outline-offset:2px}
.gk-bugjagd .bj-cat{width:150px;height:auto;border-radius:6px;display:block}
.gk-bugjagd .bj-noimg{display:grid;place-items:center;width:150px;height:96px;border:1px dashed #9AA8A0;border-radius:6px;color:#9AA8A0}
.gk-bugjagd .bj-noimg svg{width:30px;height:30px}
.gk-bugjagd .bj-pop{position:absolute;left:50%;top:14px;transform:translateX(-50%);background:#fff;border-radius:10px;box-shadow:0 10px 30px rgba(0,0,0,.3);padding:12px 16px;min-width:180px;font:600 15px/1.3 system-ui,sans-serif;color:#111;animation:bjPop .25s ease}
.gk-bugjagd .bj-pop span{display:block;text-align:right;color:#1a5fb4;font-weight:800;margin-top:8px}
@keyframes bjPop{from{transform:translate(-50%,-6px);opacity:0}}
.gk-bugjagd .bj-log{background:#0B1D24;color:#D4E6EA;font:500 12.5px/1.55 var(--mono);padding:9px 12px;display:flex;flex-direction:column;gap:3px;overflow-x:auto;max-height:240px;overflow-y:auto}
.gk-bugjagd .bj-log p{margin:0;white-space:pre-wrap;overflow-wrap:anywhere}
.gk-bugjagd .bj-log .lg-err{color:#FFB4A2;background:rgba(255,138,107,.12);border-radius:4px;padding:1px 6px;margin:0 -6px}
.gk-bugjagd .bj-log .lg-warn{color:#FFE08A;background:rgba(255,201,74,.10);border-radius:4px;padding:1px 6px;margin:0 -6px}
.gk-bugjagd .bj-log .lg-ok{color:#C9F27A}
.gk-bugjagd .bj-log .lg-cmd{color:#8FD3F4}
.gk-bugjagd .bj-log .lg-dim{color:#6F96A1}
.gk-bugjagd .bj-log .lg-leak{color:#FFB4A2;font-weight:800}
.gk-bugjagd .bj-pv.term{background:#0B1D24;border-color:var(--bj-edge)}
.gk-bugjagd .bj-pv.term .bj-pv-h{background:#0F2830;border-color:var(--bj-edge);color:#9DB7BF}
.gk-bugjagd .bj-pv.term .bj-url{background:#0B1D24;border-color:var(--bj-edge);color:#CFE3E8}
.gk-bugjagd .bj-pv.term .bj-log{max-height:none;padding:12px 14px}
.gk-bugjagd .bj-try{margin:0;padding:6px 12px 8px;font-size:13px;color:#4F6A5B;background:#F6F8F5}
.gk-bugjagd .bj-pv.term .bj-try{display:none}

/* ---------- the card: fix options as code diffs ---------- */
.gk-bugjagd .bj-card{display:flex;flex-direction:column;gap:10px;min-width:0}
.gk-bugjagd .bj-card .qblock{margin:0}
.gk-bugjagd .bj-opts{gap:10px}
.gk-bugjagd .bj-opts .ans>.opt.bj-fix{display:flex;flex-direction:column;align-items:stretch;gap:6px;text-align:left;justify-content:flex-start;padding:10px 12px;min-height:54px;background:var(--bj-ed);border-color:var(--bj-edge);box-shadow:0 4px 0 var(--bj-edge);color:var(--bj-ink);overflow:hidden;position:relative}
.gk-bugjagd .bj-opts .ans>.opt.bj-fix:not(:disabled):hover{border-color:var(--bj-f)}
.gk-bugjagd .bj-opts .ans>.opt.bj-fix.right{border-color:var(--bj-ok);box-shadow:0 4px 0 #8FBF3E,0 0 0 3px rgba(201,242,122,.3);background:var(--bj-ed)}
.gk-bugjagd .bj-opts .ans>.opt.bj-fix.wrong{opacity:.6;border-color:var(--bj-bug);box-shadow:0 4px 0 #A8503A;background:var(--bj-ed);color:var(--bj-ink)}
.gk-bugjagd .bj-note{font:800 13px/1.3 var(--body);color:var(--bj-p);white-space:normal}
.gk-bugjagd .bj-diff{display:flex;flex-direction:column;gap:2px;overflow-x:auto;padding-bottom:2px;scrollbar-width:thin}
.gk-bugjagd .bj-dl{display:flex;align-items:baseline;gap:8px;font:500 var(--bj-fs)/1.5 var(--mono);white-space:pre-wrap;overflow-wrap:anywhere;border-radius:4px;padding:1px 4px}
.gk-bugjagd .bj-dl code{min-width:0}
.gk-bugjagd .bj-dl code{font:inherit;background:none;padding:0;color:inherit}
.gk-bugjagd .bj-dl b{width:1em;flex:none;text-align:center}
.gk-bugjagd .bj-dl.del{background:rgba(255,138,107,.13)}.gk-bugjagd .bj-dl.del b{color:var(--bj-bug)}
.gk-bugjagd .bj-dl.del code{text-decoration:line-through;text-decoration-color:rgba(255,138,107,.7)}
.gk-bugjagd .bj-dl.add{background:rgba(201,242,122,.10)}.gk-bugjagd .bj-dl.add b{color:var(--bj-ok)}
.gk-bugjagd .bj-fix .mk{position:absolute;top:8px;right:10px;font-size:16px;color:var(--bj-bug)}
.gk-bugjagd .bj-why{margin:0;font-weight:700;background:var(--soft);border-radius:14px;padding:10px 14px;box-shadow:inset 4px 0 0 var(--coral)}
.gk-bugjagd .bj-why span{color:var(--coral);font-weight:900}
.gk-bugjagd .bj-solved{background:var(--soft);border-radius:18px;padding:16px;display:flex;flex-direction:column;gap:10px}
.gk-bugjagd .bj-solved-h{font:400 23px/1.1 var(--display);display:flex;align-items:center;gap:10px;flex-wrap:wrap}
.gk-bugjagd .bj-solved-h>span{width:34px;height:34px;border-radius:50%;display:grid;place-items:center;background:var(--sun);color:var(--sun-ink);font-size:18px}
.gk-bugjagd .bj-solved-h em{font:800 13px/1 var(--body);font-style:normal;color:var(--muted);margin-left:auto}
.gk-bugjagd .bj-solved-p{font-weight:700}

/* dev tier (14–18): sober, sharper corners, mono headings */
body[data-tier="dev"] .gk-bugjagd .bj-solved-h{font:800 18px/1.2 var(--mono)}
body[data-tier="dev"] .gk-bugjagd .bj-dots li{border-radius:6px}
body[data-tier="dev"] .gk-bugjagd .bj-ed,body[data-tier="dev"] .gk-bugjagd .bj-pv{border-radius:10px}

/* light theme outside the lab tiers: keep the dots/cards readable (editor + console stay dark on purpose) */
:root[data-theme="light"] body:not([data-tier]) .gk-bugjagd .bj-pv{border-color:#CBD8CF}

/* phones: editor bleeds a little to gain width; tags stay compact */
@media (max-width:560px){
  .gk-bugjagd .bj-ed,.gk-bugjagd .bj-pv{margin:0 -6px;border-radius:12px}
  .gk-bugjagd{--bj-fs:13.5px}
  .gk-bugjagd.young{--bj-fs:16px}
  .gk-bugjagd .bj-ln{width:2.6em;padding-right:.8em}
  .gk-bugjagd .bj-h1{font-size:22px}
  .gk-bugjagd .bj-dots li{width:30px;height:30px}
}
@media (prefers-reduced-motion:reduce){.gk-bugjagd .bj-line.needs,.gk-bugjagd .bj-line.new,.gk-bugjagd .bj-pv.flash,.gk-bugjagd .bj-pop{animation:none!important}.gk-bugjagd .bj-page{transition:none}}
@media (forced-colors:active){.gk-bugjagd .bj-line.bug,.gk-bugjagd .bj-line.new{outline:2px solid Highlight;outline-offset:-2px}.gk-bugjagd .bj-tag::before{border:1px solid CanvasText}}
