:root {
  --bg: #101318; --panel: #191d24; --panel2: #20252e; --line: #303744; --text: #e4e8ee; --dim: #8a93a3;
  --faint: #58606e; --accent: #4fd1c5; --warn: #ffb547; --err: #ff5d5d; --pcb: #0e3a2e; --pcb2: #144a3b;
  --silk: #cde8dc; --led: #39ff6a; --ledoff: #122c1e; --seg: #ff3428; --out: #ff9f43; --in: #4fd1c5;
  --mono: "DejaVu Sans Mono", "Cascadia Mono", Consolas, ui-monospace, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 var(--mono); }
.hidden { display: none !important; }
a { color: var(--accent); }
h1 { font-size: 22px; margin: 0 0 10px; } h2 { font-size: 14px; color: var(--accent); margin: 0 0 10px; } h3 { color: var(--accent); font-size: 14px; margin: 14px 0 4px; }
.dim { color: var(--dim); } .faint { color: var(--faint); font-size: 13px; } .accent { color: var(--accent); }
.card { background: var(--panel); border-radius: 10px; padding: 14px 16px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: #2c323d; color: var(--text);
  border: 0; border-radius: 7px; padding: 7px 14px; font: inherit; font-weight: bold; cursor: pointer; text-decoration: none; }
.btn:hover { background: #3a4250; } .btn.primary { background: var(--accent); color: #082320; } .btn.primary:hover { filter: brightness(1.1); }
.btn.big { padding: 11px 22px; font-size: 15px; } .btn.sm { padding: 5px 10px; font-size: 13px; } .btn.danger:hover { background: #5a2a2e; }
select { background: #2c323d; color: var(--text); border: 0; border-radius: 7px; padding: 5px 8px; font: inherit; font-size: 13px; }

/* header */
.top { display: flex; align-items: center; justify-content: space-between; padding: 12px 24px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { display: flex; gap: 14px; align-items: center; }
.logo { width: 40px; height: 32px; border-radius: 6px; background: var(--pcb2); display: flex; align-items: flex-end; gap: 3px; padding: 0 0 6px 6px; }
.logo i { width: 5px; height: 5px; border-radius: 50%; background: var(--ledoff); } .logo i.on { background: var(--led); box-shadow: 0 0 6px var(--led); }
.name { color: var(--accent); font-weight: bold; font-size: 20px; letter-spacing: 1px; } .course { color: var(--dim); font-size: 13px; }
.engine { display: flex; gap: 8px; align-items: center; color: var(--dim); font-size: 13px; background: var(--panel2); padding: 6px 12px; border-radius: 99px; }
.engine .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--faint); } .engine.ok .dot { background: var(--accent); box-shadow: 0 0 6px var(--accent); }
.engine.bad .dot { background: var(--err); }

.view { padding: 18px 24px; }
/* missing */
.missing { max-width: 760px; margin: 40px auto; padding: 28px 32px; }
.missing .row { display: flex; gap: 16px; align-items: center; margin: 16px 0; flex-wrap: wrap; }
.missing .hint { color: var(--dim); font-size: 13px; max-width: 420px; }
.missing .or { color: var(--faint); margin-top: 24px; }
.missing details { margin-top: 26px; color: var(--dim); } .missing summary { cursor: pointer; color: var(--text); }

/* home */
.announce:empty { display: none; }
.announce { margin-bottom: 14px; display: grid; gap: 8px; }
.note { background: #22302b; border-left: 4px solid var(--accent); border-radius: 8px; padding: 10px 14px; }
.note b { color: var(--accent); }
.home { display: grid; grid-template-columns: 360px 1fr; gap: 16px; align-items: start; }
.col-left { display: grid; gap: 16px; }
.drop { border: 2px dashed var(--line); border-radius: 10px; padding: 22px 12px; text-align: center; background: #161a20; transition: .15s; }
.drop.over { border-color: var(--accent); background: #1d2a2c; }
.drop .big { font-size: 22px; font-weight: bold; margin: 8px 0 6px; } .drop .dim { font-size: 13px; }
.folder { width: 46px; height: 34px; margin: 0 auto; background: var(--dim); border-radius: 4px; position: relative; }
.folder::before { content: ""; position: absolute; top: -6px; left: 0; width: 22px; height: 8px; background: var(--dim); border-radius: 3px 3px 0 0; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0 8px; }
.recent .r { padding: 7px 8px; border-radius: 6px; cursor: pointer; } .recent .r:hover { background: var(--panel2); }
.recent .r b { display: block; } .recent .r span { color: var(--faint); font-size: 12px; }
.tabs { display: flex; gap: 8px; margin-bottom: 12px; }
.tab { background: #1e232b; color: var(--text); border: 0; border-radius: 7px; padding: 7px 14px; font: inherit; font-weight: bold; cursor: pointer; }
.tab.on { background: var(--accent); color: #082320; }
.tabs { flex-wrap: wrap; align-items: center; }
.search { margin-left: auto; min-width: 200px; flex: 0 1 280px; background: #1e232b; color: var(--text); border: 1px solid #2c333d; border-radius: 7px; padding: 7px 10px; font: inherit; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: -4px 0 12px; }
.chip { background: transparent; color: var(--text); border: 1px solid #2c333d; border-radius: 999px; padding: 3px 11px; font: inherit; font-size: 13px; cursor: pointer; opacity: .8; }
.chip.on { border-color: var(--accent); color: var(--accent); opacity: 1; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.item { background: var(--panel2); border-radius: 9px; padding: 6px; cursor: pointer; border: 2px solid transparent; }
.item:hover { border-color: var(--accent); }
.item img { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; border-radius: 5px; background: #000; }
.item .t { font-weight: bold; margin: 6px 6px 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .u { margin: 0 6px 4px; font-size: 12px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .s { margin: 0 6px 4px; font-size: 12px; color: var(--accent); } .item .s.dl { color: var(--warn); }
.item .s.fast { color: var(--accent); font-weight: 700; } .item .s.slow { color: var(--warn); }
.badge { display: inline-block; font-size: 12px; padding: 0 6px; border-radius: 4px; background: #3d3320; color: var(--warn); }
.badge.vhdl { background: #2f2840; color: #b48cff; }

/* job panel */
.job { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); width: min(900px, calc(100% - 32px)); background: var(--panel2);
  border-radius: 12px; box-shadow: 0 8px 40px #000a; padding: 14px 16px; z-index: 20; }
.job.fail { background: #30201f; }
.job-head { display: flex; gap: 12px; align-items: center; } .grow { flex: 1; }
.spin { width: 18px; height: 18px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: sp 0.8s linear infinite; }
.spin.stop { animation: none; border-color: var(--err); } .spin.okk { animation: none; border-color: var(--accent); }
@keyframes sp { to { transform: rotate(360deg); } }
.job pre { background: #0a0c0f; border-radius: 6px; padding: 8px 10px; margin: 10px 0; max-height: 120px; overflow: auto; font-size: 12.5px; white-space: pre-wrap; color: var(--dim); }
.job.full pre { max-height: 50vh; }
.job pre .e { color: var(--err); } .job pre .w { color: var(--warn); }
.job-btns { display: flex; gap: 8px; justify-content: flex-end; }

/* modal */
.modal { position: fixed; inset: 0; background: #000a; display: grid; place-items: center; z-index: 30; }
.m-box { background: var(--panel); border-radius: 12px; padding: 20px; display: grid; grid-template-columns: 440px 1fr; gap: 24px; width: min(940px, 96vw); }
.m-box img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 6px; background: #000; }
.m-box .row { display: flex; gap: 10px; margin-top: 16px; }

/* simulator */
.sim { display: grid; grid-template-columns: minmax(520px, 680px) minmax(420px, 1fr); gap: 16px; align-items: start; }
.monitor { background: #1a1d22; border-radius: 14px; padding: 14px 14px 8px; border: 2px solid #2a2f37; }
.screen-wrap { position: relative; background: #000; aspect-ratio: 4/3; }
#screen { width: 100%; height: 100%; image-rendering: pixelated; display: block; cursor: default; }
.nosig { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; gap: 6px; color: var(--dim); }
.nosig b { font-size: 18px; color: var(--text); }
.mon-foot { display: flex; justify-content: space-between; color: var(--dim); font-size: 12px; padding: 6px 2px 0; }
.pled { width: 8px; height: 8px; border-radius: 50%; background: var(--ledoff); margin-top: 4px; } .pled.on { background: var(--led); box-shadow: 0 0 6px var(--led); } .pled.sb { background: var(--out); }
.board { margin-top: 14px; background: var(--pcb); border-radius: 12px; padding: 12px 14px; color: var(--silk); }
.b-title { font-size: 12px; margin-bottom: 8px; } .b-title b { color: var(--silk); }
.b-row { display: flex; gap: 14px; align-items: center; }
#seg { background: #140809; border-radius: 6px; }
.usb { flex: 1; background: var(--pcb2); border-radius: 6px; padding: 8px 10px; font-size: 12px; display: flex; flex-direction: column; min-height: 74px; }
.usb span { color: #9fbfb2; }
.pad { display: grid; grid-template-columns: 34px 34px 34px; grid-template-rows: 30px 30px 30px; gap: 2px; }
.pb { border-radius: 50%; border: 3px solid #1c2a25; background: #d6d9de; font: bold 11px var(--mono); color: #445; cursor: pointer; padding: 0; }
.pb.on { background: #8a9099; } .pb.u { grid-area: 1/2; } .pb.l { grid-area: 2/1; } .pb.c { grid-area: 2/2; } .pb.r { grid-area: 2/3; } .pb.d { grid-area: 3/2; }
.pb.unused { opacity: .45; }
.leds, .sws { display: grid; grid-template-columns: repeat(16, 1fr); gap: 4px; margin-top: 10px; text-align: center; font-size: 11px; }
.led { height: 9px; border-radius: 2px; background: var(--ledoff); margin: 2px 6px; }
.sw { height: 34px; border-radius: 4px; background: #0b0d10; position: relative; cursor: pointer; margin: 0 5px; }
.sw::after { content: ""; position: absolute; left: 3px; right: 3px; height: 13px; bottom: 3px; background: #d6d9de; border-radius: 2px; transition: .1s; }
.sw.on::after { bottom: 18px; } .sw.unused { opacity: .45; }
.sim-right { display: grid; gap: 10px; }
.head .title { font-size: 16px; } .head .stat { display: flex; justify-content: space-between; color: var(--dim); font-size: 13px; margin: 4px 0 10px; }
.ctl { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.cards { display: grid; gap: 10px; max-height: 46vh; overflow: auto; }
.pc { background: var(--panel2); border-radius: 9px; padding: 10px 12px; }
.pc .h { display: flex; justify-content: space-between; } .pc .h b { color: var(--accent); } .pc .h span { color: var(--faint); font-size: 12px; }
.pc input[type=range] { width: 100%; accent-color: var(--accent); }
.pc .val { font-weight: bold; } .pc .st { color: var(--dim); font-size: 12px; } .pc .warn { color: var(--warn); font-size: 12px; }
.pc .hold { min-width: 150px; } .pc .hold.on { background: var(--accent); color: #082320; }
.pc .rowf { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.kp { display: grid; grid-template-columns: repeat(4, 46px); gap: 6px; margin-top: 6px; }
.kp button { height: 34px; border: 0; border-radius: 6px; background: #3a404c; color: var(--text); font: bold 16px var(--mono); cursor: pointer; }
.kp button.on { background: var(--accent); color: #082320; }
.joy { display: flex; gap: 14px; align-items: center; }
.jpad { width: 130px; height: 130px; border-radius: 10px; background: #0e1116; position: relative; touch-action: none; cursor: grab; }
.jpad .k { position: absolute; width: 30px; height: 30px; border-radius: 50%; background: var(--accent); transform: translate(-50%, -50%); box-shadow: 0 0 10px var(--accent); }
.term { background: #06080a; color: #aaf0aa; border-radius: 5px; padding: 6px 8px; height: 96px; overflow: auto; white-space: pre-wrap; font-size: 12.5px; margin: 6px 0; }
.term-in { display: flex; gap: 6px; } .term-in input { flex: 1; background: #0e1116; color: var(--text); border: 1px solid var(--line); border-radius: 5px; padding: 5px 8px; font: inherit; }
.pmods .ph { display: flex; justify-content: space-between; align-items: baseline; }
.headers { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.hdr { background: #0e3228; border-radius: 6px; padding: 6px 8px; } .hdr b { color: var(--silk); font-size: 12px; }
.pins { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px 2px; margin-top: 4px; justify-items: center; }
.pin { width: 14px; height: 14px; border-radius: 50%; background: #283039; border: 2px solid #080a0c; cursor: default; }
.pin.unused { width: 6px; height: 6px; border: 0; background: var(--faint); margin: 4px; }
.pin.hi.out { background: var(--out); box-shadow: 0 0 6px var(--out); } .pin.hi.in { background: var(--in); box-shadow: 0 0 6px var(--in); }
.pin.free { cursor: pointer; outline: 1px dashed #4a5566; outline-offset: 2px; }
.foot { padding: 0 4px; }
.toast { position: fixed; top: 76px; left: 50%; transform: translateX(-50%); background: var(--text); color: #101318; padding: 8px 18px; border-radius: 8px; font-weight: bold; z-index: 40; }

@media (max-width: 1100px) {
  .home, .sim { grid-template-columns: 1fr; }
  .m-box { grid-template-columns: 1fr; }
}

.pair { display: flex; flex-direction: column; gap: 6px; padding: 14px 16px; margin-bottom: 18px; border-radius: 10px;
  background: rgba(255, 181, 71, .12); border: 1px solid rgba(255, 181, 71, .5); color: var(--text, #e4e8ee); }
.pair b { color: #ffb547; }
.snes { display: grid; grid-template-columns: repeat(12, 1fr); gap: 4px; margin: 6px 0; }
.snes .sb { padding: 5px 0; min-width: 0; font-size: 12px; }
.snes .sb.on { background: var(--accent, #4fd1c5); color: #08201e; }

/* publish form */
.pub label { display: block; margin: 10px 0 0; font-size: 13px; color: var(--dim, #9aa3ad); }
.pub input:not([type=checkbox]), .pub textarea { display: block; width: 100%; box-sizing: border-box; margin-top: 4px; padding: 8px 10px;
  background: #11151b; color: var(--text); border: 1px solid #2f3742; border-radius: 6px; font: inherit; }
.pub label.chk { display: flex; gap: 8px; align-items: flex-start; color: var(--text); }
.pub .hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.m-box .row .grow, .row .grow { flex: 1; }
.item .by { font-size: 12px; opacity: .75; }

/* browser mode (no PC program) */
.engine.web { cursor: pointer; } .engine.web .dot { background: #f0b429; box-shadow: 0 0 6px #f0b429; }
.m-box.need { grid-template-columns: 1fr; max-width: 640px; }
.item .s.dl { opacity: .75; }

/* GitHub link + share */
.gh { display: flex; gap: 8px; margin-top: 12px; }
.gh input { flex: 1; min-width: 0; padding: 8px 10px; background: #11151b; color: var(--text); border: 1px solid #2f3742; border-radius: 6px; font: inherit; font-size: 13px; }
.sh-btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
/* Urdu */
.top .lang { margin-left: auto; margin-right: 12px; font-family: 'Noto Naskh Arabic', var(--mono, monospace); }
body.ur .ur-t { direction: rtl; unicode-bidi: plaintext; font-family: 'Noto Naskh Arabic', var(--mono, monospace); }
body.ur #engine-text, body.ur #toast, body.ur #job-phase, body.ur .item .s, body.ur #need-what, body.ur .m-text p { font-family: 'Noto Naskh Arabic', var(--mono, monospace); }
body.ur .tab span:first-child, body.ur .chip { font-family: 'Noto Naskh Arabic', var(--mono, monospace); }
/* how to play */
.pc.howto .ctl { display: flex; gap: 10px; align-items: baseline; margin: 4px 0; font-size: 13px; }
.pc.howto kbd { flex: 0 0 auto; min-width: 92px; background: #0f1318; border: 1px solid #2f3742; border-bottom-width: 2px; border-radius: 5px;
  padding: 1px 7px; font: inherit; font-weight: bold; color: var(--text); }
.pc.howto details { margin-top: 6px; } .pc.howto summary { cursor: pointer; font-size: 12px; }

.pc.howto .h { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.pc.howto .code { font-size: 12px; font-weight: bold; }
