/* Server Simulator: night-sky fantasy look from the UI mockups.
   Glass panels with a soft blue edge glow sit over painted island art.
   Amber is the single action/selection accent; green, purple and cyan come from the board's zones and traffic. */

:root {
  --bg: #070b1c;
  --glass: rgba(16, 22, 54, 0.86);
  --glass-2: rgba(26, 36, 82, 0.9);
  --line: rgba(130, 160, 255, 0.24);
  --line-strong: rgba(140, 175, 255, 0.5);
  --text: #eef2ff;
  --muted: #9ba7d4;
  --accent: #ffc440;
  --accent-2: #ff9f1c;
  --accent-ink: #2a1600;
  --ok: #3ee6a0;
  --warn: #ffb547;
  --bad: #ff5a4e;
  --cyan: #56d0ff;
  --purple: #8f5cff;
  --radius: 12px;
  --radius-lg: 18px;
  --font: "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --glow: 0 0 0 1px rgba(255,255,255,0.04) inset, 0 12px 40px rgba(0,0,0,0.45), 0 0 26px rgba(70,130,255,0.18);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: 600 14px/1.45 var(--font);
}

canvas#scene { position: fixed; inset: 0; display: block; touch-action: none; cursor: grab; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
h1, h2, h3, h4 { margin: 0; line-height: 1.15; }
p { margin: 0 0 0.6em; }
.ico { display: inline-grid; place-items: center; line-height: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.eyebrow { color: var(--muted); font-size: 13px; font-weight: 700; margin-bottom: 4px; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  font: inherit; font-weight: 800;
  color: var(--text);
  background: linear-gradient(180deg, rgba(40,54,110,0.85), rgba(24,32,74,0.9));
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 16px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s, transform .1s, background .15s;
}
.btn:hover:not(:disabled) { border-color: var(--line-strong); box-shadow: 0 0 14px rgba(90,150,255,0.25); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:focus-visible, .mbtn:focus-visible, .rail-btn:focus-visible, .icon-btn:focus-visible, .tab:focus-visible, .seg-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: linear-gradient(180deg, #ffd766, #ffb21e); color: var(--accent-ink); border-color: #ffd766; box-shadow: 0 0 18px rgba(255,180,40,0.35); }
.btn-primary:hover:not(:disabled) { box-shadow: 0 0 26px rgba(255,190,60,0.55); border-color: #ffe39a; }
.btn-outline { background: rgba(255,196,64,0.08); border-color: rgba(255,196,64,0.75); color: #ffe7a8; }
.btn-danger { color: #ffb4ad; }
.btn-danger:hover:not(:disabled) { border-color: var(--bad); box-shadow: 0 0 14px rgba(255,90,78,0.3); }
.btn-small { padding: 7px 11px; font-size: 13px; }
.btn-tiny { padding: 2px 9px; font-size: 12px; border-radius: 7px; }
.btn-square { padding: 7px; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 42px; height: 42px;
  color: var(--text);
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.icon-btn:hover { border-color: var(--line-strong); box-shadow: 0 0 14px rgba(90,150,255,0.3); }

/* ---------- Brand ---------- */

.brand { display: flex; align-items: center; gap: 10px; }
.brand-text { display: grid; line-height: 1; }
.brand-text small { font-size: 13px; font-weight: 800; color: #dfe6ff; letter-spacing: 0.02em; }
.brand-text b { font-size: 22px; font-weight: 900; color: var(--accent); text-shadow: 0 0 14px rgba(255,170,40,0.35); }
.brand-lg .brand-text small { font-size: 15px; }
.brand-lg .brand-text b { font-size: 26px; }

/* ---------- Menu screens ---------- */

.screen { position: fixed; inset: 0; overflow: auto; padding: 16px; }
.screen-menu {
  display: grid;
  align-items: center;
  padding-left: clamp(16px, 7vw, 120px);
  background: linear-gradient(90deg, rgba(7,11,28,0.85) 0%, rgba(7,11,28,0.55) 30%, rgba(7,11,28,0) 52%);
}
.screen-levels { display: grid; place-items: center; background: rgba(6,10,26,0.72); backdrop-filter: blur(3px); }

.menu-col { width: min(420px, 100%); display: grid; gap: 0; }
.menu-col > * { animation: rise .5s cubic-bezier(.2,.8,.2,1) both; animation-delay: calc(var(--i, 0) * 60ms + 80ms); }
.title { display: grid; font-weight: 900; font-size: clamp(46px, 6.4vw, 78px); line-height: 0.98; letter-spacing: -0.01em; margin: 34px 0 18px; text-shadow: 0 6px 24px rgba(0,0,0,0.5); }
.title-accent { background: linear-gradient(180deg, #ffe07a 10%, #ffb21e 60%, #ff8a00); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 0 16px rgba(255,170,40,0.35)); }
.title-sm { font-size: 38px; margin-top: 0; }
.tagline { color: #c7d0f2; font-size: 17px; font-weight: 700; margin: 0 0 26px; max-width: 30ch; }

.menu-buttons { display: grid; gap: 10px; }
.mbtn {
  display: flex; align-items: center; gap: 14px;
  font: inherit; font-size: 18px; font-weight: 800;
  color: var(--text);
  text-align: left;
  background: linear-gradient(180deg, rgba(26,34,72,0.92), rgba(14,20,48,0.92));
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px 18px;
  cursor: pointer;
  animation: rise .5s cubic-bezier(.2,.8,.2,1) both;
  animation-delay: calc(var(--i, 0) * 60ms + 200ms);
  transition: border-color .15s, box-shadow .2s, transform .15s;
}
.mbtn:hover:not(:disabled) { border-color: var(--line-strong); box-shadow: 0 0 20px rgba(90,150,255,0.25); transform: translateX(4px); }
.mbtn:disabled { opacity: 0.5; cursor: not-allowed; }
.mbtn-label { flex: 1; }
.mbtn-primary {
  position: relative; overflow: hidden;
  background: linear-gradient(180deg, #ffd766, #ffb21e);
  color: var(--accent-ink);
  border-color: #ffe08a;
  box-shadow: 0 0 24px rgba(255,180,40,0.45);
}
.mbtn-primary:hover:not(:disabled) { box-shadow: 0 0 34px rgba(255,190,60,0.7); }
.mbtn-primary::after {
  content: ""; position: absolute; inset: 0 auto 0 -40%; width: 30%;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,0.55), transparent);
  transform: skewX(-20deg); transition: left .6s;
}
.mbtn-primary:hover::after { left: 120%; }
.mbtn-pill { font-size: 13px; font-weight: 800; color: #c9d4ff; background: rgba(100,130,255,0.18); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; }
.mbtn-pill:empty { display: none; }

.stat-card {
  display: grid; grid-template-columns: 1fr 1fr;
  margin-top: 22px;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--glow);
}
.stat-item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; }
.stat-item + .stat-item { border-left: 1px solid var(--line); }
.stat-item small { display: block; color: #8fb2ff; font-size: 14px; font-weight: 800; }
.stat-item b { font-size: 17px; font-weight: 900; }
.stat-ico { color: #8fb2ff; }
.star { color: var(--accent); filter: drop-shadow(0 0 6px rgba(255,190,60,0.6)); }

.levels-wrap { width: min(1040px, 100%); }
.levels-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 20px; }
.levels-head h2 { font-size: 34px; font-weight: 900; }
.level-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(178px, 1fr)); gap: 14px; }
.level-grid li { animation: rise .45s cubic-bezier(.2,.8,.2,1) both; animation-delay: calc(var(--i, 0) * 40ms); }
.level-card {
  position: relative; width: 100%; min-height: 168px;
  display: flex; flex-direction: column; gap: 6px; text-align: left;
  font: inherit; color: var(--text);
  background: linear-gradient(180deg, rgba(28,38,86,0.92), rgba(12,18,46,0.94));
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  cursor: pointer;
  box-shadow: var(--glow);
  transition: transform .15s, border-color .15s, box-shadow .2s;
}
.level-card:hover:not(:disabled) { transform: translateY(-3px); border-color: var(--accent); box-shadow: 0 0 26px rgba(255,190,60,0.3); }
.level-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.level-card.locked { opacity: 0.55; cursor: not-allowed; }
.level-num { font-size: 30px; font-weight: 900; color: #6f86d6; font-variant-numeric: tabular-nums; }
.level-card.done .level-num { color: var(--accent); text-shadow: 0 0 14px rgba(255,180,40,0.4); }
.level-title { font-weight: 900; font-size: 16px; flex: 1; }
.level-diff { font-size: 12px; font-weight: 800; color: var(--muted); }
.diff-beginner { color: #7fe3b8; } .diff-easy { color: #8fd0ff; } .diff-medium { color: #ffd27a; } .diff-hard { color: #ff9d7a; } .diff-expert { color: #d29bff; }
.level-stars { color: var(--accent); letter-spacing: 3px; font-size: 17px; }
.level-card.locked .level-stars { color: var(--muted); letter-spacing: 0; font-size: 12px; display: flex; align-items: center; gap: 6px; }

/* ---------- HUD ---------- */

.topbar {
  position: fixed; top: 12px; left: 16px; right: 16px;
  display: flex; align-items: center; gap: 22px;
  z-index: 6; pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.topbar .brand { padding-right: 22px; border-right: 1px solid var(--line); }

.mission-pill {
  display: flex; align-items: center; gap: 14px;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 9px 18px;
  box-shadow: var(--glow);
  min-width: 0;
  font-variant-numeric: tabular-nums;
}
.pill-ico { color: #b9c8ff; }
.pill-title { font-size: 16px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill-bar { width: 130px; height: 7px; background: rgba(255,255,255,0.1); border-radius: 99px; overflow: hidden; flex: none; }
.pill-fill { height: 100%; width: 0; background: linear-gradient(90deg, #2ee59d, #7ff5c6); border-radius: 99px; box-shadow: 0 0 10px rgba(62,230,160,0.6); transition: width .4s; }
.pill-count { font-size: 14px; font-weight: 800; color: var(--ok); white-space: nowrap; display: flex; align-items: center; gap: 6px; }
.pill-count.bad { color: var(--bad); }
.pill-count.muted { color: var(--muted); }
.pill-clock { font-size: 17px; font-weight: 900; color: #fff; }
.pill-paused { color: var(--accent); }

.top-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.xp-pill {
  display: inline-flex; align-items: center; gap: 8px;
  font: inherit; font-size: 15px; font-weight: 900; color: var(--text);
  background: var(--glass); border: 1px solid var(--line); border-radius: 999px;
  padding: 8px 16px; cursor: pointer; box-shadow: var(--glow);
  font-variant-numeric: tabular-nums;
}
.xp-pill.bump { animation: bump .6s ease; }
.avatar-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px 3px 3px;
  color: var(--text);
  background: var(--glass); border: 1px solid var(--line); border-radius: 999px;
  cursor: pointer; box-shadow: var(--glow);
}
.avatar-img { display: inline-grid; line-height: 0; }

.rail {
  position: fixed; left: 16px; top: 96px;
  display: grid; gap: 8px; padding: 10px;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--glow);
  z-index: 6;
}
.rail-btn {
  position: relative;
  display: grid; place-items: center;
  width: 46px; height: 46px;
  color: #c9d3f5;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 12px;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s, box-shadow .15s;
}
.rail-btn:hover { color: #fff; background: rgba(90,130,255,0.14); }
.rail-btn[aria-pressed="true"], .rail-btn.active {
  color: #fff;
  background: linear-gradient(180deg, rgba(60,110,255,0.45), rgba(40,70,200,0.35));
  border-color: rgba(120,170,255,0.75);
  box-shadow: 0 0 16px rgba(80,140,255,0.45);
}
.rail-dot { position: absolute; top: 9px; right: 9px; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.rail-sep { height: 1px; background: var(--line); margin: 2px 6px; }

.panel {
  position: fixed;
  background: linear-gradient(180deg, rgba(24,32,78,0.9), rgba(10,15,40,0.92));
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--glow);
  backdrop-filter: blur(8px);
  z-index: 5;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(140,170,255,0.35) transparent;
  transition: opacity .22s, transform .22s, visibility .22s;
}
.panel.hidden { opacity: 0; pointer-events: none; visibility: hidden; }
.drawer.hidden { transform: translateX(-16px); }
.mission-card.hidden { transform: translateX(16px); }
.panel-title { font-size: 15px; font-weight: 900; display: flex; align-items: center; gap: 8px; }
.panel-note { color: var(--muted); font-size: 12.5px; margin: 4px 0 0; }

.drawer { top: 96px; left: 98px; max-height: calc(100vh - 120px); width: 236px; padding: 14px 12px; }
.drawer-head { padding: 0 4px 6px; }
.pal-group { font-size: 11.5px; font-weight: 900; color: #8fa3e6; margin: 14px 4px 6px; text-transform: uppercase; letter-spacing: 0.06em; }
.pal-item {
  width: 100%;
  display: grid; grid-template-columns: 30px 1fr auto; grid-template-areas: "ic name new" "ic cost cost";
  column-gap: 10px; align-items: center; text-align: left;
  font: inherit; color: var(--text);
  background: rgba(255,255,255,0.02);
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 7px 8px; margin-bottom: 3px;
  cursor: grab; touch-action: none; user-select: none;
  transition: background .12s, border-color .12s, transform .12s;
}
.pal-item:hover { background: rgba(90,130,255,0.12); border-color: var(--line); transform: translateX(2px); }
.pal-item.active { border-color: var(--accent); background: rgba(255,196,64,0.12); box-shadow: 0 0 14px rgba(255,190,60,0.25); }
.pal-icon { grid-area: ic; width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; font-size: 10px; font-weight: 900; color: #fff; box-shadow: inset 0 -3px 0 rgba(0,0,0,0.25), 0 0 10px var(--c); background: var(--c); }
.pal-name { grid-area: name; font-weight: 800; font-size: 13.5px; }
.pal-cost { grid-area: cost; color: var(--muted); font-size: 12px; }
.pal-new { grid-area: new; font-size: 10.5px; font-weight: 900; color: var(--accent-ink); background: var(--accent); border-radius: 6px; padding: 1px 6px; }

.mission-card { top: 96px; right: 16px; bottom: 112px; width: 344px; padding: 0 0 16px; }
.tabs { position: sticky; top: 0; z-index: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 10px 12px 8px; background: linear-gradient(180deg, rgba(24,32,78,0.98), rgba(24,32,78,0.85)); }
.tab { font: inherit; font-weight: 800; font-size: 13px; color: var(--muted); background: transparent; border: 1px solid transparent; border-radius: 9px; padding: 6px; cursor: pointer; }
.tab[aria-selected="true"] { color: var(--text); background: rgba(90,130,255,0.18); border-color: var(--line); }
#mission, #inspector { padding: 6px 18px 0; }

.mission-head { position: relative; padding: 4px 0 12px; }
.mission-head .flag { position: absolute; right: -6px; top: -4px; opacity: 0.95; }
.mission-title { font-size: 26px; font-weight: 900; margin-bottom: 6px; padding-right: 64px; }
.mission-summary { color: #c4cdf0; font-size: 13.5px; }
.budget { display: grid; grid-template-columns: 1fr auto; gap: 6px; font-size: 14px; margin: 6px 0 14px; font-variant-numeric: tabular-nums; }
.budget strong { font-size: 17px; font-weight: 900; }
.meter { grid-column: 1 / -1; height: 7px; background: rgba(255,255,255,0.1); border-radius: 99px; overflow: hidden; }
.meter-fill { height: 100%; background: linear-gradient(90deg, #2ee59d, #7ff5c6); border-radius: 99px; box-shadow: 0 0 10px rgba(62,230,160,0.5); transition: width .4s; }
.budget.over strong { color: var(--bad); }
.budget.over .meter-fill { background: linear-gradient(90deg, #ff5a4e, #ff9a8f); box-shadow: 0 0 10px rgba(255,90,78,0.5); }

.obj-list { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 9px; }
.obj-list li { position: relative; padding-left: 32px; font-size: 13.5px; }
.obj-list:not(.live) li::before { content: ""; position: absolute; left: 8px; top: 7px; width: 7px; height: 7px; border-radius: 2px; background: #6f86d6; }
.obj-list .bonus { color: #ffe3a3; }
.obj-list li.bad { color: #ffb4ad; }
.obj-list.live .tick {
  position: absolute; left: 0; top: 0;
  width: 21px; height: 21px;
  border: 2px solid rgba(140,170,255,0.45);
  border-radius: 6px;
  display: grid; place-items: center;
  color: #062317;
  transition: background .2s, border-color .2s;
}
.obj-list.live li.ok .tick { background: var(--ok); border-color: var(--ok); box-shadow: 0 0 10px rgba(62,230,160,0.5); animation: pop .35s ease; }
.obj-list.live li.ok > .obj-text { color: #e6ecff; }

.target-row { display: flex; align-items: center; gap: 10px; font-size: 13.5px; background: rgba(255,255,255,0.04); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; margin: 6px 0 12px; }
.target-row .ico { color: var(--accent); }
.hints { margin: 0 0 12px; padding: 10px 12px 10px 30px; background: rgba(255,196,64,0.07); border: 1px solid rgba(255,196,64,0.25); border-radius: 10px; font-size: 13px; display: grid; gap: 6px; }
.hints li { animation: rise .3s ease both; }
.mission-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 6px; }

.facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 10px 0; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 800; }
.status-healthy { color: var(--ok); } .status-busy { color: var(--warn); } .status-overloaded, .status-down { color: var(--bad); }
.sub { font-size: 11.5px; color: #8fa3e6; margin: 14px 0 6px; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 900; }
.svc-head { display: flex; align-items: center; gap: 10px; margin: 6px 0 8px; }
.svc-head h3 { font-size: 19px; font-weight: 900; }
.opt { display: grid; gap: 5px; margin: 12px 0; font-size: 13px; }
.opt span { color: var(--muted); }
select { font: inherit; color: var(--text); background: rgba(12,18,46,0.9); border: 1px solid var(--line); border-radius: 9px; padding: 7px 9px; width: 100%; }
select:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.conn-list { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 6px; font-size: 13.5px; }
.conn-list li { display: flex; justify-content: space-between; align-items: center; gap: 8px; }

.deploy-dock { position: fixed; right: 16px; bottom: 20px; width: 344px; z-index: 6; }
.btn-deploy {
  position: relative; overflow: hidden;
  width: 100%;
  display: flex; align-items: center; justify-content: center; gap: 12px;
  font: inherit; font-size: 18px; font-weight: 900;
  color: var(--accent-ink);
  background: linear-gradient(180deg, #ffd766, #ffae17);
  border: 2px solid #ffe08a;
  border-radius: 16px;
  padding: 17px 18px;
  cursor: pointer;
  box-shadow: 0 0 28px rgba(255,170,30,0.55), inset 0 -4px 0 rgba(160,80,0,0.25);
  transition: transform .12s, box-shadow .2s;
}
.btn-deploy:hover { box-shadow: 0 0 40px rgba(255,180,40,0.8), inset 0 -4px 0 rgba(160,80,0,0.25); transform: translateY(-1px); }
.btn-deploy:active { transform: translateY(1px); }
.btn-deploy::after { content: ""; position: absolute; inset: 0 auto 0 -40%; width: 30%; background: linear-gradient(100deg, transparent, rgba(255,255,255,0.6), transparent); transform: skewX(-20deg); transition: left .7s; }
.btn-deploy:hover::after { left: 120%; }
.btn-deploy:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }

.panel-log { left: 98px; bottom: 104px; width: 380px; max-height: 34vh; padding: 12px 14px; }
#log { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 4px; font-size: 12.5px; font-variant-numeric: tabular-nums; }
#log li { padding-left: 10px; border-left: 3px solid var(--line); animation: rise .25s ease both; }
#log .log-ok { border-color: var(--ok); } #log .log-warn { border-color: var(--warn); } #log .log-bad { border-color: var(--bad); color: #ffcdc8; }

.runbar {
  position: fixed; left: 98px; right: 376px; bottom: 20px;
  display: flex; align-items: center; gap: 14px;
  background: var(--glass); border: 1px solid var(--line); border-radius: 16px;
  padding: 10px 14px; box-shadow: var(--glow);
  z-index: 6;
}
.timeline { flex: 1; }
.timeline-bar { position: relative; height: 12px; background: rgba(255,255,255,0.08); border-radius: 99px; overflow: hidden; }
.timeline-fill { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, rgba(62,230,160,0.35), rgba(62,230,160,0.6)); box-shadow: 0 0 10px rgba(62,230,160,0.5); }
.tl-mark { position: absolute; top: 0; bottom: 0; min-width: 5px; opacity: 0.9; }
.tl-spike { background: var(--warn); } .tl-ddos, .tl-az, .tl-crash { background: var(--bad); } .tl-cron { background: #f173bd; } .tl-deploy { background: #3fe0c5; }
.timeline-hours { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 4px; font-variant-numeric: tabular-nums; }
.run-controls { display: flex; gap: 8px; align-items: center; }
.seg { display: flex; background: rgba(0,0,0,0.25); border: 1px solid var(--line); border-radius: 12px; padding: 3px; }
.seg-btn { font: inherit; font-weight: 900; color: var(--muted); background: transparent; border: 0; border-radius: 9px; padding: 8px 12px; cursor: pointer; }
.seg-btn[aria-pressed="true"] { color: var(--accent-ink); background: var(--accent); box-shadow: 0 0 12px rgba(255,190,60,0.5); }

/* ---------- Effects ---------- */

#vignette { position: fixed; inset: 0; pointer-events: none; z-index: 4; opacity: 0; transition: opacity .6s; box-shadow: inset 0 0 160px 30px rgba(255,40,40,0.55); }
#vignette.on { opacity: 1; animation: alarm 1.6s ease-in-out infinite; }

.banner {
  position: fixed; left: 50%; top: 38%; z-index: 7; transform: translate(-50%, -50%);
  pointer-events: none; text-align: center;
  font-size: clamp(32px, 5vw, 60px); font-weight: 900; line-height: 1.05;
  color: #fff; text-shadow: 0 0 30px rgba(90,180,255,0.8), 0 4px 18px rgba(0,0,0,0.6);
  animation: banner 1.8s cubic-bezier(.2,.8,.2,1) both;
}
.banner small { display: block; font-size: 0.36em; color: var(--accent); letter-spacing: 0.08em; text-transform: uppercase; }

#toasts { position: fixed; top: 84px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; width: min(480px, calc(100vw - 32px)); z-index: 20; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 10px;
  background: rgba(16,22,54,0.95);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 13.5px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.45);
  animation: toast-in .25s cubic-bezier(.2,.8,.2,1);
}
.toast::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.toast-ok::before { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.toast-warn::before { background: var(--warn); box-shadow: 0 0 8px var(--warn); }
.toast-bad { border-color: rgba(255,90,78,0.5); }
.toast-bad::before { background: var(--bad); box-shadow: 0 0 8px var(--bad); }
.toast-achievement { border-color: rgba(255,196,64,0.7); box-shadow: 0 0 24px rgba(255,180,40,0.35); }
.toast-achievement::before { display: none; }
.toast-achievement .ico { color: var(--accent); }
.toast-out { opacity: 0; transform: translateY(-6px); transition: opacity .3s, transform .3s; }

/* ---------- Dialogs ---------- */

dialog#modal {
  width: min(460px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 0;
  color: var(--text);
  background: linear-gradient(180deg, rgba(26,36,86,0.98), rgba(10,15,40,0.98));
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.6), 0 0 40px rgba(70,130,255,0.25);
  overflow: auto;
}
dialog#modal[open] { animation: dlg-in .28s cubic-bezier(.2,.8,.2,1); }
dialog#modal.wide { width: min(780px, calc(100vw - 32px)); }
dialog#modal::backdrop { background: rgba(3,6,18,0.6); backdrop-filter: blur(3px); }

.dlg { position: relative; padding: 24px 26px; }
.dlg h2 { font-size: 26px; font-weight: 900; margin-bottom: 10px; }
.dlg h3 { font-size: 15px; font-weight: 900; margin: 18px 0 8px; color: #dfe6ff; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; flex-wrap: wrap; }
.dlg-actions.split { justify-content: space-between; }
.dlg .menu-buttons .mbtn { animation: none; font-size: 16px; padding: 11px 16px; }
.dlg a { color: var(--accent); text-underline-offset: 3px; }

.story { font-size: 15.5px; max-width: 68ch; color: #d5ddff; }
.brief-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 26px; }
.plain-list { margin: 0; padding-left: 20px; display: grid; gap: 5px; }
.forecast { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; font-size: 13.5px; }
.forecast time { font-weight: 900; color: var(--accent); font-variant-numeric: tabular-nums; margin-right: 6px; }
.svc-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 10px; }
.svc-card { display: flex; gap: 12px; background: rgba(255,255,255,0.04); border: 1px solid var(--line); border-radius: 12px; padding: 12px; font-size: 13px; }
.svc-card p { margin: 4px 0 0; }
.svc-card .pal-icon { flex: none; }

.result { overflow: hidden; }
.result-head { text-align: center; }
.result-head h2 { font-size: 32px; }
.stars-big { display: flex; justify-content: center; gap: 14px; margin: 6px 0 10px; }
.stars-big .s { font-size: 54px; line-height: 1; color: rgba(255,255,255,0.15); transform: scale(0); animation: star-pop .5s cubic-bezier(.2,1.6,.4,1) forwards; animation-delay: calc(var(--d) * 1ms); }
.stars-big .s.on { color: var(--accent); text-shadow: 0 0 24px rgba(255,180,40,0.8); }
.star-reasons { list-style: none; padding: 0; margin: 0 auto 16px; display: grid; gap: 3px; font-size: 13.5px; width: fit-content; }
.star-reasons .ok { color: var(--text); } .star-reasons .bad { color: var(--muted); }
.xp-gain { text-align: center; font-size: 22px; font-weight: 900; color: var(--accent); margin: 0 0 14px; font-variant-numeric: tabular-nums; }
.xp-gain small { display: block; font-size: 13px; color: var(--muted); font-weight: 700; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.stat { background: rgba(255,255,255,0.05); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: grid; gap: 2px; border-top: 3px solid var(--line); }
.stat.ok { border-top-color: var(--ok); } .stat.bad { border-top-color: var(--bad); }
.stat-label { font-size: 12px; color: var(--muted); }
.stat-value { font-size: 22px; font-weight: 900; font-variant-numeric: tabular-nums; }
.stat-note { font-size: 12px; color: var(--muted); }
.lessons { margin: 0; padding-left: 20px; display: grid; gap: 6px; font-size: 13.5px; }
.ach-new { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 8px; }
.ach-new .ach { animation: rise .4s ease both; animation-delay: calc(var(--i) * 120ms + 900ms); }
#confetti { position: absolute; inset: 0; pointer-events: none; width: 100%; height: 100%; }

.ach { display: flex; align-items: center; gap: 12px; background: rgba(255,255,255,0.04); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.ach .badge { width: 42px; height: 42px; flex: none; border-radius: 12px; display: grid; place-items: center; color: var(--accent-ink); background: linear-gradient(180deg, #ffd766, #ffae17); box-shadow: 0 0 14px rgba(255,180,40,0.45); }
.ach.locked .badge { color: #7c88b8; background: rgba(255,255,255,0.06); box-shadow: none; }
.ach.locked strong { color: var(--muted); }
.ach p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }
.ach .xp { margin-left: auto; font-weight: 900; color: var(--accent); font-size: 13px; white-space: nowrap; }
.ach.locked .xp { color: var(--muted); }
.ach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 8px; }

.profile { display: flex; align-items: center; gap: 18px; }
.rank-title { font-size: 22px; font-weight: 900; }
.xp-bar { height: 10px; background: rgba(255,255,255,0.1); border-radius: 99px; overflow: hidden; margin: 8px 0 4px; }
.xp-fill { height: 100%; background: linear-gradient(90deg, #ffb21e, #ffe07a); box-shadow: 0 0 10px rgba(255,180,40,0.5); border-radius: 99px; }
.avatar-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.avatar-card { display: grid; justify-items: center; gap: 6px; text-align: center; font: inherit; color: var(--text); background: rgba(255,255,255,0.04); border: 1px solid var(--line); border-radius: 14px; padding: 14px 10px; cursor: pointer; transition: border-color .15s, transform .15s, box-shadow .2s; }
.avatar-card:hover:not(:disabled) { transform: translateY(-2px); border-color: var(--line-strong); }
.avatar-card.current { border-color: var(--accent); box-shadow: 0 0 18px rgba(255,190,60,0.35); }
.avatar-card:disabled { cursor: not-allowed; }
.avatar-card:disabled svg { filter: grayscale(1) brightness(.5); }
.avatar-card small { color: var(--muted); font-size: 11.5px; }

.set-list { display: grid; gap: 2px; }
.set-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.set-row span { display: grid; }
.set-row small { color: var(--muted); font-size: 12px; font-weight: 600; }
.set-row input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--accent); }
.set-row select { width: auto; }
.set-row input[type="range"] { accent-color: var(--accent); }
.keys { border-collapse: collapse; font-size: 13.5px; width: 100%; }
.keys th { text-align: left; font-weight: 800; padding: 5px 16px 5px 0; white-space: nowrap; }
.keys td { color: var(--muted); padding: 5px 0; }
.credit-links { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.credit-links li { display: grid; grid-template-columns: 80px 1fr; gap: 8px; }
.catalog { display: grid; gap: 6px; }
.catalog .svc-card { align-items: flex-start; }

/* ---------- Keyframes ---------- */

@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
@keyframes dlg-in { from { opacity: 0; transform: translateY(14px) scale(.97); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(-10px) scale(.97); } }
@keyframes pop { 0% { transform: scale(.6); } 60% { transform: scale(1.18); } 100% { transform: scale(1); } }
@keyframes bump { 0%, 100% { transform: scale(1); } 40% { transform: scale(1.12); box-shadow: 0 0 24px rgba(255,190,60,0.6); } }
@keyframes star-pop { 0% { transform: scale(0) rotate(-30deg); } 70% { transform: scale(1.25) rotate(8deg); } 100% { transform: scale(1) rotate(0); } }
@keyframes banner { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.7); } 15% { opacity: 1; transform: translate(-50%, -50%) scale(1.04); } 25% { transform: translate(-50%, -50%) scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -60%) scale(1); } }
@keyframes alarm { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }

/* ---------- Small screens ---------- */

@media (max-width: 1100px) {
  .topbar .brand .brand-text { display: none; }
  .topbar { gap: 12px; }
  .pill-bar { width: 80px; }
  .mission-card, .deploy-dock { width: 300px; }
  .runbar { right: 332px; }
  .drawer { width: 210px; }
}
@media (max-width: 760px) {
  .topbar .brand { display: none; }
  .pill-bar, .pill-count { display: none; }
  .xp-pill { padding: 8px 10px; }
  .rail { top: auto; bottom: 16px; left: 50%; transform: translateX(-50%); display: flex; padding: 6px; }
  .rail-sep { width: 1px; height: auto; margin: 6px 2px; }
  .drawer { left: 16px; right: 16px; top: auto; bottom: 86px; width: auto; height: 32vh; }
  .mission-card { left: 16px; right: 16px; width: auto; top: 76px; bottom: auto; max-height: 40vh; }
  .deploy-dock { left: 16px; right: 16px; width: auto; bottom: 86px; }
  .runbar { left: 16px; right: 16px; bottom: 86px; flex-wrap: wrap; }
  .panel-log { display: none; }
  .screen-menu { padding-left: 16px; background: rgba(7,11,28,0.7); }
  .brief-cols { grid-template-columns: 1fr; }
}

body.reduced *, body.reduced *::before, body.reduced *::after { animation: none !important; transition: none !important; }
body.reduced .stars-big .s { transform: none; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
