:root {
  --bg: #0b0f17;
  --panel: #131a26;
  --panel2: #1a2333;
  --line: #263248;
  --text: #e6ecf5;
  --muted: #8d9bb3;
  --accent: #f0a43a;
  --link: #49b4ff;
  --good: #4fd68a;
  --warn: #ffcc4d;
  --terran: #5aa0ff;
  --protoss: #f3c74e;
  --zerg: #c779ff;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { scroll-padding-top: 64px; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }

.wtop { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 16px; padding: 10px 16px; background: rgba(11, 15, 23, .96); border-bottom: 1px solid var(--line); }
.brand { color: var(--text); font-weight: 700; font-size: 18px; white-space: nowrap; }
.brand span { color: var(--accent); font-weight: 600; }
.wnav { display: flex; gap: 4px; flex-wrap: wrap; order: 2; margin-left: auto; }
.wnav a { color: var(--muted); padding: 4px 10px; border-radius: 999px; font-size: 14px; }
.wnav a:hover { color: var(--text); text-decoration: none; background: var(--panel2); }
.wnav a.on { color: var(--text); background: var(--panel2); }
.wnav a.ext { color: var(--accent); }
.menu-btn { display: block; background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 6px; font-size: 18px; padding: 2px 10px; cursor: pointer; }

.wlayout { display: grid; grid-template-columns: 290px minmax(0, 1fr); }
/* Sidebar hidden with the ☰ button (desktop); the choice is remembered */
body.side-hidden .wlayout { grid-template-columns: minmax(0, 1fr); }
body.side-hidden .wside { display: none; }
body.side-hidden .wmain { margin: 0 auto; }
.wside { position: sticky; top: 53px; height: calc(100vh / var(--z) - 53px); overflow-y: auto; padding: 14px 12px; border-right: 1px solid var(--line); }
.wside input { width: 100%; background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 14px; margin-bottom: 12px; }
.tree h4 { margin: 14px 0 4px; font-size: 11px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--muted); }
.tree a { display: block; padding: 3px 8px; border-radius: 6px; color: var(--text); font-size: 14px; }
.tree a:hover { background: var(--panel2); text-decoration: none; }
.tree a.on { background: #1d2a40; color: var(--accent); }
.wmain { padding: 20px 28px 60px; min-width: 0; max-width: 1180px; }

@media (max-width: 900px) {
  .wlayout { grid-template-columns: 1fr; }
  .wside { display: none; position: fixed; top: 53px; left: 0; right: 0; z-index: 9; background: var(--bg); border-right: 0; border-bottom: 1px solid var(--line); height: calc(100vh / var(--z) - 53px); }
  body.menu .wside, body.menu.side-hidden .wside { display: block; }
  .wnav { display: none; }
  .wmain { padding: 16px; }
}

h1 { font-size: 26px; margin: 0 0 4px; }
h2 { font-size: 19px; margin: 26px 0 8px; }
h3 { font-size: 16px; margin: 20px 0 6px; color: var(--accent); }
.crumbs { color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.lead { color: var(--muted); margin: 0 0 16px; }
.ref { display: inline-block; font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 0 8px; margin-left: 6px; }
.content p, .content li { max-width: 860px; }
.content ul, .content ol { padding-left: 22px; }
.content li { margin: 3px 0; }
.note { background: #18222f; border-left: 3px solid var(--accent); padding: 8px 12px; border-radius: 6px; margin: 12px 0; max-width: 860px; }

table.tbl { border-collapse: collapse; margin: 8px 0 12px; width: 100%; max-width: 900px; font-size: 14px; }
.tbl th, .tbl td { border: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; }
.tbl th { background: var(--panel2); color: var(--muted); font-weight: 600; }
.tbl-wrap { overflow-x: auto; }

a.kw { color: var(--accent); font-weight: 600; }
a.kw::before { content: ""; }
.kwc { display: inline-block; font-weight: 700; font-size: 12px; letter-spacing: .3px; color: var(--accent); background: #2a2214; border: 1px solid #4a3a1a; border-radius: 4px; padding: 0 6px; margin: 2px 4px 2px 0; }
a.kwc:hover { text-decoration: none; border-color: var(--accent); }

.related { margin-top: 28px; padding-top: 12px; border-top: 1px solid var(--line); }
.related a { display: inline-block; margin: 3px 6px 3px 0; padding: 3px 10px; border: 1px solid var(--line); border-radius: 999px; font-size: 13px; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; margin: 12px 0; }
.box { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
a.box { color: var(--text); display: block; }
a.box:hover { border-color: var(--accent); text-decoration: none; }
.box b { display: block; margin-bottom: 2px; }
.box small { color: var(--muted); }

/* Skills */
.filters { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 10px 0 14px; }
.chip { background: var(--panel2); border: 1px solid var(--line); color: var(--muted); padding: 3px 11px; border-radius: 999px; cursor: pointer; font-size: 13px; }
.chip.on { color: var(--text); border-color: var(--accent); }
.chip[data-v=Terran].on { border-color: var(--terran); }
.chip[data-v=Protoss].on { border-color: var(--protoss); }
.chip[data-v=Zerg].on { border-color: var(--zerg); }
.filters select, .filters input { background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; font-size: 13px; }
.sep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }
.skill { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; margin-bottom: 10px; }
.skill-h { display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; }
.skill-h a.name { color: var(--text); font-weight: 700; font-size: 16px; }
.pill { font-size: 11.5px; padding: 0 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.pill.Active { color: var(--good); border-color: #23573a; }
.pill.Reaction { color: var(--link); border-color: #1e4a6b; }
.pill.Passive { color: var(--muted); }
.pill.cost { color: var(--protoss); border-color: #5a4a1a; }
.pill.Terran { color: var(--terran); } .pill.Protoss { color: var(--protoss); } .pill.Zerg { color: var(--zerg); }
.ru { margin: 6px 0 4px; }
.orig { color: var(--muted); font-size: 13.5px; white-space: pre-line; margin: 4px 0; }
.orig a.kw { font-weight: 600; }
.who { font-size: 13px; color: var(--muted); }
.who a { margin-right: 8px; }
.count { color: var(--muted); font-size: 13px; }

/* Units */
.ugrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; margin-bottom: 20px; }
.utile { position: relative; display: block; border-radius: 10px; overflow: hidden; background: var(--panel2); border: 1px solid var(--line); color: var(--text); }
.utile:hover { border-color: var(--accent); text-decoration: none; }
.utile img { display: block; width: 100%; height: 150px; object-fit: cover; object-position: top; }
.utile span { position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 6px 5px; font-size: 12px; line-height: 1.2; background: linear-gradient(transparent, rgba(0, 0, 0, .9)); }
.uhead { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; }
.uhead img { width: 150px; height: 300px; object-fit: cover; object-position: top; border-radius: 10px; background: var(--panel2); }
.ustats { display: grid; grid-template-columns: repeat(4, minmax(70px, auto)); gap: 6px 18px; margin: 10px 0; }
.ustats div b { display: block; font-size: 20px; }
.ustats div small { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .5px; }
.tags { margin: 4px 0; }
.tagp { display: inline-block; font-size: 12px; padding: 0 8px; margin: 0 4px 4px 0; border-radius: 999px; background: var(--panel2); color: var(--muted); }

/* Attack sequence */
.seq-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 12px 0; }
.seq { counter-reset: st; max-width: 900px; }
.st { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; }
.st > summary { list-style: none; cursor: pointer; padding: 10px 14px; display: flex; gap: 10px; align-items: baseline; }
.st > summary::-webkit-details-marker { display: none; }
.st > summary::before { counter-increment: st; content: counter(st); flex: none; width: 24px; height: 24px; border-radius: 50%; background: #2a2214; color: var(--accent); font-weight: 700; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; }
.st > summary b { font-size: 15px; }
.st > summary small { color: var(--muted); margin-left: auto; font-size: 12px; white-space: nowrap; }
.st[open] { border-color: #3a4a66; }
.st .body { padding: 0 14px 12px 48px; }
.st .body h5 { margin: 12px 0 4px; font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.st .mini { font-size: 13px; color: var(--muted); }
.st .mini a { margin-right: 6px; display: inline-block; }
.pool { display: inline-block; font-size: 11px; padding: 0 6px; border-radius: 4px; margin-left: 6px; }
.pool.a { background: #1d2f46; color: var(--link); } .pool.b { background: #2c2a17; color: var(--warn); } .pool.c { background: #3a1d1d; color: #ff8a8a; }

.res-group h2 { margin-top: 16px; }
.res-item { padding: 6px 0; border-bottom: 1px solid #1d2638; }
.res-item small { color: var(--muted); display: block; }
mark { background: #4a3a10; color: var(--text); border-radius: 2px; }

/* Language switch */
.lang { order: 3; margin-left: 8px; display: flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; flex: none; }
.lang button { background: none; border: 0; color: var(--muted); padding: 3px 10px; font-size: 13px; font-weight: 700; cursor: pointer; }
.lang button.on { background: var(--panel2); color: var(--accent); }

/* Collapsible rulebook diagrams */
details.fig { max-width: 860px; margin: 8px 0; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
details.fig > summary { cursor: pointer; padding: 6px 12px; color: var(--muted); font-size: 13.5px; }
details.fig > summary::marker { color: var(--accent); }
details.fig[open] > summary { color: var(--text); }
details.fig img { display: block; width: 100%; height: auto; border-radius: 0 0 8px 8px; }

/* Scale the whole UI up on wide and 4K screens (the media width is the window width in CSS px).
   Zoom also multiplies vw/vh, so viewport-sized rules divide by var(--z). */
html { --z: 1; }
@media (min-width: 1700px) { html { zoom: 1.1; --z: 1.1; } }
@media (min-width: 2000px) { html { zoom: 1.25; --z: 1.25; } }
@media (min-width: 2400px) { html { zoom: 1.45; --z: 1.45; } }
@media (min-width: 3000px) { html { zoom: 1.7; --z: 1.7; } }
@media (min-width: 3600px) { html { zoom: 2; --z: 2; } }
