/* Deephold: Bellmarch's lantern-lit parchment, gone underground. */
:root {
  --ink: #14110c; --ink2: #221c14; --ink3: #2e261b; --line: #4a3e2c;
  --paper: #eadfc4; --dim: #b0a284; --faint: #7a6e58;
  --gold: #e0b050; --gold2: #f4d488; --red: #d05040; --green: #70b860; --blue: #7aa8d8;
  --pix: "Pixelify Sans", ui-monospace, monospace; --serif: "Alegreya", Georgia, serif;
  --bg: 20, 17, 12; --bg2: 26, 21, 15;
}
* { box-sizing: border-box; }
/* (phone) the visible height: 100vh is the screen with the browser bars hidden, so a sheet sized by it runs under the URL bar; dvh follows them */
:root { --vh: 100vh; }
@supports (height: 100dvh) { :root { --vh: 100dvh; } }
html, body { margin: 0; height: 100%; overflow: hidden; background: #08060a; color: var(--paper); font: 16px/1.4 var(--serif); -webkit-tap-highlight-color: transparent; user-select: none; }
[hidden] { display: none !important; }
#view { position: fixed; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; touch-action: none; cursor: crosshair; }
button { font: 600 14px var(--pix); color: var(--paper); background: var(--ink3); border: 2px solid var(--line); border-radius: 3px; padding: 6px 10px; cursor: pointer; touch-action: manipulation; box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.35); white-space: nowrap; }
button:hover:not(:disabled) { border-color: var(--gold); }
button:active:not(:disabled) { transform: translateY(1px); box-shadow: none; }
button:disabled { opacity: 0.45; cursor: default; }
button.primary { background: #7a4a18; border-color: var(--gold); color: #fff3d8; }
button.on { border-color: var(--gold2); background: #5a3a14; }
button small { display: block; font-size: 10px; opacity: 0.7; font-weight: 400; }
input, select { font: 15px var(--pix); color: var(--paper); background: var(--ink2); border: 2px solid var(--line); border-radius: 3px; padding: 5px 8px; }
.fine { font-size: 14px; color: var(--dim); }
.fine p { margin: 6px 0; }
.kicker { font: 600 12px var(--pix); text-transform: uppercase; letter-spacing: 0.12em; color: var(--gold); margin: 14px 0 6px; }
.row { display: flex; gap: 8px; margin: 10px 0; flex-wrap: wrap; align-items: end; }
.row label { font: 600 13px var(--pix); color: var(--dim); display: grid; gap: 3px; }
#seed { width: 110px; }

.screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px; overflow: auto; z-index: 5; background: radial-gradient(ellipse at 50% 40%, rgba(var(--bg), 0.35), rgba(8, 6, 10, 0.85)); }
.card { width: min(560px, 100%); background: rgba(var(--bg2), 0.95); border: 2px solid var(--line); outline: 2px solid #0a0806; padding: 20px 24px; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6); margin: auto; }
.card.wide { width: min(700px, 100%); }
.card h1 { font: 700 56px/1 var(--pix); color: var(--gold2); margin: 4px 0 10px; text-shadow: 3px 3px 0 #5a3410, 0 0 24px rgba(240, 180, 80, 0.25); }
.lede { margin: 0 0 12px; }
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mode:first-child { grid-column: 1 / -1; }
.mode { display: block; border: 2px solid var(--line); padding: 8px 10px; cursor: pointer; background: var(--ink2); }
.mode:has(input:checked) { border-color: var(--gold); background: #2e2214; }
.mode b { font: 700 15px var(--pix); }
.mode small { display: block; font: 13px/1.3 var(--serif); color: var(--dim); margin-top: 4px; }
.mode input { accent-color: var(--gold); }

.panel { background: rgba(var(--bg), 0.9); border: 2px solid var(--line); outline: 1px solid #0a0806; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5); }

/* Top: resources */
#top { position: fixed; top: 8px; left: 8px; right: 200px; display: flex; gap: 5px; flex-wrap: wrap; z-index: 2; pointer-events: none; }
.chip { font: 600 14px var(--pix); background: rgba(var(--bg), 0.9); border: 2px solid var(--line); padding: 3px 8px; display: flex; gap: 5px; align-items: center; pointer-events: auto; }
.chip i { font-style: normal; }
.chip small { color: var(--faint); font-size: 11px; }
.chip.low { border-color: var(--red); color: #ffb0a0; }
.chip.up { animation: up 0.6s; }
@keyframes up { from { border-color: var(--gold2); } }

/* Left: goals and the log */
#left { position: fixed; left: 8px; top: 48px; width: 300px; z-index: 2; pointer-events: none; }
#goals { padding: 8px 10px; font-size: 14px; pointer-events: auto; }
#goals h3 { font: 600 12px var(--pix); text-transform: uppercase; letter-spacing: 0.1em; color: var(--gold); margin: 0 0 4px; }
#goals li { list-style: none; margin: 1px 0; }
#goals li.ok { color: var(--faint); text-decoration: line-through; }
#goals li.cur { color: var(--gold2); }
#goals ul { padding: 0; margin: 0; }
#log { margin-top: 6px; display: grid; gap: 3px; }
#log div { font-size: 13px; background: rgba(var(--bg), 0.78); padding: 3px 8px; border-left: 3px solid var(--line); transition: opacity 1s; }
#log .warn { border-color: var(--red); color: #ffc8b8; }
#log .gold { border-color: var(--gold); color: var(--gold2); }

/* Right: the depth gauge */
#depth { position: fixed; right: 8px; top: 8px; width: 184px; padding: 6px; z-index: 2; }
#depth h3 { font: 600 12px var(--pix); text-transform: uppercase; letter-spacing: 0.1em; color: var(--gold); margin: 2px 2px 6px; }
.lay { display: grid; grid-template-columns: 12px 1fr auto; gap: 6px; align-items: center; padding: 4px 6px; border: 2px solid transparent; cursor: pointer; font: 13px var(--pix); margin-bottom: 2px; background: var(--ink2); }
.lay:hover { border-color: var(--line); }
.lay.cur { border-color: var(--gold); background: #2e2214; }
.lay.dark { opacity: 0.45; }
.lay i { width: 12px; height: 26px; display: block; border: 1px solid #000; }
.lay b { font-weight: 600; display: block; line-height: 1.1; }
.lay small { color: var(--dim); font-size: 11px; display: block; }
.lay .tag { font-size: 12px; text-align: right; line-height: 1.1; }

/* Minimap under the depth gauge */
#mini { position: fixed; right: 8px; top: 316px; width: 184px; image-rendering: pixelated; z-index: 2; cursor: pointer; }

/* Bottom bar */
#bar { position: fixed; left: 8px; right: 8px; bottom: 8px; padding: 6px; display: grid; grid-template-columns: minmax(200px, 300px) 1fr auto; gap: 8px; align-items: center; z-index: 2; }
#sel { font-size: 14px; min-height: 40px; display: flex; gap: 8px; align-items: center; }
#sel .por { width: 40px; height: 40px; image-rendering: pixelated; background: var(--ink2); border: 2px solid var(--line); flex: none; }
#sel b { font: 600 14px var(--pix); display: block; }
#sel small { color: var(--dim); display: block; font-size: 12px; line-height: 1.2; }
#acts { display: flex; gap: 6px; flex-wrap: wrap; }
#tools { display: flex; gap: 5px; flex-wrap: wrap; justify-content: flex-end; }
.hpbar { height: 4px; background: #000; width: 120px; margin-top: 3px; }
.hpbar span { display: block; height: 100%; background: var(--green); }

/* Popups: build, research, realm */
#popup { position: fixed; left: 50%; bottom: 76px; transform: translateX(-50%); width: min(720px, calc(100% - 16px)); max-height: calc(var(--vh, 100vh) * 0.60); overflow: auto; padding: 10px 12px; z-index: 3; }
#popup h3 { font: 600 13px var(--pix); text-transform: uppercase; letter-spacing: 0.1em; color: var(--gold); margin: 0 0 8px; display: flex; justify-content: space-between; gap: 12px; align-items: baseline; flex-wrap: wrap; }
#popup h3 .fine { text-transform: none; letter-spacing: 0; font: 13px var(--serif); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr)); gap: 6px; }
.opt { text-align: left; white-space: normal; padding: 6px 8px; display: grid; grid-template-columns: 34px 1fr; gap: 8px; align-items: start; }
.opt.pick { outline: 2px solid var(--gold); outline-offset: -2px; box-shadow: 0 0 12px rgba(240, 200, 90, 0.45); }
.opt canvas { width: 34px; height: 34px; image-rendering: pixelated; }
.opt b { font: 600 14px var(--pix); display: block; }
.opt small { font: 12px/1.25 var(--serif); opacity: 0.85; }
.opt .cost { font: 12px var(--pix); color: var(--gold2); opacity: 1; display: block; margin-top: 2px; }
.opt .why { color: #ffb0a0; }
.opt.known { border-color: var(--green); }
.rival { border: 2px solid var(--line); padding: 8px; margin-bottom: 8px; background: var(--ink2); }
.rival h4 { margin: 0 0 4px; font: 600 15px var(--pix); display: flex; gap: 8px; align-items: center; }
.rival h4 i { width: 12px; height: 12px; display: inline-block; border: 1px solid #000; }
.rival .st { margin-left: auto; font-size: 12px; color: var(--dim); }
.rel { height: 6px; background: linear-gradient(90deg, #a03020, #6a5a3a 50%, #3a8a3a); position: relative; margin: 6px 0; }
.rel b { position: absolute; top: -3px; width: 3px; height: 12px; background: #fff; }

#toast { position: fixed; left: 50%; top: 50px; transform: translateX(-50%); font: 600 14px var(--pix); background: rgba(90, 30, 20, 0.92); border: 2px solid var(--red); padding: 5px 12px; z-index: 4; pointer-events: none; }
#end { z-index: 6; }
#end.won h1 { color: var(--gold2); }
#end.lost h1 { color: #ff8070; }

@media (max-width: 900px) {
  #left { width: 220px; }
  #left #goals { display: none; }
  #top { right: 8px; top: 6px; }
  .chip { font-size: 12px; padding: 2px 5px; }
  #depth { top: auto; bottom: 120px; width: 150px; }
  .lay small { display: none; }
  #bar { grid-template-columns: 1fr; }
  #tools { justify-content: flex-start; }
  #tools button { padding: 5px 7px; font-size: 12px; }
  #popup { bottom: 150px; }
}

@media (max-height: 700px) { #mini { display: none; } }
@media (max-height: 520px) {
  #left { top: 40px; width: 240px; }
  #left #goals { display: none; }
  #log div { font-size: 12px; }
  #depth { top: 6px; bottom: auto; width: 124px; padding: 3px; }
  #depth h3 { display: none; }
  .lay { padding: 2px 4px; font-size: 11px; grid-template-columns: 8px 1fr auto; gap: 4px; }
  .lay i { width: 8px; height: 16px; }
  .lay small, .lay .tag small { display: none; }
  #bar { grid-template-columns: auto 1fr; padding: 4px; gap: 6px; }
  #sel { min-height: 0; font-size: 12px; }
  #sel > div > small:not(:first-of-type) { display: none; }
  #acts { grid-column: 1 / -1; }
  #acts:empty { display: none; }
  #tools button { padding: 4px 6px; font-size: 12px; }
  #popup { bottom: 70px; max-height: calc(var(--vh, 100vh) * 0.70); }
}
.chip.full { border-color: var(--gold2); }
.lay.alarm { box-shadow: inset 0 0 0 2px #a02818; }
.lay.alarm.blink { box-shadow: inset 0 0 0 2px #ff5030, 0 0 8px #ff503080; }
.lay.alarm b::after { content: ""; display: inline-block; width: 12px; height: 12px; margin-left: 4px; vertical-align: -1px; background: #ff7060; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' shape-rendering='crispEdges'%3E%3Cpath d='M0 0h2v1h-2zM10 0h2v1h-2zM0 1h3v1h-3zM9 1h3v1h-3zM1 2h3v1h-3zM8 2h3v1h-3zM2 3h3v1h-3zM7 3h3v1h-3zM3 4h6v1h-6zM4 5h4v1h-4zM3 6h6v1h-6zM2 7h3v1h-3zM7 7h3v1h-3zM0 8h1v1h-1zM2 8h2v1h-2zM8 8h2v1h-2zM11 8h1v1h-1zM1 9h2v1h-2zM9 9h2v1h-2zM0 10h1v1h-1zM2 10h1v1h-1zM9 10h1v1h-1zM11 10h1v1h-1z'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' shape-rendering='crispEdges'%3E%3Cpath d='M0 0h2v1h-2zM10 0h2v1h-2zM0 1h3v1h-3zM9 1h3v1h-3zM1 2h3v1h-3zM8 2h3v1h-3zM2 3h3v1h-3zM7 3h3v1h-3zM3 4h6v1h-6zM4 5h4v1h-4zM3 6h6v1h-6zM2 7h3v1h-3zM7 7h3v1h-3zM0 8h1v1h-1zM2 8h2v1h-2zM8 8h2v1h-2zM11 8h1v1h-1zM1 9h2v1h-2zM9 9h2v1h-2zM0 10h1v1h-1zM2 10h1v1h-1zM9 10h1v1h-1zM11 10h1v1h-1z'/%3E%3C/svg%3E") center / contain no-repeat; } /* the army icon (icons.js) */
/* Phones: a compact title so "Found the hold" is in sight without scrolling. */
@media (max-width: 600px) {
  .card { padding: 12px 14px; }
  .card h1 { font-size: 38px; margin: 2px 0 6px; }
  .card .lede { font-size: 14px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
  .modes { grid-template-columns: 1fr; gap: 4px; }
  .mode { padding: 5px 8px; }
  .mode small { display: none; }
  .mode:has(input:checked) small { display: block; font-size: 12px; }
  .row.opts { gap: 6px; }
  #popup { left: 6px; right: 6px; width: auto; transform: none; max-height: calc(var(--vh, 100vh) * 0.52); overflow: auto; }
}
.chip.idle { pointer-events: auto; cursor: pointer; border-color: #7a8aa0; }
@media (max-width: 600px) {
  #mini { display: none; }
  #depth { bottom: auto; top: 64px; width: 128px; padding: 3px; }
  #depth h3 { display: none; }
  .lay { padding: 2px 4px; grid-template-columns: 8px 1fr auto; gap: 4px; }
  .lay i { width: 8px; height: 16px; }
  .lay .tag small { display: none; }
}
@media (max-height: 520px) {
  #bar { padding: 3px 4px; }
  #sel .por { display: none; }
  #sel small { font-size: 11px; line-height: 1.15; }
  #acts button, #tools button { padding: 3px 6px; font-size: 11px; }
  #acts button small { display: none; }
}

/* Round 7: founding, the floor list, the lore tree, heroes */
.modes.two .mode:first-child { grid-column: auto; }
#clan { width: 180px; }
.heroname { display: inline-flex; gap: 6px; align-items: center; margin-top: 6px; font: 13px var(--serif); color: var(--dim); }
#heroname { width: 180px; flex: 1; }
#clanrand { padding: 2px 6px; }
#swatches { display: flex; gap: 4px; flex-wrap: wrap; }
.sw { width: 22px; height: 22px; padding: 0; border: 2px solid #0a0806; outline: 1px solid var(--line); cursor: pointer; }
.sw.on { outline: 2px solid var(--gold2); }
.trait { text-align: left; white-space: normal; padding: 5px 8px; }
.trait b { font: 600 13px var(--pix); display: block; }
.trait small { font: 12px/1.25 var(--serif); color: var(--dim); }
.trait.on { border-color: var(--gold); background: #2e2214; }
#depth h3 { display: flex; justify-content: space-between; align-items: center; }
#depth .ud { display: flex; gap: 3px; }
#depth .ud button { padding: 0 6px; font-size: 11px; line-height: 18px; }
.lays { max-height: 250px; overflow-y: auto; scrollbar-width: thin; }
.tree { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(190px, 100%), 1fr)); gap: 8px; }
.branch h4 { font: 600 12px var(--pix); color: var(--gold2); margin: 0 0 4px; text-transform: uppercase; letter-spacing: 0.08em; }
.branch .opt { width: 100%; margin-bottom: 4px; }
.xpbar { height: 3px; background: #000; width: 120px; margin-top: 2px; }
.xpbar span { display: block; height: 100%; background: var(--gold2); }
.tal { color: var(--gold2) !important; }
.terr { color: #c8d8a0 !important; } /* what the ground does for the unit picked (sim terrainOf) */
.lv { color: var(--gold2); font-size: 11px; }
.relics { margin: 0; padding-left: 16px; font-size: 13px; }
.relics small { color: var(--dim); }
@media (max-width: 700px) { .lays { max-height: calc(var(--vh, 100vh) * 0.30); } }
.namerow { display: flex; gap: 4px; }

/* Round 8: heroes at the founding, the army list, build tabs */
#army { position: fixed; right: 8px; top: 466px; width: 184px; bottom: 166px; padding: 6px; z-index: 2; overflow-y: auto; scrollbar-width: thin; }
#army h3 { font: 600 12px var(--pix); text-transform: uppercase; letter-spacing: 0.08em; color: var(--gold); margin: 2px 2px 6px; display: flex; justify-content: space-between; gap: 4px; }
#army h3 span { color: var(--dim); letter-spacing: 0; }
#army .captrow { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin: 0 2px 8px; padding-bottom: 6px; border-bottom: 1px solid rgba(255,255,255,0.08); }
#army .captrow > b { font: 600 11px var(--pix); text-transform: uppercase; letter-spacing: 0.06em; color: var(--gold); width: 100%; }
#army .captrow .seg { display: flex; width: 100%; }
#army .captrow .seg button { flex: 1; padding: 3px 2px; font-size: 11px; }
#army .captrow .seg button.on { background: var(--gold); color: #1a1208; }
#army .captrow small { color: var(--dim); font-size: 10px; line-height: 1.25; }
#army .captrow .capall { width: 100%; margin-top: 2px; }
body.compact #army .captrow .seg button, body.compact #army .captrow .capall { min-height: 40px; font-size: 13px; }
#army .kind { display: grid; grid-template-columns: 30px 1fr; gap: 6px; align-items: center; width: 100%; text-align: left; padding: 2px 4px; margin-bottom: 2px; }
#army .kind canvas { width: 30px; height: 30px; image-rendering: pixelated; }
#army .kind b { font: 600 12px var(--pix); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#army .kind small { font-size: 11px; color: var(--dim); }
#army .kind.on { border-color: var(--gold); background: #2e2214; }
#army .groups { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 6px; }
#army .groups button { padding: 1px 6px; font: 600 12px var(--pix); }
#army .groups small { display: block; font-size: 10px; color: var(--dim); }
#army .fine { font-size: 12px; margin: 2px; }
.tabs { display: flex; gap: 4px; margin-bottom: 6px; flex-wrap: wrap; }
.tabs button.on { border-color: var(--gold); background: #2e2214; }
.chip.full { border-color: var(--gold); }
@media (max-height: 700px) { #army { top: 316px; } }
@media (max-width: 900px) { #army { display: none; } }

/* Together: lobby and the game master's panel. */
#together { border: 1px solid #3a2e20; padding: 8px 10px; margin: 6px 0 10px; background: rgba(0,0,0,0.2); }
#lobby .code { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
#lobby .code b { font: 700 28px var(--pix); letter-spacing: 0.2em; color: var(--gold); }
#lobby .code small { color: var(--dim); }
#lobby .members { list-style: none; padding: 0; margin: 0 0 8px; display: grid; gap: 3px; }
#lobby .members li { display: flex; gap: 8px; align-items: center; }
#lobby .members li.off { opacity: 0.45; }
#lobby .members i { width: 10px; height: 10px; display: inline-block; }
#lobby .members span { color: var(--dim); margin-left: auto; }
#lobby .members em { color: var(--gold); font-size: 12px; }
#lobby .seats { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 6px; }
#lobby .seats .on, #lobby .teams .on { border-color: var(--gold); color: var(--gold); }
#gm { position: fixed; left: 8px; top: 52px; width: 250px; max-height: calc(var(--vh, 100vh) - 230px); overflow-y: auto; padding: 8px; z-index: 3; scrollbar-width: thin; }
body.gm #left { display: none; }
#gm h3 { display: flex; justify-content: space-between; margin: 0 0 4px; font: 600 13px var(--pix); color: var(--gold); text-transform: uppercase; letter-spacing: 0.08em; }
#gm h4 { margin: 8px 0 4px; font: 600 12px var(--pix); color: var(--dim); }
#gm .pbar { height: 5px; background: #1a140e; margin-bottom: 6px; }
#gm .pbar span { display: block; height: 100%; background: linear-gradient(90deg, #6a3aa0, #c070ff); }
#gm .holds { display: flex; flex-wrap: wrap; gap: 3px; margin-bottom: 6px; }
#gm .hold { font-size: 12px; padding: 2px 6px; }
#gm .hold i { display: inline-block; width: 8px; height: 8px; margin-right: 4px; }
#gm .hold.on { border-color: var(--gold); }
#gm .hold.out { opacity: 0.4; text-decoration: line-through; }
#gm .beats { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; }
#gm .beat { display: flex; justify-content: space-between; font-size: 12px; padding: 3px 5px; }
#gm .beat.good b { color: #a8d890; }
#gm .idea { display: block; width: 100%; text-align: left; font-size: 12px; margin-bottom: 3px; }
#gm .idea small { display: block; color: var(--dim); }
#gm .say { width: 100%; margin-top: 6px; }
#gm .feed { list-style: none; padding: 0; margin: 6px 0 0; font-size: 12px; color: var(--dim); }
#log .chat { color: #c8d8ff; }
#log .gm { color: #d0a0ff; font-style: italic; }

/* ======================================================================
   Deephold's own face: slate and copper. Engraved capitals, hairline
   steel frames with cut corners, one warm accent. Clean and cold, so the
   lamps in the world are the warmest thing on screen.
   ====================================================================== */
:root {
  --ink: #0b0c0e; --ink2: #121418; --ink3: #181b20; --line: #2b3036; --line2: #3c434b;
  --paper: #dcd8d0; --dim: #8e8b85; --faint: #5c5a56;
  --gold: #c9773a; --gold2: #e9a065; --red: #c8483a; --green: #6fae7a; --blue: #86b4c8; --ice: #9cc4d4;
  --pix: "Barlow Condensed", "Arial Narrow", sans-serif; --serif: "Barlow", system-ui, sans-serif; --head: "Cinzel", Georgia, serif; --mono: "JetBrains Mono", ui-monospace, monospace;
  --bg: 12, 13, 16; --bg2: 16, 18, 21;
  --cut: polygon(9px 0, 100% 0, 100% calc(100% - 9px), calc(100% - 9px) 100%, 0 100%, 0 9px);
  --cut-s: polygon(5px 0, 100% 0, 100% calc(100% - 5px), calc(100% - 5px) 100%, 0 100%, 0 5px);
}
html, body { background: #050607; font: 15px/1.4 var(--serif); letter-spacing: 0.01em; }
button { font: 500 13px var(--pix); text-transform: uppercase; letter-spacing: 0.07em; color: var(--paper); background: linear-gradient(180deg, rgba(255,255,255,0.045), rgba(255,255,255,0.01)); border: 1px solid var(--line2); border-radius: 0; padding: 6px 11px; box-shadow: none; clip-path: var(--cut-s); transition: border-color 0.12s, color 0.12s, background 0.12s; }
button:hover:not(:disabled) { border-color: var(--gold); color: var(--gold2); }
button:active:not(:disabled) { transform: none; background: rgba(201,119,58,0.12); }
button.primary { background: linear-gradient(180deg, #d2834a, #a85a26); border-color: #e9a065; color: #140c06; font-weight: 600; }
button.primary:hover:not(:disabled) { color: #000; filter: brightness(1.08); }
button.on { border-color: var(--gold); color: var(--gold2); background: linear-gradient(180deg, rgba(201,119,58,0.18), rgba(201,119,58,0.06)); box-shadow: inset 0 -2px 0 var(--gold); }
button small { font: 400 10px var(--serif); text-transform: none; letter-spacing: 0; color: var(--dim); opacity: 1; }
input, select { font: 500 14px var(--serif); color: var(--paper); background: #0e1013; border: 1px solid var(--line2); border-radius: 0; padding: 5px 8px; }
input:focus, select:focus { outline: none; border-color: var(--gold); }
.kicker { font: 600 11px var(--pix); letter-spacing: 0.24em; color: var(--gold); margin: 18px 0 8px; display: flex; align-items: center; gap: 10px; }
.kicker::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, var(--line2), transparent); }
.row label { font: 500 11px var(--pix); letter-spacing: 0.14em; text-transform: uppercase; color: var(--dim); }
.fine { font-size: 13px; color: var(--dim); }

.screen { background: radial-gradient(ellipse at 50% 30%, rgba(30,34,40,0.55), rgba(3,4,5,0.92)); }
.card { background: linear-gradient(180deg, rgba(20,22,26,0.97), rgba(12,13,16,0.98)); border: 1px solid var(--line2); outline: none; clip-path: var(--cut); box-shadow: none; padding: 26px 30px; position: relative; }
.card::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px; background: linear-gradient(90deg, transparent, var(--gold) 20%, var(--gold) 80%, transparent); opacity: 0.85; }
.card.wide { width: min(760px, 100%); }
.card h1 { font: 900 64px/1 var(--head); letter-spacing: 0.14em; color: #e8e2d6; text-shadow: 0 2px 0 #000, 0 0 30px rgba(201,119,58,0.25); margin: 6px 0 14px; }
#end h1 { font-size: 44px; }
.lede { color: #b8b4ac; font-size: 15px; }
.mode { border: 1px solid var(--line); background: rgba(255,255,255,0.02); clip-path: var(--cut-s); }
.mode:has(input:checked) { border-color: var(--gold); background: rgba(201,119,58,0.08); }
.mode b { font: 600 15px var(--pix); letter-spacing: 0.05em; text-transform: uppercase; }
.mode small { font: 13px/1.35 var(--serif); }
.mode input { accent-color: var(--gold); }
#together { border: 1px solid var(--line); background: rgba(156,196,212,0.03); clip-path: var(--cut-s); }
#lobby .code b { font: 700 30px var(--mono); color: var(--ice); letter-spacing: 0.3em; }

.panel { background: rgba(var(--bg), 0.84); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); border: 1px solid var(--line); outline: none; box-shadow: 0 6px 24px rgba(0,0,0,0.45); clip-path: var(--cut); }
.panel h3, #goals h3, #depth h3, #army h3, #popup h3, #gm h3 { font: 700 12px var(--head) !important; letter-spacing: 0.2em !important; color: var(--gold) !important; text-transform: uppercase; }

/* The resource strip: one thin bar, numbers in a steady mono. */
#top { top: 0; left: 50%; right: auto; transform: translateX(-50%); gap: 0; flex-wrap: nowrap; background: rgba(var(--bg), 0.86); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); border: 1px solid var(--line); border-top: 0; padding: 0 6px; clip-path: polygon(0 0, 100% 0, calc(100% - 12px) 100%, 12px 100%); pointer-events: auto; max-width: calc(100% - 420px); overflow-x: auto; scrollbar-width: none; }
.chip { font: 500 13px var(--mono); background: none; border: 0; border-right: 1px solid var(--line); padding: 6px 10px; gap: 6px; color: var(--paper); white-space: nowrap; }
.chip:last-child { border-right: 0; }
.chip i { font-style: normal; font-size: 13px; opacity: 0.9; filter: saturate(0.6); }
.chip.low { color: #ff9a88; background: rgba(200,72,58,0.12); }
.chip.full { color: var(--gold2); }
.chip.idle { color: var(--ice); cursor: pointer; }
@keyframes up { from { color: var(--gold2); text-shadow: 0 0 8px var(--gold); } }

#left { top: 10px; width: 280px; }
#goals { padding: 10px 12px; font: 13px/1.45 var(--serif); }
#goals li.cur { color: #f0e6d4; }
#goals li.cur::marker { color: var(--gold); }
#goals li.ok { color: var(--faint); }
#log { gap: 2px; }
#log div { background: linear-gradient(90deg, rgba(var(--bg), 0.8), rgba(var(--bg), 0)); border-left: 2px solid var(--line2); font: 13px var(--serif); padding: 3px 10px; text-shadow: 0 1px 2px #000; }
#log .warn { border-color: var(--red); color: #f2b4a8; }
#log .gold { border-color: var(--gold); color: #f0cfa8; }
#log .gm { border-color: #9a6ad0; color: #d4b8f4; }

#depth { top: 10px; }
.lay { font: 500 13px var(--pix); background: transparent; border: 0; border-left: 2px solid transparent; clip-path: none; padding: 4px 6px; letter-spacing: 0.04em; }
.lay:hover { background: rgba(255,255,255,0.03); }
.lay.cur { border-left-color: var(--gold); background: linear-gradient(90deg, rgba(201,119,58,0.16), transparent); }
.lay i { width: 4px; height: 24px; border: 0; }
.lay small { font: 11px var(--serif); }
.ud button { padding: 1px 7px; }

#mini { border: 1px solid var(--line); }
#bar { bottom: 0; left: 50%; right: auto; transform: translateX(-50%); width: min(1180px, calc(100% - 16px)); border-bottom: 0; clip-path: polygon(14px 0, calc(100% - 14px) 0, 100% 100%, 0 100%); padding: 8px 18px 10px; }
#sel b { font: 600 14px var(--pix); letter-spacing: 0.05em; text-transform: uppercase; }
#sel .por { border: 1px solid var(--line2); background: #0c0e11; }
#tools { gap: 4px; }
.hpbar { background: #050607; height: 3px; }
.hpbar span { background: linear-gradient(90deg, #4f8f5c, #8fd09c); }
#army .kind { clip-path: none; text-transform: none; letter-spacing: 0; border: 0; border-left: 2px solid transparent; background: transparent; }
#army .kind:hover { background: rgba(255,255,255,0.03); }
#army .kind.on { border-left-color: var(--gold); background: linear-gradient(90deg, rgba(201,119,58,0.16), transparent); }
#army .kind b { font: 600 13px var(--pix); letter-spacing: 0.04em; }
#popup { bottom: 84px; }
#popup .tabs button { clip-path: none; border-width: 0 0 2px; border-color: transparent; background: none; }
#popup .tabs button.on { border-color: var(--gold); box-shadow: none; }
.opt { text-transform: none; letter-spacing: 0; clip-path: var(--cut-s); }
.opt b { font: 600 14px var(--pix); letter-spacing: 0.04em; text-transform: uppercase; }
.opt small { font: 12px/1.3 var(--serif); color: var(--dim); }
.opt .cost { font: 500 11px var(--mono); color: var(--gold2); }
.opt.known { border-color: #3d6a48; }
.rival { border: 1px solid var(--line); background: rgba(255,255,255,0.02); clip-path: var(--cut-s); }
.rival h4 { font: 600 15px var(--pix); letter-spacing: 0.05em; text-transform: uppercase; }
#toast { font: 500 14px var(--pix); letter-spacing: 0.05em; background: rgba(12,13,16,0.92); border: 1px solid var(--line2); border-left: 3px solid var(--gold); clip-path: var(--cut-s); top: 44px; }
#gm .pbar span { background: linear-gradient(90deg, #5a3a90, #b080f0); }
#gm .beat { text-transform: none; letter-spacing: 0; font: 500 12px var(--pix); }
#gm .hold, #gm .idea { text-transform: none; letter-spacing: 0; }
@media (max-width: 900px) { #top { max-width: 100%; left: 0; transform: none; clip-path: none; } #bar { width: 100%; left: 0; transform: none; clip-path: none; } }
#left { top: 46px; }
#depth { top: 46px; }
#mini { top: 352px; }
#army { top: 502px; }
#gm { top: 46px; }
@media (max-height: 700px) { #army { top: 352px; } }
/* round 10: folding goals */
#goals .gcount { float: right; cursor: pointer; font: 600 11px var(--mono, monospace); letter-spacing: 0; color: var(--faint); text-transform: none; }
#goals .gcount:hover { color: var(--gold2); }
/* round 10: a building's actions get the bar's width; the tools move under them */
@media (min-width: 901px) {
  #bar:has(#acts:not(:empty)) { grid-template-columns: minmax(200px, 300px) 1fr; }
  #bar:has(#acts:not(:empty)) #tools { grid-column: 1 / -1; justify-self: end; }
}
#acts { max-height: calc(var(--vh, 100vh) * 0.38); overflow-y: auto; }

/* Round 12: the compact floor picker, numbers only */
#depth h3 { display: flex !important; margin: 0 2px 5px; }
#depth .fname { font: 600 13px var(--pix) !important; letter-spacing: 0.02em !important; text-transform: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#depth .fl { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; }
#depth .fb { position: relative; padding: 0; height: 22px; min-width: 0; font: 600 12px var(--pix); color: #ece4d4; background: linear-gradient(var(--t), #14100c 140%); border: 1px solid #0a0806; box-shadow: inset 0 1px 0 rgba(255,255,255,0.12); }
#depth .fb.dark { opacity: 0.4; filter: grayscale(0.6); }
#depth .fb.cur { outline: 2px solid var(--gold2, #f4d488); outline-offset: -1px; z-index: 1; }
#depth .fb.alarm { background: #8a1a10; }
#depth .fb.alarm.blink { background: #e03020; }
#depth .fb em { position: absolute; right: 1px; top: -3px; font-style: normal; font-size: 8px; color: #f4d488; }
#depth .fb s { position: absolute; right: 0; bottom: -2px; text-decoration: none; font-size: 7px; opacity: 0.8; }
#depth .fb u { position: absolute; left: 1px; top: -3px; text-decoration: none; font-size: 8px; color: #ff7060; }
#depth { height: auto !important; max-height: none !important; overflow: visible !important; }
#mini { top: 142px !important; }
#army { top: 292px !important; }
@media (max-height: 700px) { #army { top: 142px !important; } }
@media (max-width: 900px) { #depth { width: 150px; } #depth .fb { height: 19px; font-size: 10px; } #depth .fname { font-size: 11px !important; } }

/* Round 12: the next-step hint and the menu */
#goals .hint { display: flex; gap: 8px; align-items: center; margin: -2px -2px 8px; padding: 6px 8px; background: linear-gradient(90deg, rgba(240,200,90,0.16), rgba(240,200,90,0.04)); border-left: 3px solid var(--gold2, #f4d488); font: 14px/1.3 var(--serif, Georgia, serif); color: #f0e6cc; }
#goals .hint.warn { background: linear-gradient(90deg, rgba(230,70,40,0.3), rgba(230,70,40,0.06)); border-left-color: #ff6040; }
#goals .hint span { flex: 1; }
#goals .hint .hgo { flex: none; padding: 3px 9px; font-size: 12px; }
#popup .menu { display: grid; gap: 8px; min-width: 300px; }
#popup .mrow { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
#popup .mrow > b { width: 64px; font: 600 12px var(--pix); text-transform: uppercase; letter-spacing: 0.08em; color: var(--dim); }
#popup .mrow button.on { border-color: var(--gold2, #f4d488); color: var(--gold2, #f4d488); }
#popup .mhelp { font: 13px/1.4 var(--serif, Georgia, serif); color: var(--dim); max-height: calc(var(--vh, 100vh) * 0.40); overflow: auto; }
#popup .mhelp summary { cursor: pointer; color: var(--gold); font: 600 13px var(--pix); }
#b-auto.on { border-color: #8ac060; color: #b8e090; }
@media (max-width: 900px) { #goals .hint { font-size: 12px; padding: 4px 6px; } }
/* On small screens only the hint of the goals panel shows. */
@media (max-width: 900px), (max-height: 520px) {
  #left #goals:has(.hint) { display: block; padding: 0; background: none; border: 0; box-shadow: none; clip-path: none; }
  #left #goals h3, #left #goals ul { display: none; }
  #left #goals .hint { margin: 0 0 4px; background: rgba(20,14,8,0.88); }
}
#log div.go { pointer-events: auto; cursor: pointer; }
#log div.go:hover { text-decoration: underline; }

/* Work panel: trades for miners */
.labor { display: grid; gap: 4px; margin: 6px 0 10px; }
.labor .lrow { display: grid; grid-template-columns: 26px 1fr auto 30px 30px auto; grid-template-rows: auto auto; column-gap: 8px; align-items: center; padding: 6px 8px; border: 1px solid rgba(200, 150, 90, 0.18); border-radius: 6px; background: rgba(40, 28, 18, 0.35); }
.labor .li { grid-row: 1 / 3; font-size: 18px; text-align: center; }
.labor .lrow > b { grid-column: 2; }
.labor .lrow > small { grid-column: 2; grid-row: 2; opacity: 0.7; font-size: 11px; }
.labor .ln { grid-column: 3; grid-row: 1 / 3; font-size: 18px; font-weight: bold; text-align: right; min-width: 44px; }
.labor .ln small { display: block; font-size: 10px; font-weight: normal; opacity: 0.65; }
.labor button { grid-row: 1 / 3; min-width: 28px; }
.labor [data-dec] { grid-column: 4; } .labor [data-inc] { grid-column: 5; } .labor [data-pick] { grid-column: 6; }
#sel small.passive { color: #e8c890; opacity: 0.9; }
@media (max-width: 600px) { .labor .lrow { grid-template-columns: 22px 1fr auto 28px 28px; } .labor .lrow > small { display: none; } .labor [data-pick] { display: none; } }

.labor .ln small i.idle { color: #e8a060; font-style: normal; }

/* ---------- round 14: readability and phones ---------- */
/* Alerts: a death, a horde or a raid gets a banner you can click to look. */
#alert { position: fixed; left: 50%; top: 84px; transform: translateX(-50%); z-index: 5; max-width: min(560px, calc(100vw - 24px)); font: 600 14px var(--pix); letter-spacing: 0.03em; color: #ffe0d0; background: rgba(70, 18, 12, 0.94); border: 1px solid #e0603a; border-left: 4px solid #ff7040; padding: 6px 12px; text-align: left; cursor: pointer; box-shadow: 0 4px 18px rgba(0,0,0,0.5); animation: alertIn 0.25s ease-out; }
#alert b { color: #ffd0a0; margin-left: 6px; white-space: nowrap; }
@keyframes alertIn { from { transform: translate(-50%, -8px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
/* Numbers in the top bar can be tapped for their name. */
#top .chip { cursor: pointer; }
#top .chip[data-idle] { cursor: pointer; }
/* Disabled buttons look disabled. */
button:disabled { opacity: 0.5; filter: grayscale(0.7); border-style: dashed; }
/* Lore: locked techs stay readable, marked by a lock instead of a fade. */
#popup .tree .opt.locked:disabled { opacity: 0.85; filter: none; }
#popup .tree .opt.locked small { color: #b8ad98; }
#popup .tree .opt:disabled small, #popup .tree .opt:disabled b { color: #c8bfae; }
/* Help and small print: never under 11px, and lighter. */
#sel small, .fine { color: #b8b2a6; }
#sel > div > small { font-size: 12px; }
#depth .fb em, #depth .fb u { font-size: 10px; }
#depth .fb s { font-size: 9px; }
/* The army list is as tall as what it holds. */
#army { bottom: auto !important; max-height: calc(var(--vh, 100vh) - 470px - 170px); height: auto; }
/* Narrow screens: the current goal and two log lines (main.js caps them), no wall of text over the world. */
@media (max-width: 900px) {
  #log div { font-size: 12px; padding: 2px 6px; }
}
/* Phones */
@media (max-width: 600px) {
  #title { overflow-x: hidden; }
  .card h1 { font-size: 38px !important; letter-spacing: 0.08em !important; margin: 2px 0 6px !important; }
  #top { flex-wrap: wrap; justify-content: center; row-gap: 2px; overflow: visible; }
  #top .chip { font-size: 11px; padding: 1px 4px; }
  #left { left: 6px; right: 6px; width: auto !important; top: 64px; }
  #left #goals .hint { font-size: 12px; }
  #log { max-width: 70%; }
  #alert { top: 64px; font-size: 13px; }
  #depth { bottom: auto !important; top: 150px; right: 6px; width: 132px !important; }
  #depth .fl { grid-template-columns: repeat(8, 1fr); }
  #depth .fb { height: 17px !important; font-size: 10px !important; }
  #bar #sel small:not(:first-of-type) { display: none; }
  #acts button { padding: 3px 6px; font-size: 11px; }
  #acts button small { display: none; }
  #tools button { padding: 4px 6px !important; font-size: 11px !important; }
}

/* ---------- Hearth: the interface in the same warm materials as the hold ---------- */
body[data-look="hearth"] {
  --ink: #120d09; --ink2: #1b140e; --ink3: #251b13; --line: #4a3622; --line2: #6a4e30;
  --paper: #efe3cc; --dim: #b9a88a; --faint: #8a7a60;
  --gold: #d8903e; --gold2: #f2c27a;
  --bg: 22, 15, 10; --bg2: 30, 21, 14;
}
body[data-look="hearth"] .panel, body[data-look="hearth"] #bar, body[data-look="hearth"] #top, body[data-look="hearth"] #popup {
  box-shadow: inset 0 0 0 1px rgba(216, 144, 62, 0.22), inset 0 0 24px rgba(216, 144, 62, 0.06), 0 6px 20px rgba(0, 0, 0, 0.45);
}
body[data-look="hearth"] button { background-color: rgba(48, 32, 20, 0.85); }
body[data-look="hearth"] button.on { box-shadow: inset 0 0 0 1px var(--gold2), 0 0 10px rgba(242, 194, 122, 0.25); }
#alert i { font-style: normal; color: #ffb080; margin-left: 4px; }
#alert b { display: inline-block; padding: 1px 6px; margin-left: 6px; border: 1px solid rgba(255,176,128,0.5); }
#alert b:hover { background: rgba(255,140,90,0.2); }
#sel i.warnc { font-style: normal; color: #e8a060; }
#popup .marks .mk { padding: 2px 6px; font-size: 12px; margin: 2px 2px 0 0; }
/* Hotkeys printed on the bar's buttons (desktop). */
#tools button[data-key] { position: relative; }
#tools button[data-key]::after { content: attr(data-key); position: absolute; right: 2px; top: 1px; font: 600 9px var(--pix); color: var(--gold2); opacity: 0.7; }
@media (pointer: coarse), (max-width: 900px) { #tools button[data-key]::after { display: none; } }
/* Founder screen: one's own hold first; extra options folded; playing together below. */
#title details.more { margin: 8px 0 4px; }
#title details.more > summary { cursor: pointer; font: 600 12px var(--pix); letter-spacing: 0.12em; text-transform: uppercase; color: var(--gold); padding: 4px 0; }
#title details.more[open] > summary { margin-bottom: 6px; }
#together.after { margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--line); }
/* The chronicle on the end screen. */
#end-chron { margin: 4px 0 14px; padding: 10px 12px; border-left: 3px solid var(--gold); background: rgba(var(--bg2), 0.6); text-align: left; }
#end-chron h3 { margin: 0 0 6px; font: 600 13px var(--pix); letter-spacing: 0.12em; text-transform: uppercase; color: var(--gold2); }
#end-chron p { margin: 3px 0; font-size: 14px; color: #d8cfbe; }
.chip.spoil { border-color: #d07040 !important; color: #ffc0a0; }
.chip small { font-size: 10px; opacity: 0.75; margin-left: 1px; }
/* The Book of Grudges in the Realm panel. */
#popup .book ul { list-style: none; padding: 0; margin: 4px 0 0; }
#popup .book li { font-size: 13px; padding: 3px 6px; border-left: 3px solid #b04030; margin: 2px 0; background: rgba(60, 20, 14, 0.35); }
#popup .book li.done { border-color: var(--gold); background: rgba(60, 44, 20, 0.3); color: var(--dim); }

/* ======================================================================
   UI round: hall groups, Realm market, shortcut card, coach-marks, phone HUD
   ====================================================================== */
/* The Great Hall's actions in groups: Train · Hall · Trade. */
#acts .actlab { align-self: center; font: 600 10px var(--pix); letter-spacing: 0.16em; text-transform: uppercase; color: var(--faint); padding: 0 2px 0 6px; border-left: 1px solid var(--line); }
#acts .actlab:first-child { border-left: 0; padding-left: 0; }
/* Realm tabs and the market. */
#popup .rtabs { display: flex; gap: 4px; margin: -2px 0 10px; border-bottom: 1px solid var(--line); }
#popup .market { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
#popup .market h4 { margin: 0 0 2px; font: 600 13px var(--pix); letter-spacing: 0.14em; text-transform: uppercase; color: var(--gold2); }
#popup .market .fine { margin: 0 0 6px; font-size: 12px; }
#popup .mk-opt { width: 100%; margin-bottom: 6px; grid-template-columns: 28px 1fr; align-items: center; }
#popup .mk-opt .mi { font-size: 20px; text-align: center; }
#popup .mk-opt:disabled { opacity: 0.55; filter: grayscale(0.85); border-style: dashed; cursor: not-allowed; }
#popup .mk-opt:disabled .cost { color: var(--faint); text-decoration: line-through; }
@media (max-width: 600px) { #popup .market { grid-template-columns: 1fr; } }

/* The shortcut card (?). */
#keys { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(860px, calc(100% - 16px)); max-height: calc(var(--vh, 100vh) - 24px); overflow: auto; padding: 12px 16px; z-index: 6; }
#keys h3 { display: flex; justify-content: space-between; align-items: center; margin: 0 0 8px; }
#keys .kx, #sheet .kx { padding: 1px 8px; font-size: 12px; }
#keys .kgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(250px, 100%), 1fr)); gap: 8px 18px; }
#keys section h4 { margin: 4px 0 4px; font: 600 12px var(--pix); letter-spacing: 0.16em; text-transform: uppercase; color: var(--gold2); border-bottom: 1px solid var(--line); padding-bottom: 2px; }
#keys .krow { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; padding: 2px 0; }
#keys .krow span { flex: none; }
#keys .krow small { color: var(--dim); font-size: 13px; text-align: right; }
#keys kbd { display: inline-block; font: 600 12px var(--mono, monospace); color: var(--paper); background: rgba(255,255,255,0.05); border: 1px solid var(--line2, var(--line)); border-bottom-width: 2px; padding: 0 5px; margin: 1px 0; white-space: nowrap; }

/* Coach-marks: a small card by what it points at, and a ring around it. */
#coach { position: fixed; z-index: 5; width: min(290px, calc(100vw - 16px)); padding: 8px 11px 8px; background: rgba(var(--bg), 0.96); border: 1px solid var(--gold); border-left: 3px solid var(--gold2); box-shadow: 0 6px 22px rgba(0,0,0,0.55); font: 13px/1.35 var(--serif); color: var(--paper); }
#coach small { display: block; font: 600 10px var(--pix); letter-spacing: 0.16em; text-transform: uppercase; color: var(--gold); }
#coach b { display: block; font: 600 15px var(--pix); letter-spacing: 0.04em; color: var(--gold2); margin: 1px 0 2px; }
#coach p { margin: 0 0 6px; }
#coach .crow { display: flex; gap: 6px; justify-content: flex-end; }
#coach .crow button { padding: 2px 8px; font-size: 11px; }
#coach .carrow { position: absolute; left: calc(var(--ax, 50%) - 7px); width: 0; height: 0; border: 7px solid transparent; }
#coach[data-side="above"] .carrow { bottom: -15px; border-top-color: var(--gold); }
#coach[data-side="below"] .carrow { top: -15px; border-bottom-color: var(--gold); }
#coach[data-side="none"] .carrow { display: none; }
#coach-ring { position: fixed; z-index: 4; pointer-events: none; border: 2px solid var(--gold2); border-radius: 4px; box-shadow: 0 0 0 3px rgba(242, 194, 122, 0.18), 0 0 16px rgba(242, 194, 122, 0.45); animation: coachPulse 1.2s ease-in-out infinite; }
@keyframes coachPulse { 50% { box-shadow: 0 0 0 6px rgba(242, 194, 122, 0.06), 0 0 22px rgba(242, 194, 122, 0.25); } }

/* Phone-only pieces stay out of the desktop HUD. */
#fab, #b-fold, #goals .gpill, #depth .fsel, #top .chip.ph, #tools .cpt { display: none; }
#tools button i { font-style: normal; }


/* (The phone HUD moved to body.compact at the end of this file.) */
/* A popup never covers a building's actions when the bar grows taller. */
#popup { bottom: max(84px, calc(var(--barh, 101px) - 17px)); }
@media (max-width: 900px) { #popup { bottom: max(150px, calc(var(--barh, 150px) + 6px)); } }
#sel small.adj { color: #f2c27a; }
/* The saga on the founder screen. */
#saga .mode { display: block; margin-bottom: 8px; }
#saga .mode.on { border-color: var(--gold2); }
.trait.deed b { color: var(--gold2); }
.trait.deed small i { font-style: normal; color: #d8b070; }

/* ======================================================================
   The Hold Book (O · 📖 Hold): one page to run the hold, in six tabs.
   ====================================================================== */
#book { position: fixed; inset: 20px max(20px, calc((100vw - 1440px) / 2)); z-index: 6; display: flex; flex-direction: column; padding: 0; overflow: hidden; background: rgba(var(--bg), 0.97); font: 14px/1.4 var(--serif); color: var(--paper); user-select: text; }
#book[hidden] { display: none; }
body.booked #toast { z-index: 7; }
#book .fine { font-size: 13px; color: var(--dim); }
#book small { font-size: 12px; }
#book button { font-size: 13px; padding: 4px 9px; }
#book button small { display: block; font: 12px var(--serif); color: var(--dim); white-space: normal; text-align: left; margin-top: 1px; }
#book button:disabled { opacity: 0.55; cursor: default; }
#book select, #book input[type="search"] { font-size: 13px; padding: 4px 6px; max-width: 100%; }
#book .bk-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px 6px; border-bottom: 1px solid var(--line); }
#book .bk-head h2 { margin: 0; font: 700 17px var(--head, var(--pix)); letter-spacing: 0.12em; color: var(--gold2); text-transform: uppercase; min-width: 0; }
#book .bk-head h2 .fine { text-transform: none; letter-spacing: 0; font: 13px var(--serif); margin-left: 8px; }
#book .bk-ctl { display: flex; gap: 6px; flex: none; }
#book .bk-ctl .kx { padding: 4px 10px; }
#book .bk-tabs { display: flex; gap: 2px; padding: 0 10px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; flex: none; }
#book .bk-tabs button { background: none; border: 0; border-bottom: 3px solid transparent; border-radius: 0; box-shadow: none; padding: 8px 12px 6px; font-size: 14px; color: var(--dim); }
#book .bk-tabs button.on { color: var(--gold2); border-bottom-color: var(--gold); box-shadow: none; }
#book .bk-body { flex: 1; overflow: auto; padding: 10px 14px 18px; overscroll-behavior: contain; }
#book section + section { margin-top: 12px; }
#book h4 { margin: 4px 0 8px; font: 600 13px var(--pix); letter-spacing: 0.14em; text-transform: uppercase; color: var(--gold2); }
#book h4 .fine { text-transform: none; letter-spacing: 0; font: 13px var(--serif); margin-left: 6px; }
#book h5 { margin: 0 0 4px; font: 600 14px var(--pix); color: var(--gold2); letter-spacing: 0.04em; }
#book h5 small { color: var(--dim); font: 12px var(--serif); margin-left: 4px; }
#book .pos { color: #9ad070; } #book .neg { color: #f0907a; } #book .flat { color: var(--dim); }
#book .warnc { color: #e8a060; font-style: normal; }
#book .hpbar, #book .xpbar, #book .capbar, #book .strbar { display: block; height: 6px; background: rgba(0,0,0,0.45); border: 1px solid var(--line); overflow: hidden; }
#book .hpbar > span, #book .xpbar > span, #book .capbar > span, #book .strbar > span { display: block; height: 100%; background: #70b860; }
#book .xpbar > span { background: #7aa8d8; }
#book .capbar > span { background: var(--gold); }
#book .strbar > span { background: var(--gold); }
#book .seg { display: inline-flex; flex-wrap: wrap; gap: 3px; }
#book .seg button.part { border-style: dashed; }
#book .bk-acts { display: flex; flex-wrap: wrap; gap: 5px; }
#book .bk-acts button { text-align: left; }
#book .bk-opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); gap: 8px 14px; margin: 8px 0; }
#book .bk-opts label { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px 8px; background: rgba(0,0,0,0.18); border: 1px solid var(--line); }
#book .bk-opts label > b { font: 600 12px var(--pix); letter-spacing: 0.08em; text-transform: uppercase; color: var(--dim); min-width: 92px; }
#book .bk-opts label > small { flex-basis: 100%; color: var(--dim); }
/* Folk */
#book .bk-trades { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr)); gap: 6px; }
#book .bk-trade { display: grid; grid-template-columns: 24px 1fr auto; grid-template-areas: "i n c" "i s p"; gap: 0 6px; align-items: center; padding: 6px 8px; background: rgba(0,0,0,0.2); border: 1px solid var(--line); }
#book .bk-trade .ti { grid-area: i; font-size: 18px; }
#book .bk-trade b { grid-area: n; font: 600 14px var(--pix); }
#book .bk-trade .tn { grid-area: c; font: 600 18px var(--mono, monospace); color: var(--gold2); text-align: right; }
#book .bk-trade small { grid-area: s; color: var(--dim); }
#book .bk-trade .tpm { grid-area: p; display: flex; gap: 3px; }
#book .bk-trade .tpm button { padding: 1px 9px; font-size: 15px; }
#book .marks { margin: 4px 0 0; }
#book .marks .mk { padding: 2px 7px; font-size: 12px; margin: 2px 3px 0 0; }
#book .bk-filt, #book .bk-bulk { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
#book .bk-filt input { flex: 1 1 160px; min-width: 0; }
#book .ftable { border: 1px solid var(--line); }
#book .frow { display: grid; grid-template-columns: 26px minmax(110px, 1.1fr) 160px minmax(170px, 1.7fr) 160px 110px 120px; gap: 6px; align-items: center; padding: 4px 8px; border-top: 1px solid rgba(255,255,255,0.05); }
#book .frow:nth-child(even) { background: rgba(0,0,0,0.14); }
#book .frow.chk { background: rgba(216,144,62,0.12); }
#book .frow input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--gold); margin: 0; }
#book .fhead { position: sticky; top: -10px; z-index: 1; background: rgba(var(--bg2), 0.98); border-top: 0; border-bottom: 1px solid var(--line); }
#book .fhead button { background: none; border: 0; box-shadow: none; padding: 4px 0; text-align: left; font: 600 12px var(--pix); letter-spacing: 0.08em; text-transform: uppercase; color: var(--dim); }
#book .fhead button.on { color: var(--gold2); box-shadow: none; }
#book .fname b { font: 600 14px var(--pix); } #book .fname small { color: var(--faint); margin-left: 5px; }
#book .frow select { width: 100%; }
#book .fdo { font-size: 13px; }
#book .st-idle .fdo { color: #e8a060; } #book .st-fight .fdo { color: #f0907a; }
#book .fz { padding: 2px 6px; font-size: 12px; text-align: left; overflow: hidden; text-overflow: ellipsis; }
#book .fload { font: 13px var(--mono, monospace); }
#book .fhp { display: grid; gap: 1px; } #book .fhp small { color: var(--dim); }
/* Stores */
#book .srows { display: grid; gap: 3px; }
#book .srow2 { display: grid; grid-template-columns: 26px 110px 110px minmax(140px, 1fr) 90px 160px; gap: 8px; align-items: center; text-align: left; padding: 5px 8px; background: rgba(0,0,0,0.16); border: 1px solid var(--line); box-shadow: none; font: 14px var(--serif); white-space: normal; }
#book .srow2.on { border-color: var(--gold2); background: rgba(216,144,62,0.1); }
#book .srow2.full { border-left: 3px solid var(--gold); } #book .srow2.over { border-left: 3px solid #d07040; }
#book .srow2 .si { font-size: 18px; }
#book .srow2 b { font: 600 14px var(--pix); }
#book .srow2 .sv { font: 600 15px var(--mono, monospace); color: var(--gold2); } #book .srow2 .sv small { color: var(--faint); font-size: 12px; }
#book .srow2 .scap { display: grid; gap: 2px; } #book .srow2 .scap small { font-size: 12px; margin: 0; }
#book .srow2 .sr { font: 600 14px var(--mono, monospace); } #book .srow2 .sr small { display: inline; color: var(--faint); }
#book svg.spark { width: 100%; height: 26px; display: block; }
#book svg.spark polyline { fill: none; stroke: var(--gold2); stroke-width: 2; stroke-linejoin: round; }
#book svg.spark .cap, #book .bk-big .cap { stroke: var(--dim); stroke-width: 1; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; }
#book svg.spark text { fill: var(--faint); font: 10px var(--serif); }
#book .bk-big { margin-top: 4px; padding: 8px 10px; background: rgba(0,0,0,0.2); border: 1px solid var(--line); }
#book .bk-big svg { max-width: 100%; height: auto; display: block; touch-action: pan-y; }
#book .bk-big polyline { fill: none; stroke: var(--gold2); stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
#book .bk-big .grid { stroke: rgba(255,255,255,0.08); stroke-width: 1; vector-effect: non-scaling-stroke; }
#book .bk-big text { fill: var(--dim); font: 12px var(--serif); }
#book .bk-big .capt { fill: var(--dim); }
#book .bk-big .cross { stroke: var(--dim); stroke-width: 1; vector-effect: non-scaling-stroke; }
#book .bk-big circle { fill: var(--gold2); stroke: rgba(var(--bg), 1); stroke-width: 2; }
#book .bk-big .tip { fill: var(--paper); font-weight: 600; paint-order: stroke; stroke: rgba(var(--bg), 0.95); stroke-width: 4px; }
#book .bk-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); gap: 8px; }
#book .bk-card { display: grid; gap: 4px; align-content: start; padding: 8px 10px; background: rgba(0,0,0,0.2); border: 1px solid var(--line); border-left: 3px solid var(--line2, var(--line)); }
#book .bk-card > small { font: 600 12px var(--pix); letter-spacing: 0.1em; text-transform: uppercase; color: var(--dim); }
#book .bk-card > b { font: 600 20px var(--mono, monospace); color: var(--gold2); }
#book .bk-card.warm { border-left-color: var(--gold); } #book .bk-card.bad { border-left-color: #d05040; } #book .bk-card.good { border-left-color: #70b860; }
/* Realm */
#book .bk-rivals { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(330px, 100%), 1fr)); gap: 8px; }
#book .bk-rival { padding: 8px 10px; background: rgba(0,0,0,0.2); border: 1px solid var(--line); border-left: 3px solid var(--line2, var(--line)); }
#book .bk-rival.st-friendly { border-left-color: #70b860; } #book .bk-rival.st-hostile { border-left-color: #d05040; } #book .bk-rival.st-unfriendly { border-left-color: #c07040; } #book .bk-rival.st-destroyed { opacity: 0.6; }
#book .bk-rival h4 { display: flex; align-items: center; gap: 6px; margin: 0 0 4px; letter-spacing: 0.06em; }
#book .bk-rival h4 i { width: 12px; height: 12px; display: inline-block; border: 1px solid #000; }
#book .bk-rival .st { margin-left: auto; font: 12px var(--serif); text-transform: none; letter-spacing: 0; color: var(--dim); }
#book .bk-rival p { margin: 0 0 6px; }
.rkind { margin: 0 0 4px; font-size: 12px; line-height: 1.35; color: var(--dim); } .rkind b { color: #e8d8a8; font-weight: 600; letter-spacing: 0.02em; } .rkind span::before { content: "— "; }
#book .bk-kin { display: grid; grid-template-columns: 64px minmax(80px, 1fr) 64px auto; align-items: center; gap: 8px; margin: 3px 0; }
#book .bk-kin .strbar { display: block; height: 8px; background: rgba(0,0,0,0.35); border: 1px solid var(--line); }
#book .bk-kin .strbar > span { display: block; height: 100%; background: var(--gold2, #d0a040); }
#book .bk-kin .bk-acts { flex-wrap: nowrap; }
#book .bk-relrow { display: grid; grid-template-columns: auto 1fr auto 34px; gap: 6px; align-items: center; margin-bottom: 4px; }
#book .bk-relrow small { text-align: right; font-family: var(--mono, monospace); }
#book .rel { position: relative; height: 8px; background: linear-gradient(90deg, #a03828, #8a6a3a 50%, #5a9a48); border: 1px solid var(--line); }
#book .rel b { position: absolute; top: -4px; width: 4px; height: 14px; margin-left: -2px; background: var(--paper); box-shadow: 0 0 0 1px #000; }
#book .bk-str { display: grid; grid-template-columns: auto auto 1fr; gap: 8px; align-items: center; margin-bottom: 6px; font-size: 13px; }
#book .bk-str b { color: var(--gold2); font-family: var(--mono, monospace); }
#book .warb { border-color: #8a3a2a; }
#book .bk-grudges { list-style: none; padding: 0; margin: 0; }
#book .bk-grudges li { font-size: 13px; padding: 3px 8px; border-left: 3px solid #b04030; margin: 2px 0; background: rgba(60, 20, 14, 0.35); }
#book .bk-grudges li.done { border-color: var(--gold); background: rgba(60, 44, 20, 0.3); color: var(--dim); }
#book .bk-charters { display: grid; gap: 6px; }
#book .bk-ch { display: grid; grid-template-columns: 180px 1fr; gap: 2px 10px; align-items: center; padding: 6px 8px; background: rgba(0,0,0,0.16); border: 1px solid var(--line); }
#book .bk-ch > small { grid-column: 1; }
#book .bk-ch > .sworn, #book .bk-ch > .bk-acts { grid-column: 2; grid-row: 1 / span 2; }
#book .bk-ch .sworn { color: var(--gold2); font: 600 14px var(--pix); } #book .bk-ch .sworn small { display: block; font: 12px var(--serif); color: var(--dim); }
#book .market { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
#book .market h4 { margin: 0 0 2px; }
#book .market .fine { margin: 0 0 6px; }
#book .mk-opt { width: 100%; margin-bottom: 6px; display: grid; grid-template-columns: 28px 1fr; gap: 6px; align-items: center; text-align: left; white-space: normal; }
#book .mk-opt .mi { font-size: 20px; text-align: center; }
#book .mk-opt b { display: block; } #book .mk-opt small { display: block; font-size: 12px; color: var(--dim); }
#book .mk-opt .cost { color: var(--gold2); } #book .mk-opt .why { color: #e8a060; }
/* Lore */
#book .bk-lorehead { display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: baseline; margin-bottom: 6px; }
#book .bk-lorehead b { font: 600 18px var(--mono, monospace); color: var(--gold2); }
#book .bk-study { display: grid; gap: 3px; padding: 8px 10px; background: rgba(216,144,62,0.08); border: 1px solid var(--line); border-left: 3px solid var(--gold); max-width: 640px; }
#book .bk-study.idle { border-left-color: var(--line2, var(--line)); background: rgba(0,0,0,0.18); }
#book .bk-study .hpbar > span { background: var(--gold); }
#book .bk-tree { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr)); gap: 10px; }
#book .bk-branch h5 { border-bottom: 1px solid var(--line); padding-bottom: 3px; text-transform: uppercase; letter-spacing: 0.12em; font-size: 13px; }
#book .bk-tech { display: block; width: 100%; text-align: left; margin-bottom: 5px; white-space: normal; padding: 6px 8px; }
#book .bk-tech b { font: 600 14px var(--pix); display: block; }
#book .bk-tech .cost { color: var(--gold2); } #book .bk-tech .why { color: #e8a060; }
#book .bk-tech.ready { border-color: var(--gold); }
#book .bk-tech.known { opacity: 0.6; border-style: solid; background: rgba(90,140,70,0.12); }
#book .bk-tech.busy { opacity: 1; border-color: var(--gold2); }
#book .bk-tech.locked { opacity: 0.5; }
#book .bk-tech .hpbar { margin-top: 3px; } #book .bk-tech .hpbar > span { background: var(--gold); }
/* Army */
#book .bk-armt { border: 1px solid var(--line); overflow-x: auto; }
#book .arow { display: grid; grid-template-columns: minmax(130px, 1.3fr) 56px repeat(var(--nf, 1), 64px) minmax(220px, 1.2fr); gap: 6px; align-items: center; padding: 4px 8px; border-top: 1px solid rgba(255,255,255,0.05); min-width: max-content; }
#book .arow b { font: 600 14px var(--pix); } #book .arow small { display: block; }
#book .ahead { font: 600 12px var(--pix); letter-spacing: 0.08em; text-transform: uppercase; color: var(--dim); border-top: 0; border-bottom: 1px solid var(--line); }
#book .arow button { padding: 2px 8px; }
#book .bk-heroes { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); gap: 8px; align-items: start; }
#book .bk-hero { padding: 8px 10px; background: rgba(0,0,0,0.2); border: 1px solid var(--line); border-left: 3px solid var(--gold); display: grid; gap: 5px; align-content: start; }
#book .bk-hero.away { opacity: 0.65; border-left-style: dashed; }
#book .bk-hero p { margin: 0; }
#book .bk-hero .hbars { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; align-items: center; }
#book .bk-hero .tal { color: var(--gold2); font-size: 13px; }
#book .bk-talent { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; padding: 5px; border: 1px dashed var(--gold); }
#book .bk-talent > b { flex-basis: 100%; color: var(--gold2); font: 600 13px var(--pix); }
#book .bk-talent button { flex: 1 1 120px; text-align: left; white-space: normal; }
/* Chronicle */
#book .bk-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(140px, 100%), 1fr)); gap: 6px; }
#book .bk-stat { padding: 6px 8px; background: rgba(0,0,0,0.2); border: 1px solid var(--line); }
#book .bk-stat b { display: block; font: 600 17px var(--mono, monospace); color: var(--gold2); }
#book .bk-stat small { color: var(--dim); }
#book .bk-stat b.pos { color: #9ad070; } #book .bk-stat b.neg { color: #f0907a; }
#book .bk-saga { margin-top: 8px; padding: 8px 12px; border-left: 3px solid var(--gold); background: rgba(var(--bg2), 0.6); }
#book .bk-saga p { margin: 2px 0; }
#book .bk-layers { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(180px, 100%), 1fr)); gap: 5px; }
#book .bk-layer { text-align: left; border-left: 4px solid var(--t); white-space: normal; padding: 5px 8px; }
#book .bk-layer b { font: 600 13px var(--pix); display: block; }
#book .bk-layer.dark { opacity: 0.55; }
#book .relics { padding-left: 18px; margin: 0; } #book .relics li { margin: 2px 0; }
#book .bk-annals { list-style: none; padding: 0; margin: 0; }
#book .bk-annals li { font-size: 13px; padding: 3px 8px; border-left: 3px solid var(--line); margin: 2px 0; background: rgba(0,0,0,0.14); }
#book .bk-annals li.warn { border-color: #d05040; } #book .bk-annals li.gold { border-color: var(--gold); }
#book .bk-annals small { color: var(--faint); margin-right: 6px; font-family: var(--mono, monospace); }
/* Laptops: the folk table loses its fixed widths. */
@media (max-width: 1100px) {
  #book .frow { grid-template-columns: 26px 1fr 140px 1.4fr 130px 90px 100px; }
  #book .srow2 { grid-template-columns: 26px 96px 100px 1fr 80px 120px; }
}
/* Phones: a full-height sheet; tables become cards. */
@media (max-width: 760px) {
  #book { inset: 0; border: 0; outline: 0; }
  #book .bk-head { padding: 8px 10px 4px; }
  #book .bk-head h2 { font-size: 14px; }
  #book .bk-head h2 .fine { display: block; margin: 2px 0 0; font-size: 12px; }
  #book .bk-tabs { padding: 0 4px; }
  #book .bk-tabs button { padding: 8px 9px 6px; font-size: 13px; }
  #book .bk-body { padding: 8px 10px 24px; }
  #book .bk-opts { grid-template-columns: 1fr; }
  #book .bk-trades { grid-template-columns: 1fr 1fr; }
  #book .bk-trade { grid-template-columns: 20px 1fr auto; padding: 5px 6px; }
  #book .bk-trade b { font-size: 13px; }
  #book .fhead { display: flex; flex-wrap: wrap; gap: 2px 10px; position: static; }
  #book .fhead > span { display: none; }
  #book .frow:not(.fhead) { grid-template-columns: 24px 1fr 1fr; grid-template-areas: "c n t" ". d d" ". f f" ". l h"; gap: 3px 8px; padding: 6px 8px; }
  #book .frow > input { grid-area: c; } #book .frow .fname { grid-area: n; } #book .frow > select { grid-area: t; }
  #book .frow .fdo { grid-area: d; } #book .frow .fz { grid-area: f; justify-self: start; max-width: 100%; } #book .frow .fload { grid-area: l; } #book .frow .fhp { grid-area: h; }
  #book .srow2 { grid-template-columns: 24px 1fr auto; grid-template-areas: "i n v" ". c r" ". s s"; gap: 3px 8px; }
  #book .srow2 .si { grid-area: i; } #book .srow2 b { grid-area: n; } #book .srow2 .sv { grid-area: v; text-align: right; }
  #book .srow2 .scap { grid-area: c; } #book .srow2 .sr { grid-area: r; text-align: right; } #book .srow2 svg.spark { grid-area: s; }
  #book .bk-rivals, #book .bk-heroes { grid-template-columns: 1fr; }
  #book .bk-ch { grid-template-columns: 1fr; }
  #book .bk-ch > .sworn, #book .bk-ch > .bk-acts { grid-column: 1; grid-row: auto; }
  #book .market { grid-template-columns: 1fr; }
  #book .bk-tree { grid-template-columns: 1fr 1fr; gap: 6px; }
  #book .bk-armt { overflow-x: visible; }
  #book .arow { grid-template-columns: minmax(0, 1fr) 44px repeat(var(--nf, 1), 52px); min-width: 0; }
  #book .arow > :last-child { grid-column: 1 / -1; }
  #book .ahead > :last-child { display: none; }
  #book .bk-tabs { flex-wrap: wrap; justify-content: space-between; overflow: visible; }
  #book .bk-tabs button { padding: 7px 6px 5px; }
}
@media (max-width: 420px) { #book .bk-tree { grid-template-columns: 1fr; } }
/* Hold Book: Economy and Empire tabs */
.bk-econs { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); gap: 8px; }
.bk-econ { padding: 8px 10px; border: 1px solid var(--line); background: rgba(var(--bg2), 0.6); }
.bk-econ h5 { margin: 0 0 6px; display: flex; gap: 6px; align-items: baseline; font: 600 13px var(--pix); letter-spacing: 0.06em; }
.bk-econ h5 b { margin-left: auto; }
.bk-econ .er { display: grid; grid-template-columns: 1fr 70px 52px; gap: 6px; align-items: center; font-size: 12px; margin: 2px 0; }
.bk-econ .er i { display: block; height: 6px; border-radius: 2px; }
.bk-econ .er i.pos { background: #6fae7a; } .bk-econ .er i.neg { background: #c8584a; }
.bk-econ .er b { text-align: right; }
.pos { color: #9ad08a; } .neg { color: #f09080; }
.bk-emps { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(190px, 100%), 1fr)); gap: 6px; }
.bk-emp { display: grid; gap: 2px; text-align: left; padding: 6px 8px; border-left: 4px solid var(--t); background: rgba(var(--bg2), 0.6); }
.bk-emp small { font-size: 11px; color: var(--dim); }
.bk-emp.claimed { box-shadow: inset 0 0 0 1px var(--gold); }
.bk-emp.unknown, .bk-emp.locked { opacity: 0.6; }
.bk-wins { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr)); gap: 8px; }
.bk-win { padding: 8px 10px; border: 1px solid var(--line); background: rgba(var(--bg2), 0.6); display: grid; gap: 4px; }
.bk-win small { font-size: 12px; color: var(--dim); }
.bk-win.best { border-color: var(--gold); box-shadow: inset 0 0 0 1px rgba(240, 208, 96, 0.35); }
.bk-win.won { border-color: #6fae7a; }
.bk-win.ms .hpbar { width: 100%; }
.bk-win b small { float: right; color: var(--dim); font-weight: 400; }
.ms-steps { list-style: none; margin: 2px 0; padding: 0; display: grid; gap: 3px; font-size: 12px; }
.ms-steps li { display: grid; gap: 2px; color: var(--dim); }
.ms-steps li.ok { color: #9ad08a; }
.ms-steps li.cur { color: #e8d8a8; }
.ms-steps li small { color: var(--dim); }
.ms-steps li i { display: block; height: 3px; background: linear-gradient(90deg, var(--gold2) var(--k), rgba(255, 255, 255, 0.08) var(--k)); border-radius: 2px; }
.bk-win .ms-next { color: #e8d8a8; }
.bk-win .ms-next b { color: var(--gold2); font-weight: 600; }
.ms-waits { margin-top: 8px; display: grid; gap: 4px; font-size: 13px; }
.ms-deep { margin: 0; } .ms-deep small { color: var(--dim); }
.ms-deep.waves b { color: #f09080; } .ms-deep.broken b { color: #9ad08a; }
.ms-chains { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; font-size: 12px; }
.ms-chains li small { color: var(--dim); } .ms-chains li.done { color: #9ad08a; } .ms-chains li.running { color: #e8d8a8; }
#goals .ms-l { margin: 6px 0 0; font-size: 13px; color: #e8d8a8; }
#goals .ms-l b { color: var(--gold2); }
#goals .ms-l small { color: var(--dim); margin-left: 4px; }
body.compact #goals:not(.open) .ms-l { display: none; }
@media (max-width: 600px) { .bk-econs, .bk-emps, .bk-wins { grid-template-columns: 1fr; } }

/* ======================================================================
   COMPACT mode (body.compact): phones, landscape phones, small tablets and
   small laptops. Auto when the window is ≤900 wide or ≤600 tall; the Menu
   can force Compact or Full. Always in sight: day (tap: pause), food, wood,
   stone, folk, heart, trouble, the goal pill, the floor, and one row of
   Dig · Build · Hold · Army · Map · Menu · More. Everything else one tap away.
   ====================================================================== */
body.compact { --toph: 34px; }
body.compact.touch { --toph: 42px; }
/* Top bar: one thin line across the top. */
body.compact #top { left: 0 !important; right: 0 !important; top: 0 !important; transform: none !important; max-width: none !important; width: 100%; height: var(--toph); flex-wrap: nowrap !important; justify-content: flex-start; align-items: stretch; overflow: hidden !important; clip-path: none !important; padding: 0 2px !important; row-gap: 0; }
/* (main.js puts only the key numbers and what is in trouble on the bar; every chip there shows.) */
body.compact #top .chip { display: flex; align-items: center; font-size: 12px !important; padding: 0 6px !important; gap: 3px; flex: 0 1 auto; min-width: 0; height: 100%; }
body.compact #top .chip.day { cursor: pointer; }
body.compact #top .chip.more { flex: none; margin-left: auto; min-width: 44px; justify-content: center; font-size: 18px !important; padding: 0 12px !important; color: var(--gold2); cursor: pointer; border-right: 0; }
body.compact #top .chip .lbl { display: none; }
body.compact #top .chip.alarmc { color: #ff9a88; background: rgba(200,72,58,0.18); cursor: pointer; }
@media (min-width: 520px) { body.compact #top .chip.day .lbl { display: inline; } }
/* The stores sheet (⋯). */
body.compact #sheet:not([hidden]) { display: block; position: fixed; left: 6px; right: 6px; top: calc(var(--toph) + 4px); z-index: 5; padding: 8px 10px; max-height: calc(var(--vh, 100vh) - var(--toph) - var(--barh, 60px) - 16px); overflow: auto; }
#sheet h3 { display: flex; justify-content: space-between; align-items: center; margin: 0 0 6px; }
#sheet .sgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(150px, 100%), 1fr)); gap: 2px 12px; }
#sheet .srow { display: grid; grid-template-columns: 22px 1fr auto; gap: 4px; align-items: center; padding: 3px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
#sheet .srow i { font-style: normal; }
#sheet .srow b { font: 500 13px var(--pix); letter-spacing: 0.04em; }
#sheet .srow span { font: 500 13px var(--mono, monospace); color: var(--gold2); }
#sheet .schips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
#sheet .schips .chip { border: 1px solid var(--line); font-size: 12px; padding: 3px 6px; }
#sheet .fine { margin: 6px 0 0; font-size: 12px; }

/* Goal pill (top left) and the log under it. */
body.compact #left { top: calc(var(--toph) + 4px) !important; left: 4px !important; right: 182px !important; width: auto !important; }
body.compact #left #goals, body.compact #left #goals:has(.hint) { display: block !important; padding: 0 !important; background: none !important; border: 0 !important; box-shadow: none !important; clip-path: none !important; -webkit-backdrop-filter: none; backdrop-filter: none; }
body.compact #goals .gpill { display: flex; align-items: center; gap: 6px; min-height: 34px; padding: 3px 8px; background: rgba(var(--bg), 0.9); border: 1px solid var(--line); border-left: 3px solid var(--gold2); font: 12px/1.25 var(--serif); color: #f0e6cc; cursor: pointer; }
body.compact #goals .gpill.warn { border-left-color: #ff6040; background: rgba(70, 18, 12, 0.92); }
body.compact #goals .gpill span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body.compact #goals .gpill b { flex: none; color: var(--gold); font-size: 13px; padding: 6px 8px; margin: -4px -8px -4px 0; }
body.compact #goals .gpill .hgo { flex: none; padding: 2px 8px; font-size: 11px; }
body.compact #left #goals:not(.open) > :not(.gpill) { display: none !important; }
body.compact #left #goals.open > .hint, body.compact #left #goals.open > h3, body.compact #left #goals.open > ul { display: block !important; }
body.compact #left #goals.open > .hint { display: flex !important; margin: 0 !important; border-top: 0; }
body.compact #left #goals.open > h3, body.compact #left #goals.open > ul { background: rgba(var(--bg), 0.94); margin: 0 !important; padding: 4px 8px; border: 1px solid var(--line); border-top: 0; }
body.compact #left #goals.open > ul { font-size: 12px; max-height: calc(var(--vh, 100vh) * 0.40); overflow: auto; }
body.compact #log { max-width: 100% !important; margin-top: 4px; }
body.compact #log div { font-size: 12px; padding: 2px 6px; }

/* Floor: ▲ [list] ▼ at the top right. */
body.compact #depth { top: calc(var(--toph) + 4px) !important; right: 4px !important; bottom: auto !important; left: auto !important; width: 174px !important; padding: 2px !important; }
body.compact #depth h3 { display: flex !important; gap: 3px; margin: 0 !important; align-items: center; }
body.compact #depth .fname, body.compact #depth .fl { display: none !important; }
body.compact #depth .fsel { display: block; flex: 1; min-width: 0; font: 500 12px var(--pix); padding: 2px; height: 32px; text-transform: none; letter-spacing: 0; }
body.compact #depth .ud { display: contents !important; }
body.compact #depth .ud button[data-d="-1"] { order: -1; }
body.compact #depth .ud button { padding: 0 8px !important; height: 32px; min-width: 32px; font-size: 12px; }

/* Map and army live behind the bar's buttons; the old floating buttons go. */
body.compact #fab, body.compact #mini, body.compact #army { display: none !important; }
body.compact #tools .cpt { display: inline-flex; }
body.compact[data-sheet="map"] #mini { display: block !important; position: fixed; top: auto !important; right: 6px !important; left: auto; bottom: calc(var(--barh, 60px) + 6px) !important; width: min(calc(100vw - 12px), calc((var(--vh, 100vh) - var(--toph) - var(--barh, 60px) - 20px) * 1.25)) !important; height: auto !important; max-height: calc(var(--vh, 100vh) - var(--toph) - var(--barh, 60px) - 20px); z-index: 5; background: #0a080c; }
body.compact[data-sheet="army"] #army { display: block !important; position: fixed; top: auto !important; right: 6px !important; left: auto; bottom: calc(var(--barh, 60px) + 6px) !important; width: min(340px, calc(100vw - 12px)) !important; max-height: calc(var(--vh, 100vh) - var(--toph) - var(--barh, 60px) - 20px) !important; z-index: 5; }
body.compact[data-sheet="army"] #army .kind { padding: 6px 4px; min-height: 44px; }

/* The alert: above the bar at the left, never over the middle of the view. */
body.compact #alert { top: auto !important; bottom: calc(var(--barh, 60px) + 8px); left: 6px; right: auto; transform: none; max-width: min(560px, calc(100vw - 12px)); font-size: 13px; animation: none; }
body.compact #alert:not([hidden]) { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; white-space: normal; right: auto; width: max-content; max-width: calc(100vw - 12px); }
body.compact #alert b { display: inline-flex; align-items: center; min-height: 36px; margin: 0; white-space: nowrap; }
body.compact.touch #alert b { min-height: 40px; }

/* The bar. */
body.compact #bar { left: 0 !important; right: 0 !important; width: 100% !important; transform: none !important; clip-path: none !important; bottom: 0; padding: 4px 6px 4px !important; gap: 4px !important; overflow: visible; }
body.compact #sel { min-height: 0 !important; }
body.compact #sel .por { width: 30px; height: 30px; }
body.compact #sel > div { min-width: 0; }
body.compact #sel .hpbar, body.compact #sel .xpbar, body.compact #sel .tal, body.compact #sel .passive { display: none; }
body.compact #acts > * { flex: none; }
body.compact #acts .actlab { display: none; }
body.compact #tools { display: grid !important; gap: 3px !important; justify-content: stretch; }
body.compact #tools > button { order: 2; display: none; }
body.compact #tools > button.prim { order: 1; display: inline-flex; }
body.compact.toolsmore #tools > button { display: inline-flex; }
body.compact #tools button { flex-direction: column; align-items: center; justify-content: center; gap: 1px; padding: 3px 2px !important; font-size: 10px !important; letter-spacing: 0.03em; overflow: hidden; min-width: 0; line-height: 1.1; }
body.compact #tools button i { font-size: 17px; line-height: 1; }
body.compact #tools button i + span { margin: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.compact #tools button[data-key]::after { display: none; }
body.compact #popup { left: 50% !important; right: auto !important; transform: translateX(-50%) !important; width: min(720px, calc(100% - 12px)) !important; bottom: calc(var(--barh, 60px) + 4px) !important; max-height: calc(var(--vh, 100vh) - var(--toph) - var(--barh, 60px) - 12px) !important; }
body.compact #coach { width: min(320px, calc(100vw - 70px)); }
body.compact.booked #coach { z-index: 8; }
body.compact.booked #coach-ring { z-index: 8; }
body.compact #keys .kgrid { grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr)); }

/* Portrait: the bar at the bottom, selection on top, a row of tools; the selection folds away. */
@media (orientation: portrait) {
  body.compact #bar { grid-template-columns: 1fr !important; max-height: calc(var(--vh, 100vh) * 0.26); }
  body.compact #b-fold { display: block; position: absolute; left: 6px; top: -34px; height: 34px; padding: 0 10px; font-size: 11px; background: rgba(var(--bg), 0.94); border-bottom: 0; clip-path: none; }
  body.compact #sel > div > small:first-of-type { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  body.compact #sel > div > small:not(:first-of-type) { display: none; }
  body.compact #acts { flex-wrap: wrap !important; gap: 3px !important; max-height: min(92px, calc(var(--vh, 100vh) * 0.14)); overflow-y: auto; scrollbar-width: thin; }
  body.compact #tools { grid-template-columns: repeat(7, 1fr); }
  body.compact #tools button { height: 46px; }
  body.compact.selfold #sel, body.compact.selfold #acts { display: none !important; }
  body.compact #alert { bottom: calc(var(--barh, 60px) + 42px); }
}
/* Landscape: one short strip at the bottom: what is selected, its actions (scrolling sideways), the tools as icons. */
@media (orientation: landscape) {
  body.compact #bar { grid-template-columns: minmax(0, min(190px, 22vw)) minmax(0, 1fr) auto !important; align-items: center; max-height: none; }
  body.compact #b-fold { display: none !important; }
  body.compact #sel { overflow: hidden; }
  body.compact #sel > div > b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
  body.compact #sel > div > small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 11px !important; }
  body.compact #sel > div > small:not(:first-of-type) { display: none; }
  body.compact #acts { grid-column: auto !important; flex-wrap: nowrap !important; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; gap: 3px !important; align-items: center; display: flex !important; min-width: 0; }
  body.compact #acts:empty { display: flex !important; }
  body.compact #acts button small { display: none; }
  body.compact #tools { grid-template-columns: repeat(7, 42px); grid-column: auto !important; justify-self: end !important; }
  body.compact #tools button { height: 42px; }
  body.compact #tools button i + span { display: none; }
  body.compact #left { right: auto !important; width: min(42vw, 380px) !important; }
}
/* Wide enough landscape (small laptops, 1024×600 tablets): the tools keep their names. */
@media (orientation: landscape) and (min-width: 1000px) {
  body.compact #tools { grid-template-columns: repeat(7, 58px); }
  body.compact #tools button i + span { display: block; }
  body.compact #bar { grid-template-columns: minmax(0, 240px) minmax(0, 1fr) auto !important; }
}
/* Touch: every target at least 40px. */
body.compact.touch #acts button, body.compact.touch #sel button, body.compact.touch #book .bk-ctl button, body.compact.touch #book [data-act="inc"], body.compact.touch #book [data-act="dec"], body.compact.touch #sheet .kx, body.compact.touch #keys .kx { min-width: 40px; }
body.compact.touch #acts button, body.compact.touch #sel button, body.compact.touch #popup button, body.compact.touch #book button, body.compact.touch #sheet button, body.compact.touch #keys button, body.compact.touch #coach button, body.compact.touch #army button { min-height: 40px; }
body.compact.touch #depth .fsel, body.compact.touch #depth .ud button { height: 40px; }
body.compact.touch #goals .gpill { min-height: 40px; }
body.compact.touch #book select, body.compact.touch #popup select { min-height: 40px; }
@media (orientation: landscape) { body.compact.touch #tools { grid-template-columns: repeat(7, 44px); } body.compact.touch #tools button { height: 44px; } }
@media (orientation: landscape) and (min-width: 1000px) { body.compact.touch #tools { grid-template-columns: repeat(7, 58px); } }
@media (orientation: portrait) { body.compact.touch #tools button { height: 48px; } }

/* The Hold Book in compact: the whole screen, tabs scroll sideways, tables become cards. */
body.compact #book { inset: 0 !important; border: 0; outline: 0; }
body.compact #book { inset: 0; border: 0; outline: 0; }
body.compact #book .bk-head { padding: 8px 10px 4px; }
body.compact #book .bk-head h2 { font-size: 14px; }
body.compact #book .bk-head h2 .fine { display: block; margin: 2px 0 0; font-size: 12px; }
body.compact #book .bk-tabs { padding: 0 4px; }
body.compact #book .bk-tabs button { padding: 8px 9px 6px; font-size: 13px; }
body.compact #book .bk-body { padding: 8px 10px 24px; }
body.compact #book .bk-opts { grid-template-columns: 1fr; }
body.compact #book .bk-trades { grid-template-columns: 1fr 1fr; }
body.compact #book .bk-trade { grid-template-columns: 20px 1fr auto; padding: 5px 6px; }
body.compact #book .bk-trade b { font-size: 13px; }
body.compact #book .fhead { display: flex; flex-wrap: wrap; gap: 2px 10px; position: static; }
body.compact #book .fhead > span { display: none; }
body.compact #book .frow:not(.fhead) { grid-template-columns: 24px 1fr 1fr; grid-template-areas: "c n t" ". d d" ". f f" ". l h"; gap: 3px 8px; padding: 6px 8px; }
body.compact #book .frow > input { grid-area: c; } body.compact #book .frow .fname { grid-area: n; } body.compact #book .frow > select { grid-area: t; }
body.compact #book .frow .fdo { grid-area: d; } body.compact #book .frow .fz { grid-area: f; justify-self: start; max-width: 100%; } body.compact #book .frow .fload { grid-area: l; } body.compact #book .frow .fhp { grid-area: h; }
body.compact #book .srow2 { grid-template-columns: 24px 1fr auto; grid-template-areas: "i n v" ". c r" ". s s"; gap: 3px 8px; }
body.compact #book .srow2 .si { grid-area: i; } body.compact #book .srow2 b { grid-area: n; } body.compact #book .srow2 .sv { grid-area: v; text-align: right; }
body.compact #book .srow2 .scap { grid-area: c; } body.compact #book .srow2 .sr { grid-area: r; text-align: right; } body.compact #book .srow2 svg.spark { grid-area: s; }
body.compact #book .bk-rivals, #book .bk-heroes { grid-template-columns: 1fr; }
body.compact #book .bk-ch { grid-template-columns: 1fr; }
body.compact #book .bk-ch > .sworn, #book .bk-ch > .bk-acts { grid-column: 1; grid-row: auto; }
body.compact #book .market { grid-template-columns: 1fr; }
body.compact #book .bk-tree { grid-template-columns: 1fr 1fr; gap: 6px; }
body.compact #book .bk-armt { overflow-x: visible; }
body.compact #book .arow { grid-template-columns: minmax(0, 1fr) 44px repeat(var(--nf, 1), 52px); min-width: 0; }
body.compact #book .arow > :last-child { grid-column: 1 / -1; }
body.compact #book .ahead > :last-child { display: none; }
body.compact #book .bk-tabs { flex-wrap: wrap; justify-content: space-between; overflow: visible; }
body.compact #book .bk-tabs button { padding: 7px 6px 5px; }
body.compact #book .bk-tabs { flex-wrap: nowrap !important; justify-content: flex-start !important; overflow-x: auto !important; scrollbar-width: none; }
body.compact #book .bk-tabs button { flex: none; white-space: nowrap; }
body.compact #book .bk-head { flex-wrap: wrap; }
@media (orientation: landscape) { body.compact #book .bk-head h2 .fine { display: inline; } }
.trait.locked { opacity: 0.6; cursor: default; border-style: dashed; }
.trait.locked small i { font-style: normal; color: #d8b070; }

/* Together: the lobby's kingdom count, ready marks and the host's settings. */
#lobby .members li { flex-wrap: wrap; }
#lobby .members li.me b { color: var(--gold2); }
#lobby .members i { border: 1px solid rgba(0, 0, 0, 0.6); }
#lobby .members span { font-size: 13px; text-align: right; }
#lobby .members u { text-decoration: none; font: 600 12px var(--pix); color: var(--faint); min-width: 52px; text-align: right; }
#lobby .members u.yes { color: var(--green); }
#lobby .kcount { margin: 0 0 6px; }
#lobby .hostset { font-size: 13px; color: var(--dim); display: flex; flex-wrap: wrap; gap: 4px; align-items: baseline; margin: 4px 0 6px; }
#lobby .hostset b { font: 600 12px var(--pix); color: var(--gold); text-transform: uppercase; letter-spacing: 0.08em; margin-right: 4px; }
#lobby .hostset span { background: var(--ink2); border: 1px solid var(--line); padding: 1px 6px; }
#lobby .lwarn { margin: 4px 0; font: 600 13px var(--pix); color: #ffc8a0; background: rgba(120, 50, 20, 0.35); border-left: 3px solid #e0803a; padding: 3px 8px; }
#lobby #ready.on { border-color: var(--green); color: var(--green); }

/* Together in the game: the chat feed and line, pings, and the link's state. */
#pings { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; }
#chat { position: fixed; left: 8px; bottom: calc(var(--barh, 101px) + 10px); width: min(440px, calc(100vw - 72px)); z-index: 4; pointer-events: none; }
#chatfeed { display: flex; flex-direction: column; gap: 2px; align-items: flex-start; }
#chatfeed .cline { font: 14px/1.3 var(--serif); background: rgba(var(--bg), 0.82); border-left: 3px solid var(--c, var(--line)); padding: 2px 8px; max-width: 100%; overflow-wrap: anywhere; pointer-events: auto; animation: cIn 0.2s ease-out; }
#chatfeed .cline b { font: 600 13px var(--pix); color: var(--c, var(--paper)); margin-right: 4px; }
#chatfeed .cline i { font: 11px var(--pix); color: var(--faint); font-style: normal; }
#chatfeed .cline .at { font: 12px var(--pix); color: var(--gold2); }
#chatfeed .cline .aidbtn { font: 12px var(--pix); padding: 1px 8px; margin-left: 2px; color: var(--paper); background: #3c6a34; border: 1px solid #70b860; cursor: pointer; pointer-events: auto; }
#chatfeed .cline .aidbtn:disabled { opacity: 0.6; cursor: default; }
#chatfeed .cline.go { cursor: pointer; }
#chatfeed .cline.q-help, #chatfeed .cline.q-attack { background: rgba(80, 24, 14, 0.88); }
#chatfeed .cline:nth-last-child(n+7) { display: none; }
#chatfeed .cline.old { display: none; }
#chat.open #chatfeed .cline.old, #chat.open #chatfeed .cline:nth-last-child(n+7) { display: block; }
#chat.open #chatfeed .cline:nth-last-child(n+13) { display: none; }
@keyframes cIn { from { opacity: 0; transform: translateY(4px); } }
#chatbar { margin-top: 4px; padding: 5px; display: grid; gap: 4px; pointer-events: auto; }
#chatbar[hidden] { display: none; }
#chatbar .cq { display: flex; gap: 3px; flex-wrap: wrap; }
#chatbar .cq button { padding: 3px 7px; font-size: 13px; }
#chatbar .cl { display: flex; gap: 3px; }
#chatbar .cl input { flex: 1; min-width: 0; font-size: 15px; }
#chatbar .cl button { padding: 4px 8px; }
#b-chat { position: fixed; right: 8px; bottom: calc(var(--barh, 101px) + 10px); z-index: 4; font-size: 18px; padding: 4px 9px; }
#netwait { position: fixed; left: 50%; top: 96px; transform: translateX(-50%); z-index: 6; font: 600 14px var(--pix); color: var(--gold2); background: rgba(var(--bg), 0.94); border: 2px solid var(--gold); padding: 6px 14px; pointer-events: none; max-width: calc(100vw - 24px); text-align: center; }
#netwait::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 8px; border: 2px solid var(--gold); border-right-color: transparent; border-radius: 50%; vertical-align: -1px; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#netwait.full { inset: 0; top: 0; transform: none; max-width: none; display: flex; align-items: center; justify-content: center; font-size: 18px; border: 0; background: radial-gradient(ellipse at 50% 45%, rgba(var(--bg), 0.92), rgba(8, 6, 10, 0.98)); }
#netwait.full[hidden], #netwait[hidden] { display: none; }
body.compact #chat { left: 4px; bottom: calc(var(--barh, 60px) + 48px); width: calc(100vw - 60px); }
body.compact #chatfeed .cline { font-size: 12px; padding: 1px 6px; }
body.compact #chatfeed .cline:nth-last-child(n+4) { display: none; }
body.compact #chat.open #chatfeed .cline:nth-last-child(n+4):not(:nth-last-child(n+9)) { display: block; }
body.compact #chatbar .cq button { font-size: 12px; padding: 4px 6px; }
body.compact #b-chat { right: 4px; bottom: calc(var(--barh, 60px) + 48px); }
body.compact #netwait { top: calc(var(--toph) + 8px); font-size: 13px; }
/* ---------- the weight of battle: "To arms!", the battle report, ranks, the fallen ---------- */
#alert.arms { font-size: 16px; letter-spacing: 0.06em; background: linear-gradient(90deg, rgba(110, 20, 10, 0.96), rgba(70, 18, 12, 0.94)); border-color: #ff9050; animation: alertIn 0.25s ease-out, armsPulse 1.2s ease-in-out 2; }
@keyframes armsPulse { 50% { box-shadow: 0 0 22px rgba(255, 110, 50, 0.65); } }
#bcard { position: fixed; left: 8px; bottom: 132px; z-index: 6; width: min(290px, calc(100vw - 16px)); font: 500 13px var(--pix); color: #efe4cc; background: rgba(26, 18, 12, 0.95); border: 1px solid #b89040; border-top: 3px solid #e0b050; padding: 6px 10px 6px; box-shadow: 0 4px 16px rgba(0,0,0,0.5); animation: noteIn 0.3s ease-out; }
@keyframes noteIn { from { transform: translateX(-12px); opacity: 0; } to { transform: none; opacity: 1; } }
#bcard.grim { border-color: #a04030; border-top-color: #d05a3a; }
#bcard h4 { margin: 0 0 3px; font: 700 15px "Cinzel", Georgia, serif; color: #f4d488; }
#bcard.grim h4 { color: #ffb090; }
#bcard h4 small { display: block; font: 500 12px var(--pix); color: #b8ae98; letter-spacing: 0.02em; }
#bcard ul { margin: 0; padding: 0 0 0 16px; }
#bcard li { margin: 2px 0; line-height: 1.3; }
#bcard li.lost { color: #ffc0a8; }
#bcard em { font-style: normal; color: #ffd890; }
#bcard .bc-row { display: flex; gap: 6px; justify-content: flex-end; margin-top: 6px; }
#bcard button { font: inherit; font-size: 13px; color: #f0e0c0; background: rgba(80, 60, 30, 0.6); border: 1px solid rgba(220, 180, 100, 0.5); padding: 2px 8px; cursor: pointer; }
i.rank { font-style: normal; font-size: 0.85em; color: #c8b8a0; }
i.rank.r2 { color: #e8c890; }
i.rank.r3 { color: #ffd060; }
.bk-fallen { list-style: none; margin: 0; padding: 0; columns: 2 220px; font-size: 13px; }
.bk-fallen li { margin: 1px 0; break-inside: avoid; color: #d8ccb4; }
.bk-fallen li.champ b { color: #ffd060; }
.bk-fallen li.hero b { color: #f4d488; }
.bk-fallen small { color: #8a8070; margin-right: 4px; }
body.compact #bcard { bottom: auto; top: calc(var(--toph, 40px) + 40px); width: min(240px, calc(100vw - 16px)); font-size: 12px; }
body.compact #bcard h4 { font-size: 14px; }
/* ===== The long game: saga track, heirlooms, end-card score, clan ambitions ===== */
.saga-box { margin: 8px 0; padding: 6px 10px; border: 2px solid var(--line); border-radius: 3px; background: rgba(var(--bg2), 0.5); text-align: left; }
.saga-box summary { cursor: pointer; font: 600 13px var(--pix); color: var(--gold2); }
.saga-track { font-size: 13px; }
.saga-track .st-sum { margin: 6px 0 2px; color: var(--dim); }
.saga-track .st-sum b { color: var(--gold2); }
.st-next { margin: 4px 0; color: #d8b070; }
.saga-track .st-gens { margin: 4px 0 6px; padding-left: 18px; color: #d8cfbe; }
.saga-track .st-gens li { margin: 1px 0; }
.saga-track .st-deeds { list-style: none; margin: 4px 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr)); gap: 4px 10px; }
.saga-track .st-deeds li { padding: 3px 6px; border-left: 3px solid var(--line); }
.saga-track .st-deeds li b { display: block; font: 600 12px var(--pix); }
.saga-track .st-deeds li small { color: var(--dim); }
.saga-track .st-deeds li.done { border-color: var(--gold); }
.saga-track .st-deeds li.done b { color: var(--gold2); }
.saga-track .st-deeds li.now { border-color: var(--green); }
.saga-track .st-deeds li.locked { opacity: 0.65; }
.modes.heirs { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr)); gap: 6px; }
.mode.heir.on { border-color: var(--gold2); }
#end-chron .epitaph { font-style: italic; color: var(--gold2); margin: 8px 0; }
#end-chron .end-score h3 b { font-size: 18px; color: var(--gold2); margin-left: 6px; }
#end-chron .end-score h3 .fine { margin-left: 8px; text-transform: none; letter-spacing: 0; }
#end-chron .end-score ul { list-style: none; margin: 4px 0 8px; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr)); gap: 2px 14px; font-size: 13px; }
#end-chron .end-score li { display: flex; justify-content: space-between; gap: 8px; border-bottom: 1px dotted var(--line); }
#end-chron .end-score li small { color: var(--dim); }
#end-chron .end-score li b.neg { color: var(--red); }
#end-chron .end-deeds small { color: var(--dim); }
#end .card { max-height: calc(var(--vh, 100vh) * 0.92); overflow-y: auto; }
ul.amb { list-style: none; margin: 2px 0; padding: 0; }
ul.amb li { margin: 2px 0; color: #e8d8a8; }
ul.amb li small { color: var(--dim); margin-left: 4px; }
#goals .amb-h { margin: 6px 0 0; font: 600 11px var(--pix); text-transform: uppercase; letter-spacing: 0.1em; color: var(--gold); }
body.compact #goals:not(.open) .amb-h, body.compact #goals:not(.open) ul.amb { display: none; }
/* ======================================================================
   UX round: the coach keeps off the panels, report queue, grouped log
   ====================================================================== */
#coach { padding-right: 26px; }
#coach .cx { position: absolute; top: 3px; right: 3px; padding: 0 6px !important; min-height: 0 !important; font-size: 12px; line-height: 18px; background: transparent; border: 0; color: var(--dim); cursor: pointer; }
#coach .cx:hover { color: var(--paper); }
#coach[data-side="left"] .carrow, #coach[data-side="right"] .carrow { left: auto; top: calc(var(--ay, 50%) - 7px); }
#coach[data-side="left"] .carrow { right: -15px; border-left-color: var(--gold); }
#coach[data-side="right"] .carrow { left: -15px; border-right-color: var(--gold); }
/* A battle report waits behind the Hold Book: the Chronicle tab says so. */
#book .bk-tabs [data-k="chron"].bk-new { position: relative; border-color: #e0b050; color: #ffe0a0; }
#book .bk-tabs [data-k="chron"].bk-new::after { content: "Battle report"; margin-left: 6px; padding: 0 5px; font: 600 10px var(--pix); letter-spacing: 0.06em; text-transform: uppercase; color: #1a120c; background: #e0b050; border-radius: 2px; animation: coachPulse 1.2s ease-in-out infinite; }
#b-book.bk-new { position: relative; }
#b-book.bk-new::after { content: ""; position: absolute; top: 3px; right: 3px; width: 8px; height: 8px; border-radius: 50%; background: #e0b050; box-shadow: 0 0 0 2px rgba(26, 18, 12, 0.9); animation: coachPulse 1.2s ease-in-out infinite; }
#bcard li.more { list-style: none; margin-left: -16px; color: #d8b070; font-size: 0.92em; }
/* The log: repeats counted, routine lines go quickly. */
#log div { transition: opacity 0.8s linear; }
#log .lx { font-style: normal; font: 600 11px var(--pix); color: var(--gold2); background: rgba(255, 255, 255, 0.07); padding: 0 4px; margin-left: 4px; border-radius: 2px; }
#log .warn .lx { color: #ffc0a8; }
body.compact #coach { padding-right: 26px; }

/* ===== the long game: sellswords, gold for the realm's business, the Deep Threat, tales (midgame) ===== */
.bk-mercs { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(250px, 100%), 1fr)); gap: 8px; }
.bk-merc { padding: 8px 10px; background: rgba(0,0,0,0.2); border: 1px solid var(--line); border-left: 3px solid var(--line2, var(--line)); display: grid; gap: 4px; align-content: start; }
.bk-merc.on { border-left-color: var(--gold); background: rgba(216,144,62,0.08); }
.bk-merc.bad { border-left-color: var(--red); }
.bk-merc h5 { margin: 0; display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; }
.bk-merc h5 small { font: 12px var(--serif); color: var(--dim); text-transform: none; letter-spacing: 0; }
.bk-merc p { margin: 0; }
.bk-merc .why { color: var(--dim); font-size: 12px; align-self: center; }
.mk-mercs { margin-top: 10px; }
.mk-mercs h4 { margin: 0 0 6px; }
.gact { border-style: dashed !important; }
span.gact.on { display: inline-grid; padding: 4px 8px; border: 1px solid var(--gold); color: var(--gold2); font-size: 13px; }
span.gact.on small { color: var(--dim); }
.bk-deep { display: grid; gap: 4px; padding: 8px 10px; border: 1px solid var(--line); border-left: 3px solid var(--red); background: rgba(160,40,30,0.12); max-width: 640px; }
.bk-deep.broken { border-left-color: var(--green); background: rgba(112,184,96,0.08); }
.bk-deep .hpbar > span { background: var(--red); }
.bk-deep .bk-acts { margin-top: 2px; }
.bk-chain { display: grid; gap: 3px; padding: 8px 10px; margin-bottom: 6px; border: 1px solid var(--line); border-left: 3px solid var(--gold); background: rgba(0,0,0,0.18); max-width: 640px; }
.bk-chain ol { list-style: none; margin: 2px 0 0; padding: 0; }
.bk-chain li { margin: 1px 0; color: var(--dim); }
.bk-chain li.ok { color: var(--green); }
.bk-chain li.cur { color: var(--paper); }
.bk-chain li small { color: var(--gold2); margin-left: 4px; }
ul.bk-sites { list-style: none; margin: 2px 0; padding: 0; }
ul.bk-sites li { margin: 2px 0; }
ul.bk-sites li.ok { color: var(--dim); }
ul.bk-sites li small { color: var(--dim); }
#goals .chain-l { margin: 6px 0 0; font-size: 13px; color: #e8d8a8; }
#goals .chain-l b { color: var(--gold2); }
#goals .chain-l small { color: var(--dim); margin-left: 4px; }
body.compact #goals:not(.open) .chain-l { display: none; }

/* The deep's own rules: the floor button's mark, the first-reach banner, the milestone hint, a late start in the saga. */
#depth .fb .fr { position: absolute; left: 0; bottom: -3px; font: normal 7px/1 sans-serif; opacity: 0.85; pointer-events: none; }
#depthban { position: fixed; left: 50%; bottom: 112px; transform: translateX(-50%); z-index: 6; width: min(420px, calc(100vw - 32px)); padding: 8px 14px 9px; background: linear-gradient(180deg, rgba(26, 18, 12, 0.96), rgba(16, 11, 8, 0.96)); border: 1px solid #b89040; border-top: 3px solid var(--t, #e0b050); box-shadow: 0 6px 24px rgba(0,0,0,0.6); color: #efe4cc; text-align: center; cursor: pointer; animation: alertIn 0.35s ease-out; }
#depthban small { display: block; font: 600 10px var(--pix); letter-spacing: 0.16em; text-transform: uppercase; color: #c8b890; }
#depthban b { display: block; font: 700 19px "Cinzel", Georgia, serif; color: #f4d488; margin: 2px 0 3px; }
#depthban p { margin: 0; font: 500 13px/1.35 var(--pix); color: #e0d6c0; }
body.compact #depthban { bottom: 150px; }
#coach.hint { border-left-color: #8ab0d0; opacity: 0.94; }
#coach.hint small { color: #9ab8d0; }
#coach.hint b { font-size: 14px; }
#coach.hint p:empty { display: none; }
.st-late { font-style: normal; color: #c8b890; }

/* ---------- phones: keep the bars clear of the gesture bar / home indicator and the notch ---------- */
@supports (height: 100dvh) { html, body { height: 100dvh; } }
#bar { padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }
body.compact #bar { padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px)) !important; }
body.touch #bar { padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px)) !important; }
body.compact #top, body.touch #top { padding-top: env(safe-area-inset-top, 0px); }
body.compact #bar, body.touch #bar { padding-left: max(6px, env(safe-area-inset-left, 0px)) !important; padding-right: max(6px, env(safe-area-inset-right, 0px)) !important; }
body.compact { --toph: calc(34px + env(safe-area-inset-top, 0px)); }
body.compact.touch { --toph: calc(42px + env(safe-area-inset-top, 0px)); }

/* Army groups: fixed slots (1–9, or 1–5 and ⋯ on a phone). Tap picks, tap again looks; hold or ✎ Set stores. */
#army .gbox { margin: 0 0 8px; border-bottom: 1px solid var(--line); padding-bottom: 6px; }
#army .ghead { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin: 0 2px 4px; font: 600 11px var(--pix); text-transform: uppercase; letter-spacing: 0.08em; color: var(--dim); }
#army .ghead .gset { padding: 2px 8px; font: 600 12px var(--pix); text-transform: none; letter-spacing: 0; }
#army .gslots { display: grid; grid-template-columns: repeat(5, 1fr); gap: 3px; }
#army .gslot { position: relative; overflow: hidden; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2px 0; min-width: 0; font: 600 13px var(--pix); -webkit-touch-callout: none; touch-action: manipulation; }
#army .gslot b { font: inherit; line-height: 1.1; }
#army .gslot small { display: block; font-size: 10px; line-height: 1.1; color: var(--dim); }
#army .gslot.empty { opacity: 0.6; border-style: dashed; }
#army .gslot.on { border-color: var(--gold2); background: #5a3a14; opacity: 1; }
#army .gbox.setting .gslot { border-color: var(--gold); opacity: 1; }
#army .gslot::after { content: ""; position: absolute; left: 0; bottom: 0; height: 3px; width: 0; background: var(--gold2); pointer-events: none; }
#army .gslot.hold::after { animation: gfill 0.45s linear forwards; }
@keyframes gfill { to { width: 100%; } }
#army .gask { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 6px; font: 13px var(--serif); color: var(--paper); }
#army .gask button { padding: 2px 10px; }
#army .ghint { margin: 5px 2px 0; font-size: 12px; color: var(--gold2); }
body.compact[data-sheet="army"] #army .gslots { grid-template-columns: repeat(6, 1fr); gap: 5px; }
body.compact[data-sheet="army"] #army .gslot { min-height: 44px; }
body.compact[data-sheet="army"] #army .ghead .gset, body.compact[data-sheet="army"] #army .gask button { min-height: 40px; padding: 4px 14px; }

/* Founder screen: locked traits and deeds wait behind one small toggle. */
.lockt { display: inline-block; margin: 6px 0 2px; padding: 3px 10px; font: 600 12px var(--pix); color: var(--dim); background: transparent; border: 1px dashed var(--line); box-shadow: none; text-transform: none; letter-spacing: 0.02em; }
.lockt:hover { color: var(--gold2); border-color: var(--gold); }
.lockt[aria-expanded="true"] { color: var(--gold2); }

/* ======================================================================
   Pixel icons (icons.js): one-colour pictures on a 12-pixel grid, filled
   with currentColor so they take the colour of their text: parchment,
   gold when on, dimmed when disabled, red on a warning. 12, 24 and 36 px
   are exact multiples of the grid; crispEdges keeps every size hard.
   ====================================================================== */
.px { width: 1em; height: 1em; vertical-align: -0.15em; fill: currentColor; shape-rendering: crispEdges; overflow: visible; flex: none; pointer-events: none; }
.px .o { fill: none; }
.px.ol .o, #b-chat .px .o, #fab .px .o { fill: rgba(8, 5, 3, 0.75); }
i[data-ico] { font-style: normal; display: inline-flex; vertical-align: middle; line-height: 1; }
/* The bar: 18 px on a desktop, 24 px under a finger. */
#tools button i .px, #b-fold i .px { width: 18px; height: 18px; display: block; }
#tools button > i, #b-fold > i { display: inline-flex; vertical-align: middle; margin-top: -2px; }
body.compact #tools button i .px { width: 18px; height: 18px; }
body.touch #tools button i .px, body.compact.touch #tools button i .px { width: 24px; height: 24px; }
body.compact #tools button > i { margin: 0; }
#tools button.on .px, button.on > .px, button.on > i .px, button.primary .px, #tools button:hover:not(:disabled) .px { color: var(--gold2); }
#tools button.on i, button.on > i { color: var(--gold2); }
#fab .px, #b-chat .px { width: 24px; height: 24px; display: block; }
/* Top resources: 12 px chips (36 device px on a phone). */
#top .chip .px, #sheet .chip .px { width: 12px; height: 12px; display: block; }
#top .chip.more .px { width: 24px; height: 24px; color: var(--gold2); }
#top .chip i { display: inline-flex; align-items: center; }
.chip.low .px, .chip.alarmc .px, .chip.spoil .px { color: inherit; }
/* Lists and cards with a big picture by the name. */
#popup .mk-opt .mi .px, #book .mk-opt .mi .px, #book .bk-trade .ti .px, #book .srow2 .si .px, .labor .li .px { width: 24px; height: 24px; }
#sheet .srow i .px { width: 12px; height: 12px; display: block; }
/* Hold Book tabs: the picture before the word, gold on the open tab. */
#book .bk-tabs button .px { width: 12px; height: 12px; vertical-align: -1px; margin-right: 2px; }
#book .bk-tabs button.on .px { color: var(--gold2); }
#book h2 .px { width: 24px; height: 24px; vertical-align: -3px; }
/* Warnings stay red, the hint gold. */
#alert .px, .neg .px, .lwarn .px, .warn > span > .px { color: #ffb080; }
#goals .hint .px, #goals .gpill .px { color: var(--gold2); }
#goals .ms-l .px { color: var(--gold2); }
.trait.locked .px, .lockt .px { color: var(--dim); }
#goals .hint.warn .px, #goals .gpill.warn .px { color: #ffb080; }

/* ---------- watching: the spectator's panel, the caster's ticker, the scoreboard ---------- */
body.watch #left, body.watch #army, body.watch #fab, body.watch #bar, body.watch #top, body.watch #coach, body.watch #alert, body.watch #bcard, body.watch #sheet, body.watch #depthban { display: none !important; }
body.watch #chat, body.watch #b-chat { bottom: 10px; }
#spec { position: fixed; left: 8px; top: 8px; width: 344px; max-height: calc(var(--vh, 100vh) - 16px); overflow-y: auto; padding: 8px 10px; z-index: 3; scrollbar-width: thin; }
#spec h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 6px; }
#spec h3 > span:first-child { flex: 1; }
#spec h3 .fine { font: 500 12px var(--pix); letter-spacing: 0.04em; text-transform: none; color: var(--dim); }
#spec .sp-fold { padding: 0 7px; font-size: 13px; }
#spec .sp-live { margin: 0 0 6px; font: 500 13px/1.3 var(--pix); color: var(--gold2); min-height: 1.3em; }
#spec .sp-live.manual { color: var(--dim); }
#spec .sp-follow { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; color: var(--dim); }
#spec .sp-follow select { flex: 1; min-width: 0; font-size: 14px; }
.sp-holds, #board table, .sum { width: 100%; border-collapse: collapse; font: 500 13px var(--pix); }
.sp-holds th, #board th, .sum th { color: var(--dim); font-weight: 500; text-align: right; padding: 2px 4px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.sp-holds td, #board td, .sum td { text-align: right; padding: 3px 4px; white-space: nowrap; }
.sp-holds th:first-child, .sp-holds td.cl, #board td.cl, #board th:nth-child(2), .sum td.cl, .sum th:first-child, .sum td:nth-child(2) { text-align: left; }
.sp-holds td.cl, #board td.cl, .sum td.cl { max-width: 120px; overflow: hidden; text-overflow: ellipsis; }
.sp-holds td.cl i, #board td.cl i, .sum td.cl i { display: inline-block; width: 9px; height: 9px; margin-right: 5px; vertical-align: 0; }
.sp-holds tbody tr { cursor: pointer; }
.sp-holds tbody tr:hover td { background: rgba(255, 255, 255, 0.04); }
.sp-holds tr.on td { background: rgba(224, 176, 80, 0.12); }
.sp-holds tr.on td.cl { box-shadow: inset 2px 0 0 var(--gold); }
.sp-holds tr.out, #board tr.out, .sum tr.out { opacity: 0.45; text-decoration: line-through; }
.sp-holds td.sc, #board td.sc, .sum td.sc { color: var(--gold2); font-weight: 700; }
#spec .sp-btns { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
#spec .sp-btns button { font-size: 12px; padding: 4px 7px; }
#ticker { position: fixed; left: 50%; top: 10px; transform: translateX(-50%); width: min(620px, calc(100vw - 740px)); min-width: 320px; z-index: 3; display: flex; flex-direction: column; gap: 3px; pointer-events: none; }
body:not(.watch) #ticker { top: 52px; }
#ticker p { margin: 0; padding: 4px 10px 4px 8px; font: 500 14px/1.3 var(--pix); color: var(--paper); background: rgba(12, 10, 8, 0.78); border-left: 3px solid var(--c, var(--gold)); opacity: 0.72; }
#ticker p.new { opacity: 1; font-size: 16px; background: rgba(20, 16, 10, 0.92); animation: tick-in 0.35s ease-out; }
#ticker p i { margin-right: 6px; color: var(--c, var(--gold)); }
@keyframes tick-in { from { transform: translateY(-6px); opacity: 0; } to { transform: none; opacity: 1; } }
#board { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(640px, calc(100vw - 24px)); max-height: calc(var(--vh, 100vh) - 40px); overflow: auto; padding: 12px 14px; z-index: 4; }
#board h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; }
#board h3 .fine { flex: 1; text-transform: none; letter-spacing: 0.04em; font: 500 12px var(--pix); }
#board .bd-x { padding: 0 7px; }
#board td { font-size: 15px; padding: 5px 6px; }
#board small, .sum small { color: var(--dim); font-size: 11px; }
.spec-end .card { width: min(760px, 100%); }
.sum-wrap { overflow-x: auto; }
.sum tr.won td { color: var(--gold2); }
#lobby .code #wlink { font-size: 12px; padding: 3px 8px; margin-left: auto; }
#watchj { margin-left: 4px; }
/* Phones: the panel is a sheet along the bottom, the ticker runs along the top. */
@media (max-width: 700px), (max-height: 520px) {
  #spec { left: 0; right: 0; top: auto; bottom: 0; width: auto; max-height: calc(var(--vh, 100vh) * 0.46); padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); border-left: 0; border-right: 0; }
  #spec h3 { margin-bottom: 4px; }
  #spec .sp-live { font-size: 12px; margin-bottom: 4px; }
  #spec .sp-follow { margin-bottom: 4px; }
  .sp-holds { font-size: 12px; }
  .sp-holds th, .sp-holds td { padding: 2px 3px; }
  .sp-holds td.cl { max-width: 92px; }
  #spec .sp-btns { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-top: 6px; }
  #spec .sp-btns button { padding: 6px 8px; flex: none; }
  #ticker { left: 6px; right: 6px; width: auto; min-width: 0; transform: none; top: 6px; }
  body:not(.watch) #ticker { top: 48px; }
  #ticker p { font-size: 13px; }
  #ticker p.new { font-size: 14px; }
  body.watch #chat { bottom: calc(calc(var(--vh, 100vh) * 0.46) + 8px); }
  body.watch #b-chat { top: 6px; bottom: auto; right: 6px; }
  body.watch #ticker { right: 52px; }
  body.watch #depth { display: none !important; }
  #board td { font-size: 13px; padding: 4px 3px; }
}
/* ---------- hero quests ---------- */
#book .bk-quest { display: grid; gap: 3px; padding: 6px 8px; border: 1px solid var(--line); border-left: 3px solid var(--gold2); background: rgba(40,28,10,0.25); }
#book .bk-quest .q-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
#book .bk-quest .q-head b { color: var(--gold2); }
#book .bk-quest .q-head small { color: var(--dim); flex: 1 1 auto; }
#book .bk-quest .q-head button { margin-left: auto; padding: 3px 8px; min-height: 30px; }
#book .bk-quest ol { list-style: none; margin: 0; padding: 0; }
#book .bk-quest li { margin: 1px 0; color: var(--dim); }
#book .bk-quest li.ok { color: var(--green); }
#book .bk-quest li.cur { color: var(--paper); }
#book .bk-quest li small { color: var(--gold2); margin-left: 4px; }
#book .bk-quest .q-boon { margin: 0; color: var(--gold2); }
#book .bk-quest .q-reward { margin: 0; }
#book .bk-quest.failed { border-left-color: #a04030; opacity: 0.8; }
#book .bk-quest.done { border-left-color: var(--green); }
#book .q-title, #sel .quest i { color: var(--gold2); font-style: italic; }
#sel small.quest { color: #e8d8a8; }
#goals .quest-l { margin: 6px 0 0; font-size: 13px; color: #e8d8a8; cursor: pointer; }
#goals .quest-l b { color: var(--gold2); }
#goals .quest-l small { color: var(--dim); margin-left: 4px; }
#goals .quest-l .px { color: var(--gold2); }
#goals .quest-l:hover { color: var(--paper); }
body.compact #goals:not(.open) .quest-l { display: none; }
body.compact #book .bk-quest .q-head button { min-height: 36px; }
body.compact #sel small.quest { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body.compact #left #goals.open > .quest-l { display: block; background: rgba(var(--bg), 0.94); margin: 0 !important; padding: 4px 8px; border: 1px solid var(--line); border-top: 0; font-size: 12px; }
/* Hold Book: the Smithy (Stores tab) and Renown (Empire tab) */
#book .mw-pick label { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
#book .mw-tag { font: 600 13px var(--pix); color: var(--gold2); display: inline-flex; gap: 4px; align-items: center; }
#book .mw-smith { display: grid; grid-template-columns: minmax(180px, 1fr) 2fr; gap: 8px 14px; align-items: center; padding: 8px 10px; margin: 6px 0; background: rgba(0,0,0,0.2); border: 1px solid var(--line); border-left: 3px solid var(--gold); }
#book .mw-smith b { font: 600 14px var(--pix); display: block; }
#book .mw-smith small { color: var(--dim); display: block; }
#book .mw-smith .xpbar { display: block; margin-top: 3px; }
#book .mw-odds { display: flex; height: 22px; border: 1px solid var(--line); font: 600 11px var(--pix); overflow: hidden; }
#book .mw-odds span { display: flex; align-items: center; justify-content: center; white-space: nowrap; overflow: hidden; min-width: 0; padding: 0 3px; }
#book .mw-odds .q-fine { background: rgba(216,200,160,0.18); color: #e8dcc0; }
#book .mw-odds .q-superior { background: rgba(120,180,240,0.25); color: #bfe0ff; }
#book .mw-odds .q-masterwork { background: rgba(240,200,80,0.35); color: #ffe090; }
#book .mw-pieces, #book .mw-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(250px, 100%), 1fr)); gap: 8px; }
#book .mw-piece, #book .mw-item { display: grid; gap: 4px; align-content: start; padding: 8px 10px; background: rgba(0,0,0,0.18); border: 1px solid var(--line); }
#book .mw-piece.ok { border-color: var(--gold); }
#book .mw-piece b, #book .mw-item b { font: 600 14px var(--pix); display: flex; gap: 5px; align-items: center; flex-wrap: wrap; }
#book .mw-piece small, #book .mw-item small { font-size: 12px; }
#book .mw-mats { display: flex; flex-wrap: wrap; gap: 4px 10px; font-family: var(--mono, monospace); }
#book .mw-mats span { display: inline-flex; gap: 2px; align-items: center; }
#book .mw-piece button { justify-self: start; text-align: left; white-space: normal; }
#book .mw-item.q-superior { border-left: 3px solid #9cd0ff; }
#book .mw-item.q-masterwork { border-left: 3px solid #ffd060; box-shadow: inset 0 0 0 1px rgba(255,208,96,0.25); }
#book .mw-item .bk-acts { display: flex; flex-wrap: wrap; gap: 5px; }
#book .mw-item .bk-acts select { flex: 1 1 150px; min-width: 0; max-width: 100%; }
#book .mw-q-fine { color: #e0d0a8; } #book .mw-q-superior { color: #9cd0ff; } #book .mw-q-masterwork { color: #ffd060; font-weight: 600; }
#book .mw-q { list-style: none; margin: 4px 0 8px; padding: 0; display: grid; gap: 4px; }
#book .mw-q li { display: grid; grid-template-columns: minmax(0, auto) 1fr minmax(80px, 160px) auto auto; gap: 4px 8px; align-items: center; padding: 4px 8px; background: rgba(216,144,62,0.08); border-left: 3px solid var(--gold); font-size: 13px; }
#book .mw-q li .hpbar > span { background: var(--gold); }
#book .mw-q li button { padding: 2px 8px; }
#book .mw-borne { color: #ffe090; }
#book .mw-ren { color: var(--gold2); font: 600 18px var(--mono, monospace); margin-left: 4px; }
@media (max-width: 760px) {
  #book .mw-smith { grid-template-columns: 1fr; }
  #book .mw-pieces, #book .mw-items { grid-template-columns: 1fr; }
  #book .mw-q li { grid-template-columns: 1fr auto; grid-template-areas: "n x" "w w" "p t"; }
  #book .mw-q li .qn { grid-area: n; } #book .mw-q li .qw { grid-area: w; } #book .mw-q li .hpbar { grid-area: p; } #book .mw-q li .qt { grid-area: t; } #book .mw-q li button { grid-area: x; }
}
/* Seasons: the season beside the day in the top bar, and the forecast in the Economy tab. */
#top .chip.day i.sea { margin-left: 6px; }
.bk-seasons { display: grid; gap: 4px; margin: 4px 0 8px; }
.bk-seasons .sea-row { display: grid; grid-template-columns: minmax(150px, max-content) 1fr; gap: 2px 10px; align-items: baseline; padding: 4px 8px; border: 1px solid var(--line); background: rgba(var(--bg2), 0.45); }
.bk-seasons .sea-row.now { border-color: var(--gold2); }
.bk-seasons .sea-row svg.px { width: 12px; height: 12px; vertical-align: -1px; }
@media (max-width: 560px) { .bk-seasons .sea-row { grid-template-columns: 1fr; } }

/* ===== A quieter HUD: the bar keeps the key numbers, the rest live in the stores sheet ===== */
#top .chip.more { color: var(--gold2); gap: 2px; }
#top .chip.more small { color: var(--gold2); opacity: 0.85; }
#top .chip.more.on { background: rgba(240, 200, 90, 0.14); }
#top .chip.more .px { width: 18px; height: 18px; }
body.compact #top .chip.more .px { width: 24px; height: 24px; }
/* The sheet on a desktop: a popover under the bar. */
#sheet:not([hidden]) { display: block; position: fixed; z-index: 5; top: 40px; left: 50%; transform: translateX(-50%); width: min(560px, calc(100vw - 24px)); max-height: calc(var(--vh, 100vh) - 160px); overflow: auto; padding: 10px 12px; }
body.compact #sheet:not([hidden]) { transform: none; width: auto; }
#sheet .srow { cursor: pointer; }
#sheet .srow small { color: var(--dim); font-size: 11px; margin-left: 1px; }
#sheet .srow.low span, #sheet .srow.spoil span { color: #ff9a88; }
#sheet .schips .chip { cursor: pointer; border: 1px solid var(--line); }
#sheet .srow i .px { width: 12px; height: 12px; display: block; }
/* The goal card: quests, tales and ambitions on one line that opens. */
#goals .gline { margin: 6px 0 0; display: flex; align-items: baseline; gap: 6px; font-size: 13px; color: #e8d8a8; cursor: pointer; pointer-events: auto; }
#goals .gline > span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#goals .gline b { color: var(--gold2); }
#goals .gline small { color: var(--dim); }
#goals .gline .px { color: var(--gold2); }
#goals .gline em { font-style: normal; color: var(--gold); flex: none; }
#goals .gline:hover { color: var(--paper); }
#goals .aims { margin: 2px 0 0 4px; padding-left: 8px; border-left: 1px solid var(--line); }
#goals .aims .quest-l, #goals .aims .chain-l { margin: 3px 0 0; }
#goals .aims ul.amb { margin-top: 3px; }
body.compact #left #goals.open > .gline { display: flex !important; background: rgba(var(--bg), 0.94); margin: 0 !important; padding: 6px 8px; border: 1px solid var(--line); border-top: 0; font-size: 12px; }
body.compact #left #goals.open > .aims { display: block !important; background: rgba(var(--bg), 0.94); margin: 0 !important; padding: 2px 8px 6px; border: 1px solid var(--line); border-top: 0; font-size: 12px; }
body.compact #goals.open .aims .quest-l, body.compact #goals.open .aims .chain-l, body.compact #goals.open .aims ul.amb { display: block; }
body.compact.touch #goals .gline { min-height: 36px; align-items: center; }
/* The log: three lines at most; the rest is in the Hold Book's Chronicle. */
#log div.lmore, #log div.lsum { pointer-events: auto; cursor: pointer; font-size: 12px; color: var(--dim); border-left-color: var(--gold); }
#log div.lsum { color: var(--gold2); font-size: 13px; }
#log div.lmore:hover, #log div.lsum:hover { text-decoration: underline; color: var(--paper); }
/* Phones: the bar's numbers alone (a store's limit is in the sheet), so eight chips fit a 360 px screen. */
body.compact #top .chip:not(.more) small { display: none; }
body.compact #left #goals.open > .ms-l { display: block !important; background: rgba(var(--bg), 0.94); margin: 0 !important; padding: 4px 8px; border: 1px solid var(--line); border-top: 0; font-size: 12px; }
#top .chip .seac { display: inline-flex; align-items: center; gap: 5px; }
body.compact #top .chip:not(.more) { overflow: hidden; }
/* Narrow phones: the season waits in the sheet, the chips sit closer. */
@media (max-width: 419px) {
  body.compact #top .chip .seac { display: none; }
  body.compact #top .chip:not(.more) { padding: 0 4px !important; }
  body.compact #top .chip.more { padding: 0 8px !important; min-width: 40px; }
}

/* The battle bar: both sides' strength on one bar while a battle runs. */
#bscore { position: fixed; left: 50%; top: 44px; transform: translateX(-50%); z-index: 5; display: flex; align-items: center; gap: 8px; max-width: calc(100vw - 16px); padding: 4px 10px; font: 600 13px var(--pix); letter-spacing: 0.03em; color: #f0e2c0; background: rgba(24, 16, 10, 0.92); border: 1px solid #7a5a30; cursor: pointer; box-shadow: 0 3px 12px rgba(0,0,0,0.45); }
#bscore[hidden] { display: none; }
#bscore b { font-size: 15px; }
#bscore i { font-style: normal; opacity: 0.55; font-size: 11px; }
#bscore .bs-us { color: #f0d278; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#bscore .bs-foe { color: #ff9a80; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#bscore .bs-bar { position: relative; flex: 0 0 auto; width: 200px; height: 10px; background: #a03020; border: 1px solid #1a0e08; }
#bscore .bs-fill { position: absolute; left: 0; top: 0; bottom: 0; background: #e0b040; transition: width 0.5s ease-out; }
#bscore .bs-mark { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; background: #fff4d8; opacity: 0.8; }
#bscore.win { border-color: #e0b040; }
#bscore.lose { border-color: #ff6040; animation: armsPulse 1.2s ease-in-out infinite; }
body.compact #bscore { top: calc(var(--toph) + 4px); font-size: 11px; gap: 5px; padding: 3px 6px; z-index: 6; }
body.compact #bscore .bs-bar { width: 90px; height: 8px; }
body.compact #bscore .bs-us, body.compact #bscore .bs-foe { max-width: 30vw; }
body.compact.inbattle #left { top: calc(var(--toph) + 34px) !important; }
body.compact.inbattle #depth { top: calc(var(--toph) + 34px) !important; }

/* In a battle the left column steps back: the fight's hint stays, goals and old news wait. */
body.inbattle:not(.compact) #goals:not(.open) > h3, body.inbattle:not(.compact) #goals:not(.open) > ul, body.inbattle:not(.compact) #goals:not(.open) > .ms-l, body.inbattle:not(.compact) #goals:not(.open) > .gline, body.inbattle:not(.compact) #goals:not(.open) > .aims { display: none; }
body.inbattle:not(.compact) #goals:not(.open):not(:has(.hint)) { display: none; }
body.inbattle #log > *:nth-last-child(n+3) { display: none; }

/* ---------- selecting on a phone: the ✕ and the quick picks ----------
   #sel ends in a ✕ whenever one dwarf or a building is selected. #picks (compact only) is one row that scrolls
   sideways: the kinds selected, soldiers in view, all, the box, the groups; with several selected it leads with
   the count and ends with the ✕, both pinned while the chips scroll between them. */
#sel > div { flex: 1 1 auto; min-width: 0; }
#sel .desel, #picks .desel { flex: none; margin-left: auto; align-self: center; min-width: 30px; height: 30px; padding: 0 8px; font: 600 14px var(--pix); line-height: 1; color: var(--gold2); clip-path: none; }
#sel .por { cursor: pointer; }
#picks { display: none; }
body.compact #picks { display: flex; align-items: center; gap: 4px; min-width: 0; grid-column: 1 / -1; }
body.compact #picks:empty { display: none; }
body.compact #picks .prow { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 4px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; }
body.compact #picks .prow::-webkit-scrollbar { display: none; }
body.compact #picks .prow > * { flex: none; }
body.compact #picks .pn { flex: none; min-width: 30px; height: 36px; padding: 0 6px; display: inline-flex; align-items: center; justify-content: center; font: 600 16px var(--pix); color: var(--gold2); border: 1px solid var(--line); background: var(--ink2); cursor: pointer; }
body.compact #picks .pk1 { font: 600 12px var(--pix); letter-spacing: 0.05em; text-transform: uppercase; color: var(--paper); padding: 0 4px; white-space: nowrap; }
body.compact #picks button { height: 36px; padding: 0 9px; font-size: 12px; display: inline-flex; align-items: center; gap: 4px; clip-path: none; }
body.compact #picks button b { font: inherit; color: var(--gold2); }
body.compact #picks button.pk { border-color: var(--line2, var(--line)); }
body.compact #picks button.on { border-color: var(--gold2); background: #5a3a14; }
body.compact #picks button.pg { flex-direction: column; gap: 0; min-width: 36px; padding: 0 6px; font: 600 13px var(--pix); line-height: 1.05; }
body.compact #picks button.pg small { font-size: 10px; color: var(--dim); line-height: 1.05; }
body.compact #picks .desel { min-width: 46px; height: 36px; font-size: 16px; }
body.compact #sel .desel { min-width: 46px; height: 36px; font-size: 16px; }
body.compact #sel:empty { display: none; }
body.compact.touch #picks button, body.compact.touch #picks .pn, body.compact.touch #picks .desel, body.compact.touch #sel .desel { height: 40px; }
@media (orientation: portrait) { body.compact.selfold #picks { display: none !important; } }
/* Portrait: the bar is a column that never grows past its cap: the actions give way (and scroll) so the tools
   stay on the screen, on short phones too. */
@media (orientation: portrait) {
  body.compact #bar { display: flex !important; flex-direction: column; align-items: stretch; max-height: max(calc(var(--vh, 100vh) * 0.26), 214px); }
  body.compact #bar > #sel, body.compact #bar > #picks, body.compact #bar > #tools { flex: none; }
  body.compact #bar > #acts { flex: 0 1 auto; min-height: 44px; align-content: flex-start; }
  body.compact #bar > #acts:empty { display: none !important; }
}
/* Landscape: still one strip: what is selected, the quick picks, the actions, the tools. */
@media (orientation: landscape) {
  body.compact #bar { display: flex !important; align-items: center; }
  body.compact #bar > #sel { flex: 0 1 min(190px, 22vw); min-width: 0; }
  body.compact #bar > #picks { flex: 1 1 0; min-width: 120px; }
  body.compact #bar > #acts { flex: 2 1 0; }
  body.compact #bar > #acts:empty { display: none !important; }
  body.compact #bar > #tools { flex: none; margin-left: auto; }
}

/* A shared hold (co-op, one clan for all): the crew above the chat, each player's colour, name and hero. */
#crew { display: flex; flex-wrap: wrap; align-items: center; gap: 3px; margin-bottom: 4px; pointer-events: none; }
#crew[hidden] { display: none; }
#crew > b { color: var(--gold2); display: inline-flex; pointer-events: auto; }
#crew button { pointer-events: auto; display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; font: 600 12px var(--pix); text-transform: none; letter-spacing: 0; clip-path: none; background: rgba(var(--bg), 0.82); border: 1px solid var(--line); border-left: 3px solid var(--c, var(--line)); color: var(--paper); }
#crew button i { width: 8px; height: 8px; background: var(--c, #888); display: inline-block; }
#crew button small { font: 11px var(--pix); color: var(--dim); }
#crew button.me { border-color: var(--gold); border-left-color: var(--c, var(--gold)); }
#crew button.off { opacity: 0.5; }
#crew button.dead small { text-decoration: line-through; }
.crew-own { display: block; font-size: 11px; }
#lobby .lnote { margin: 6px 0 0; }
#lobby .lnote b { color: var(--gold2); }

/* Warband (the lite game): no trades to hand out, so no Work tool. */
/* (Warband keeps Work: its trades and what the miners turn into gold) */
.bk-ores { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 10px; }
.bk-ores button { min-width: 120px; padding: 6px 10px; text-align: left; }
.bk-ores button small { display: block; opacity: 0.8; }
.bk-ores button.on { border-color: var(--gold2); color: var(--gold2); }
#title .gmode { margin-top: 6px; }
#title .gmode select { min-width: 0; max-width: 100%; }

/* Planned sites and what the stores are short of. */
.opt .cost.short, .short { color: #e8a060; }
.chip.plan { color: #f0d070; cursor: pointer; pointer-events: auto; }
#toast .tact { margin-left: 8px; padding: 2px 10px; font: inherit; color: #1a120c; background: #f0d070; border: 0; border-radius: 3px; cursor: pointer; pointer-events: auto; }
#toast.has-act { pointer-events: auto; }

/* The founder's house style: a row of picks beside a small live preview (the hall and four of its folk). */
.stylerow { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
#styles { display: flex; gap: 6px; flex-wrap: wrap; flex: 1 1 220px; align-content: flex-start; }
#styles .hstyle { padding: 5px 9px; }
#stylepv { flex: 0 1 300px; width: 300px; max-width: 100%; height: auto; image-rendering: pixelated; background: #1a140e; border: 1px solid var(--line); }
#styleblurb { margin: 4px 0 0; min-height: 2.5em; }

/* ===== The founding guide: a card at the foot of the title screen, and the section it speaks of ===== */
#guide { position: fixed; left: 50%; bottom: 62px; transform: translateX(-50%); z-index: 8; width: min(430px, calc(100vw - 20px)); padding: 9px 12px 9px; background: rgba(18, 14, 10, 0.97); border: 1px solid #b89040; border-top: 3px solid #e0b050; box-shadow: 0 8px 30px rgba(0,0,0,0.7); color: #efe4cc; font: 500 14px/1.35 var(--pix); }
#guide small { display: block; color: #b8ae98; font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; }
#guide b { font: 700 16px "Cinzel", Georgia, serif; color: #f4d488; }
#guide p { margin: 3px 0 7px; }
#guide p b { font: inherit; font-weight: 700; color: #ffe0a0; }
#guide .grow { display: flex; gap: 6px; align-items: center; }
#guide .grow span { flex: 1; }
#guide button { font: inherit; font-size: 13px; padding: 3px 10px; cursor: pointer; }
.guide-hl { outline: 2px solid #f0c040 !important; outline-offset: 5px; border-radius: 2px; animation: guidePulse 1.6s ease-in-out infinite; }
@keyframes guidePulse { 0%, 100% { outline-color: #f0c040; } 50% { outline-color: rgba(240, 192, 64, 0.35); } }
#title:has(#guide:not([hidden])) .card { margin-bottom: 220px; }
/* Large models: the great foe's bar under the battle's, the army list's mark, the unit panel's tag. */
#bossbar { position: fixed; left: 50%; top: 78px; transform: translateX(-50%); z-index: 5; display: flex; align-items: center; gap: 8px; max-width: calc(100vw - 16px); padding: 3px 10px 4px; font: 600 12px var(--pix); letter-spacing: 0.03em; color: #f4d6c0; background: rgba(30, 10, 8, 0.93); border: 1px solid #8a3a2a; cursor: pointer; box-shadow: 0 3px 12px rgba(0,0,0,0.5); }
#bossbar[hidden] { display: none; }
#bossbar .bb-name { color: #ffb090; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#bossbar .bb-bar { position: relative; flex: 0 0 auto; width: min(240px, 34vw); height: 9px; background: #2a0c08; border: 1px solid #5a2018; }
#bossbar .bb-fill { position: absolute; left: 0; top: 0; bottom: 0; background: linear-gradient(#f06a4a, #b8301c); transition: width 0.25s; }
#bossbar .bb-hp { white-space: nowrap; font-size: 11px; } #bossbar .bb-hp i { font-style: normal; opacity: 0.55; }
body:not(.inbattle) #bossbar { top: 44px; }
#army .kind.bigk { border-left: 3px solid #c8a050; }
#army .kind .bigm { font-style: normal; font-size: 10px; color: #e0b860; margin-left: 3px; }
.bigtag { display: block; color: #e8c070; } .bigtag b { letter-spacing: 0.04em; }
@media (max-width: 720px) { #bossbar, body:not(.inbattle) #bossbar { top: 132px; font-size: 11px; padding: 2px 6px 3px; gap: 5px; } #bossbar .bb-bar { width: 28vw; } }
/* ---------- veteran companies, weather, strongpoints ---------- */
.codev { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; border: 1px solid rgba(0,0,0,0.6); border-radius: 2px; color: #fff4d0; vertical-align: -3px; }
.codev svg { width: 12px; height: 12px; }
.terr.co { color: #f0d890 !important; }
#book .bk-co { padding: 8px 10px; margin: 0 0 8px; background: rgba(0,0,0,0.2); border: 1px solid var(--line); border-left: 3px solid var(--gold); display: grid; gap: 5px; }
#book .bk-co h5 { margin: 0; font-size: 14px; }
#book .bk-co h5 small { font-weight: normal; opacity: 0.8; margin-left: 6px; }
#book .bk-co p { margin: 0; }
#book .bk-co .bk-hon { margin: 0; padding-left: 18px; color: #f0d890; font-size: 12px; }
#book .bk-co .roll, #book .fine.roll { opacity: 0.85; }
#book .bk-co .bk-acts { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
#book .bk-co .seg button { min-width: 22px; padding: 2px 4px; }
#bcard li.co { color: #f0d890; }
#top .chip.wx-fog i { color: #cfd8dc; } #top .chip.wx-rain i, #top .chip.wx-storm i { color: #8fb8e8; } #top .chip.wx-snow i { color: #e8f2ff; }
#top .chip.wx small svg { width: 10px; height: 10px; vertical-align: -1px; }
@media (max-width: 700px) { #book .bk-co .bk-acts button { min-height: 32px; } }

/* ---------- the title: two questions (What to play? → How?), Your clan, Play together ---------- */
#title .tkick { margin-bottom: 0; }
#title .tq { margin: 6px 0 8px; font-size: 13px; color: var(--gold2); }
#title .thead { display: flex; align-items: center; gap: 10px; margin: 2px 0 6px; }
#title .thead .tq { margin: 0; flex: 1; }
#title .tback { min-height: 44px; padding: 4px 12px; }
#title .tcont { display: flex; flex-direction: column; align-items: flex-start; width: 100%; min-height: 52px; padding: 6px 14px; margin: 2px 0 8px; text-align: left; }
#title .tcont b { font: 700 16px var(--pix); letter-spacing: 0.06em; text-transform: uppercase; }
#title .tcont small { font: 14px var(--serif); color: #1a1208; text-transform: none; letter-spacing: 0; }
.tcards { display: grid; gap: 10px; margin-bottom: 8px; }
.tcards.two { grid-template-columns: 1fr 1fr; }
.tcards.three { grid-template-columns: repeat(3, 1fr); }
.tcards .gmc { position: relative; display: grid; grid-template-rows: auto 1fr; justify-items: center; gap: 4px; padding: 10px 8px 12px; min-height: 44px; text-align: center; white-space: normal; font: 14px var(--serif); background: var(--ink2); border: 2px solid var(--line); clip-path: var(--cut-s); cursor: pointer; }
.tcards.two .gmc { padding: 18px 10px 18px; }
.tcards .gmc canvas { width: 72px; height: 54px; image-rendering: pixelated; }
.tcards.two .gmc canvas { width: 120px; height: 90px; }
.tcards .gmc b { display: block; font: 700 17px var(--pix); letter-spacing: 0.05em; text-transform: uppercase; color: var(--paper); }
.tcards.two .gmc b { font-size: 22px; }
.tcards .gmc b .px { width: 14px; height: 14px; vertical-align: -2px; }
.tcards .gmc small { display: block; font: 14px/1.3 var(--serif); color: var(--dim); margin: 3px 0 5px; text-transform: none; letter-spacing: 0; }
.tcards .gmf { display: flex; flex-wrap: wrap; justify-content: center; gap: 3px; }
.tcards .gmf i { font: 600 13px var(--pix); font-style: normal; color: var(--gold); border: 1px solid var(--line); padding: 1px 5px; background: rgba(0, 0, 0, 0.25); text-transform: none; }
.tcards .gmc:hover { border-color: var(--line2); }
.tcards .gmc.on { border-color: var(--gold); background: rgba(201, 119, 58, 0.14); box-shadow: 0 0 0 1px var(--gold2), inset 0 -3px 0 rgba(0, 0, 0, 0.35); }
.tcards .gmc.on b { color: var(--gold2); }
em.rec { display: inline-block; font: 600 13px var(--pix); font-style: normal; letter-spacing: 0.04em; text-transform: none; color: #1a1208; background: var(--gold2); padding: 1px 6px; }
.tcards .gmc em.rec { position: absolute; top: 0; left: 50%; transform: translateX(-50%); white-space: nowrap; }
#title .tlinks { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
#title .tlinks button { min-height: 44px; flex: 1 1 auto; }
#waynote { margin: 2px 0 6px; font-size: 13px; color: #e8dcc4; min-height: 1.3em; }
#waynote button { min-height: 36px; padding: 2px 10px; margin-left: 4px; }
#easy .ezsum { margin: 0 0 4px; }
#easy .ezsum button { min-height: 36px; margin-left: 6px; }
#title .tgo { position: sticky; bottom: 0; z-index: 2; display: flex; gap: 8px; flex-wrap: wrap; background: linear-gradient(transparent, rgba(var(--bg2), 0.97) 25%); padding: 12px 0 4px; margin-bottom: -4px; }
#title .tgo button { min-height: 48px; }
#title .tgo .primary { flex: 1 1 180px; font-size: 17px; }
#title .nameopts { margin: 6px 0; }
#title .hsbox { margin-top: 8px; }
#title.inlobby .tstep[data-s="t"] .thead .tback { display: none; }
#lobby .lways { margin: 8px 0; padding: 8px 10px; border: 1px solid var(--line); background: rgba(240,200,90,0.05); }
#lobby .lways .seg { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0 4px; }
#lobby .lways .seg button { min-height: 44px; flex: 1; }
#lobby .lways .seg button.on { border-color: var(--gold2); color: var(--gold2); }
#lobby .lways .lwname { color: var(--gold2); font-weight: 600; }
#lobby .lways small { display: block; }
/* How I play (title card, and a section of the Menu) */
#profile { position: fixed; inset: 0; z-index: 40; overflow: auto; display: flex; align-items: flex-start; justify-content: center; padding: 24px 12px; background: rgba(12, 8, 6, 0.86); }
#profile[hidden] { display: none; }
#profile .card { width: min(560px, 100%); }
#profile .row button { min-height: 44px; min-width: 120px; }
#profile .pfh { font: 700 24px var(--pix); color: var(--gold2); margin: 2px 0 10px; }
.pfrow { display: grid !important; grid-template-columns: 96px 1fr; gap: 2px 10px; align-items: center; margin: 6px 0; }
.pfrow .fine { grid-column: 2; font-size: 13px; }
.pfrow .seg { display: flex; flex-wrap: wrap; gap: 4px; }
.pfrow .seg button { min-height: 44px; padding: 4px 12px; flex: 1 1 auto; }
.pfrow .seg button.on { border-color: var(--gold2); color: var(--gold2); background: rgba(201,119,58,0.14); }
#popup .mhead { margin: 10px 0 2px; padding-top: 8px; border-top: 1px solid var(--line); font: 600 14px var(--pix); color: var(--gold2); }
.sccard { position: relative; }
.sccard em.rec { align-self: flex-start; margin-bottom: 2px; }
@media (max-width: 600px) {
  #title .card { padding: 10px 12px; }
  #title .card h1 { font-size: 34px !important; margin: 0 0 4px !important; }
  .tcards.two { gap: 8px; }
  .tcards.two .gmc { padding: 22px 6px 14px; }
  .tcards.two .gmc canvas { width: 96px; height: 72px; }
  .tcards.three { grid-template-columns: 1fr; gap: 6px; }
  .tcards.three .gmc { grid-template-rows: none; grid-template-columns: 56px 1fr; justify-items: start; text-align: left; padding: 8px 10px; align-items: center; }
  .tcards.three .gmc canvas { width: 56px; height: 42px; }
  .tcards.three .gmc small { margin: 1px 0 3px; }
  .tcards.three .gmf { justify-content: flex-start; }
  .tcards.three .gmc em.rec { left: auto; right: 0; transform: none; }
  .pfrow { grid-template-columns: 1fr; }
  .pfrow .fine { grid-column: 1; }
}
@media (max-height: 500px) {
  #title .card h1 { font-size: 28px !important; margin: 0 !important; }
  #title .tkick { display: none; }
  .tcards.two .gmc { padding: 14px 8px 8px; grid-template-columns: 96px 1fr; grid-template-rows: none; text-align: left; justify-items: start; align-items: center; }
  .tcards.two .gmc canvas { width: 96px; height: 72px; }
  .tcards.three .gmc { padding: 14px 6px 8px; }
  .tcards.three .gmc canvas { display: none; }
}

/* ---------- Scenarios: the picker and briefing, the HUD, the end card ---------- */
#scenpick { position: fixed; inset: 0; z-index: 40; overflow: auto; display: flex; align-items: flex-start; justify-content: center; padding: 24px 12px; background: rgba(12, 8, 6, 0.86); }
#scenpick[hidden] { display: none; }
#scenpick .card { max-width: 860px; width: 100%; }
#scenpick h1 .px { width: 22px; height: 22px; vertical-align: -3px; }
#scenpick .scgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(340px, 100%), 1fr)); gap: 8px; margin: 10px 0; }
#scenpick .sccard { display: grid; grid-template-columns: 132px 1fr; gap: 8px; align-items: start; text-align: left; white-space: normal; padding: 8px; background: var(--ink2); border: 2px solid var(--line); clip-path: var(--cut-s); }
#scenpick .sccard:hover, #scenpick .sccard:focus-visible { border-color: var(--gold2); }
#scenpick .sccard canvas { width: 132px; height: 72px; image-rendering: pixelated; background: rgba(0, 0, 0, 0.25); }
#scenpick .sct b { display: block; font: 700 15px var(--pix); color: var(--paper); text-transform: uppercase; letter-spacing: 0.04em; }
#scenpick .sct i { display: block; font: 12px var(--serif); color: var(--gold); font-style: normal; margin: 2px 0; }
#scenpick .sct small { display: block; font: 13px/1.3 var(--serif); color: var(--dim); }
#scenpick .scbest { display: block; margin-top: 4px; font-size: 12px; }
#scenpick .scbrief canvas { display: block; width: 264px; max-width: 100%; height: 110px; margin: 6px auto; image-rendering: pixelated; }
#scenpick .scbrief p { margin: 6px 0; }
#scenpick .scwin { margin: 8px 0; padding-left: 18px; }
#scenpick .scdiff button.on { border-color: var(--gold2); background: #3a2812; }
#scenpick .row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 10px; }
.medal { font: 700 13px var(--pix); }
.medal .px { width: 13px; height: 13px; vertical-align: -2px; }
@media (max-width: 600px) { #scenpick .sccard { grid-template-columns: 96px 1fr; } #scenpick .sccard canvas { width: 96px; height: 52px; } #scenpick { padding: 8px; } }
#shud { position: fixed; top: 40px; left: 50%; transform: translateX(-50%); z-index: 3; display: grid; gap: 3px; padding: 4px 10px 6px; max-width: min(640px, calc(100% - 330px)); font-size: 13px; }
#shud .scl { display: flex; gap: 8px; align-items: center; justify-content: center; flex-wrap: wrap; }
#shud .px { width: 12px; height: 12px; vertical-align: -1px; }
#shud button { padding: 3px 8px; font-size: 12px; }
#shud .scgoal { color: var(--gold2); font-weight: 700; }
#shud .scprog { color: var(--paper); }
#shud .sctimer.low, #shud .scsup.low, #shud .warnc { color: #f0907a; }
#shud .scbar { display: inline-block; width: 70px; height: 6px; background: rgba(0, 0, 0, 0.5); border: 1px solid var(--line); vertical-align: 1px; margin-left: 3px; }
#shud .scbar > span { display: block; height: 100%; background: var(--gold); }
#shud .scwag > span { display: inline-flex; align-items: center; gap: 2px; }
#shud .scwag .scbar { width: 36px; }
#shud .scwag .lost { opacity: 0.4; text-decoration: line-through; }
#shud .scwag .ok { color: #9ad070; }
#shud .scwave i { color: var(--dim); font-style: normal; }
#shud .scfoes { display: inline-flex; flex-wrap: wrap; gap: 4px; }
#shud .scfoes span { border: 1px solid var(--line); padding: 0 4px; font-size: 12px; }
body.compact #shud { top: var(--toph, 34px); left: 0; right: 0; transform: none; max-width: none; padding: 2px 4px; font-size: 12px; gap: 2px; }
body.compact #shud .scl { justify-content: flex-start; gap: 5px; }
body.compact #shud .scfoes span { font-size: 11px; }
body.compact.scen #left, body.compact.scen #depth { margin-top: calc(var(--shudb, 130px) - var(--toph, 34px) + 2px); }
/* The fight's bars and the alert go under the scenario's panel. */
body.scen #bscore { top: calc(var(--shudb, 120px) + 4px); }
body.scen #bossbar { top: calc(var(--shudb, 120px) + 40px); }
body.scen:not(.compact) #alert { top: calc(var(--shudb, 120px) + 74px); }
#end .scend .scmedal { font-size: 20px; margin: 4px 0; }
#end .scend .ok { color: #9ad070; }
#end .scend .row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 8px; }
/* The Band (the Hold Book in a scenario): heroes' trees, fighters' perks, found gear. */
#book .dvcard { border: 1px solid var(--line); margin: 0 0 6px; padding: 4px; }
#book .dvcard.open { border-color: var(--gold); }
#book .dvhead { width: 100%; text-align: left; white-space: normal; display: grid; gap: 3px; }
#book .dvtree { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 8px 0; }
#book .dvbr { display: grid; gap: 4px; align-content: start; }
#book .dvnode { text-align: left; white-space: normal; position: relative; }
#book .dvnode.on { border-color: #9ad070; background: #233018; opacity: 1; }
#book .dvnode .why { color: #e8a060; }
#book .dvslot { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; padding: 2px 0; }
#book .dvslot > small { width: 56px; text-transform: uppercase; color: var(--dim); }
#book .dvperk { display: inline-block; border: 1px solid #5a7a40; color: #b8e090; padding: 0 5px; margin: 1px; font: 600 12px var(--pix); }
#book .dvtbl td { vertical-align: top; padding: 4px 6px; }
#book .dvtbl .hpbar, #book .dvtbl .xpbar { width: 90px; }
#book .dvitem { border-bottom: 1px solid var(--line); padding: 5px 0; }
@media (max-width: 600px) { #book .dvtree { grid-template-columns: 1fr; } #book .dvtbl td:nth-child(2) { display: none; } }
#book h5 { margin: 10px 0 4px; color: var(--gold2); }
/* A scenario: no felling, no trades, no auto-work (the company is set). */
body.scen #tools [data-tool="chop"], body.scen #b-work, body.scen #b-auto { display: none !important; }

/* ---------- the Steward: one line (phone) or a small card (desktop) with the most important thing to do ---------- */
#steward { pointer-events: auto; padding: 0; margin-bottom: 6px; font: 14px/1.3 var(--serif, Georgia, serif); color: #f0e6cc; }
#steward[hidden] { display: none !important; }
#steward .sline { display: flex; align-items: center; gap: 8px; padding: 6px 8px; background: linear-gradient(90deg, rgba(240,200,90,0.16), rgba(240,200,90,0.04)); border-left: 3px solid var(--gold2, #f4d488); }
#steward .sline.warn { background: linear-gradient(90deg, rgba(230,70,40,0.32), rgba(230,70,40,0.08)); border-left-color: #ff6040; }
#steward .sico { flex: none; color: var(--gold2, #f4d488); display: inline-flex; }
#steward .sline.warn .sico { color: #ffb080; }
#steward .stxt { flex: 1; min-width: 0; cursor: pointer; }
#steward .stag { flex: none; font: 600 11px var(--pix, monospace); font-style: normal; color: #b8e0a0; padding: 2px 5px; border: 1px solid rgba(184,224,160,0.4); white-space: nowrap; }
#steward button { flex: none; padding: 4px 10px; font-size: 12px; min-height: 30px; }
#steward .smore { min-width: 34px; padding: 4px 6px; color: var(--gold2, #f4d488); }
#steward .slist { border-top: 1px solid var(--line); max-height: calc(var(--vh, 100vh) * 0.50); overflow: auto; background: rgba(var(--bg), 0.95); }
#steward .sitem { display: flex; gap: 8px; align-items: center; padding: 6px 8px; border-bottom: 1px solid rgba(255,255,255,0.06); font-size: 13px; }
#steward .sitem.warn { border-left: 3px solid #ff6040; }
#steward .sitem > span:first-child { flex: 1; min-width: 0; }
#steward .sbtns { display: flex; gap: 4px; flex: none; flex-wrap: wrap; justify-content: flex-end; }
#steward .sfoot { display: flex; gap: 6px; justify-content: flex-end; padding: 6px 8px; }
body.compact #steward { position: fixed; left: 0; right: 0; top: var(--toph); margin: 0; z-index: 4; background: rgba(var(--bg), 0.92); border: 0; border-bottom: 1px solid var(--line); clip-path: none; box-shadow: none; }
body.compact #steward .sline { min-height: 40px; padding: 2px 4px 2px 8px; font-size: 13px; }
body.compact #steward .stxt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body.compact.touch #steward .sline { min-height: 46px; }
body.compact.touch #steward button { min-height: 44px; min-width: 44px; }
body.compact #steward.open .stxt { white-space: normal; }
body.compact #steward .slist { max-height: calc(var(--vh, 100vh) - var(--toph) - var(--barh, 60px) - 60px); }
body.compact #steward .sitem { flex-wrap: wrap; }
body.compact #steward .sitem > span:first-child { flex-basis: 60%; }
body.compact.stew { --stewh: 41px; }
body.compact.touch.stew { --stewh: 47px; }
body.compact.stew #left, body.compact.stew #depth { top: calc(var(--toph) + var(--stewh) + 4px) !important; }
body.compact.stew #sheet:not([hidden]) { top: calc(var(--toph) + var(--stewh) + 4px); }
body.compact.stew #bcard { top: calc(var(--toph) + var(--stewh) + 40px); }
/* the goal pill steps aside on a phone: the Steward names the next goal when nothing else is pressing */
body.compact.stew #goals .gpill { display: none; }
@media (max-height: 500px) { body.compact #steward .sline { min-height: 36px; } body.compact.touch #steward .sline { min-height: 44px; } }
/* the slim army bar: big targets */
#acts button.slim, body.compact.touch #acts button.slim { min-height: 44px; min-width: 64px; }
#acts button.slim.on { border-color: var(--gold2, #f4d488); color: var(--gold2, #f4d488); }
/* rooms in the Build menu */
#popup .opt.room .rmi { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; color: var(--gold2, #f4d488); }
#popup .opt.room .rparts { color: #d8c8a0; }
#popup .rhint { margin: 2px 0 6px; }
/* the hold-automation controls (Work focus, labours, research goals, standing army) */
.bk-focus { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 4px 0; }
.bk-focus > b { min-width: 180px; }
.bk-focus .seg button { min-height: 36px; }
.bk-rgoals { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr)); gap: 6px; margin: 4px 0 10px; }
.bk-rg { display: flex; flex-direction: column; align-items: flex-start; text-align: left; padding: 6px 8px; min-height: 44px; }
.bk-rg.on { border-color: var(--gold2, #f4d488); }
.bk-rg small { color: var(--dim, #b8a888); }
#army .keeparmy { display: flex; align-items: center; gap: 6px; margin: 0 0 6px; font-size: 13px; }
#army .keeparmy span { flex: 1; }
#army .keeparmy button { min-width: 40px; min-height: 36px; }
body.touch #army .keeparmy button { min-width: 44px; min-height: 44px; }
/* Customize: the single rules of a Hold (Economy, Danger, Start) */
#easy { margin: 10px 0 4px; padding: 8px 10px; border: 1px solid var(--line); background: rgba(240,200,90,0.05); }
#easy .ezhead { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
#easy .ezhead button { min-height: 44px; padding: 6px 16px; font-size: 15px; }
#easy .ezhead span { flex: 1; min-width: 180px; font-size: 13px; color: #e8dcc4; }
#easy .ezrow { display: grid; grid-template-columns: 90px 1fr; gap: 2px 10px; align-items: center; margin: 6px 0; }
#easy .ezrow small { grid-column: 2; color: var(--dim, #b8a888); font-size: 12px; }
#easy .seg { display: flex; flex-wrap: wrap; gap: 4px; }
#easy .seg button { min-height: 40px; padding: 4px 10px; }
#easy .seg button.on, #easy .ezhead button.on { border-color: var(--gold2, #f4d488); color: var(--gold2, #f4d488); }
body.touch #easy .seg button { min-height: 44px; }
@media (max-width: 480px) { #easy .ezrow { grid-template-columns: 1fr; } #easy .ezrow small { grid-column: 1; } }
body.compact.stew #left { z-index: 3; }
body.stewopen #left { z-index: 7 !important; }
body.compact.stew #bscore { top: calc(var(--toph) + var(--stewh) + 4px); }
body.compact.stew.inbattle #left, body.compact.stew.inbattle #depth { top: calc(var(--toph) + var(--stewh) + 34px) !important; }
body.compact.stew #dhud { top: calc(var(--toph) + var(--stewh)); }
body.compact.stew #toast { top: calc(var(--toph) + var(--stewh) + 6px); }
body:not(.compact) #steward .sline { flex-wrap: wrap; row-gap: 6px; }
body:not(.compact) #steward .stxt { flex: 1 1 calc(100% - 34px); }
body:not(.compact) #steward .sgo { margin-left: auto; }
#army .keeparmy { display: block; }
#army .keeparmy .karow { display: flex; align-items: center; gap: 6px; }
#army .keeparmy .karow span { flex: 1; }
#army .keeparmy small { display: block; color: var(--dim, #b8a888); margin: 2px 0; }
#army .keeparmy .kamix { display: flex; flex-wrap: wrap; gap: 3px; margin: 3px 0; }
#army .keeparmy .kamix button { min-height: 32px; padding: 2px 6px; font-size: 11px; }
#army .keeparmy .kamix button.on { border-color: var(--gold2, #f4d488); color: var(--gold2, #f4d488); }
#army .keeparmy .kares { display: flex; align-items: center; gap: 4px; font-size: 12px; }
#army .keeparmy .kares input { width: 5em; }
#army .keeparmy .karow span { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- the phone's top area in a fight: one strict stack ----------
   Row 1 the top bar; row 2 the battle bar (the Steward folds to its icon and count at the right end of that row,
   or keeps away); then the goal/log column on the left and the floor picker on the right. Nothing overlaps. */
body.compact { --fightrow: 36px; }
body.compact.inbattle #bscore { top: var(--toph) !important; left: 4px; right: 4px; transform: none; height: var(--fightrow); max-width: none; justify-content: center; box-sizing: border-box; }
body.compact.inbattle.stewfold #bscore { right: 58px; }
body.compact.inbattle #left, body.compact.inbattle #depth, body.compact.stew.inbattle #left, body.compact.stew.inbattle #depth { top: calc(var(--toph) + var(--fightrow) + 4px) !important; }
body.compact.stewfold #steward:not(.open) { left: auto; right: 4px; width: 50px; top: var(--toph); border: 1px solid var(--line); }
body.compact.stewfold #steward .sline.fold { min-height: 0; height: var(--fightrow); padding: 0 4px; justify-content: center; gap: 3px; cursor: pointer; }
body.compact.stewfold #steward .scount { font: 600 13px var(--pix, monospace); color: var(--gold2, #f4d488); }
body.compact.stewfold #steward .sline.fold.warn .scount { color: #ffb080; }
/* the log folds to its count in a fight */
body.compact.inbattle #log .lmore { display: inline-block; }
/* the banner shrinks to a slim strip after three seconds (its Look stays) */
#alert.slim { animation: none; }
body.compact #alert.slim:not([hidden]) { flex-wrap: nowrap; padding: 2px 8px; min-height: 0; font-size: 12px; max-width: calc(100vw - 12px); }
body.compact #alert.slim { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body.compact #alert.slim b { min-height: 32px; flex: none; }
#alert.slim [data-a="bell"], #alert.slim [data-a="turret"], #alert.slim [data-a="wall"] { display: none; }
/* the slim army bar: one row of actions, icon over a short word */
body.compact.armyslim #acts { display: flex !important; flex-wrap: nowrap !important; gap: 4px !important; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; max-height: none; }
body.compact.armyslim #acts button { flex: 1 1 0; min-width: 44px; padding: 2px 3px; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 10px; line-height: 1.1; white-space: nowrap; }
body.compact.armyslim #acts button small { display: none; }
body.compact.armyslim #sel:empty, body.compact.armyslim #sel { display: none; }
#acts button.abil { flex: 0 0 44px !important; width: 44px; border-radius: 50%; position: relative; background: conic-gradient(rgba(0,0,0,0.55) calc(var(--cd, 0) * 360deg), transparent 0) , var(--btnbg, rgba(40,30,20,0.9)); }
#acts button.abil b { font: 700 15px var(--pix, monospace); color: var(--gold2, #f4d488); }
#acts button.abil:disabled b { color: #9a8a70; }
/* in a fight on a phone the goal card steps aside too (the battle bar and the banner speak) */
body.compact.inbattle #left #goals { display: none !important; }
/* landscape phones: the slim banner takes the log's place under the battle bar (the log keeps quiet meanwhile) */
@media (max-height: 500px) {
  body.compact.inbattle #alert.slim:not([hidden]) { top: calc(var(--toph) + var(--fightrow) + 4px) !important; bottom: auto !important; left: 4px; max-width: calc(100vw - 190px); }
  body.compact.inbattle.alertslim #log { visibility: hidden; }
}
body.compact.armyslim #acts { gap: 3px !important; }
body.compact.armyslim #acts button.slim { min-width: 0 !important; flex: 1 1 0 !important; padding: 2px 1px !important; }
body.compact.armyslim #acts button.abil { flex: 0 0 42px !important; width: 42px !important; min-width: 42px !important; }
@media (max-height: 500px) { body.compact.armyslim #acts button.slim:not(.abil) { flex: 0 0 46px !important; font-size: 9px; } }
/* landscape phones: the battle bar sits in the top bar's own row, right of the stores (before ⋯) */
@media (max-height: 500px) and (min-width: 700px) {
  body.compact.inbattle { --fightrow: 0px; }
  body.compact.inbattle #top { padding-right: calc(40vw + 8px) !important; }
  body.compact.inbattle #bscore { top: 0 !important; height: var(--toph); left: auto; right: 4px; width: 40vw; z-index: 6; }
  body.compact.inbattle.stewfold #bscore { right: 56px; width: calc(40vw - 52px); }
  body.compact.stewfold #steward:not(.open) { top: 0; right: 4px; height: var(--toph); }
  body.compact.stewfold #steward .sline.fold { height: var(--toph); }
}

/* ---------- the title's three steps: the step marks, and step 3 (founder and gift) ---------- */
#title .tsteps { display: flex; gap: 4px; margin: 0; padding: 0; list-style: none; flex: none; }
#title .tsteps li { width: 22px; height: 22px; display: grid; place-items: center; font: 700 12px var(--pix); color: var(--faint, #8a7a60); border: 1px solid var(--line); border-radius: 50%; }
#title .tsteps li.done { color: var(--gold); border-color: var(--gold); }
#title .tsteps li.on { color: #1a1208; background: var(--gold2); border-color: var(--gold2); }
#title[data-step="2"] .tkick, #title[data-step="3"] .tkick, #title[data-step="2"] .tcont, #title[data-step="3"] .tcont { display: none !important; }
.fpick .fphead { display: flex; align-items: center; gap: 6px; margin: 4px 0 3px; }
.fpick .fphead > b { font: 600 12px var(--pix); letter-spacing: 0.12em; text-transform: uppercase; color: var(--gold2); white-space: nowrap; }
.fpick .fphead > .fine { flex: 1; min-width: 0; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fpick .flink { min-height: 40px; padding: 2px 9px; font: 600 12px var(--pix); text-transform: none; letter-spacing: 0.02em; background: transparent; border: 1px dashed var(--line2); box-shadow: none; white-space: nowrap; max-width: 46%; overflow: hidden; text-overflow: ellipsis; }
.fpick .flink:hover { border-color: var(--gold); color: var(--gold2); }
.fpick .heroname { display: flex; margin: 0 0 6px; }
.fpick .heroname input { flex: 1; min-height: 40px; }
.fcards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.fcards[data-n="4"] { grid-template-columns: repeat(4, 1fr); }
.fcards.all { grid-template-columns: repeat(auto-fill, minmax(min(150px, 100%), 1fr)); }
.fcards .fc { position: relative; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 10px 4px 6px; min-height: 44px; text-align: center; white-space: normal; text-transform: none; letter-spacing: 0; border: 1px solid var(--line); background: rgba(255,255,255,0.02); clip-path: var(--cut-s); }
.fcards .fc canvas { width: 40px; height: 48px; image-rendering: pixelated; }
.fcards .fc b { font: 600 13px/1.15 var(--pix); color: var(--paper); }
.fcards .fc .role { font: 500 11px var(--pix); letter-spacing: 0.1em; text-transform: uppercase; color: var(--ice, #9ac8e0); }
.fcards .fc small { font: 12px/1.25 var(--serif); color: var(--dim); }
#heroes .fc small { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.fpick button, .fpick input, .fpick .clansum { scroll-margin-bottom: 84px; }
.fcards .fc.on { border-color: var(--gold); background: rgba(201,119,58,0.14); box-shadow: 0 0 0 1px var(--gold2); }
.fcards .fc.on b { color: var(--gold2); }
.fcards .fc em.rec, .tchips .tchip em.rec { position: absolute; top: 0; left: 50%; transform: translateX(-50%); font-size: 10px; padding: 0 4px; white-space: nowrap; }
.tchips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.tchips.all { grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr)); }
.tchips .tchip { position: relative; display: flex; flex-direction: column; justify-content: center; align-items: flex-start; min-height: 44px; padding: 6px 8px 5px; text-align: left; white-space: normal; text-transform: none; letter-spacing: 0; border: 1px solid var(--line); background: rgba(255,255,255,0.02); clip-path: var(--cut-s); }
.tchips .tchip b { font: 600 13px/1.15 var(--pix); color: var(--paper); }
.tchips .tchip small { font: 12px/1.2 var(--serif); color: var(--dim); }
.tchips .tchip small i { display: block; font-style: normal; margin-top: 2px; }
.tchips .tchip.on { border-color: var(--gold); background: rgba(201,119,58,0.14); box-shadow: 0 0 0 1px var(--gold2); }
.tchips .tchip.on b { color: var(--gold2); }
.tchips .tchip.deed b { color: var(--gold2); }
.tchips .tchip.locked { opacity: 0.6; border-style: dashed; cursor: default; }
.tchips .tchip[disabled] { opacity: 0.45; }
.tchips .tchip em.rec { left: auto; right: 6px; transform: none; }
.tchips .tchip.isrec { padding-top: 15px; }
#tnote { margin: 4px 0 2px; font-size: 13px; line-height: 1.3; }
#tnote b { color: var(--gold2); font-weight: 600; }
.clansum { display: flex; align-items: center; gap: 8px; margin: 6px 0 0; padding: 4px 4px 4px 8px; border: 1px solid var(--line); background: rgba(0,0,0,0.2); }
.clansum .csl { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; font: 13px/1.25 var(--serif); color: var(--dim); }
.clansum .csl b { color: var(--paper); font-weight: 600; }
.clansum .csw { flex: none; width: 14px; height: 20px; border: 1px solid #0008; clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 78%, 0 100%); }
.clansum button { min-height: 44px; min-width: 64px; }
#tsheet { position: fixed; inset: 0; z-index: 30; overflow: auto; display: flex; align-items: flex-start; justify-content: center; padding: 16px 10px; background: rgba(12, 8, 6, 0.86); }
#tsheet[hidden] { display: none; }
#tsheet .card { width: min(640px, 100%); margin: auto 0; }
#tsheet .thead { position: sticky; top: -1px; z-index: 2; background: rgba(var(--bg2), 0.98); padding: 4px 0; }
#tsheet .thead button { min-height: 44px; min-width: 88px; }
#tsheet .fcards .fc small { text-align: left; }
#tsheet .stylerow { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
#tsheet #stylepv { max-width: 100%; }
#tsheet #swatches { display: flex; flex-wrap: wrap; gap: 6px; }
#tsheet #swatches .sw { width: 40px; height: 40px; }
#tsheet .hstyle, #tsheet #clanrand { min-height: 44px; min-width: 44px; }
#tsheet #clan { min-height: 44px; }
#lobby .lseat { margin: 8px 0; padding: 6px 10px 8px; border: 1px solid var(--gold); background: rgba(240,200,90,0.05); }
#lobby .lseat .lseath { font: 600 13px var(--pix); letter-spacing: 0.08em; text-transform: uppercase; color: var(--gold2); margin-right: 8px; }
#lobby .lseat > small { font-size: 12px; }
@media (max-width: 600px) {
  #title[data-step="2"] .card h1, #title[data-step="3"] .card h1 { font-size: 24px !important; margin: 0 !important; }
  .fcards .fc { padding-top: 12px; }
  #heroes[data-n="4"] .fc:not(.on) small { display: none; }
  .tchips { grid-template-columns: 1fr 1fr; }
  #title .tstep[data-s="3"] .tgo { padding-top: 8px; }
}
@media (max-width: 380px) { #heroes .fc small { -webkit-line-clamp: 2; } }
@media (max-height: 500px) {
  .fcards .fc { flex-direction: row; flex-wrap: wrap; justify-content: center; column-gap: 6px; padding-top: 12px; }
  .fcards .fc canvas { width: 28px; height: 34px; }
  .fcards .fc small { flex-basis: 100%; }
}
