/* =========================================================================
   BlockCraft UI kit — nested pixel panels
   L1 panel   raised slate, ink outline, light top-left / dark bottom-right, hard drop shadow
   L2 well    recessed, darker, inverted bevel, no shadow
   L3 button  raised inside a well, lifts on hover, sinks on press
   L4 keycap  cream, ink text — every action names its key
   ========================================================================= */
:root {
  --ink: #090d0e;
  --face: #1f2b2d; --hi: #3a4f51; --lo: #131c1d;
  --well: #121a1c; --well-hi: #2a3a3c; --well-lo: #060a0b;
  --btn: #2b3b3e; --btn-hi: #4a6164; --btn-lo: #182224; --btn-hov: #344749;
  --text: #f3efe3; --mute: #95a5a2; --dim: #66756f;
  --yellow: #ffd23f; --yhi: #fff0a3; --ylo: #b8860b;
  --red: #e25b4a; --rhi: #ff8f80; --rlo: #9c3024;
  --green: #5cd67a; --teal: #45c9b8;
  --cream: #f4efe2; --chi: #ffffff; --clo: #c8bba0;
  --em: #46e38f; --xp: #d8d8d8; --shield: #b48cf0;
  --team: #3b74e0;
  --font: 'VT323', ui-monospace, Menlo, monospace;
  --title: 'Press Start 2P', 'VT323', monospace;
  --console-h: 230px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #000; color: var(--text); font-family: var(--font); user-select: none; -webkit-user-select: none; }
canvas#view { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }
.hidden { display: none !important; }
[hidden] { display: none !important; }
button { font-family: var(--font); color: inherit; }

/* ---------- primitives ---------- */
.px, .mc-panel {
  background: var(--face); color: var(--text);
  border: 2px solid var(--ink); border-radius: 4px;
  box-shadow: inset 2px 2px 0 var(--hi), inset -2px -2px 0 var(--lo), 0 4px 0 rgba(0, 0, 0, 0.42);
}
.well {
  background: var(--well); border: 2px solid var(--ink); border-radius: 3px;
  box-shadow: inset 2px 2px 0 var(--well-lo), inset -2px -2px 0 var(--well-hi);
}
.px-btn, .mc-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 22px; line-height: 1; color: var(--text); text-shadow: 0 2px 0 rgba(0, 0, 0, 0.6); text-decoration: none;
  background: var(--btn); border: 2px solid var(--ink); border-radius: 4px; padding: 7px 16px; cursor: pointer;
  box-shadow: inset 2px 2px 0 var(--btn-hi), inset -2px -2px 0 var(--btn-lo), 0 3px 0 rgba(0, 0, 0, 0.45);
  transition: transform 0.08s, box-shadow 0.08s, background 0.12s;
}
.px-btn:hover, .mc-btn:hover { background: var(--btn-hov); transform: translateY(-2px); box-shadow: inset 2px 2px 0 var(--btn-hi), inset -2px -2px 0 var(--btn-lo), 0 5px 0 rgba(0, 0, 0, 0.45); }
.px-btn:active, .mc-btn:active { transform: translateY(2px); box-shadow: inset 2px 2px 0 var(--btn-lo), inset -2px -2px 0 var(--btn-hi), 0 1px 0 rgba(0, 0, 0, 0.45); }
.px-btn.sm, .mc-btn.small { font-size: 18px; padding: 4px 10px; }
.px-btn.wide { width: 100%; justify-content: space-between; }
.px-btn.primary, .mc-btn.big { background: var(--yellow); color: #22262a; text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
  box-shadow: inset 2px 2px 0 var(--yhi), inset -2px -2px 0 var(--ylo), 0 3px 0 rgba(0, 0, 0, 0.45); }
.px-btn.primary:hover, .mc-btn.big:hover { background: #ffdc66; box-shadow: inset 2px 2px 0 var(--yhi), inset -2px -2px 0 var(--ylo), 0 5px 0 rgba(0, 0, 0, 0.45); }
.px-btn.primary kbd { background: #22262a; color: var(--yellow); box-shadow: none; }
.px-btn.danger { background: var(--red); box-shadow: inset 2px 2px 0 var(--rhi), inset -2px -2px 0 var(--rlo), 0 3px 0 rgba(0, 0, 0, 0.45); }
.px-btn.danger:hover { background: #ec6a5a; }
.px-btn.primary::after, .mc-btn.big::after { /* a faint light sweep every few seconds */
  content: ''; position: absolute; inset: 2px; border-radius: 2px; pointer-events: none;
  background: linear-gradient(105deg, transparent 40%, rgba(255, 255, 255, 0.35) 47%, transparent 54%) no-repeat;
  background-size: 300% 100%; animation: sweep 5s linear infinite;
}
@keyframes sweep { 0%, 82% { background-position: 150% 0; } 100% { background-position: -60% 0; } }
kbd {
  display: inline-block; min-width: 18px; padding: 1px 4px 0; font-family: var(--font); font-size: 15px; line-height: 15px; text-align: center;
  color: #23262a; background: var(--cream); border: 2px solid var(--ink); border-radius: 3px; text-shadow: none;
  box-shadow: inset 1px 1px 0 var(--chi), inset -1px -2px 0 var(--clo);
}
.ico { width: 22px; height: 22px; display: inline-block; flex: none; background-size: contain; image-rendering: pixelated; background-repeat: no-repeat; }
.cost-em { color: var(--em); } .cost-xp { color: var(--xp); } .cost-en { color: #d8a8ff; } .cost-sup { color: #ffcf9e; } .cost-t { color: var(--mute); }
.short { color: var(--rhi) !important; }
b.em { color: var(--em); } b.xp { color: var(--xp); } b.sculk { color: var(--teal); }

/* breathing corner brackets mark whatever is active */
.brackets { position: absolute; inset: -4px; pointer-events: none; animation: breathe 1.4s ease-in-out infinite; z-index: 3; }
.brackets i { position: absolute; width: 10px; height: 10px; border: 0 solid var(--yellow); filter: drop-shadow(0 0 0 var(--ink)) drop-shadow(1px 1px 0 var(--ink)); }
.brackets i:nth-child(1) { left: 0; top: 0; border-left-width: 3px; border-top-width: 3px; }
.brackets i:nth-child(2) { right: 0; top: 0; border-right-width: 3px; border-top-width: 3px; }
.brackets i:nth-child(3) { left: 0; bottom: 0; border-left-width: 3px; border-bottom-width: 3px; }
.brackets i:nth-child(4) { right: 0; bottom: 0; border-right-width: 3px; border-bottom-width: 3px; }
@keyframes breathe { 0%, 100% { inset: -4px; } 50% { inset: -7px; } }

/* ---------- title screen ---------- */
#menu { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; overflow-y: auto;
  background: radial-gradient(ellipse at center, rgba(4, 10, 12, 0.1) 0%, rgba(4, 10, 12, 0.7) 100%); }
.menu-inner { width: min(1060px, 96vw); display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 20px 0; }
.title-wrap { position: relative; text-align: center; margin-bottom: 6px; }
.title { font-family: var(--title); font-size: clamp(34px, 6vw, 72px); margin: 0; letter-spacing: 4px; color: #d0d0c8;
  text-shadow: 0 2px 0 #8a8a82, 0 4px 0 #66665f, 0 6px 0 #45453f, 0 8px 0 #24241f, 0 12px 12px rgba(0, 0, 0, 0.65); -webkit-text-stroke: 2px #141414; }
.title .two { color: #46e38f; margin-left: 18px; text-shadow: 0 2px 0 #2a9a4a, 0 4px 0 #1f7a3a, 0 6px 0 #145a2a, 0 8px 0 #0a3a1a, 0 12px 12px rgba(0, 0, 0, 0.65); }
.subtitle { font-family: var(--title); font-size: clamp(12px, 1.6vw, 18px); color: #fff; letter-spacing: 8px; margin-top: 10px; text-shadow: 2px 2px 0 #000; }
.splash { position: absolute; right: -40px; bottom: -6px; font-family: var(--title); font-size: 12px; color: var(--yellow); text-shadow: 2px 2px 0 #3f3000;
  transform: rotate(-16deg); animation: splash 0.6s ease-in-out infinite alternate; white-space: nowrap; }
@keyframes splash { from { transform: rotate(-16deg) scale(1); } to { transform: rotate(-16deg) scale(1.1); } }
.setup { width: 100%; padding: 16px 18px 18px; animation: dropIn 0.45s cubic-bezier(.2, 1.4, .4, 1) both; }
.step-label { font-family: var(--title); font-size: 11px; color: var(--yellow); margin: 4px 0 10px; letter-spacing: 1px; text-shadow: 0 2px 0 var(--ink); }
.step-label.small { margin-top: 14px; }
.factions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.fcard, .bcard {
  position: relative; cursor: pointer; color: var(--text); text-align: left; font: inherit;
  background: var(--well); border: 2px solid var(--ink); border-radius: 3px;
  box-shadow: inset 2px 2px 0 var(--well-lo), inset -2px -2px 0 var(--well-hi);
  transition: transform 0.1s, background 0.12s;
}
.fcard { padding: 10px; display: flex; gap: 10px; align-items: flex-start; }
.fcard:hover, .bcard:hover { background: #18232a; transform: translateY(-2px); }
.fcard.sel, .bcard.sel { background: #22303a; }
.fcard.sel::before, .bcard.sel::before { content: ''; position: absolute; inset: -5px; border: 3px solid var(--yellow); border-radius: 5px; pointer-events: none; animation: pulseRing 1.4s ease-in-out infinite; }
@keyframes pulseRing { 0%, 100% { inset: -4px; opacity: 1; } 50% { inset: -7px; opacity: 0.75; } }
.fcard .portraits { display: flex; flex-direction: column; gap: 4px; align-items: center; min-width: 128px; }
.fcard .portraits img { image-rendering: pixelated; }
.fcard .portraits img.render { width: 128px; height: auto; image-rendering: auto; filter: drop-shadow(2px 4px 0 rgba(0, 0, 0, 0.45)); transition: transform 0.2s; }
.fcard:hover .portraits img.render, .fcard.sel .portraits img.render { transform: scale(1.08) rotate(-2deg); }
.fcard h3 { margin: 0; font-family: var(--title); font-size: 13px; color: var(--text); text-shadow: 0 2px 0 var(--ink); }
.fcard .sc { font-size: 18px; color: var(--yellow); margin-top: 2px; }
.fcard p { margin: 4px 0 0; font-size: 18px; line-height: 1.05; color: #d9dcd2; }
.fcard .style { color: #9fe3b8; }
.row2 { display: grid; grid-template-columns: 1fr 260px; gap: 16px; margin-top: 12px; }
.biomes { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.bcard { padding: 6px; text-align: center; }
.bcard canvas { width: 100%; aspect-ratio: 1.6; image-rendering: pixelated; display: block; border: 2px solid var(--ink); }
.bcard .bn { font-size: 20px; margin-top: 3px; }
.seg { display: flex; flex-wrap: wrap; gap: 4px; }
.seg button { font-size: 19px; flex: 1; min-width: 56px; padding: 4px 6px; background: var(--btn); color: var(--text); border: 2px solid var(--ink); border-radius: 3px; cursor: pointer;
  box-shadow: inset 2px 2px 0 var(--btn-hi), inset -2px -2px 0 var(--btn-lo); text-shadow: 0 1px 0 #000; }
.seg button:hover { background: var(--btn-hov); }
.seg button.sel { background: var(--yellow); color: #22262a; text-shadow: none; box-shadow: inset 2px 2px 0 var(--yhi), inset -2px -2px 0 var(--ylo); }
.menu-actions { display: flex; gap: 10px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.menu-actions .mc-btn { min-width: 160px; }
.menu-actions .mc-btn.big { font-size: 26px; padding: 9px 34px; }

/* ---------- overlays ---------- */
.overlay { position: fixed; inset: 0; background: rgba(6, 10, 12, 0.62); display: flex; align-items: center; justify-content: center; z-index: 50; }
.panel-pop, .help-panel, .end-panel { animation: dropIn 0.38s cubic-bezier(.2, 1.4, .4, 1) both; }
@keyframes dropIn { from { opacity: 0; transform: translateY(-26px); } to { opacity: 1; transform: none; } }
.help-panel { width: min(980px, 94vw); max-height: 90vh; overflow-y: auto; padding: 18px; }
.help-panel h2, .pause-panel h2, .end-panel h2 { font-family: var(--title); font-size: 18px; margin: 4px 0 10px; text-align: center; color: var(--text); text-shadow: 0 3px 0 var(--ink); }
.help-panel h3, .page-body h3 { font-family: var(--title); font-size: 11px; color: var(--yellow); margin: 14px 0 6px; }
.help-panel ul { margin: 0; padding-left: 20px; font-size: 20px; line-height: 1.1; color: #d9dcd2; }
.help-panel li { margin-bottom: 4px; }
.help-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.keys { font-size: 19px; border-collapse: collapse; width: 100%; }
.help-panel .keys td { padding: 3px 6px; border-bottom: 2px solid var(--lo); color: #d9dcd2; }
.help-panel .keys td:first-child { color: var(--yellow); white-space: nowrap; }
.help-panel .mc-btn { display: flex; margin: 16px auto 0; }
.pause-panel { width: min(560px, 94vw); padding: 18px; }
.pause-panel .sub { text-align: center; color: var(--mute); font-size: 18px; margin: -4px 0 14px; }
.menu-rows { display: flex; flex-direction: column; gap: 8px; }
.row-link span { color: var(--mute); }
.settings { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 8px; margin-top: 14px; }
.settings .px-btn { font-size: 18px; padding: 6px 8px; }
.pause-foot { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.page-head { display: flex; align-items: center; gap: 14px; border-bottom: 2px solid var(--ink); padding-bottom: 10px; margin-bottom: 4px; }
.page-head h2 { margin: 0 !important; text-align: left !important; font-size: 14px !important; }
.page-body { max-height: 62vh; overflow-y: auto; font-size: 19px; line-height: 1.12; color: #d9dcd2; padding-right: 6px; }
.page-body p { margin: 4px 0 8px; }
.page-body .row { display: flex; gap: 10px; align-items: flex-start; }
.page-body .row .ico { margin-top: 3px; }
.page-body.keys .krow { display: flex; align-items: center; gap: 6px; padding: 5px 0; border-bottom: 2px solid var(--lo); }
.page-body.keys .krow span { margin-left: auto; color: #d9dcd2; text-align: right; }
.end-panel { min-width: 460px; text-align: center; padding: 20px; }
#endTitle { font-size: 30px !important; }
#endTitle.win { color: var(--green) !important; } #endTitle.lose { color: var(--rhi) !important; }
#endSub { font-size: 21px; margin-bottom: 12px; color: var(--mute); }
#endStats table { margin: 0 auto; font-size: 21px; border-collapse: collapse; }
#endStats td, #endStats th { padding: 3px 14px; border-bottom: 2px solid var(--lo); }

/* ---------- HUD: top ---------- */
#hudRoot { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#hudRoot button, #hudRoot .px, #hudRoot .well, #hudRoot #tabs > * { pointer-events: auto; }
#topbar { position: fixed; top: 8px; left: 8px; right: 8px; display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.tb-left { display: flex; align-items: flex-start; gap: 8px; }
#menuBtn { font-size: 19px; padding: 6px 10px; }
.chip { display: flex; align-items: center; gap: 8px; padding: 4px 12px; height: 38px; font-size: 26px; }
#speedTag { font-size: 18px; color: var(--yellow); }
#speedTag:empty { display: none; }
.goal { display: flex; align-items: center; gap: 10px; padding: 5px 14px 5px 10px; min-height: 38px; max-width: 420px; transition: background 0.3s; }
.goal b { display: block; font-family: var(--title); font-size: 9px; letter-spacing: 1px; color: var(--yellow); margin-bottom: 3px; }
.goal span { display: block; font-size: 18px; color: #d9dcd2; line-height: 1; }
.goal-gem { width: 14px; height: 14px; flex: none; background: var(--em); transform: rotate(45deg); border: 2px solid var(--ink); box-shadow: inset 2px 2px 0 #b6ffd2; }
.goal.urgent { background: #3a1f1c; }
.goal.urgent b { color: var(--rhi); }
.goal.urgent .goal-gem { background: var(--red); box-shadow: inset 2px 2px 0 var(--rhi); animation: blink 0.7s steps(2) infinite; }
.res-bar { display: flex; gap: 6px; padding: 5px; }
.res-chip { display: flex; align-items: center; gap: 8px; padding: 3px 12px 3px 8px; min-width: 112px;
  background: var(--well); border: 2px solid var(--ink); border-radius: 3px; box-shadow: inset 2px 2px 0 var(--well-lo), inset -2px -2px 0 var(--well-hi); }
.res-chip small { display: block; font-family: var(--title); font-size: 7px; letter-spacing: 1px; color: var(--mute); text-transform: uppercase; margin-bottom: 2px; }
.res-chip b { display: block; font-weight: normal; font-size: 26px; line-height: 22px; display: inline-block; transform-origin: left center; }
.res-chip .ico { width: 24px; height: 24px; }
.res-chip.blocked { background: #3a1f1c; animation: blink 0.7s steps(2) infinite; }
.res-chip.blocked b, .res-chip.blocked small { color: var(--rhi); }
.res-chip.denied { animation: shake 0.42s; background: #3a1f1c; }
.res-chip.denied b { color: var(--rhi); }
.bump { animation: bump 0.32s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes bump { from { transform: scale(1.22); } to { transform: scale(1); } }
@keyframes shake { 0%, 100% { transform: none; } 20% { transform: translateX(-4px); } 40% { transform: translateX(4px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(2px); } }
@keyframes blink { 50% { opacity: 0.6; } }

/* toasts */
#alerts { position: fixed; top: 62px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; z-index: 11; }
.alert { display: flex; align-items: center; gap: 8px; font-size: 21px; color: #23262a; padding: 4px 14px 4px 10px;
  background: var(--cream); border: 2px solid var(--ink); border-radius: 4px; box-shadow: inset 2px 2px 0 var(--chi), inset -2px -2px 0 var(--clo), 0 3px 0 rgba(0, 0, 0, 0.45);
  animation: toastIn 0.32s cubic-bezier(.2, 1.6, .4, 1) both; transition: opacity 0.5s, transform 0.5s; }
.alert::before { content: ''; width: 6px; height: 10px; background: var(--yellow); border: 2px solid var(--ink); flex: none; }
.alert.err { background: #ffe1db; } .alert.err::before { background: var(--red); }
.alert.warn { background: var(--red); color: #fff; box-shadow: inset 2px 2px 0 var(--rhi), inset -2px -2px 0 var(--rlo), 0 3px 0 rgba(0, 0, 0, 0.45); }
.alert.warn::before { background: #fff; }
.alert.good::before { background: var(--green); }
.alert.dying { opacity: 0; transform: translateY(-8px); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-14px) scale(0.96); } to { opacity: 1; transform: none; } }

/* ---------- HUD: console ---------- */
#console { position: fixed; left: 8px; right: 8px; bottom: 8px; height: var(--console-h); pointer-events: none; animation: consoleIn 0.5s cubic-bezier(.2, 1.3, .4, 1) both; }
@keyframes consoleIn { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.console-frame { position: absolute; inset: 0; display: grid; grid-template-columns: 216px minmax(360px, 1fr) 470px; gap: 8px; padding: 8px; pointer-events: auto; }
.mini-well { padding: 4px; display: flex; align-items: center; justify-content: center; }
#minimap { width: 200px; height: 200px; display: block; image-rendering: pixelated; cursor: crosshair; background: #000; }
.sel-area { display: flex; gap: 8px; min-width: 0; }
.portrait-well { position: relative; width: 160px; flex: none; overflow: hidden;
  background: radial-gradient(ellipse at 50% 85%, color-mix(in srgb, var(--team) 32%, #10181a) 0%, #0c1416 62%, #070b0c 100%); }
#portrait { position: absolute; left: 2px; top: 2px; width: calc(100% - 4px); height: calc(100% - 4px); }
#portraitFallback { position: absolute; inset: 14px; width: calc(100% - 28px); height: calc(100% - 28px); object-fit: contain; image-rendering: pixelated; }
.portrait-glass { position: absolute; inset: 2px; pointer-events: none; border-radius: 2px;
  background: repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 3px), radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.45) 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05); }
.portrait-well.flash { animation: hurtFlash 0.3s; }
@keyframes hurtFlash { 0% { box-shadow: inset 0 0 0 3px var(--red), inset 2px 2px 0 var(--well-lo); } 100% { box-shadow: inset 2px 2px 0 var(--well-lo), inset -2px -2px 0 var(--well-hi); } }
.info-well { flex: 1; min-width: 0; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; overflow: hidden; }
.cmd-well { padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; overflow: hidden; position: relative; }

/* folder tabs sitting on top of the console */
#tabs { position: absolute; left: 14px; bottom: calc(100% - 4px); display: flex; align-items: flex-end; gap: 4px; pointer-events: none; }
.tab { position: relative; display: flex; align-items: center; gap: 6px; height: 30px; padding: 0 9px 2px; cursor: pointer; font-size: 18px; color: var(--text);
  background: var(--face); border: 2px solid var(--ink); border-bottom: none; border-radius: 4px 4px 0 0; box-shadow: inset 2px 2px 0 var(--hi);
  transition: transform 0.1s, height 0.1s; }
.tab:hover { height: 34px; }
.tab img { width: 22px; height: 22px; image-rendering: auto; }
.tab .n { font-size: 15px; color: var(--mute); }
.tab kbd { font-size: 13px; line-height: 12px; min-width: 14px; padding: 1px 3px 0; }
.tab.idle { background: var(--yellow); color: #22262a; box-shadow: inset 2px 2px 0 var(--yhi); animation: idleHop 2.4s ease-in-out infinite; }
.tab.idle .n { color: #4a3a00; }
@keyframes idleHop { 0%, 88%, 100% { transform: none; } 92% { transform: translateY(-4px); } 96% { transform: translateY(0); } }
.tab.on { background: #2f4246; height: 34px; }

/* context hint: one line, what to do right now */
#hint { position: fixed; left: 50%; bottom: calc(var(--console-h) + 52px); transform: translateX(-50%); max-width: calc(100vw - 480px);
  font-size: 21px; color: var(--text); text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-shadow: 0 2px 0 #000, 0 0 6px rgba(0, 0, 0, 0.9), 2px 0 0 #000, -2px 0 0 #000; transition: opacity 0.6s; pointer-events: none; }
#hint b { color: var(--yellow); font-weight: normal; }
#hint .step { font-family: var(--title); font-size: 10px; color: #23262a; background: var(--yellow); border: 2px solid var(--ink); padding: 3px 6px 2px; margin-right: 8px; text-shadow: none; vertical-align: 2px; }
#hint.warn { color: var(--rhi); }
#hint.faded { opacity: 0.5; }

/* cursor label: what right-click will do */
#cursorLabel { position: fixed; z-index: 20; pointer-events: none; font-size: 18px; padding: 2px 8px 1px; color: var(--text); white-space: nowrap;
  background: var(--face); border: 2px solid var(--ink); border-radius: 3px; box-shadow: inset 2px 2px 0 var(--hi), 0 2px 0 rgba(0, 0, 0, 0.45); }
#cursorLabel.attack { background: var(--red); box-shadow: inset 2px 2px 0 var(--rhi), 0 2px 0 rgba(0, 0, 0, 0.45); }
#cursorLabel.gather { background: #1d4a33; box-shadow: inset 2px 2px 0 #2f7a52, 0 2px 0 rgba(0, 0, 0, 0.45); }
#cursorLabel.bad { background: #4a2420; color: var(--rhi); }
#cursorLabel .mb { display: inline-block; width: 9px; height: 13px; margin-right: 6px; vertical-align: -1px; border: 2px solid var(--ink); border-radius: 3px 3px 4px 4px;
  background: linear-gradient(90deg, var(--cream) 50%, var(--yellow) 50%) top / 100% 45% no-repeat, var(--cream); }

/* ---------- info well ---------- */
.sel-head { display: flex; align-items: baseline; gap: 10px; }
.sel-name { font-family: var(--title); font-size: 13px; color: var(--text); text-shadow: 0 2px 0 var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill { font-size: 15px; padding: 0 6px; border: 2px solid var(--ink); border-radius: 3px; color: #22262a; background: var(--cream); white-space: nowrap; }
.pill.enemy { background: var(--red); color: #fff; }
.pill.team { background: var(--team); color: #fff; }
.bar { position: relative; height: 16px; max-width: 340px; background: #070b0c; border: 2px solid var(--ink); border-radius: 2px; overflow: hidden; }
.bar > i { position: absolute; left: 0; top: 0; bottom: 0; width: 100%; background: var(--green); transition: width 0.12s linear, background 0.2s; box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.25); }
.bar::after { content: ''; position: absolute; inset: 0; background: repeating-linear-gradient(90deg, transparent 0 calc(10% - 2px), rgba(0, 0, 0, 0.55) calc(10% - 2px) 10%); pointer-events: none; }
.bar > b { position: absolute; right: 6px; top: -2px; font-weight: normal; font-size: 16px; color: #fff; text-shadow: 0 1px 0 #000, 1px 0 0 #000, -1px 0 0 #000; z-index: 1; }
.bar > em { position: absolute; left: 6px; top: -2px; font-style: normal; font-size: 16px; color: #fff; text-shadow: 0 1px 0 #000, 1px 0 0 #000, -1px 0 0 #000; z-index: 1; }
.bar.sh { height: 12px; } .bar.sh > i { background: var(--shield); } .bar.sh > b, .bar.sh > em { font-size: 14px; top: -3px; }
.bar.prog > i { background: var(--yellow); }
.bar.mid > i { background: var(--yellow); } .bar.low > i { background: var(--red); }
.stat-row { display: flex; flex-wrap: wrap; gap: 4px; }
.stat { display: inline-flex; align-items: center; gap: 5px; font-size: 18px; padding: 0 7px 0 4px; height: 24px; color: #d9dcd2;
  background: var(--btn-lo); border: 2px solid var(--ink); border-radius: 3px; }
.stat i { font-style: normal; font-size: 15px; color: var(--yellow); margin-right: 1px; }
.stat.warn { color: var(--rhi); }
.status { display: flex; align-items: center; gap: 8px; font-size: 19px; color: var(--mute); margin-top: auto; }
.status .dot { width: 8px; height: 8px; flex: none; border: 2px solid var(--ink); background: var(--dim); }
.status.busy .dot { background: var(--green); animation: blink 1s steps(2) infinite; }
.status.alert .dot { background: var(--red); }
.desc { font-size: 18px; color: var(--mute); line-height: 1.05; }
.queue { display: flex; gap: 5px; align-items: flex-end; margin-top: 2px; }
.qslot { position: relative; width: 44px; height: 44px; padding: 0; cursor: pointer; background: var(--btn-lo); border: 2px solid var(--ink); border-radius: 3px;
  box-shadow: inset 2px 2px 0 var(--btn), inset -2px -2px 0 #0d1314; }
.qslot.first { width: 58px; height: 58px; }
.qslot img { position: absolute; inset: 3px; width: calc(100% - 6px); height: calc(100% - 6px); object-fit: contain; pointer-events: none; }
.qslot .qbar { position: absolute; left: 3px; right: 3px; bottom: 3px; height: 5px; background: #070b0c; border: 1px solid var(--ink); }
.qslot .qbar i { display: block; height: 100%; background: var(--yellow); }
.qslot:hover::after { content: '✕'; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 26px; color: var(--rhi); background: rgba(0, 0, 0, 0.55); }
.qslot.empty { cursor: default; opacity: 0.45; } .qslot.empty:hover::after { display: none; }
.queue.watch .qslot { cursor: default; } .queue.watch .qslot:hover::after { display: none; } /* spectating: nothing to cancel */
.pips { display: inline-flex; gap: 3px; vertical-align: middle; }
.pips i { width: 10px; height: 10px; border: 2px solid var(--ink); background: #2a3a3c; }
.pips i.on { background: var(--yellow); }
/* multi-selection: one wireframe per unit (SC2), 8 x 3 */
.wire-head .sel-name { flex: none; }
.wire-tip { margin-left: auto; min-width: 0; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wires { display: grid; grid-template-columns: repeat(8, minmax(0, 46px)); grid-auto-rows: 50px; gap: 4px; align-content: start; }
.wire { position: relative; padding: 0; cursor: pointer; overflow: hidden; background: linear-gradient(#3a4d50, #223033); border: 1px solid color-mix(in srgb, var(--tc, var(--team)) 70%, var(--ink)); border-radius: 2px; }
.wire:hover { background: linear-gradient(#4a6164, #2b3b3e); border-color: var(--tc, var(--team)); }
.wire img { position: absolute; left: 0; right: 0; top: 0; width: 100%; max-width: 40px; height: 40px; margin: 0 auto; object-fit: contain; pointer-events: none; }
.wire::after { content: ''; position: absolute; inset: 0; background: var(--red); opacity: var(--dmg, 0); pointer-events: none; }
.wire .hp, .wire .sh { position: absolute; left: 2px; right: 2px; z-index: 1; background: #070b0c; pointer-events: none; }
.wire .hp { bottom: 2px; height: 4px; } .wire .sh { bottom: 7px; height: 3px; }
.wire .hp i, .wire .sh i { display: block; height: 100%; width: 100%; background: var(--green); }
.wire .sh i { background: #4aa6ff; }
.wire.mid .hp i { background: var(--yellow); } .wire.low .hp i { background: var(--red); }
.empty-state { display: flex; flex-direction: column; gap: 8px; }
.empty-state .lead { font-size: 21px; color: var(--text); }
.empty-state .lead b { color: var(--yellow); font-weight: normal; }

/* ---------- command well ---------- */
.sec { display: flex; flex-direction: column; gap: 3px; }
.sec-head { display: flex; align-items: center; gap: 8px; height: 16px; }
.sec-head .t { font-family: var(--title); font-size: 8px; letter-spacing: 1px; color: var(--mute); }
.sec-head .note { font-size: 16px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sec-head .aside { margin-left: auto; display: flex; gap: 4px; }
.sec-head .aside .px-btn { font-size: 16px; padding: 1px 6px; gap: 5px; box-shadow: inset 1px 1px 0 var(--btn-hi), inset -1px -1px 0 var(--btn-lo), 0 2px 0 rgba(0, 0, 0, 0.45); }
.sec-head .aside kbd { font-size: 12px; line-height: 11px; min-width: 12px; padding: 1px 2px 0; }
.sec-head .aside .px-btn.on { background: var(--cream); color: #22262a; text-shadow: none; }
.row { display: flex; gap: 6px; }
.cmd { position: relative; width: 66px; height: 66px; padding: 0; flex: none; cursor: pointer; color: var(--text);
  background: var(--btn); border: 2px solid var(--ink); border-radius: 4px;
  box-shadow: inset 2px 2px 0 var(--btn-hi), inset -2px -2px 0 var(--btn-lo), 0 3px 0 rgba(0, 0, 0, 0.5);
  transition: transform 0.08s, box-shadow 0.08s, background 0.12s; }
.cmd:hover { background: var(--btn-hov); transform: translateY(-2px); box-shadow: inset 2px 2px 0 var(--btn-hi), inset -2px -2px 0 var(--btn-lo), 0 5px 0 rgba(0, 0, 0, 0.5); }
.cmd:active, .cmd.pressed { transform: translateY(2px); box-shadow: inset 2px 2px 0 var(--btn-lo), inset -2px -2px 0 var(--btn-hi), 0 1px 0 rgba(0, 0, 0, 0.5); }
.cmd img { position: absolute; left: 50%; top: 5px; width: 36px; height: 36px; transform: translateX(-50%); object-fit: contain; pointer-events: none; image-rendering: pixelated; }
.cmd img.model { image-rendering: auto; width: 42px; height: 42px; top: 2px; }
.cmd .lbl { position: absolute; left: 1px; right: 1px; bottom: 3px; font-size: 15px; line-height: 15px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; text-shadow: 0 1px 0 #000; }
.cmd kbd { position: absolute; left: -5px; top: -6px; font-size: 13px; line-height: 12px; min-width: 15px; padding: 1px 3px 0; z-index: 2; pointer-events: none; }
.cmd .cost { position: absolute; right: 2px; top: 1px; font-size: 14px; line-height: 13px; text-align: right; pointer-events: none; text-shadow: 0 1px 0 #000, 1px 0 0 #000; }
.cmd.make .lbl { bottom: 2px; }
.cmd.off img { filter: grayscale(0.85) brightness(0.55); }
.cmd.off .lbl { color: var(--dim); }
.cmd.poor .cost { color: var(--rhi); }
.cmd.locked::before { content: ''; position: absolute; right: 4px; top: 4px; width: 10px; height: 8px; border: 2px solid var(--ink); background: var(--mute); z-index: 2;
  box-shadow: 0 -5px 0 -3px var(--mute); }
.cmd.active { background: #46593a; box-shadow: inset 2px 2px 0 #6f8a5c, inset -2px -2px 0 #2a3a22, 0 3px 0 rgba(0, 0, 0, 0.5); }
.cmd.wide { width: 100px; }
.cmd.go { background: #2f4a39; box-shadow: inset 2px 2px 0 #4f7a5c, inset -2px -2px 0 #1a2a20, 0 3px 0 rgba(0, 0, 0, 0.5); }
.cmd.go:hover { background: #38573f; }
.cmd .cd { position: absolute; inset: 2px; border-radius: 2px; pointer-events: none; background: conic-gradient(rgba(0, 0, 0, 0.62) var(--cd), transparent 0); }
.cmd .badge { position: absolute; right: -5px; top: -6px; min-width: 18px; height: 18px; font-size: 15px; line-height: 15px; text-align: center; color: #22262a; background: var(--yellow); border: 2px solid var(--ink); border-radius: 3px; z-index: 2; }
.drawer-head { display: flex; align-items: center; gap: 8px; }
.drawer-head .step { font-family: var(--title); font-size: 8px; color: #22262a; background: var(--yellow); border: 2px solid var(--ink); padding: 3px 5px 2px; letter-spacing: 1px; }
.drawer-head .px-btn { font-size: 16px; padding: 2px 8px; gap: 5px; }
.drawer-head kbd { font-size: 12px; line-height: 11px; min-width: 12px; padding: 1px 2px 0; }
.cmd-note { font-size: 19px; color: var(--mute); line-height: 1.1; }
.cmd-note b { color: var(--yellow); font-weight: normal; }
.cmd-well.swap > * { animation: swapIn 0.18s ease-out both; }
@keyframes swapIn { from { opacity: 0; transform: translateX(10px); } to { opacity: 1; transform: none; } }

/* tooltip */
#tooltip { position: fixed; z-index: 30; pointer-events: none; max-width: 330px; padding: 8px 12px 9px; font-size: 19px; line-height: 1.05;
  background: var(--face); color: var(--text); border: 2px solid var(--ink); border-radius: 4px;
  box-shadow: inset 2px 2px 0 var(--hi), inset -2px -2px 0 var(--lo), 0 4px 0 rgba(0, 0, 0, 0.5); }
@keyframes tipIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
#tooltip .tt-top { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
#tooltip .tt-name { font-family: var(--title); font-size: 10px; color: var(--yellow); letter-spacing: 1px; text-transform: uppercase; }
#tooltip .tt-top kbd { margin-left: auto; }
#tooltip .tt-cost { display: flex; gap: 12px; margin: 3px 0 5px; padding: 2px 6px; background: var(--well); border: 2px solid var(--ink); border-radius: 3px; }
#tooltip .tt-desc { color: #c9cec6; }
#tooltip .tt-req { color: var(--rhi); margin-top: 4px; }
#tooltip .tt-how { color: var(--mute); margin-top: 4px; font-size: 17px; }

/* World canvas integration */
#world { position: fixed; inset: 0; width: 100%; height: 100%; }
#view { z-index: 1; }
#menu { z-index: 3; }
#renderNotice { position: fixed; z-index: 100; top: 56px; left: 12px; background: var(--face); border: 2px solid var(--ink); padding: 8px; }
a.mc-btn { text-decoration: none; text-align: center; }
@media (max-width: 1240px) { .console-frame { grid-template-columns: 216px minmax(300px, 1fr) 470px; } .portrait-well { width: 132px; } #hint { max-width: calc(100vw - 200px); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* SC2 command-card grid: 5 (or 6) fixed columns × 3 rows; empty cells stay visible */
.cmd-grid { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(var(--cols, 5), minmax(0, 1fr)); grid-template-rows: repeat(3, minmax(0, 1fr)); gap: 6px; padding: 5px 4px 3px; }
.cmd-grid .cmd { width: auto; height: auto; min-width: 0; }
.cmd-grid .cmd:hover { transform: none; }
.cmd-grid .slot { border: 2px solid rgba(0, 0, 0, 0.4); border-radius: 3px; background: rgba(0, 0, 0, 0.16); box-shadow: inset 1px 1px 0 rgba(0, 0, 0, 0.25); }
.cmd-grid .cmd img { top: 3px; }
.cmd-grid .cmd.make img.model { width: 34px; height: 34px; top: 0; }
.cmd-grid .cmd.make .lbl { bottom: 13px; }
.cmd-grid.capped { gap: 5px; padding-top: 3px; }
.cmd-grid.capped .cmd img { width: 30px; height: 30px; top: 1px; }
.cmd-grid.capped .cmd.make img.model { width: 28px; height: 28px; top: 1px; }
.cmd-grid.capped .cmd .lbl { font-size: 14px; line-height: 14px; bottom: 2px; }
.cmd-grid.capped .cmd.make .lbl { bottom: 12px; }
.cmd-grid.capped .cmd .cost { font-size: 13px; }
/* drawer tiles are a step smaller so two full rows fit */
.cmd.sm { width: 56px; height: 58px; }
.cmd.sm img, .cmd.sm img.model { width: 32px; height: 32px; top: 2px; }
.cmd.sm .lbl { font-size: 14px; line-height: 14px; bottom: 13px; }
.cmd.make img.model { width: 38px; height: 38px; top: 1px; }
.cmd.make .lbl { bottom: 14px; }
.cmd.make .cost { left: 1px; right: 1px; top: auto; bottom: 1px; text-align: center; font-size: 14px; }
.cmd.sm .cost { font-size: 13px; }
.cmd.poor img { opacity: 0.55; }

#portrait { width: calc(100% - 4px) !important; height: calc(100% - 4px) !important; }

#portraitHit { position: fixed; pointer-events: auto; z-index: 11; }
.portrait-well .portrait-glass { display: none; }

/* ---------- SC2 HUD additions (hud_sc2.js) ---------- */
.bar.en { height: 10px; } .bar.en > i { background: linear-gradient(#d8a8ff, #9a6ae0); } .bar.en > b { font-size: 13px; top: -4px; }
.stat em { font-style: normal; color: #9fe39a; font-size: 15px; }
.stat.dim { color: #9aa49a; font-size: 15px; text-transform: lowercase; }
.queue.wide .qslot { width: 34px; height: 34px; }
.queue.wide .qslot.first { width: 44px; height: 44px; }
.cargo { display: flex; gap: 3px; flex-wrap: wrap; margin: 2px 0; }
.cargo img { width: 28px; height: 28px; border: 1px solid rgba(255,255,255,.18); background: rgba(0,0,0,.25); }
/* Tab subgroup: the other types step back */
.wires.tabbed .wire:not(.active) { background: #1d282a; }
.wires.tabbed .wire:not(.active) img { opacity: 0.8; }
/* SC2 autocast: thin marching border (1px, never chunky) */
.cmd.auto { outline: 1px dashed #ffe14a; outline-offset: -3px; animation: autoMarch 1.2s linear infinite; }
@keyframes autoMarch { 50% { outline-color: #fff6c0; } }
