* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --panel: rgba(18, 22, 28, 0.88);
  --panel-border: rgba(255, 255, 255, 0.08);
  --gold: #ffd75e;
  --danger: #ff5d52;
  --good: #59ff9c;
}

html, body { width: 100%; height: 100%; overflow: hidden; background: #0b0e13; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: #e8e6df;
  user-select: none;
  -webkit-user-select: none;
}

#game { position: fixed; inset: 0; display: block; }

/* soft vignette over the world */
body::after {
  content: '';
  position: fixed; inset: 0; pointer-events: none; z-index: 5;
  background: radial-gradient(ellipse at center, transparent 62%, rgba(0, 0, 0, 0.38));
}
#ui { position: fixed; inset: 0; pointer-events: none; }
#ui > * { pointer-events: auto; }

#dragrect {
  position: fixed; display: none; pointer-events: none;
  border: 1.5px solid var(--good);
  background: rgba(89, 255, 156, 0.12);
  z-index: 30;
}

/* ---------- top bar ---------- */
#topbar {
  position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 6px;
  background: var(--panel);
  border: 1px solid var(--panel-border); border-top: none;
  border-radius: 0 0 12px 12px;
  padding: 7px 14px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.45);
  white-space: nowrap;
  z-index: 10;
}
.res { flex: 0 0 auto; font-size: 14px; padding: 2px 7px; border-radius: 6px; }
.res small { opacity: 0.65; font-size: 11px; }
.res.danger { background: rgba(255, 93, 82, 0.22); color: #ffb3ad; animation: pulse 1.2s infinite; }
#r-plot {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
}
#r-plot.active {
  background: rgba(255, 215, 94, 0.16);
  color: #ffe8a0;
}
.sep { width: 1px; height: 20px; background: var(--panel-border); margin: 0 4px; }

.tbtn {
  flex: 0 0 auto;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--panel-border);
  color: #e8e6df; border-radius: 7px;
  padding: 4px 9px; font-size: 13px; cursor: pointer;
  transition: background 0.12s;
}
.tbtn:hover { background: rgba(255, 255, 255, 0.16); }
.tbtn.active { background: var(--gold); color: #1c1608; border-color: transparent; }
.tbtn.demolish { margin-top: 8px; width: 100%; }
.tbtn.demolish:hover { background: rgba(255, 93, 82, 0.3); }

/* ---------- banner + messages ---------- */
#banner {
  position: absolute; top: 104px; left: 50%; transform: translateX(-50%) scale(0.9);
  font-size: 26px; font-weight: 700; text-align: center;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8);
  opacity: 0; transition: opacity 0.4s, transform 0.4s;
  pointer-events: none !important;
  max-width: 80vw;
  z-index: 12;
}
#banner.show { opacity: 1; transform: translateX(-50%) scale(1); }
#banner.bad { color: var(--danger); }

#messages {
  position: absolute; left: 14px; top: 58px;
  display: flex; flex-direction: column; gap: 4px;
  max-width: 360px; z-index: 8;
  pointer-events: none !important;
}
.msg {
  background: var(--panel); border: 1px solid var(--panel-border);
  border-radius: 8px; padding: 6px 10px; font-size: 13px;
  transition: opacity 1s;
  animation: slidein 0.25s ease-out;
}
.msg.bad { border-color: rgba(255, 93, 82, 0.5); color: #ffc4bf; }
.msg.warn { color: #ffe2a3; }
.msg.fade { opacity: 0; }
@keyframes slidein { from { transform: translateX(-16px); opacity: 0; } }
@keyframes pulse { 50% { opacity: 0.55; } }

/* ---------- bottom bar ---------- */
#bottombar {
  position: absolute; bottom: 0; left: 50%; transform: translateX(-50%);
  display: flex; gap: 14px; align-items: flex-end;
  max-width: min(980px, calc(100vw - 32px));
  background: var(--panel);
  border: 1px solid var(--panel-border); border-bottom: none;
  border-radius: 14px 14px 0 0;
  padding: 10px 14px 8px;
  box-shadow: 0 -4px 18px rgba(0, 0, 0, 0.45);
  z-index: 10;
}
#buildmenu, #unitmenu { display: flex; gap: 6px; }
#unitmenu { border-left: 1px solid var(--panel-border); padding-left: 14px; }
#selectionmenu {
  display: grid; grid-template-columns: minmax(220px, 1fr) minmax(260px, auto);
  gap: 12px; align-items: stretch;
  min-width: min(760px, calc(100vw - 64px));
}
.selection-title {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  margin-bottom: 6px; font-size: 12px;
}
.selection-title small { opacity: 0.58; font-size: 10.5px; }
.selection-grid {
  display: grid; grid-template-columns: repeat(6, 58px); gap: 5px;
  max-height: 129px; overflow-y: auto; padding-right: 2px;
}
.selcard, .building-card, .cmdbtn {
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid var(--panel-border);
  color: #e8e6df; border-radius: 8px;
  font-family: inherit;
}
.selcard {
  width: 58px; height: 62px; padding: 4px 3px;
  display: grid; grid-template-rows: 19px 15px 12px 5px; align-items: center;
  cursor: pointer; transition: background 0.12s, transform 0.08s, border-color 0.12s;
}
.selcard:hover { background: rgba(255, 255, 255, 0.14); transform: translateY(-1px); }
.selcard.hero { border-color: rgba(255, 215, 94, 0.45); }
.selicon { font-size: 18px; line-height: 1; }
.selname {
  font-size: 9.5px; line-height: 1.05; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.selmeta { font-size: 8.5px; opacity: 0.58; text-transform: uppercase; }
.mini-hp {
  display: block; width: 100%; height: 5px; overflow: hidden;
  background: rgba(0, 0, 0, 0.55); border-radius: 999px;
}
.mini-hp span {
  display: block; height: 100%;
  background: linear-gradient(90deg, #d64545, #6fdc7f);
  border-radius: inherit;
}
#selection-actions {
  display: grid; grid-template-columns: repeat(4, 68px); grid-auto-rows: 62px;
  gap: 6px; align-content: start; justify-content: end;
}
.cmdbtn {
  width: 68px; min-height: 62px; padding: 5px 4px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  cursor: pointer; transition: background 0.12s, transform 0.08s, border-color 0.12s;
}
.cmdbtn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.14); transform: translateY(-1px); }
.cmdbtn.active, .cmdbtn.ready { border-color: var(--gold); background: rgba(255, 215, 94, 0.16); }
.cmdbtn.learnable { border-color: var(--good); background: rgba(89, 255, 156, 0.12); }
.cmdbtn.disabled, .cmdbtn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.cmdbtn.poor { opacity: 0.42; }
.cmdicon { font-size: 20px; line-height: 1; }
.cmdbtn b { font-size: 10.5px; line-height: 1.1; }
.cmdbtn small {
  font-size: 8.5px; max-width: 58px; opacity: 0.62;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ability-actions { display: contents; }
.building-card {
  display: grid; grid-template-columns: 34px minmax(130px, 1fr); grid-template-rows: auto 6px;
  gap: 4px 8px; align-items: center; min-width: 260px;
  padding: 9px 10px;
}
.building-card .selicon { grid-row: 1 / 3; font-size: 25px; }
.building-card b { font-size: 13px; }
.building-card small { display: block; margin-top: 2px; font-size: 11px; opacity: 0.7; }
.building-card .mini-hp { grid-column: 2; }
.plot-card {
  min-width: 300px;
  padding: 10px 12px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  background: rgba(255, 215, 94, 0.08);
  border: 1px solid rgba(255, 215, 94, 0.22);
  border-radius: 8px;
}
.plot-card.active { background: rgba(255, 215, 94, 0.13); }
.plot-icon { font-size: 27px; text-align: center; }
.plot-card b { font-size: 13px; }
.plot-card small { display: block; margin-top: 2px; font-size: 11px; opacity: 0.72; }
.plot-card .plot-effect {
  color: #ffe8a0;
  opacity: 0.88;
  white-space: normal;
  line-height: 1.25;
}
.plot-card .mini-hp { margin-top: 6px; height: 6px; }

.bbtn {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  width: 74px; padding: 6px 2px 5px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--panel-border);
  border-radius: 10px; color: #e8e6df; cursor: pointer;
  position: relative;
  transition: background 0.12s, transform 0.08s;
}
.bbtn:hover { background: rgba(255, 255, 255, 0.14); transform: translateY(-2px); }
.bbtn.active { background: rgba(255, 215, 94, 0.25); border-color: var(--gold); }
.bbtn.poor { opacity: 0.42; }
.bbtn .icon { font-size: 22px; line-height: 1.1; }
.bbtn .bname { font-size: 10.5px; opacity: 0.9; }
.bbtn .cost { font-size: 10px; color: var(--gold); }
.bbtn .hot {
  position: absolute; top: 3px; right: 5px;
  font-size: 9px; opacity: 0.55;
  border: 1px solid var(--panel-border); border-radius: 4px; padding: 0 3px;
}

/* ---------- minimap ---------- */
#minimap-wrap {
  position: absolute; right: 12px; bottom: 12px;
  width: 190px; height: 190px;
  border: 2px solid var(--panel-border); border-radius: 10px;
  overflow: hidden; cursor: crosshair;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.5);
  z-index: 10;
}
#minimap-wrap canvas {
  position: absolute; inset: 0; width: 100%; height: 100%;
  image-rendering: pixelated;
}

/* ---------- hero panel ---------- */
#heropanel {
  position: absolute; left: 12px; bottom: 12px; width: 248px;
  background: var(--panel);
  border: 1px solid rgba(201, 164, 74, 0.4);
  border-radius: 12px; padding: 10px 12px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.5);
  z-index: 11;
}
.hprow { display: flex; gap: 10px; align-items: center; }
.hpportrait { font-size: 34px; filter: drop-shadow(0 2px 6px rgba(0,0,0,0.6)); }
.hpinfo { flex: 1; font-size: 13px; }
.hplvl { color: var(--gold); font-weight: 700; margin-left: 4px; }
.hpbar.herohp { height: 7px; margin: 5px 0 0; }
.hpbar.heroxp { height: 5px; margin: 3px 0 0; }
.xpfill { height: 100%; background: linear-gradient(90deg, #7f5ce8, #c9a44a); border-radius: 4px; }
.hpabils { display: flex; gap: 7px; margin-top: 9px; }
.abtn {
  position: relative; width: 49px; height: 49px;
  border-radius: 9px; background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--panel-border);
  cursor: pointer; font-size: 21px; color: #e8e6df;
  transition: background 0.12s;
}
.abtn:hover { background: rgba(255, 255, 255, 0.14); }
.abtn.ready { border-color: rgba(89, 255, 156, 0.55); }
.abtn.unlearned { opacity: 0.45; }
.abtn .aicon, .abtn .ahot, .abtn .apips, .abtn .acd { pointer-events: none; }
.abtn .ahot { position: absolute; top: 1px; left: 5px; font-size: 9px; opacity: 0.65; }
.abtn .apips { position: absolute; bottom: 1px; left: 0; right: 0; font-size: 7.5px; letter-spacing: 1.5px; color: var(--gold); text-align: center; }
.abtn .acd {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.66); border-radius: 9px; font-size: 15px; font-weight: 700;
}
.abtn .alearn {
  position: absolute; top: -8px; right: -8px; width: 19px; height: 19px;
  border-radius: 50%; background: var(--gold); color: #1c1608;
  font-weight: 800; font-size: 14px; line-height: 19px; text-align: center;
  animation: pulse 1s infinite; cursor: pointer;
}
.hppoints { margin-top: 7px; font-size: 11.5px; color: var(--gold); }

/* ---------- hero picker (start screen) ---------- */
.herorow { display: flex; gap: 10px; justify-content: center; margin-bottom: 14px; }
.herocard {
  flex: 1; display: flex; flex-direction: column; gap: 3px; align-items: center;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--panel-border); border-radius: 12px;
  padding: 10px 8px; color: #e8e6df; cursor: pointer;
  transition: all 0.12s; font-family: inherit;
}
.herocard:hover { background: rgba(255, 255, 255, 0.12); transform: translateY(-2px); }
.herocard.sel { border-color: var(--gold); background: rgba(255, 215, 94, 0.14); }
.herocard .hicon { font-size: 26px; }
.herocard b { font-size: 12.5px; }
.herocard small { font-size: 10px; opacity: 0.65; line-height: 1.35; }
.herocard .habils { font-size: 13px; margin-top: 2px; }

/* ---------- selection panel ---------- */
#selpanel {
  position: absolute; left: 12px; bottom: 212px;
  min-width: 210px; max-width: 280px;
  background: var(--panel); border: 1px solid var(--panel-border);
  border-radius: 12px; padding: 10px 12px;
  font-size: 13px; z-index: 9;
}
#selpanel .selunit { margin-right: 8px; }
.hpbar { height: 8px; background: rgba(0,0,0,0.55); border-radius: 4px; margin: 6px 0 3px; overflow: hidden; }
.hpfill { height: 100%; background: linear-gradient(90deg, #d64545, #6fdc7f); border-radius: 4px; }

/* ---------- tooltip ---------- */
#tooltip {
  position: fixed; z-index: 40; pointer-events: none !important;
  background: rgba(10, 13, 18, 0.96);
  border: 1px solid rgba(255, 215, 94, 0.35);
  border-radius: 10px; padding: 9px 12px;
  font-size: 12.5px; max-width: 260px; line-height: 1.5;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
}
.tcost { color: var(--gold); }
.tfx { color: #9fd6ff; }
.tdesc { opacity: 0.8; }

.hidden { display: none !important; }

/* ---------- overlay screens ---------- */
.screen {
  position: absolute; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, rgba(10, 14, 20, 0.82), rgba(5, 7, 10, 0.95));
  backdrop-filter: blur(3px);
}
.screen .panel {
  position: relative;
  max-width: 720px; width: calc(100vw - 40px);
  max-height: calc(100vh - 32px); overflow-y: auto;
  background: var(--panel); border: 1px solid var(--panel-border);
  border-radius: 18px; padding: 30px 34px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}
.screen .panel.shell-panel {
  width: min(1180px, calc(100vw - 44px));
  max-width: none;
  min-height: min(690px, calc(100vh - 36px));
  padding: 0;
  display: grid;
  grid-template-columns: 278px minmax(0, 1fr);
  text-align: left;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(25, 31, 34, 0.96), rgba(12, 15, 20, 0.94)),
    radial-gradient(circle at 72% 18%, rgba(255, 215, 94, 0.14), transparent 34%);
}
.screen h1 {
  font-size: 44px; letter-spacing: 6px; margin-bottom: 6px;
  color: var(--gold);
  text-shadow: 0 0 30px rgba(255, 215, 94, 0.3);
}
.shell-side {
  padding: 24px 18px;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.22);
  display: flex; flex-direction: column; gap: 18px;
}
.brandblock {
  display: grid; grid-template-columns: 44px minmax(0, 1fr);
  gap: 12px; align-items: center;
}
.brandmark {
  width: 44px; height: 44px; border-radius: 9px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #ffd75e, #9f6c26);
  color: #181008; font-size: 28px; font-weight: 900;
  box-shadow: 0 0 24px rgba(255, 215, 94, 0.22);
}
.brandblock h1 {
  font-size: 30px; line-height: 1; letter-spacing: 2px; margin: 0;
}
.brandblock p { margin-top: 5px; font-size: 12px; opacity: 0.7; }
.shell-panel .profilerow {
  display: grid; gap: 8px; justify-content: stretch;
  margin: 0; padding: 12px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
}
.shell-panel .profilerow label {
  display: grid; gap: 6px; font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.08em; color: rgba(232, 230, 223, 0.62);
}
.shell-panel .profilerow input { width: 100%; font-size: 14px; text-transform: none; letter-spacing: 0; }
.shell-panel #prof-stats { min-height: 18px; line-height: 1.35; }
.shellnav { display: grid; gap: 7px; }
.shellnav-btn {
  width: 100%; min-height: 46px; padding: 0 12px;
  display: flex; align-items: center; justify-content: flex-start;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid transparent;
  border-radius: 8px;
  color: #e8e6df; font-family: inherit; font-size: 15px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, transform 0.08s;
}
.shellnav-btn:hover { background: rgba(255, 255, 255, 0.1); transform: translateX(2px); }
.shellnav-btn.active {
  border-color: rgba(255, 215, 94, 0.45);
  background: rgba(255, 215, 94, 0.14);
  color: #ffe8a0;
}
.shell-online {
  margin-top: auto;
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px; border-radius: 8px;
  background: rgba(89, 255, 156, 0.08);
  border: 1px solid rgba(89, 255, 156, 0.14);
  font-size: 12px;
}
.shell-online span { opacity: 0.65; }
.shell-online b { color: var(--good); }
.shell-main {
  min-width: 0;
  padding: 26px;
  overflow-y: auto;
}
.menu-view { display: none; }
.menu-view.active { display: block; }
.playhero {
  min-height: 210px;
  display: grid; grid-template-columns: minmax(0, 1fr) 220px;
  gap: 22px; align-items: end;
  padding: 24px;
  border: 1px solid rgba(255, 215, 94, 0.14);
  border-radius: 12px;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.48), rgba(0, 0, 0, 0.1)),
    radial-gradient(circle at 78% 22%, rgba(255, 215, 94, 0.18), transparent 32%),
    linear-gradient(135deg, rgba(89, 255, 156, 0.08), rgba(255, 93, 82, 0.08));
  margin-bottom: 18px;
}
.eyebrow {
  display: inline-block; margin-bottom: 8px;
  color: var(--gold); font-size: 11px; font-weight: 800;
  letter-spacing: 0.16em; text-transform: uppercase;
}
.screen h2 {
  font-size: 34px; line-height: 1.05; letter-spacing: 0;
  color: #f4f1e7; margin-bottom: 10px;
}
.playcopy p {
  max-width: 570px;
  font-size: 15px; line-height: 1.55; opacity: 0.78;
}
.play-actions { display: grid; gap: 10px; align-content: end; }
.play-actions .diffbtn { width: 100%; align-items: flex-start; }
.menu-section {
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.035);
  margin-bottom: 14px;
}
.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 14px; margin-bottom: 12px;
}
.section-head.wide {
  align-items: start; margin-bottom: 16px;
}
.section-head b { font-size: 14px; }
.section-head small {
  max-width: 340px; color: rgba(232, 230, 223, 0.62);
  font-size: 12px; line-height: 1.4;
}
.section-head.wide h2 { margin: 0; }
.setup-grid {
  display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(260px, 0.65fr);
  gap: 14px;
}
.run-setup #continuerow { justify-content: stretch; }
.run-setup #continuerow .diffbtn { width: 100%; margin-bottom: 8px; }
.run-setup .diffrow {
  display: grid; grid-template-columns: 1fr; gap: 8px; margin: 0;
}
.multiplayer-grid {
  display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(300px, 0.9fr);
  gap: 14px; align-items: start;
}
.roomhub { display: grid; gap: 10px; }
.roomcard, .profilecard {
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.045);
}
.roomcard.active { border-color: rgba(255, 215, 94, 0.28); background: rgba(255, 215, 94, 0.08); }
.roomcard.locked { opacity: 0.5; }
.roomcard b, .profilecard b { display: block; margin-bottom: 4px; font-size: 14px; }
.roomcard small, .profilecard p {
  display: block; color: rgba(232, 230, 223, 0.68);
  font-size: 12px; line-height: 1.45;
}
.roomactions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.roomcard > .diffbtn { margin-top: 12px; width: 100%; }
.profilecards {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.shell-panel .controls {
  justify-content: flex-start; gap: 8px;
  opacity: 1;
}
.shell-panel .controls span {
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 8px 10px;
  color: rgba(232, 230, 223, 0.72);
}
.shell-panel .controls b { color: var(--gold); }
.shell-panel .resume {
  position: absolute; right: 24px; bottom: 20px;
  z-index: 2;
}
.shell-panel .herorow {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 0;
}
.shell-panel .herocard {
  min-width: 0;
  align-items: flex-start;
  text-align: left;
  min-height: 168px;
}
.shell-panel .herocard .hcinematic {
  width: 100%;
}
.panel.lose h1 { color: var(--danger); text-shadow: 0 0 30px rgba(255, 93, 82, 0.3); }
.panel.win h1 { color: var(--good); text-shadow: 0 0 30px rgba(89, 255, 156, 0.3); }
.tagline { opacity: 0.85; margin-bottom: 18px; font-size: 15px; }
.howto {
  text-align: left; font-size: 13.5px; line-height: 1.65;
  background: rgba(0, 0, 0, 0.25); border-radius: 10px;
  padding: 12px 16px; margin-bottom: 18px;
  display: flex; flex-direction: column; gap: 5px;
}
.howto.stats { font-size: 15px; }
.diffrow { display: flex; gap: 10px; justify-content: center; margin-bottom: 16px; }
.diffbtn {
  display: flex; flex-direction: column; gap: 2px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--panel-border);
  color: #e8e6df; border-radius: 10px;
  padding: 10px 18px; font-size: 15px; font-weight: 600; cursor: pointer;
  transition: all 0.12s;
}
.diffbtn small { font-size: 10.5px; font-weight: 400; opacity: 0.65; }
.diffbtn:hover { background: rgba(255, 255, 255, 0.16); transform: translateY(-2px); }
.diffbtn.primary { background: rgba(255, 215, 94, 0.18); border-color: rgba(255, 215, 94, 0.5); }
.diffbtn.primary:hover { background: rgba(255, 215, 94, 0.3); }
.controls { display: flex; flex-wrap: wrap; gap: 6px 14px; justify-content: center; font-size: 12px; opacity: 0.7; }

/* On narrower screens, pin the build bar between the hero panel and minimap. */
@media (max-width: 1650px) {
  #bottombar { left: 286px; right: 218px; transform: none; justify-content: center; }
}

@media (max-width: 760px) {
  #topbar {
    left: 8px; right: 8px; transform: none;
    max-width: calc(100vw - 16px);
    justify-content: flex-start;
    overflow-x: auto;
    padding: 6px 8px;
  }
  .res { font-size: 12px; padding: 2px 5px; }
  #r-plot { max-width: 170px; }
}

/* ---------- co-op lobby ---------- */
.mprow { display: flex; gap: 10px; align-items: center; justify-content: center; margin-bottom: 10px; flex-wrap: wrap; }
.mphint { font-size: 11px; opacity: 0.6; max-width: 240px; text-align: left; }
#mp-panel { margin-top: 4px; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.mpstatus { font-size: 13px; color: #ffe2a3; }
.mpstatus.ok { color: var(--good); }
.mpcode {
  width: 100%; height: 56px; resize: none;
  background: rgba(0, 0, 0, 0.4); color: #9fd6ff;
  border: 1px solid var(--panel-border); border-radius: 8px;
  font-size: 10px; font-family: monospace; padding: 6px;
}
.diffrow.disabled { pointer-events: none; opacity: 0.45; }
#waitind {
  position: absolute; top: 64px; left: 50%; transform: translateX(-50%);
  background: var(--panel); border: 1px solid rgba(255, 215, 94, 0.4);
  border-radius: 10px; padding: 8px 16px; font-size: 14px;
  z-index: 12; animation: pulse 1.2s infinite;
}

/* hero portraits and menu cinematics */
.herocard .hcinematic {
  width: 112px; max-width: 100%; aspect-ratio: 16 / 10;
  object-fit: cover; object-position: center top;
  border-radius: 10px; border: 1px solid var(--panel-border);
  background: rgba(0, 0, 0, 0.35);
}
.herocard .hcinematic + .hicon { display: none; }
.hpportrait img {
  width: 46px; height: 46px; object-fit: cover; object-position: top;
  border-radius: 9px; border: 1px solid rgba(201, 164, 74, 0.5); display: block;
}

/* profile + continue */
.profilerow {
  display: flex; gap: 12px; align-items: center; justify-content: center;
  margin-bottom: 12px; font-size: 13px; flex-wrap: wrap;
}
.profilerow input {
  background: rgba(0, 0, 0, 0.35); color: var(--gold);
  border: 1px solid var(--panel-border); border-radius: 7px;
  padding: 4px 8px; font-size: 13px; width: 150px; font-family: inherit;
}
#prof-stats { opacity: 0.75; font-size: 12px; }
#continuerow { display: flex; justify-content: center; margin-bottom: 10px; }

/* mode picker + public lobby */
.moderow, .survivalstyle {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px; margin-bottom: 12px;
}
.survivalstyle { margin-top: -2px; }
.modecard, .stylecard {
  display: flex; flex-direction: column; gap: 2px; align-items: center;
  background: rgba(255, 255, 255, 0.05); border: 1px solid var(--panel-border);
  border-radius: 10px; padding: 10px 12px; color: #e8e6df; cursor: pointer;
  font-family: inherit; transition: all 0.12s;
}
.modecard:hover, .stylecard:hover { background: rgba(255, 255, 255, 0.12); transform: translateY(-2px); }
.modecard.sel, .stylecard.sel { border-color: var(--gold); background: rgba(255, 215, 94, 0.14); }
.modecard.locked { opacity: 0.45; cursor: not-allowed; }
.modecard b, .stylecard b { font-size: 13px; }
.modecard small, .stylecard small { font-size: 10.5px; opacity: 0.68; }
.lobbybox {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px;
  text-align: left; background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--panel-border); border-radius: 10px;
  padding: 10px; margin-bottom: 12px;
}
.lobbytop { display: flex; align-items: center; justify-content: space-between; gap: 8px; grid-column: 1 / -1; }
.lobbytop div { display: flex; flex-direction: column; gap: 1px; }
.lobbytop b { font-size: 13px; }
.lobbytop small, #lobby-count { font-size: 11px; opacity: 0.68; }
.lobbyactions { display: flex; gap: 8px; justify-content: flex-end; grid-column: 1 / -1; flex-wrap: wrap; }
.lobbystatus { grid-column: 1 / -1; font-size: 12px; color: #ffe2a3; min-height: 18px; }
.lobbystatus.ok { color: var(--good); }
.lobbyplayers, .lobbychat {
  min-height: 96px; max-height: 118px; overflow-y: auto;
  background: rgba(0, 0, 0, 0.28); border: 1px solid var(--panel-border);
  border-radius: 8px; padding: 7px; font-size: 12px;
}
.lobbyplayer, .lobbymsg { display: flex; gap: 7px; align-items: baseline; margin-bottom: 5px; min-width: 0; }
.lobbyplayer { justify-content: space-between; }
.lobbyplayer span, .lobbymsg span { overflow-wrap: anywhere; }
.lobbyplayer small { opacity: 0.6; white-space: nowrap; }
.lobbymsg { flex-direction: column; gap: 1px; }
.lobbymsg b { color: var(--gold); font-size: 11px; }
.lobbyempty { opacity: 0.5; font-style: italic; }
.lobbyform { display: flex; gap: 8px; grid-column: 1 / -1; }
.lobbyform input {
  flex: 1; min-width: 0; background: rgba(0, 0, 0, 0.35); color: #e8e6df;
  border: 1px solid var(--panel-border); border-radius: 7px;
  padding: 7px 8px; font-size: 13px; font-family: inherit;
  user-select: text; -webkit-user-select: text;
}

/* campaign level picker */
.levelrow { display: flex; gap: 7px; justify-content: center; margin-bottom: 12px; }
.levelcard {
  flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; align-items: center;
  background: rgba(255, 255, 255, 0.05); border: 1px solid var(--panel-border);
  border-radius: 10px; padding: 8px 5px; color: #e8e6df; cursor: pointer;
  transition: all 0.12s; font-family: inherit;
}
.levelcard:hover:not(.locked) { background: rgba(255, 255, 255, 0.12); transform: translateY(-2px); }
.levelcard.sel { border-color: var(--danger); background: rgba(255, 93, 82, 0.12); }
.levelcard.locked { opacity: 0.4; cursor: not-allowed; }
.levelcard .lvnum { font-size: 15px; font-weight: 800; color: var(--gold); }
.levelcard b { font-size: 10.5px; }
.levelcard small { font-size: 8.5px; opacity: 0.6; line-height: 1.25; }
.levelcard .lvboss { font-size: 9px; color: #ff9a8f; }

/* boss health bar */
#bossbar {
  position: absolute; top: 52px; left: 50%; transform: translateX(-50%);
  width: min(560px, 60vw); z-index: 12; text-align: center;
  pointer-events: none !important;
}
#bossbar b { font-size: 15px; color: #ff9a8f; text-shadow: 0 2px 8px rgba(0,0,0,0.8); }
.bossfillwrap {
  height: 12px; margin-top: 3px;
  background: rgba(0, 0, 0, 0.65); border: 1px solid rgba(255, 93, 82, 0.6);
  border-radius: 6px; overflow: hidden;
}
#boss-fill { height: 100%; background: linear-gradient(90deg, #7c1f1f, #e6493a); transition: width 0.2s; }

@media (max-width: 720px) {
  .screen .panel { padding: 22px 18px; }
  .screen h1 { font-size: 34px; letter-spacing: 4px; }
  .lobbybox { grid-template-columns: 1fr; }
  .lobbyactions { justify-content: stretch; }
  .lobbyactions .tbtn, .lobbyform .tbtn { flex: 1; }
  .herorow, .levelrow { flex-wrap: wrap; }
  #heropanel {
    left: 8px; bottom: 8px;
    width: min(248px, calc(100vw - 160px));
    padding: 8px 10px;
  }
  #minimap-wrap {
    right: 8px; bottom: 8px;
    width: 136px; height: 136px;
  }
  #bottombar {
    left: 8px; right: 8px; bottom: 152px;
    transform: none; max-width: none; padding: 8px;
    max-height: 36vh; overflow-y: auto;
  }
  #selectionmenu { grid-template-columns: 1fr; min-width: 0; width: 100%; }
  .selection-grid { grid-template-columns: repeat(5, 1fr); max-height: 132px; }
  .selcard { width: 100%; }
  #selection-actions { grid-template-columns: repeat(4, 1fr); justify-content: stretch; }
  .cmdbtn { width: 100%; }
  .plot-card { min-width: 0; }
}

@media (max-width: 920px) {
  .screen { align-items: stretch; justify-content: stretch; }
  .screen .panel.shell-panel {
    width: 100vw;
    min-height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    grid-template-columns: 1fr;
    overflow-y: auto;
  }
  .shell-side {
    padding: 14px;
    border-right: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }
  .brandblock { grid-template-columns: 38px minmax(0, 1fr); }
  .brandmark { width: 38px; height: 38px; font-size: 24px; border-radius: 8px; }
  .brandblock h1 { font-size: 25px; }
  .shellnav { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .shellnav-btn {
    min-height: 38px;
    justify-content: center;
    padding: 0 6px;
    font-size: 12.5px;
  }
  .shellnav-btn:hover { transform: none; }
  .shell-online { margin-top: 0; }
  .shell-main {
    padding: 14px;
    overflow: visible;
  }
  .playhero,
  .setup-grid,
  .multiplayer-grid,
  .profilecards {
    grid-template-columns: 1fr;
  }
  .playhero {
    min-height: 0;
    padding: 18px;
  }
  .screen h2 { font-size: 28px; }
  .section-head,
  .section-head.wide {
    display: grid;
    gap: 6px;
  }
  .shell-panel .herorow { grid-template-columns: 1fr; }
  .shell-panel .herocard {
    min-height: 0;
    display: grid;
    grid-template-columns: 116px minmax(0, 1fr);
    grid-template-rows: auto auto auto;
    column-gap: 10px;
    align-items: center;
  }
  .shell-panel .herocard .hcinematic {
    grid-row: 1 / 4;
  }
  .roomactions { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .shellnav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .shell-panel .profilerow { padding: 10px; }
  .shell-panel .herocard { grid-template-columns: 96px minmax(0, 1fr); }
  .play-actions { grid-template-columns: 1fr; }
}
