/* ===== CloudLab HUD (game layer, intentionally distinct from Windows UI) ===== */
#hud {
  width: var(--hud-w); flex: none; height: 100%; overflow-y: auto; background: #0e1726; color: #dbe4f0;
  font-family: var(--font); font-size: 13px; border-left: 1px solid #000; display: flex; flex-direction: column;
  transition: width .2s;
}
body.hud-collapsed #hud { width: 44px; overflow: hidden; }
body.hud-collapsed #hud > :not(.hud-collapsed-bar) { display: none !important; }
.hud-collapsed-bar { display: none; flex-direction: column; align-items: center; gap: 14px; padding: 10px 0; height: 100%; }
body.hud-collapsed .hud-collapsed-bar { display: flex; }
.hud-vert { writing-mode: vertical-rl; transform: rotate(180deg); color: #9fb3cc; font-weight: 600; letter-spacing: .3px; white-space: nowrap; }
.hud-vert-count { color: #5eead4; font-weight: 700; }
.hud-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px 8px; }
.hud-brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; color: #fff; letter-spacing: .2px; }
.hud-brand .ico svg path { fill: #38bdf8; }
.hud-head-r { display: flex; gap: 4px; }
.hud-icon { width: 30px; height: 30px; border: none; border-radius: 6px; background: transparent; color: #9fb3cc; font-size: 15px; cursor: pointer; }
.hud-icon:hover { background: #1c2a40; color: #fff; }
.hud-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 0 14px 10px; }
.hud-stats > div { background: #152238; border: 1px solid #1f3150; border-radius: 8px; padding: 6px 8px; display: flex; flex-direction: column; }
.hud-stats span { font-size: 10px; text-transform: uppercase; letter-spacing: .8px; color: #7f93ad; }
.hud-stats b { font-size: 16px; color: #fff; font-variant-numeric: tabular-nums; }
.hud-level { padding: 6px 14px 10px; border-top: 1px solid #1c2a40; }
.hud-lvl-tag { display: flex; align-items: center; gap: 8px; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: #5eead4; font-weight: 700; }
.hud-lvl-title { font-size: 18px; font-weight: 700; color: #fff; margin: 4px 0 8px; line-height: 1.25; }
.hud-bar { height: 6px; border-radius: 3px; background: #1c2a40; overflow: hidden; }
.hud-bar > div { height: 100%; background: linear-gradient(90deg, #22d3ee, #34d399); transition: width .4s; }
.hud-pips { display: inline-flex; gap: 3px; }
.hud-pips i { width: 7px; height: 7px; border-radius: 50%; background: #2a3b57; display: inline-block; }
.hud-pips i.on { background: #fbbf24; }
.hud-brief { margin: 0 14px 8px; background: #132036; border: 1px solid #1f3150; border-radius: 8px; }
.hud-brief summary { padding: 8px 10px; cursor: pointer; color: #9fb3cc; font-weight: 600; font-size: 12px; list-style: none; }
.hud-brief summary::before { content: '▸ '; }
.hud-brief[open] summary::before { content: '▾ '; }
.hud-brief .hud-story { padding: 0 12px 10px; }
.hud-story { line-height: 1.55; color: #c9d6e6; user-select: text; }
.hud-story code, .hud-task code, .hud-hint code { background: #22324d; color: #a5f3fc; padding: 1px 5px; border-radius: 4px; font-family: var(--mono); font-size: 12px; user-select: text; }
.hud-tasks { padding: 4px 10px; display: flex; flex-direction: column; gap: 4px; }
.hud-task { display: flex; gap: 10px; padding: 8px; border-radius: 8px; border: 1px solid transparent; color: #7f93ad; }
.hud-task.active { background: #15243c; border-color: #2b4672; color: #e8eef7; box-shadow: 0 0 0 1px rgba(56,189,248,.15); }
.hud-task.done { color: #8aa0b8; }
.hud-task.done .hud-task-text { text-decoration: line-through; text-decoration-color: rgba(138,160,184,.5); }
.hud-task.flash { animation: hudflash 1.2s; }
@keyframes hudflash { 0% { background: rgba(52,211,153,.35); } 100% { background: transparent; } }
.hud-task-chk { width: 22px; height: 22px; flex: none; border-radius: 50%; border: 1.5px solid #3a5070; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; }
.hud-task.active .hud-task-chk { border-color: #38bdf8; color: #38bdf8; }
.hud-task.done .hud-task-chk { background: #10b981; border-color: #10b981; color: #fff; }
.hud-task.hinted .hud-task-chk { background: #b7791f; border-color: #b7791f; }
.hud-task-body { flex: 1; min-width: 0; }
.hud-task-text { line-height: 1.45; }
.hud-task-text b { color: inherit; }
.hud-task.active .hud-task-text b { color: #fff; }
.hud-hint-btn { margin-top: 6px; background: none; border: 1px dashed #3a5070; color: #93c5fd; border-radius: 6px; font-size: 11px; padding: 3px 8px; cursor: pointer; }
.hud-hint-btn:hover { background: #1c2a40; }
.hud-hint { margin-top: 6px; background: #2a2412; border: 1px solid #5c4a17; color: #fde68a; border-radius: 6px; padding: 7px 9px; line-height: 1.5; font-size: 12px; user-select: text; }
.hud-ask { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.hud-chip { background: #1e3352; border: 1px solid #2f4d7a; color: #e0f2fe; padding: 5px 10px; border-radius: 14px; font-size: 12px; cursor: pointer; }
.hud-chip:hover { background: #26436b; }
.hud-feedback { margin: 6px 14px; padding: 9px 30px 9px 10px; position: relative; border-radius: 8px; background: #3a1d1d; border: 1px solid #7f2d2d; color: #fecaca; line-height: 1.45; font-size: 12px; animation: hudshake .35s; }
@keyframes hudshake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.hud-x { position: absolute; right: 6px; top: 6px; background: none; border: none; color: #fca5a5; cursor: pointer; }
.hud-done { margin: 10px 14px; padding: 12px; border-radius: 8px; background: #0f2f2a; border: 1px solid #14532d; color: #bbf7d0; display: flex; flex-direction: column; gap: 10px; font-weight: 600; }
.hud-foot { margin-top: auto; display: flex; gap: 6px; padding: 12px 14px; border-top: 1px solid #1c2a40; flex-wrap: wrap; }

.hud-btn { background: #1e2d45; color: #e2e8f0; border: 1px solid #2f4566; border-radius: 8px; padding: 8px 16px; font-size: 13px; font-weight: 600; cursor: pointer; }
.hud-btn:hover { background: #26395a; }
.hud-btn.primary { background: linear-gradient(180deg, #0ea5e9, #0284c7); border-color: #0284c7; color: #fff; }
.hud-btn.primary:hover { background: linear-gradient(180deg, #38bdf8, #0ea5e9); }
.hud-btn.small { padding: 5px 10px; font-size: 12px; }
.hud-btn.danger { background: #7f1d1d; border-color: #991b1b; }
.hud-btn.wide { margin: 8px 14px; width: calc(100% - 28px); }
.hud-input { width: 100%; background: #0b1424; border: 1px solid #2f4566; color: #fff; border-radius: 8px; padding: 10px 12px; font-size: 15px; outline: none; }
.hud-input.small { padding: 5px 8px; font-size: 12px; width: auto; flex: 1; min-width: 80px; border-radius: 6px; }
.hud-input:focus { border-color: #38bdf8; }
.hud-input.err { border-color: #ef4444; animation: hudshake .3s; }

/* modals */
.hud-modal { position: fixed; inset: 0; z-index: 500000; background: rgba(4,10,20,.62); backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; animation: fadein .2s; }
@keyframes fadein { from { opacity: 0; } }
.hud-modal-card { width: min(620px, calc(100vw - 40px)); max-height: calc(100vh - 40px); overflow: auto; background: #0f1a2c; color: #dbe4f0; border: 1px solid #22385a; border-radius: 14px; padding: 28px 32px; box-shadow: 0 30px 80px rgba(0,0,0,.5); font-size: 14px; line-height: 1.55; animation: popin .25s cubic-bezier(.2,.9,.3,1.2); }
@keyframes popin { from { transform: scale(.94); opacity: 0; } }
.hud-modal h1 { margin: 4px 0 0; font-size: 34px; color: #fff; letter-spacing: -.5px; }
.hud-modal h2 { margin: 6px 0 6px; font-size: 24px; color: #fff; }
.hud-modal h3 { margin: 8px 0 14px; font-size: 18px; color: #fff; line-height: 1.4; }
.hud-modal .hud-sub { color: #93c5fd; font-weight: 600; margin-bottom: 10px; }
.hud-modal p { color: #c9d6e6; }
.hud-modal kbd { background: #22324d; border: 1px solid #3a5070; border-radius: 4px; padding: 0 5px; font-family: var(--mono); font-size: 12px; }
.hud-logo-big .ico svg path { fill: #38bdf8; }
.hud-list { padding-left: 20px; color: #c9d6e6; margin: 8px 0 14px; }
.hud-list li { margin: 3px 0; }
.hud-label { display: block; font-size: 12px; color: #9fb3cc; margin: 6px 0; font-weight: 600; }
.hud-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; align-items: flex-start; }
.hud-actions.spread { justify-content: space-between; }
.hud-fine { margin-top: 16px; font-size: 11px; color: #64748b; }
.hud-meta { display: flex; gap: 14px; align-items: center; color: #9fb3cc; font-size: 12px; margin-bottom: 12px; }
.hud-modal .hud-story { background: #132036; border: 1px solid #1f3150; border-radius: 10px; padding: 14px 16px; }
.hud-obj-h { margin-top: 14px; font-weight: 700; color: #5eead4; font-size: 12px; text-transform: uppercase; letter-spacing: .8px; }
.hud-q-count { color: #9fb3cc; font-size: 12px; margin-top: 4px; }
.hud-q-opts { display: flex; flex-direction: column; gap: 8px; }
.hud-q-opt { display: flex; align-items: flex-start; gap: 12px; text-align: left; background: #152238; border: 1px solid #2a4064; color: #e2e8f0; border-radius: 10px; padding: 11px 14px; font-size: 14px; cursor: pointer; line-height: 1.4; }
.hud-q-opt:hover:not(:disabled) { background: #1b2d4a; border-color: #38bdf8; }
.hud-q-opt:disabled { cursor: default; opacity: .75; }
.hud-q-opt.right { background: #0f3b2e; border-color: #10b981; opacity: 1; }
.hud-q-opt.wrong { background: #3b1717; border-color: #b91c1c; }
.hud-q-letter { width: 24px; height: 24px; flex: none; border-radius: 50%; background: #22324d; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: #93c5fd; }
.hud-expl { margin-top: 12px; min-height: 0; border-radius: 8px; line-height: 1.5; }
.hud-expl.good { background: #0f2f2a; border: 1px solid #14532d; color: #bbf7d0; padding: 10px 12px; }
.hud-expl.bad { background: #3a1d1d; border: 1px solid #7f2d2d; color: #fecaca; padding: 10px 12px; }
.hud-stars { text-align: center; font-size: 46px; letter-spacing: 6px; color: #334155; }
.hud-stars .on { color: #fbbf24; text-shadow: 0 0 18px rgba(251,191,36,.5); }
.hud-modal.done h2, .hud-modal.done .hud-sub { text-align: center; }
.hud-scorebox { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.hud-scorebox > div { background: #132036; border: 1px solid #1f3150; border-radius: 10px; padding: 10px; text-align: center; color: #9fb3cc; font-size: 12px; }
.hud-scorebox b { color: #fff; font-size: 18px; }
.hud-modal.levels .hud-modal-card { width: min(900px, calc(100vw - 40px)); }
.hud-lv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; margin-top: 10px; }
.hud-lv-card { text-align: left; background: #132036; border: 1px solid #22385a; color: #dbe4f0; border-radius: 10px; padding: 12px; cursor: pointer; display: flex; flex-direction: column; gap: 6px; font-family: inherit; }
.hud-lv-card:hover:not(:disabled) { border-color: #38bdf8; background: #172a46; }
.hud-lv-card.current { box-shadow: 0 0 0 2px #38bdf8; }
.hud-lv-card.done { border-color: #14532d; }
.hud-lv-card.locked { opacity: .45; cursor: not-allowed; }
.hud-lv-num { font-size: 22px; font-weight: 800; color: #38bdf8; }
.hud-lv-title { font-weight: 700; color: #fff; font-size: 14px; line-height: 1.3; }
.hud-lv-meta { display: flex; gap: 10px; align-items: center; font-size: 11px; color: #9fb3cc; }
.hud-lv-status { font-size: 12px; color: #a7f3d0; }
.hud-teacher { color: #9fb3cc; font-size: 12px; }
.hud-teacher summary { cursor: pointer; }
.hud-row { display: flex; gap: 8px; margin-top: 8px; align-items: center; }

/* certificate */
.hud-modal.certificate .hud-modal-card { width: min(820px, calc(100vw - 40px)); background: #fff; color: #1e293b; }
.cert { border: 3px double #0e7490; border-radius: 10px; padding: 36px 40px; text-align: center; background: linear-gradient(180deg, #f0f9ff, #fff 40%); }
.cert-top .ico svg path { fill: #0284c7; }
.cert-kicker { font-size: 13px; letter-spacing: 3px; text-transform: uppercase; color: #0e7490; font-weight: 700; margin-top: 6px; }
.cert-name { font-size: 38px; font-weight: 700; margin: 14px 0 6px; color: #0f172a; font-family: Georgia, 'Times New Roman', serif; }
.cert-text { color: #475569; }
.cert-course { font-size: 22px; font-weight: 700; color: #0369a1; margin: 6px 0; }
.cert-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 22px 0 14px; }
.cert-stats div { display: flex; flex-direction: column; }
.cert-stats b { font-size: 20px; color: #0f172a; }
.cert-stats span { font-size: 12px; color: #64748b; }
.cert-skills { font-size: 11px; color: #64748b; line-height: 1.6; }
.hud-modal.certificate .hud-btn { color: #0f172a; background: #e2e8f0; border-color: #cbd5e1; }
.hud-modal.certificate .hud-btn.primary { color: #fff; background: #0284c7; }
@media print {
  body > *:not(.hud-modal) { display: none !important; }
  .hud-modal { position: static; background: #fff; backdrop-filter: none; }
  .hud-modal-card { box-shadow: none; border: none; }
  .hud-actions { display: none; }
}
@media (max-width: 1280px) { :root { --hud-w: 320px; } }
