:root {
  --sky: #55c6f5;
  --ink: #2e3650;
  --ink2: #5a6480;
  --card: #ffffff;
  --line: #e3e9f2;
  --soft: #f3f7fc;
  --yellow: #ffc94d;
  --blue: #58c7ff;
  --green: #3ecf8e;
  --red: #ff5a67;
  --orange: #ff9f43;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(30, 60, 110, .18), 0 2px 6px rgba(30, 60, 110, .08);
  font-family: Nunito, "Arial Rounded MT Bold", system-ui, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--sky); }
button { font: inherit; color: inherit; cursor: pointer; }
input, select { font: inherit; color: var(--ink); }
.hidden { display: none !important; }
#app { position: fixed; inset: 0; }
#app canvas { display: block; }

/* ---- floating labels ---- */
#labels { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.label { position: absolute; left: 0; top: 0; white-space: nowrap; font-size: 12px; font-weight: 800; line-height: 1.25;
  padding: 4px 9px; border-radius: 10px; background: rgba(255,255,255,.95); box-shadow: 0 3px 10px rgba(30,60,110,.2); }
.label small { font-weight: 600; color: var(--ink2); }
.label.bubble { border-radius: 999px; }
.label.alert { background: var(--red); color: #fff; animation: bob 1s ease-in-out infinite; }
.label.name { background: var(--ink); color: #fff; text-align: center; }
.label.name small { color: #b9c3dc; }
.label.ov { background: #fff; border: 2px solid var(--green); text-align: center; }
.label.ov.warn { border-color: var(--yellow); }
.label.ov.bad { border-color: var(--red); background: #fff1f2; }
.label.ov.off { border-color: #b9c3dc; color: var(--ink2); }
.label.ov.cool { border-color: var(--blue); }
.label.ov.net { border-color: var(--blue); text-align: left; font-size: 11px; }
.k-server { color: #8fa3c0; } .k-switch { color: #3a4660; } .k-router { color: #35b5a2; } .k-firewall { color: #ff7a59; }
.bar { display: inline-block; width: 46px; height: 7px; border-radius: 9px; background: #e3e9f2; vertical-align: middle; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--green); border-radius: 9px; }
@keyframes bob { 50% { margin-top: -4px; } }

/* ---- HUD ---- */
.hud { position: fixed; z-index: 5; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
.pill { background: #fff; border-radius: 999px; box-shadow: var(--shadow); display: flex; align-items: center; gap: 14px; padding: 8px 18px; }
#topbar { top: 14px; left: 14px; right: 14px; display: flex; justify-content: space-between; gap: 12px; pointer-events: none; }
#topbar > * { pointer-events: auto; }
.logo { font-weight: 900; letter-spacing: .5px; font-size: 17px; gap: 8px; }
.logo i { width: 6px; height: 6px; border-radius: 50%; background: var(--ink); display: inline-block; }
.logo .y { color: #f0a500; } .logo .b { color: #1ea7ea; }
.stat { display: flex; flex-direction: column; line-height: 1.05; min-width: 58px; }
.stat small { font-size: 11px; color: var(--ink2); font-weight: 700; text-transform: uppercase; letter-spacing: .5px; }
.stat b { font-size: 17px; font-weight: 900; }
.speed { display: flex; gap: 4px; }
.speed button { border: 0; background: var(--soft); border-radius: 999px; padding: 6px 10px; font-size: 11px; font-weight: 900; }
.speed button.on { background: var(--ink); color: #fff; }
.saved { font-size: 11px; font-weight: 800; color: var(--ink2); white-space: nowrap; transition: color .3s; }
.saved.flash { color: #1b9e63; }
.mode { font-weight: 900; padding: 6px 12px; border-radius: 999px; background: var(--yellow); }
.mode.hacker { background: var(--ink); color: #5dff9c; font-family: "JetBrains Mono", monospace; }
.neg { color: var(--red); }

#dock { left: 50%; bottom: 16px; transform: translateX(-50%); display: flex; gap: 6px; background: #fff; padding: 8px; border-radius: 24px; box-shadow: var(--shadow); align-items: center; }
#dock button { border: 0; background: transparent; border-radius: 16px; padding: 6px 12px; font-weight: 800; font-size: 12px; display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 64px; }
#dock button span { font-size: 22px; line-height: 1.1; }
#dock button:hover { background: var(--soft); }
#dock button.on { background: var(--ink); color: #fff; }
#dock button.has-badge { position: relative; }
#dock .badge { position: absolute; top: 2px; right: 8px; min-width: 18px; height: 18px; border-radius: 9px; background: var(--red); color: #fff; font-size: 11px; font-weight: 900; line-height: 18px; padding: 0 5px; animation: bob 1s ease-in-out infinite; }
#dock .sep { width: 2px; height: 40px; background: var(--line); border-radius: 2px; margin: 0 4px; }

#hint { left: 50%; bottom: 100px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 8px 16px; border-radius: 999px; font-weight: 800; font-size: 13px; box-shadow: var(--shadow); }
#catalog { left: 50%; bottom: 100px; transform: translateX(-50%); display: flex; gap: 10px; padding: 12px; }
#catalog:not(.hidden) + #hint { bottom: 262px; }
.cat-sep { width: 2px; align-self: stretch; background: var(--line); border-radius: 2px; }
.cat-item.office { background: #fffaf0; border-color: #f3dcae; }
.cat-item:disabled { opacity: .6; cursor: default; }
.cat-item { width: 150px; border: 2px solid var(--line); border-radius: 14px; background: #fff; padding: 10px; text-align: left; }
.cat-item:hover { border-color: var(--blue); }
.cat-item.on { border-color: var(--ink); background: var(--soft); }
.cat-item b { display: block; font-size: 14px; }
.cat-item .price { font-weight: 900; color: #1b9e63; }
.cat-item small { display: block; color: var(--ink2); font-size: 11px; line-height: 1.3; margin-top: 4px; }
.cat-item .ico { font-size: 26px; }

#objectives { left: 14px; top: 86px; width: 290px; padding: 14px 16px; font-size: 13px; max-height: calc(100vh - 330px); overflow: auto; }
#objectives h3 { margin: 0 0 8px; font-size: 14px; display: flex; justify-content: space-between; align-items: center; }
#objectives h3 button { border: 0; background: var(--soft); border-radius: 999px; font-size: 11px; padding: 2px 8px; }
#objectives ol { margin: 0; padding: 0; list-style: none; }
#objectives li { display: flex; gap: 8px; padding: 4px 0; line-height: 1.3; color: var(--ink2); font-weight: 700; }
#objectives li .ck { flex: 0 0 18px; height: 18px; border-radius: 50%; border: 2px solid #c9d3e3; display: grid; place-items: center; font-size: 11px; }
#objectives li.done { color: #9aa6ba; text-decoration: line-through; }
#objectives li.done .ck { background: var(--green); border-color: var(--green); color: #fff; }
#objectives li.cur { color: var(--ink); }
#objectives li.cur .ck { border-color: var(--blue); background: #e7f7ff; }
#objectives .tip { margin-top: 8px; background: #fff8e6; padding: 8px 10px; border-radius: 12px; font-size: 12px; color: #6b5310; font-weight: 700; }
#objectives.min ol, #objectives.min .tip { display: none; }

#log { left: 14px; bottom: 16px; width: 360px; display: flex; flex-direction: column-reverse; gap: 6px; pointer-events: none; }
#log div { background: rgba(255,255,255,.93); border-radius: 12px; padding: 6px 10px; font-size: 12px; font-weight: 700; box-shadow: 0 3px 10px rgba(30,60,110,.14); }
#log div.bad { background: #fff1f2; color: #b3182a; }
#log div.good { background: #effcf5; color: #146c43; }
#log div small { color: var(--ink2); margin-right: 6px; }

/* the card clips, #side-body scrolls: a rounded scroller over the WebGL canvas can blank it on mobile compositors */
#side { right: 14px; top: 86px; bottom: 16px; width: 400px; overflow: hidden; display: flex; flex-direction: column; padding: 0; font-size: 13px; }
#side-body { flex: 1; min-height: 0; overflow: auto; padding: 16px 18px; }
#side h2 { margin: 0; font-size: 19px; font-weight: 900; }
#side h4 { margin: 16px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--ink2); }
#side .close { position: sticky; top: 0; float: right; border: 0; background: var(--soft); border-radius: 999px; width: 30px; height: 30px; font-weight: 900; }
.sub { color: var(--ink2); font-weight: 700; margin-top: 2px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { padding: 3px 9px; border-radius: 999px; font-weight: 800; font-size: 11px; background: var(--soft); }
.chip.ok { background: #e2f8ec; color: #146c43; }
.chip.bad { background: #ffe5e8; color: #b3182a; }
.chip.warn { background: #fff4d6; color: #8a6200; }
.btn { border: 0; background: var(--ink); color: #fff; border-radius: 12px; padding: 7px 12px; font-weight: 800; font-size: 12px; }
.btn.alt { background: var(--soft); color: var(--ink); }
.btn.go { background: var(--green); }
.btn.warn { background: var(--red); }
.btn.sm { padding: 4px 9px; font-size: 11px; border-radius: 9px; }
.btn:disabled { opacity: .45; cursor: default; }
.row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 6px 0; }
.row label { font-weight: 800; min-width: 74px; }
.row input, .row select { border: 2px solid var(--line); border-radius: 10px; padding: 5px 8px; font-size: 12px; font-weight: 700; background: #fff; min-width: 0; }
.row input { width: 140px; }
.mono { font-family: "JetBrains Mono", monospace; font-size: 11.5px; }
.box { background: var(--soft); border-radius: 12px; padding: 10px; margin-top: 6px; }
.muted { color: var(--ink2); }

/* rack elevation */
.elev { display: grid; grid-template-columns: 26px 1fr; grid-template-rows: repeat(42, 13px); gap: 1px 6px; background: #1b2236; border-radius: 12px; padding: 10px 10px; margin-top: 8px; }
.elev .u { color: #6d7a99; font-size: 9px; font-weight: 800; text-align: right; line-height: 13px; font-family: "JetBrains Mono", monospace; }
.elev .slot { border-radius: 3px; background: #262f48; border: 0; padding: 0; }
.elev .slot { color: transparent; font-size: 9px; font-weight: 800; text-align: left; padding: 0 6px; }
.elev .slot i { font-style: normal; }
.elev .slot:hover { background: #3a4a70; color: #cfe3ff; }
.elev .slot.sel { color: var(--ink); }
.elev .slot.sel { background: var(--yellow); }
.elev .dev { border-radius: 4px; border: 0; font-size: 10px; font-weight: 800; text-align: left; padding: 0 6px; display: flex; align-items: center; gap: 6px; overflow: hidden; white-space: nowrap; }
.elev .dev .dot { width: 6px; height: 6px; border-radius: 50%; background: #5dff9c; box-shadow: 0 0 6px #5dff9c; flex: 0 0 auto; }
.elev .dev .dot.off { background: #6d7a99; box-shadow: none; }
.elev .dev .dot.hot { background: #ff4d5e; box-shadow: 0 0 6px #ff4d5e; }
.elev .dev.server { background: #e6ebf2; color: var(--ink); }
.elev .dev.gpu { background: #262b36; color: #3ecf8e; outline: 1px solid #3ecf8e; }
.elev .dev.switch { background: #4a5878; color: #fff; }
.elev .dev.router { background: #35b5a2; color: #fff; }
.elev .dev.firewall { background: #ff7a59; color: #fff; }
.elev .dev.pending { opacity: .5; outline: 1px dashed #9ad8ff; }
.installs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 8px; }
.installs button { border: 2px solid var(--line); background: #fff; border-radius: 12px; padding: 7px 9px; text-align: left; font-size: 12px; font-weight: 800; }
.installs button:hover { border-color: var(--blue); }
.installs button small { display: block; color: var(--ink2); font-weight: 700; }

/* ports */
.ports { display: grid; grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); gap: 5px; margin-top: 6px; }
.port { border: 2px solid var(--line); background: #fff; border-radius: 10px; padding: 4px 5px; font-size: 10.5px; font-weight: 800; text-align: center; line-height: 1.2; }
.port small { display: block; font-weight: 700; color: var(--ink2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.port.up { border-color: var(--green); background: #effcf5; }
.port.pend { border-color: #9ad8ff; border-style: dashed; }
.port.sel { border-color: var(--ink); box-shadow: 0 0 0 2px var(--yellow); }

.trace { list-style: none; padding: 0; margin: 6px 0 0; }
.trace li { padding: 4px 0 4px 22px; position: relative; font-size: 12px; font-weight: 700; }
.trace li::before { content: '✓'; position: absolute; left: 0; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--green); color: #fff; font-size: 10px; display: grid; place-items: center; }
.trace li.bad::before { content: '✕'; background: var(--red); }
.trace .hint { color: #8a6200; background: #fff4d6; border-radius: 8px; padding: 4px 8px; margin-top: 4px; display: inline-block; }

table.rules { width: 100%; border-collapse: collapse; font-size: 11px; }
table.rules td, table.rules th { padding: 3px 4px; border-bottom: 1px solid var(--line); text-align: left; }
details { margin: 6px 0; } details summary { cursor: pointer; padding: 4px 0; }
table.rules th { color: var(--ink2); font-size: 10px; text-transform: uppercase; }

/* staff + contracts */
.people { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.person { display: flex; gap: 10px; align-items: center; background: var(--soft); border-radius: 14px; padding: 6px 10px 6px 6px; }
.person img { width: 58px; height: 58px; border-radius: 14px; background: linear-gradient(#8fdcff, #55c6f5); flex: 0 0 auto; }
.person .who { flex: 1; min-width: 0; }
.person .who b { display: block; font-size: 14px; }
.person .who small { color: var(--ink2); font-weight: 700; display: block; }
.stars { color: #f0a500; letter-spacing: 1px; }
.contract { background: var(--soft); border-radius: 14px; padding: 10px 12px; margin-top: 8px; border-left: 6px solid var(--blue); }
.contract.ok { border-left-color: var(--green); }
.contract.bad { border-left-color: var(--red); }
.contract .top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.contract .pay { font-weight: 900; color: #1b9e63; }
.reqs { list-style: none; padding: 0; margin: 6px 0; }
.reqs li { font-size: 12px; font-weight: 700; padding: 2px 0; }
.reqs li small { display: block; color: var(--ink2); font-weight: 600; padding-left: 20px; }
.assign { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.assign button { border: 2px solid var(--line); background: #fff; border-radius: 999px; padding: 2px 8px; font-size: 11px; font-weight: 800; }
.assign button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.assign button:disabled { opacity: .35; }
.happy { height: 6px; border-radius: 6px; background: #e3e9f2; overflow: hidden; margin-top: 4px; }
.happy i { display: block; height: 100%; background: linear-gradient(90deg, var(--red), var(--yellow), var(--green)); }

/* toasts */
#toasts { position: fixed; top: 84px; left: 50%; transform: translateX(-50%); z-index: 20; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; }
.toast { background: var(--ink); color: #fff; padding: 8px 16px; border-radius: 999px; font-weight: 800; font-size: 13px; box-shadow: var(--shadow); animation: pop .25s ease-out; }
.toast.bad { background: var(--red); }
.toast.good { background: #1b9e63; }
@keyframes pop { from { transform: scale(.8); opacity: 0; } }

/* terminal */
#terminal { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; background: rgba(20, 30, 60, .35); }
.term-win { width: min(1080px, 96vw); height: min(560px, 80vh); background: #0f1424; border-radius: 16px; box-shadow: 0 30px 80px rgba(0,0,0,.45); display: flex; flex-direction: column; overflow: hidden; font-family: "JetBrains Mono", monospace; }
.term-bar { background: #1c2340; color: #b9c3dc; padding: 8px 12px; display: flex; align-items: center; gap: 10px; font-size: 12px; }
.term-bar b { flex: 1; text-align: center; }
.term-bar button { border: 0; background: transparent; color: #b9c3dc; font-size: 14px; }
.dots i { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-right: 5px; background: #ff5f57; }
.dots i:nth-child(2) { background: #febc2e; } .dots i:nth-child(3) { background: #28c840; }
.term-body { flex: 1; display: flex; min-height: 0; }
#term-help { width: 300px; flex: 0 0 auto; overflow: auto; background: #151b30; border-left: 1px solid #232c4a; padding: 10px 12px; color: #9fb0d6; font-size: 11.5px; }
#term-help b { color: #fff; display: block; font-family: Nunito, sans-serif; font-size: 13px; }
#term-help small { display: block; color: #6d7a99; margin-bottom: 6px; }
#term-help h5 { margin: 10px 0 4px; color: #5dff9c; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; font-family: Nunito, sans-serif; }
#term-help button { display: block; width: 100%; text-align: left; background: transparent; border: 0; border-radius: 6px; padding: 4px 6px; color: inherit; font: inherit; }
#term-help button:hover { background: #232c4a; }
#term-help button code { display: block; color: #cfe3ff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#term-help span { display: block; color: #6d7a99; font-size: 10.5px; font-family: Nunito, sans-serif; }
#term-help .warn { color: #ffc14d; }
#term-out { flex: 1; margin: 0; padding: 12px 14px; color: #cfe3ff; font-size: 12.5px; overflow: auto; white-space: pre-wrap; line-height: 1.45; font-family: inherit; }
#term-out .cmd { color: #5dff9c; }
#term-out .err { color: #ff8f9a; }
.term-in { display: flex; padding: 8px 14px 12px; color: #5dff9c; font-size: 12.5px; align-items: center; }
.term-in input { flex: 1; background: transparent; border: 0; outline: 0; color: #fff; font-family: inherit; font-size: 12.5px; }

/* start screen */
#start { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; background: radial-gradient(circle at 50% 30%, #8fdcff, #55c6f5 60%); }
.start-card { text-align: center; padding: 20px; }
.logo.big { font-size: 58px; display: flex; gap: 18px; justify-content: center; align-items: center; color: #fff; text-shadow: 0 6px 0 rgba(30,60,110,.18); }
.logo.big i { width: 14px; height: 14px; background: #fff; }
.logo.big .y { color: var(--yellow); } .logo.big .b { color: var(--ink); }
.tag { color: #fff; font-weight: 800; font-size: 18px; margin: 6px 0 30px; }
.modes { display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; }
.mode-card { width: 280px; border: 0; border-radius: 26px; background: #fff; padding: 22px 22px 16px; text-align: left; box-shadow: var(--shadow); transition: transform .15s; }
.mode-card:hover { transform: translateY(-4px) rotate(-1deg); }
.mode-card b { font-size: 26px; font-weight: 900; display: block; }
.mode-card small { color: var(--ink2); font-weight: 800; }
.mode-card ul { padding-left: 18px; margin: 10px 0 0; font-weight: 700; font-size: 14px; line-height: 1.6; }
.mode-card.hacker { background: #0f1424; color: #cfe3ff; }
.mode-card.hacker b { color: #5dff9c; font-family: "JetBrains Mono", monospace; font-size: 23px; }
.mode-card.hacker small { color: #8a96b8; }
.pets { display: flex; gap: 8px; justify-content: center; align-items: center; margin-top: 22px; color: #fff; font-weight: 800; }
.pets button { border: 2px solid rgba(255,255,255,.7); background: rgba(255,255,255,.2); color: #fff; border-radius: 999px; padding: 8px 16px; font-weight: 900; font-size: 15px; }
.pets button.on { background: #fff; color: var(--ink); border-color: #fff; box-shadow: var(--shadow); }
.resume { display: flex; gap: 12px; justify-content: center; margin-top: 22px; flex-wrap: wrap; }
.resume-btn { border: 0; border-radius: 999px; padding: 12px 22px; font-weight: 900; font-size: 16px; background: var(--ink); color: #fff; box-shadow: var(--shadow); }
.resume-btn small { font-weight: 700; opacity: .75; margin-left: 6px; }
.resume-btn.alt { background: rgba(255,255,255,.9); color: var(--ink); }
.legal { margin-top: 18px; font-size: 13px; font-weight: 700; color: rgba(255,255,255,.85); }
.legal a { color: #fff; }
.keys { color: #fff; font-weight: 700; margin-top: 26px; font-size: 13px; opacity: .9; }
kbd { background: rgba(255,255,255,.25); border-radius: 6px; padding: 1px 6px; font-family: inherit; }

/* ---------------------------------------------------------------------------------------
   Touch + small screens. Portrait phones get a bottom sheet; landscape phones get a narrow
   side panel. Everything respects the notch and home bar via safe-area insets.
   --------------------------------------------------------------------------------------- */
html, body { height: 100dvh; overscroll-behavior: none; }
body.touch { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
body.touch input, body.touch select, body.touch #term-out { -webkit-user-select: text; user-select: text; }
body.touch button, body.touch a { touch-action: manipulation; }
body.touch .row input, body.touch .row select, body.touch .term-in input { font-size: 16px; } /* < 16px makes iOS zoom on focus */

#touchbar { left: 50%; transform: translateX(-50%); bottom: calc(96px + env(safe-area-inset-bottom)); display: flex; gap: 8px; z-index: 7; }
#touchbar button { border: 0; border-radius: 999px; padding: 12px 18px; font-weight: 900; font-size: 15px; background: #fff; color: var(--ink); box-shadow: var(--shadow); }
#touchbar button.go { background: var(--green); color: #fff; }
#touchbar button.go:disabled { background: #b9c3d3; }
#sheet-grip { display: none; }
#term-help-btn { display: none; }

@media (max-width: 900px), (max-height: 540px) and (orientation: landscape) {
  #topbar { top: calc(8px + env(safe-area-inset-top)); left: calc(8px + env(safe-area-inset-left)); right: calc(8px + env(safe-area-inset-right)); gap: 6px; flex-wrap: nowrap; }
  #topbar .logo { display: none; }
  #topbar .pill { padding: 5px 12px; gap: 9px; }
  .stat { min-width: 0; }
  .stat small { font-size: 9px; }
  .stat b { font-size: 13px; }
  .speed button { padding: 5px 8px; font-size: 10px; }
  .mode { padding: 4px 9px; font-size: 12px; }
  #st-saved { display: none; }
  #objectives { display: block !important; top: calc(60px + env(safe-area-inset-top)); left: calc(8px + env(safe-area-inset-left)); width: min(290px, 70vw); max-height: 40vh; padding: 10px 12px; font-size: 12px; }
  #log { display: none !important; }
  #toasts { top: calc(58px + env(safe-area-inset-top)); width: 92vw; }
  .toast { font-size: 12px; text-align: center; }

  #dock { left: calc(8px + env(safe-area-inset-left)); right: calc(8px + env(safe-area-inset-right)); bottom: calc(8px + env(safe-area-inset-bottom)); transform: none; overflow-x: auto; justify-content: flex-start; gap: 2px; padding: 6px; border-radius: 20px; scrollbar-width: none; }
  #dock::-webkit-scrollbar { display: none; }
  #dock button { min-width: 50px; padding: 4px 6px; font-size: 9px; flex: 0 0 auto; }
  #dock button span { font-size: 20px; }
  #dock .sep { height: 30px; margin: 0 2px; flex: 0 0 2px; }

  #catalog { left: 8px; right: 8px; transform: none; bottom: calc(80px + env(safe-area-inset-bottom)); overflow-x: auto; padding: 8px; gap: 8px; scrollbar-width: none; }
  #catalog::-webkit-scrollbar { display: none; }
  .cat-item { width: 124px; flex: 0 0 auto; padding: 8px; }
  .cat-item small { display: none; }
  #hint { bottom: calc(80px + env(safe-area-inset-bottom)); max-width: 92vw; font-size: 12px; text-align: center; }
  #catalog:not(.hidden) + #hint { bottom: calc(178px + env(safe-area-inset-bottom)); }
  body.touch #catalog:not(.hidden) ~ #touchbar { bottom: calc(178px + env(safe-area-inset-bottom)); }

  .label { font-size: 10px; padding: 3px 7px; }

  /* console fills the screen; commands slide over it */
  .term-win { width: 100vw; height: 100dvh; border-radius: 0; padding-top: env(safe-area-inset-top); }
  .term-body { position: relative; }
  #term-help { display: none; position: absolute; inset: 0 0 0 auto; width: min(320px, 86vw); z-index: 2; box-shadow: -10px 0 30px rgba(0,0,0,.4); }
  #terminal.help-open #term-help { display: block; }
  #term-help-btn { display: inline-block; font-size: 16px !important; }

  /* title screen scrolls instead of clipping */
  #start { place-items: start center; overflow-y: auto; padding: calc(16px + env(safe-area-inset-top)) 0 24px; }
  .logo.big { font-size: 34px; gap: 10px; flex-wrap: wrap; }
  .logo.big i { width: 9px; height: 9px; }
  .tag { font-size: 14px; margin-bottom: 18px; }
  .mode-card { width: min(280px, 86vw); padding: 16px 18px 12px; }
  .mode-card b { font-size: 22px; }
  .mode-card ul { font-size: 13px; line-height: 1.45; }
  .keys { display: none; }
  .pets { flex-wrap: wrap; gap: 6px; padding: 0 12px; }
  .pets span { flex: 1 0 100%; font-size: 13px; }
  .pets button { font-size: 13px; padding: 7px 12px; }
}

/* portrait phones: the inspector is a bottom sheet above the dock */
@media (max-width: 760px) and (orientation: portrait) {
  #side { left: 0; right: 0; top: auto; bottom: calc(70px + env(safe-area-inset-bottom)); width: auto; height: 46dvh; border-radius: 22px 22px 0 0; padding-top: 16px; }
  #side-body { padding: 4px 16px 16px; }
  #side.expanded { height: calc(100dvh - 130px - env(safe-area-inset-top)); }
  #sheet-grip { display: block; position: fixed; left: 50%; transform: translateX(-50%); z-index: 6; width: 70px; height: 22px; border: 0; background: transparent; }
  #sheet-grip i { display: block; width: 44px; height: 5px; border-radius: 3px; background: #c9d3e3; margin: 0 auto; }
  #sheet-grip.hidden { display: none; }
  #objectives.sheet-open { display: none !important; }
  #touchbar { bottom: calc(84px + env(safe-area-inset-bottom)); }
}

/* landscape phones: a narrow side panel, full height between HUD and dock */
@media (max-height: 540px) and (orientation: landscape) {
  #side { top: calc(52px + env(safe-area-inset-top)); bottom: calc(76px + env(safe-area-inset-bottom)); right: calc(8px + env(safe-area-inset-right)); width: min(380px, 44vw); }
  #side-body { padding: 12px 14px; }
  #objectives { max-height: 52vh; width: min(260px, 36vw); }
  #objectives.sheet-open { display: none !important; }
  #touchbar { bottom: calc(76px + env(safe-area-inset-bottom)); }
}
@media (max-width: 760px) and (orientation: portrait) {
  #sheet-grip { bottom: calc(70px + env(safe-area-inset-bottom) + 46dvh - 22px); }
  #sheet-grip.expanded { bottom: calc(100dvh - 60px - env(safe-area-inset-top) + env(safe-area-inset-bottom) - 22px); }
}

/* next-steps card at the top of rack/device/infra panels */
.next { background: linear-gradient(135deg, #eef9ff, #f6fbff); border: 2px solid #cfeeff; border-radius: 16px; padding: 10px 12px; margin: 12px 0 4px; }
.next-h { font-weight: 900; font-size: 13px; margin-bottom: 4px; }
.next ol { list-style: none; margin: 0; padding: 0; }
.next li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding: 4px 0; font-weight: 700; color: var(--ink2); }
.next li .ck { flex: 0 0 18px; height: 18px; border-radius: 50%; border: 2px solid #c9d3e3; display: grid; place-items: center; font-size: 10px; background: #fff; }
.next li.done { color: #9aa6ba; text-decoration: line-through; }
.next li.done .ck { background: var(--green); border-color: var(--green); color: #fff; }
.next li.cur { color: var(--ink); }
.next li.cur .ck { border-color: var(--blue); background: #e7f7ff; }
.next li .t { flex: 1 1 auto; min-width: 0; }
.next li .btn { margin-left: 26px; }
.showme { margin-top: 6px; border: 0; border-radius: 999px; background: var(--ink); color: #fff; font-weight: 800; font-size: 12px; padding: 5px 12px; }

/* collapsible dock */
#dock .dock-toggle { color: var(--ink2); }
#dock.collapsed { padding: 6px; }
#dock.collapsed > :not(.dock-toggle) { display: none; }
#dock.collapsed .dock-toggle { flex-direction: row; gap: 6px; font-size: 13px; padding: 6px 14px; }
#dock.collapsed .dock-toggle span { font-size: 18px; }
@media (max-width: 900px), (max-height: 540px) and (orientation: landscape) {
  #dock.collapsed { left: 50%; right: auto; transform: translateX(-50%); }
}
/* portrait phones: two stacked HUD rows so nothing is clipped */
@media (max-width: 760px) and (orientation: portrait) {
  #topbar { flex-wrap: wrap; row-gap: 6px; }
  #topbar .pill.stats { flex: 1 1 100%; justify-content: space-between; gap: 6px; padding: 5px 12px; }
  #topbar .stat b { font-size: 14px; }
  #objectives { top: calc(112px + env(safe-area-inset-top)); }
  #toasts { top: calc(112px + env(safe-area-inset-top)); }
}
