/* Crown & Cannon — leather, brass and parchment over a painted map */
:root {
  --ink: #f3e6c8; --ink2: #cdbd98; --dim: #9a8e74;
  --gold: #d9b45a; --gold2: #f2d58a; --goldA: rgba(217, 180, 90, 0.42);
  --panel: rgba(16, 20, 28, 0.88); --panel2: rgba(26, 31, 42, 0.92);
  --red: #b3262e; --red2: #d9473e; --green: #7fb35a; --blue: #4f8fc0;
  --serif: "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
  --ui: "Segoe UI", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0b1220; color: var(--ink); font-family: var(--serif); user-select: none; }
canvas#map, canvas#overlay { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
canvas#overlay { pointer-events: none; }
.hidden { display: none !important; }
button { font-family: inherit; }
input, select { font-family: var(--serif); }

/* ---------------------------------------------------------------- panels & buttons */
.panel {
  background: linear-gradient(180deg, rgba(30, 36, 48, 0.92), var(--panel));
  border: 1px solid var(--goldA); border-radius: 6px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 240, 200, 0.06), inset 0 0 0 1px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(3px);
}
.btn {
  color: var(--ink); background: linear-gradient(180deg, #2c3342, #1b2029); border: 1px solid var(--goldA);
  border-radius: 4px; padding: 7px 14px; font-size: 14px; cursor: pointer; letter-spacing: 0.02em;
  transition: border-color .12s, box-shadow .12s, transform .05s, background .12s;
}
.btn:hover { border-color: var(--gold); box-shadow: 0 0 10px rgba(217, 180, 90, 0.25); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn.disabled { opacity: 0.45; cursor: default; box-shadow: none; }
.btn.primary { background: linear-gradient(180deg, #a1262d, #6e161b); border-color: var(--gold); color: #fff4dc; }
.btn.primary:hover { background: linear-gradient(180deg, #b82e35, #7d1b20); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.tiny { padding: 2px 7px; font-size: 12px; }
.btn.on { border-color: var(--gold2); background: linear-gradient(180deg, #4a3d1e, #2b2312); color: var(--gold2); }
.btn.big { display: block; width: 100%; padding: 14px 22px; font-size: 20px; text-align: left; margin: 0 0 10px; }
.btn.big small { display: block; font-size: 13px; color: var(--ink2); margin-top: 2px; letter-spacing: 0.03em; }
.btn.back { padding: 5px 12px; }

input[type=text], input:not([type]), select {
  background: #0f131b; color: var(--ink); border: 1px solid var(--goldA); border-radius: 4px; padding: 7px 10px; font-size: 15px; width: 100%;
}
select option { background: #151a23; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border-radius: 3px; background: linear-gradient(90deg, #4a3d1e, #8a6f2c); outline: none; margin: 6px 0; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #ffe7a6, #b8892e); border: 1px solid #3b2a0c; cursor: pointer; box-shadow: 0 1px 3px rgba(0,0,0,0.6); }
input[type=range]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #ffe7a6, #b8892e); border: 1px solid #3b2a0c; cursor: pointer; }

/* ---------------------------------------------------------------- screens */
#screens { position: fixed; inset: 0; pointer-events: none; }
.screen { position: absolute; inset: 0; pointer-events: auto; display: flex; align-items: center; justify-content: center; }
.menu-veil { position: absolute; inset: 0; background: radial-gradient(ellipse at 30% 50%, rgba(5, 8, 14, 0.15), rgba(5, 8, 14, 0.75) 70%), linear-gradient(90deg, rgba(5, 8, 14, 0.75), rgba(5, 8, 14, 0.05) 55%); pointer-events: none; }
/* title and buttons flow in one column, so they can never overlap at any window size */
#scr-menu { flex-direction: column; justify-content: center; align-items: flex-start; padding: 3vh 7vw 44px; overflow-y: auto; }
.title-block { position: relative; margin-bottom: clamp(16px, 4.5vh, 48px); }
.title-block h1 { margin: 0; font-size: clamp(38px, min(6.4vw, 10.5vh), 96px); line-height: 1.04; font-weight: normal; letter-spacing: 0.04em; color: var(--gold2);
  text-shadow: 0 2px 0 #5a3d10, 0 4px 18px rgba(0,0,0,0.8); font-variant: small-caps; }
.title-block h1 span { color: var(--ink); font-style: italic; font-size: 0.7em; }
.title-block .subtitle { font-size: clamp(14px, min(1.6vw, 2.8vh), 24px); color: var(--ink2); font-style: italic; letter-spacing: 0.18em; margin-top: 4px; text-shadow: 0 2px 8px #000; }
.crest { font-size: clamp(32px, 6.5vh, 54px); color: var(--gold); text-shadow: 0 3px 12px #000; line-height: 1; margin-bottom: 4px; }
.menu-buttons { position: relative; width: min(440px, 80vw); }
.menu-buttons .btn.big { background: linear-gradient(90deg, rgba(20, 24, 33, 0.92), rgba(20, 24, 33, 0.55));
  padding: clamp(8px, 1.6vh, 14px) 22px; font-size: clamp(16px, 2.6vh, 20px); margin-bottom: clamp(6px, 1.2vh, 10px); }
.menu-buttons .btn.big small { font-size: clamp(11.5px, 1.7vh, 13px); }
.menu-buttons .btn.big.primary { background: linear-gradient(90deg, rgba(150, 33, 40, 0.95), rgba(110, 22, 27, 0.6)); }
.menu-foot { position: absolute; bottom: 14px; left: 7vw; right: 24px; display: flex; justify-content: space-between; color: var(--dim); font-size: 13px; }
.sheet { width: min(760px, 94vw); max-height: 92vh; overflow: auto; padding: 18px 24px 22px; }
.sheet.wide { width: min(1240px, 96vw); }
.sheet header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; border-bottom: 1px solid var(--goldA); padding-bottom: 10px; }
.sheet header h2 { margin: 0; font-weight: normal; font-variant: small-caps; letter-spacing: 0.08em; color: var(--gold2); font-size: 28px; }
.sheet h3 { font-weight: normal; font-variant: small-caps; color: var(--gold); letter-spacing: 0.08em; margin: 6px 0 10px; font-size: 19px; border-bottom: 1px solid rgba(217,180,90,0.2); padding-bottom: 4px; }
.sheet footer { display: flex; justify-content: flex-end; margin-top: 14px; }
.sheet footer .btn.big { width: auto; text-align: center; margin: 0; padding: 12px 36px; }
.setup-grid, .lobby-grid { display: grid; grid-template-columns: 1.05fr 1fr 1fr; gap: 22px; }
.row { margin-bottom: 12px; }
.row > label, .row > div > label { display: block; font-size: 13px; color: var(--ink2); margin-bottom: 5px; letter-spacing: 0.04em; }
.row.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.inline { display: flex; gap: 6px; align-items: center; }
.hint { font-size: 12.5px; color: var(--dim); margin-top: 5px; font-style: italic; line-height: 1.35; }
.notice { background: rgba(179, 38, 46, 0.2); border: 1px solid var(--red); padding: 10px; border-radius: 4px; margin-bottom: 10px; }
.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.card { border: 1px solid var(--goldA); border-radius: 5px; padding: 8px 9px; cursor: pointer; background: rgba(10, 13, 19, 0.6); font-size: 12px; color: var(--ink2); line-height: 1.3; }
.card b { display: block; font-size: 14.5px; color: var(--ink); font-weight: normal; margin-bottom: 2px; }
.card.on { border-color: var(--gold2); background: rgba(80, 62, 22, 0.45); box-shadow: 0 0 10px rgba(217,180,90,0.2); }
.card i { display: block; color: var(--gold); font-style: normal; margin-top: 3px; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.swatch { width: 28px; height: 28px; border-radius: 4px; border: 2px solid rgba(0,0,0,0.5); cursor: pointer; box-shadow: inset 0 -6px 8px rgba(0,0,0,0.25); }
.swatch.on { border-color: var(--gold2); box-shadow: 0 0 8px var(--gold); }
.sigils { display: flex; flex-wrap: wrap; gap: 5px; }
.sigil { width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; font-size: 20px; border: 1px solid var(--goldA); border-radius: 4px; cursor: pointer; background: rgba(10, 13, 19, 0.6); font-family: "Segoe UI Symbol", var(--serif); }
.sigil.on { border-color: var(--gold2); color: var(--gold2); background: rgba(80, 62, 22, 0.45); }
.sigil.locked { opacity: 0.3; cursor: not-allowed; }
.seg { display: flex; gap: 4px; }
.seg .btn { flex: 1; padding: 6px 4px; font-size: 13px; }
.preview-box { position: relative; border: 1px solid var(--goldA); border-radius: 4px; overflow: hidden; background: #0a1420; aspect-ratio: 1.6; }
.preview-box canvas { width: 100%; height: 100%; display: block; image-rendering: auto; }
#suPreviewMsg { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--ink2); font-style: italic; background: rgba(5,8,14,0.5); }
.rooms { min-height: 120px; max-height: 300px; overflow: auto; border: 1px solid rgba(217,180,90,0.2); border-radius: 4px; }
.room { display: grid; grid-template-columns: 90px 1fr 120px 90px; align-items: center; padding: 8px 10px; border-bottom: 1px solid rgba(217,180,90,0.12); gap: 8px; }
.room .code { font-family: Consolas, monospace; color: var(--gold2); letter-spacing: 0.15em; }
.room small { color: var(--dim); }
.empty { padding: 30px; text-align: center; color: var(--dim); font-style: italic; }
.mp-top { display: grid; grid-template-columns: 1fr 1fr 160px; gap: 12px; align-items: end; }
.code { font-family: Consolas, monospace; letter-spacing: 0.15em; color: var(--gold2); }
.lplayer { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border: 1px solid rgba(217,180,90,0.18); border-radius: 4px; margin-bottom: 6px; background: rgba(10,13,19,0.5); }
.lplayer .banner { width: 26px; height: 30px; font-size: 14px; }
.lplayer .nm { flex: 1; }
.lplayer .nm small { display: block; color: var(--dim); font-size: 12px; }
.chat { height: 300px; overflow: auto; border: 1px solid rgba(217,180,90,0.2); border-radius: 4px; padding: 6px 8px; margin-bottom: 8px; font-size: 14px; background: rgba(5,8,14,0.4); }
.chat .sys { color: var(--dim); font-style: italic; }
.chat b { color: var(--gold2); font-weight: normal; }
.loading { text-align: center; }
.loading #loadingText { font-size: 20px; color: var(--ink2); font-style: italic; margin-top: 10px; }
.spin { animation: spin 2.4s linear infinite; display: inline-block; }
@keyframes spin { 0% { transform: rotateY(0deg); } 100% { transform: rotateY(360deg); } }

/* codex */
.codex { display: grid; grid-template-columns: 220px 1fr; gap: 20px; min-height: 60vh; }
#codexNav button { display: block; width: 100%; text-align: left; margin-bottom: 4px; }
#codexBody { line-height: 1.55; font-size: 15.5px; color: var(--ink); max-height: 72vh; overflow: auto; padding-right: 10px; }
#codexBody h4 { color: var(--gold2); font-weight: normal; font-variant: small-caps; font-size: 21px; margin: 4px 0 8px; letter-spacing: 0.05em; }
#codexBody h5 { color: var(--gold); font-weight: normal; font-size: 16px; margin: 14px 0 4px; font-variant: small-caps; letter-spacing: 0.05em; }
#codexBody table { border-collapse: collapse; width: 100%; font-size: 13.5px; margin: 8px 0; }
#codexBody td, #codexBody th { border-bottom: 1px solid rgba(217,180,90,0.18); padding: 5px 6px; text-align: left; vertical-align: top; }
#codexBody th { color: var(--gold); font-weight: normal; }
#codexBody kbd { font-family: Consolas, monospace; background: #222836; border: 1px solid var(--goldA); border-radius: 3px; padding: 0 5px; font-size: 12.5px; color: var(--gold2); }
#codexBody p { margin: 6px 0 10px; }
#codexBody ul { margin: 4px 0 10px; padding-left: 20px; }

/* archives */
.arch-top { display: flex; gap: 20px; align-items: center; margin-bottom: 14px; }
.arch-rank { font-size: 30px; color: var(--gold2); font-variant: small-caps; }
.xpbar { height: 10px; background: #0d1118; border: 1px solid var(--goldA); border-radius: 5px; overflow: hidden; margin: 6px 0; }
.xpbar div { height: 100%; background: linear-gradient(90deg, #8a6f2c, #f2d58a); }
.statgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 10px 0 16px; }
.statgrid div { border: 1px solid rgba(217,180,90,0.2); border-radius: 4px; padding: 8px; text-align: center; }
.statgrid b { display: block; font-size: 22px; color: var(--gold2); font-weight: normal; }
.statgrid small { color: var(--dim); }
.deeds { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.deed { border: 1px solid rgba(217,180,90,0.2); border-radius: 4px; padding: 8px; font-size: 13px; color: var(--dim); }
.deed b { display: block; color: var(--ink2); font-weight: normal; font-size: 15px; }
.deed.got { border-color: var(--gold); background: rgba(80,62,22,0.3); color: var(--ink2); }
.deed.got b { color: var(--gold2); }
.hist { width: 100%; border-collapse: collapse; font-size: 14px; }
.hist td, .hist th { padding: 5px; border-bottom: 1px solid rgba(217,180,90,0.15); text-align: left; }
.hist th { color: var(--gold); font-weight: normal; }

/* ---------------------------------------------------------------- HUD */
#hud { position: fixed; inset: 0; pointer-events: none; }
#hud > *, #hud .panel, #hud button, #hud input { pointer-events: auto; }
#hud #toast, #hud #spawnHint { pointer-events: none; }
.banner { width: 44px; height: 52px; display: flex; align-items: center; justify-content: center; font-size: 24px; color: #f6ead0; font-family: "Segoe UI Symbol", var(--serif);
  clip-path: polygon(0 0, 100% 0, 100% 62%, 50% 100%, 0 62%); text-shadow: 0 1px 2px rgba(0,0,0,0.7); box-shadow: inset 0 -10px 14px rgba(0,0,0,0.3); flex: none; }
#realmCard { position: absolute; top: 10px; left: 10px; width: 300px; padding: 10px 12px; }
.rc-head { display: flex; gap: 10px; align-items: center; }
.rc-name { font-size: 19px; color: var(--gold2); line-height: 1.1; }
.rc-title { font-size: 12.5px; color: var(--ink2); font-style: italic; }
.rc-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px; margin: 9px 0 6px; }
.stat { display: flex; align-items: baseline; gap: 5px; font-size: 13px; white-space: nowrap; }
.stat b { font-size: 17px; font-weight: normal; color: var(--ink); }
.stat small { color: var(--dim); font-size: 11.5px; }
.stat small.up { color: #b5d97a; }
.ic { display: inline-block; width: 14px; height: 14px; border-radius: 50%; flex: none; position: relative; top: 1px; }
.ic-gold { background: radial-gradient(circle at 35% 35%, #ffe7a6, #b8892e 70%); box-shadow: 0 0 0 1px #4a3208; }
.ic-troops { background: radial-gradient(circle at 35% 35%, #f0a0a0, #9b2228 70%); box-shadow: 0 0 0 1px #3b0a0a; }
.ic-pop { background: radial-gradient(circle at 35% 35%, #bfe0a0, #4f7f2a 70%); box-shadow: 0 0 0 1px #1c300d; }
.ic-land { background: radial-gradient(circle at 35% 35%, #a6d0f0, #2f6a9c 70%); box-shadow: 0 0 0 1px #0d2438; }
.ic-inf::before { content: '⚔'; } .ic-cav::before { content: '♞'; } .ic-flag::before { content: '⚑'; }
.ic-inf, .ic-cav, .ic-flag { width: auto; height: auto; border-radius: 0; font-style: normal; font-family: "Segoe UI Symbol", var(--serif); font-size: 16px; top: 0; }
.popbar { display: flex; height: 6px; border-radius: 3px; overflow: hidden; background: #0d1118; border: 1px solid rgba(217,180,90,0.25); }
.popbar #popTroops { background: linear-gradient(90deg, #7a1b20, #c2363d); }
.popbar #popPeas { background: linear-gradient(90deg, #3e6a22, #7fb35a); }
.rc-actions { display: flex; gap: 6px; margin-top: 9px; }
.rc-actions .btn { flex: 1; }
#btnEra { position: relative; overflow: hidden; }
#btnEra .prog { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--gold2); }
#decreeBox { margin-top: 8px; display: grid; gap: 5px; }
.decree { display: flex; justify-content: space-between; align-items: center; gap: 8px; text-align: left; font-size: 13px; }
.decree small { color: var(--dim); }

#topCenter { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); padding: 6px 16px 8px; text-align: center; min-width: 240px; }
#phaseText { font-size: 13px; color: var(--ink2); font-style: italic; letter-spacing: 0.04em; }
#clock { font-size: 22px; color: var(--gold2); line-height: 1.1; font-variant-numeric: tabular-nums; }
#spControls { position: absolute; right: 8px; top: 8px; display: flex; gap: 3px; }
#victoryBar { height: 4px; background: rgba(255,255,255,0.08); border-radius: 2px; margin-top: 4px; overflow: hidden; }
#victoryBar div { height: 100%; width: 0; background: linear-gradient(90deg, #8a6f2c, #f2d58a); }

#topRight { position: absolute; top: 10px; right: 10px; width: 290px; display: flex; flex-direction: column; gap: 8px; max-height: calc(100vh - 280px); }
#leaderboard { padding: 6px 8px 8px; }
.lb-head { display: flex; justify-content: space-between; align-items: center; font-variant: small-caps; color: var(--gold); letter-spacing: 0.06em; font-size: 15px; margin-bottom: 4px; }
.lbr { display: grid; grid-template-columns: 18px 12px 1fr 52px 50px; gap: 5px; align-items: center; font-size: 13px; padding: 2px 3px; border-radius: 3px; cursor: pointer; }
.lbr:hover { background: rgba(255,240,200,0.06); }
.lbr.me { background: rgba(217,180,90,0.13); }
.lbr .dot { width: 11px; height: 11px; border-radius: 2px; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.5); }
.lbr .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lbr .n i { font-style: normal; font-size: 11px; margin-left: 3px; }
.lbr .v { text-align: right; color: var(--ink2); font-variant-numeric: tabular-nums; }
.lbr .rk { color: var(--dim); text-align: right; }
#popups { display: flex; flex-direction: column; gap: 6px; }
.popup { padding: 9px 11px; font-size: 13.5px; border-color: var(--gold); animation: slidein .25s ease-out; }
.popup .acts { display: flex; gap: 6px; margin-top: 7px; }
.popup .acts .btn { flex: 1; }
@keyframes slidein { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
#infoPanel { padding: 10px 12px; font-size: 13.5px; overflow: auto; }
#infoPanel h4 { margin: 0 0 6px; font-weight: normal; color: var(--gold2); font-size: 17px; display: flex; justify-content: space-between; align-items: center; }
#infoPanel .kv { display: flex; justify-content: space-between; border-bottom: 1px solid rgba(217,180,90,0.12); padding: 3px 0; }
#infoPanel .kv span:first-child { color: var(--ink2); }
#infoPanel .acts { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
#infoPanel .acts .btn { flex: 1 1 45%; }
.hpbar { height: 6px; background: #0d1118; border-radius: 3px; overflow: hidden; margin: 4px 0; border: 1px solid rgba(217,180,90,0.25); }
.hpbar div { height: 100%; background: linear-gradient(90deg, #6b8f3a, #9ccf6a); }

#bottomLeft { position: absolute; left: 10px; bottom: 10px; width: 380px; display: flex; flex-direction: column; gap: 6px; }
#log { padding: 6px 8px; }
.log-head { display: flex; justify-content: space-between; align-items: center; font-variant: small-caps; color: var(--gold); letter-spacing: 0.06em; font-size: 14px; margin-bottom: 3px; }
#logRows { height: 150px; overflow-y: auto; font-size: 13px; line-height: 1.35; display: flex; flex-direction: column-reverse; }
#logRows div { padding: 2px 2px; border-bottom: 1px solid rgba(217,180,90,0.07); cursor: default; }
#logRows div.loc { cursor: pointer; }
#logRows div.loc:hover { background: rgba(255,240,200,0.05); }
#logRows .war { color: #f0a090; } #logRows .good { color: #c6e39a; } #logRows .bad { color: #f08a7a; }
#logRows .trade { color: #f2d58a; } #logRows .diplo { color: #a8cdf0; } #logRows .chat { color: #e8dcff; }
#logRows time { color: var(--dim); font-size: 11px; margin-right: 5px; font-variant-numeric: tabular-nums; }
#chatRow input { margin-top: 5px; font-size: 13px; padding: 5px 8px; }
#attacksList { display: flex; flex-direction: column; gap: 4px; }
.atk { display: flex; align-items: center; gap: 7px; padding: 4px 8px; font-size: 13px; }
.atk .bar { flex: 1; height: 5px; background: #0d1118; border-radius: 3px; overflow: hidden; }
.atk .bar div { height: 100%; background: linear-gradient(90deg, #7a1b20, #d9473e); }
.atk.vs .bar div { background: linear-gradient(90deg, #444, #aaa); }
.atk .x { padding: 0 6px; }

#controlBar { position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%); display: flex; align-items: stretch; gap: 12px; padding: 8px 12px; }
.sliders { display: flex; flex-direction: column; gap: 3px; width: 200px; }
.sliders label { display: block; font-size: 12.5px; color: var(--ink2); }
.sliders label > span { display: flex; justify-content: space-between; }
.sliders label b { color: var(--gold2); font-weight: normal; }
.sliders em { display: block; font-size: 11px; color: var(--dim); font-style: normal; margin-top: -3px; }
.modes { display: flex; flex-direction: column; gap: 3px; justify-content: center; }
.modes .btn { display: flex; gap: 6px; align-items: center; padding: 3px 10px; font-size: 13px; }
.rings { display: flex; gap: 4px; margin: 4px 0; }
.rings span { flex: 1; height: 7px; border-radius: 2px; background: #2a2f3a; border: 1px solid rgba(217,180,90,0.3); overflow: hidden; }
.rings span i { display: block; height: 100%; background: linear-gradient(90deg, #6b8f3a, #9ccf6a); }
.atk.army { cursor: pointer; }
.atk.army .bar div { background: linear-gradient(90deg, #8a6f2c, #f2d58a); }
#buildBar { display: flex; gap: 4px; align-items: stretch; border-left: 1px solid rgba(217,180,90,0.2); padding-left: 10px; }
.bb { width: 62px; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; padding: 4px 2px 3px; position: relative; }
.bb img { width: 30px; height: 30px; margin-bottom: 1px; }
.bb .nm { font-size: 10.5px; line-height: 1.1; text-align: center; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 58px; }
.bb .c { font-size: 11px; color: var(--gold2); }
.bb .k { position: absolute; top: 1px; left: 3px; font-size: 10px; color: var(--dim); font-family: Consolas, monospace; }
.bb.poor .c { color: #d97a6a; }
.bb.locked { opacity: 0.35; }
.bb.on { border-color: var(--gold2); background: linear-gradient(180deg, #4a3d1e, #2b2312); }

#minimapBox { position: absolute; right: 10px; bottom: 10px; padding: 4px; }
#minimap { display: block; width: 300px; height: auto; border-radius: 3px; cursor: crosshair; image-rendering: auto; }

#tooltip { position: fixed; z-index: 50; pointer-events: none; max-width: 300px; padding: 7px 10px; font-size: 13px; line-height: 1.35;
  background: linear-gradient(180deg, #f1e3c2, #e2cfa4); color: #2a1d0e; border: 1px solid #8a6f2c; border-radius: 4px; box-shadow: 0 4px 14px rgba(0,0,0,0.5); }
#tooltip b { color: #5a1d12; font-weight: normal; font-variant: small-caps; font-size: 15px; letter-spacing: 0.03em; }
#tooltip .sub { color: #5c4a2e; font-size: 12px; }
#tooltip .row2 { display: flex; justify-content: space-between; gap: 12px; }

#toast { position: absolute; top: 90px; left: 50%; transform: translateX(-50%); text-align: center; pointer-events: none; }
.toastmsg { font-size: 22px; color: var(--gold2); text-shadow: 0 2px 4px #000, 0 0 18px rgba(0,0,0,0.8); padding: 8px 26px; margin-bottom: 6px;
  background: linear-gradient(90deg, transparent, rgba(10,12,18,0.75), transparent); animation: toastin .35s ease-out; letter-spacing: 0.03em; }
.toastmsg.war { color: #ffb19e; } .toastmsg.good { color: #d9f0a8; }
.toastmsg { max-width: min(820px, 64vw); margin-left: auto; margin-right: auto; }
.toastmsg.long { font-size: 16.5px; line-height: 1.4; padding: 10px 34px; }
@keyframes toastin { from { transform: translateY(-10px) scale(0.96); opacity: 0; } to { transform: none; opacity: 1; } }
#spawnHint { position: absolute; top: 96px; left: 50%; transform: translateX(-50%); text-align: center; text-shadow: 0 2px 6px #000; }
.sh-title { font-size: 28px; color: var(--gold2); }
.sh-sub { font-size: 15px; color: var(--ink); margin-top: 4px; }
.sh-sub b { color: var(--gold2); font-size: 18px; margin-left: 6px; }

/* radial */
#radial { position: fixed; width: 0; height: 0; z-index: 40; }
#radial .rcenter { position: absolute; transform: translate(-50%, -50%); width: 70px; height: 70px; border-radius: 50%; display: flex; align-items: center; justify-content: center; text-align: center; font-size: 11.5px; line-height: 1.15; padding: 6px;
  background: radial-gradient(circle, rgba(30,36,48,0.95), rgba(14,17,24,0.95)); border: 1px solid var(--gold); color: var(--ink2); }
#radial .ropt { position: absolute; transform: translate(-50%, -50%); width: 64px; height: 64px; border-radius: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 10.5px; line-height: 1.1; text-align: center; padding: 4px; background: radial-gradient(circle at 40% 35%, #333b4c, #171b24); border: 1px solid var(--goldA); color: var(--ink); cursor: pointer;
  box-shadow: 0 3px 10px rgba(0,0,0,0.5); animation: pop .14s ease-out; }
#radial .ropt:hover { border-color: var(--gold2); background: radial-gradient(circle at 40% 35%, #4a3d1e, #241d0f); color: var(--gold2); }
#radial .ropt.dis { opacity: 0.4; pointer-events: none; }
#radial .ropt .g { font-size: 20px; font-family: "Segoe UI Symbol", var(--serif); margin-bottom: 1px; }
#radial .ropt.danger { border-color: rgba(217,71,62,0.7); }
@keyframes pop { from { transform: translate(-50%, -50%) scale(0.5); opacity: 0; } to { transform: translate(-50%, -50%) scale(1); opacity: 1; } }

/* modal */
#modal { position: fixed; inset: 0; background: rgba(4, 6, 10, 0.55); display: flex; align-items: center; justify-content: center; z-index: 30; }
#modalBox { width: min(860px, 94vw); max-height: 88vh; overflow: auto; padding: 18px 22px; }
#modalBox h2 { margin: 0 0 10px; font-weight: normal; font-variant: small-caps; color: var(--gold2); letter-spacing: 0.07em; font-size: 26px; }
.menu-list .btn { display: block; width: 100%; margin-bottom: 8px; padding: 11px; font-size: 17px; }
.dtable { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.dtable td, .dtable th { padding: 5px 6px; border-bottom: 1px solid rgba(217,180,90,0.13); text-align: left; }
.dtable th { color: var(--gold); font-weight: normal; }
.dtable .rel { font-size: 12px; padding: 1px 7px; border-radius: 10px; border: 1px solid; }
.rel.ally { color: #f2d58a; border-color: #8a6f2c; } .rel.war { color: #ff9c8a; border-color: #8a2a22; } .rel.peace { color: var(--ink2); border-color: #555; } .rel.team { color: #a8cdf0; border-color: #2f5f8a; } .rel.truce { color: #c6e39a; border-color: #4f6f2a; }
.dtable .btn { padding: 2px 7px; font-size: 12px; margin: 1px; }
.end-hero { text-align: center; margin-bottom: 12px; }
.end-hero h1 { margin: 0; font-weight: normal; font-variant: small-caps; font-size: 44px; color: var(--gold2); text-shadow: 0 3px 10px #000; letter-spacing: 0.05em; }
.end-hero.lost h1 { color: #e88a7a; }
.end-hero p { color: var(--ink2); font-style: italic; margin: 4px 0; }
.end-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 18px; }
.end-grid canvas { width: 100%; height: 220px; border: 1px solid rgba(217,180,90,0.2); border-radius: 4px; background: rgba(5,8,14,0.5); }
.xprow { display: flex; justify-content: space-between; border-bottom: 1px solid rgba(217,180,90,0.12); padding: 3px 0; font-size: 14px; }
.xprow b { color: var(--gold2); font-weight: normal; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(217,180,90,0.3); border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 1640px) {
  #bottomLeft { width: 320px; }
  #logRows { height: 120px; }
  .bb { width: 50px; padding: 3px 1px; }
  .bb .nm { display: none; }
  .bb img { width: 26px; height: 26px; }
  #minimap { width: 240px; }
  .sliders { width: 170px; }
}
@media (max-width: 1420px) {
  #bottomLeft { width: 290px; }
  #logRows { height: 100px; }
  .bb { width: 44px; }
  .bb .c { font-size: 10px; }
  .modes .btn span { display: none; }
  .modes .btn { padding: 6px 9px; }
  #minimap { width: 200px; }
  .sliders { width: 150px; }
  #controlBar { gap: 8px; padding: 6px 8px; left: calc(50% - 10px); }
  #realmCard { width: 270px; }
  #topRight { width: 250px; }
}
@media (max-width: 1100px) {
  .setup-grid, .lobby-grid { grid-template-columns: 1fr 1fr; }
}

/* ---------------------------------------------------------------- v2 command panel */
.stat small.down { color: #f08a7a; }
#btnEra.poor { opacity: 0.7; }
.lbh { display: flex; gap: 14px; font-size: 11px; color: var(--dim); font-variant: normal; letter-spacing: 0; }
.lbr { grid-template-columns: 18px 12px 1fr 40px 50px; }
#cmdPanel { position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%); width: min(760px, calc(100vw - 760px)); min-width: 520px; padding: 8px 12px 9px; max-height: 46vh; overflow-y: auto; }
#cmdHead:empty { display: none; }
.cmd-title { font-size: 17px; color: var(--gold2); margin-bottom: 5px; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.cmd-title small { font-size: 12.5px; color: var(--ink2); font-style: italic; }
.cmd-hint { font-size: 14px; color: var(--ink2); line-height: 1.45; padding: 4px 2px; }
.cmd-hint b { color: var(--gold2); font-weight: normal; }
#cmdPanel .sub { font-size: 12px; color: var(--dim); margin-top: 5px; line-height: 1.35; }
#cmdPanel .kv { display: flex; justify-content: space-between; gap: 10px; border-bottom: 1px solid rgba(217,180,90,0.12); padding: 3px 0; font-size: 13px; }
#cmdPanel .kv span:first-child { color: var(--ink2); }
.buildbar { display: grid; grid-template-columns: repeat(11, 1fr); gap: 4px; }
.bb { width: auto; min-width: 0; display: flex; flex-direction: column; align-items: center; padding: 4px 2px 3px; position: relative; }
.bb img { width: 46px; height: 38px; margin-bottom: 1px; image-rendering: auto; }
.bb .nm { max-width: 100%; }
.orders { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.orders .btn.poor, .rbtn.poor .c { color: #e8907e; }
.ugrid { display: flex; flex-wrap: wrap; gap: 5px; }
.ucard { width: 74px; display: flex; flex-direction: column; align-items: center; padding: 3px 3px 4px; position: relative; }
.ucard img { width: 40px; height: 40px; }
.ucard b { position: absolute; top: 2px; right: 5px; font-weight: normal; color: var(--gold2); font-size: 13px; }
.ucard .hpbar { width: 100%; margin: 2px 0 1px; height: 5px; }
.ucard small { font-size: 11.5px; color: var(--ink2); }
.recruit { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.rbtn { width: 112px; display: flex; flex-direction: column; align-items: center; padding: 4px 4px 5px; }
.rbtn img { width: 40px; height: 40px; }
.rbtn .nm { font-size: 12.5px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 104px; }
.rbtn .c { font-size: 12px; color: var(--gold2); }
.rbtn .c small { color: var(--ink2); }
.rbtn.locked { opacity: 0.35; }
.queue { display: flex; align-items: center; gap: 4px; margin-top: 6px; flex-wrap: wrap; }
.qchip { position: relative; width: 34px; height: 34px; padding: 2px; border-radius: 4px; border: 1px solid var(--goldA); background: rgba(10,13,19,0.7); cursor: pointer; }
.qchip img { width: 28px; height: 28px; }
.qchip:hover { border-color: #d9473e; }
.qbar { position: absolute; left: 2px; right: 2px; bottom: 2px; height: 3px; background: #0d1118; }
.qbar i { display: block; height: 100%; background: var(--gold2); }
.place-row, .bstat { display: flex; gap: 12px; align-items: center; font-size: 13.5px; color: var(--ink2); }
.place-row img, .bstat img { width: 80px; height: 64px; flex: none; }
.why { margin-top: 5px; font-size: 14px; } .why.bad { color: #f08a7a; } .why.ok { color: #c6e39a; }
.rings2 { display: flex; flex-direction: column; gap: 4px; margin: 2px 0 6px; }
.ring { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.ring label { width: 84px; color: var(--ink2); }
.ring small { width: 64px; text-align: right; color: var(--dim); }
.segs { flex: 1; display: grid; grid-template-columns: repeat(8, 1fr); gap: 3px; }
.segs span { height: 16px; border-radius: 2px; background: #2a1d1a; border: 1px solid rgba(217,180,90,0.3); position: relative; overflow: hidden; display: flex; align-items: flex-end; }
.segs span i { display: block; width: 100%; background: linear-gradient(180deg, #b9ad92, #7c705c); }
.segs span.gate { border-color: var(--gold2); }
.segs span.gate i { background: linear-gradient(180deg, #a77b48, #6a4a26); }
.segs span.down { background: repeating-linear-gradient(45deg, #5a1d18, #5a1d18 3px, #2a1210 3px, #2a1210 6px); border-color: #d9473e; }
#groups { position: absolute; bottom: calc(10px + var(--cmdh, 0px)); left: 50%; transform: translateX(-50%); display: flex; gap: 4px; pointer-events: auto; }
#cmdPanel ~ #groups { bottom: auto; top: 86px; }
.grp { display: flex; gap: 4px; align-items: baseline; }
.grp b { color: var(--gold2); font-weight: normal; }
.grp small { color: var(--dim); font-size: 10.5px; }
#alerts { display: flex; flex-direction: column; gap: 4px; }
.alert { padding: 5px 9px; font-size: 13px; cursor: pointer; color: #f0c0a8; border-color: rgba(217,71,62,0.6); }
.alert.hot { color: #ffb19e; border-color: #d9473e; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 14px rgba(217,71,62,0.5); } }
body.cur-attack canvas#map { cursor: crosshair; }
body.cur-place canvas#map { cursor: copy; }
@media (max-width: 1640px) {
  #cmdPanel { width: calc(100vw - 640px); min-width: 470px; }
  .bb img { width: 36px; height: 30px; }
  .bb .nm { display: none; }
}
@media (max-width: 1420px) {
  #cmdPanel { width: calc(100vw - 560px); min-width: 420px; }
  .rbtn { width: 96px; }
}

/* v2.1 castle works */
.works { margin-top: 8px; border-top: 1px solid rgba(217,180,90,0.18); padding-top: 6px; }
.wgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(172px, 1fr)); gap: 5px; margin-top: 4px; }
.wbtn { display: grid; grid-template-columns: 22px 1fr auto; align-items: center; gap: 5px; padding: 4px 7px; font-size: 12.5px; text-align: left; }
.wbtn .wic { font-size: 15px; line-height: 1; font-family: "Segoe UI Emoji", "Segoe UI Symbol", sans-serif; }
.wbtn .wn { white-space: normal; line-height: 1.15; }
.wbtn .wc { color: var(--gold2); font-size: 12px; }
.wbtn.poor .wc { color: #e8907e; }
.wbtn.done { opacity: 0.75; border-color: rgba(127,179,90,0.6); }
.wbtn.done .wc { color: var(--green); }
.wbtn.busy { border-color: var(--gold2); box-shadow: inset 0 0 10px rgba(217,180,90,0.25); opacity: 1; }
.wbtn:disabled:not(.done):not(.busy) { opacity: 0.5; }

/* v2.1 tutorial */
#tutPanel { position: absolute; top: 178px; left: 10px; width: 300px; padding: 10px 13px 11px; z-index: 30; pointer-events: auto; border-color: var(--gold); box-shadow: 0 0 22px rgba(217,180,90,0.25), 0 6px 24px rgba(0,0,0,0.5); }
#tutPanel .tut-head { font-size: 11.5px; color: var(--dim); letter-spacing: 0.08em; text-transform: uppercase; }
#tutPanel h4 { margin: 3px 0 6px; font-weight: normal; font-variant: small-caps; color: var(--gold2); font-size: 19px; letter-spacing: 0.04em; }
#tutPanel .tut-text { font-size: 14px; line-height: 1.45; color: var(--ink); }
#tutPanel .tut-text b { color: var(--gold2); font-weight: normal; }
#tutPanel .tut-btns { display: flex; gap: 6px; align-items: center; justify-content: space-between; margin-top: 10px; }
#tutPanel .tut-wait { font-size: 12.5px; color: var(--dim); font-style: italic; }
#tutPanel .tut-prog { margin-top: 6px; color: var(--green); }
#tutArrow { position: absolute; left: 0; top: 0; display: none; pointer-events: none; z-index: 25; }
#tutArrow span { display: block; font-size: 34px; color: #ffe08a; text-shadow: 0 0 10px rgba(255,210,100,0.9), 0 2px 4px #000; animation: tutBob 0.9s ease-in-out infinite; }
@keyframes tutBob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(10px); } }
.tut-glow { box-shadow: 0 0 0 2px #ffe08a, 0 0 16px 4px rgba(255,210,100,0.75) !important; animation: tutGlow 1.1s ease-in-out infinite; position: relative; z-index: 2; }
@keyframes tutGlow { 0%, 100% { box-shadow: 0 0 0 2px #ffe08a, 0 0 8px 2px rgba(255,210,100,0.55); } 50% { box-shadow: 0 0 0 2px #fff2c0, 0 0 20px 6px rgba(255,210,100,0.9); } }

/* ---------------------------------------------------------------- v2.2 touch screens, tablets and phones */
html, body { overscroll-behavior: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
canvas#map { touch-action: none; }
#hud, .screen, #modal { touch-action: manipulation; }
#touchBar { display: none; }
body.touch #touchBar { display: grid; position: absolute; left: 10px; top: 190px; grid-template-columns: 1fr; gap: 4px; padding: 5px; }
.tb { width: 56px; height: 46px; padding: 2px 0; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 19px; line-height: 1; font-family: "Segoe UI Symbol", var(--serif); }
.tb small { font-size: 10px; margin-top: 3px; color: var(--ink2); font-family: var(--serif); letter-spacing: 0.02em; }
.tb.on { border-color: var(--gold2); background: linear-gradient(180deg, #4a3d1e, #2b2312); color: var(--gold2); box-shadow: 0 0 10px rgba(217,180,90,0.35); }
.tb:disabled { opacity: 0.32; }
body.touch:not(.show-log) #log { display: none; }
body.touch:not(.show-lb) #leaderboard { display: none; }
body.touch:not(.show-map) #minimapBox { display: none; }
body.touch #cmdPanel { left: 88px; right: 10px; width: auto; min-width: 0; transform: none; }
body.touch.show-map #cmdPanel { right: 262px; }
body.touch #minimap { width: 240px; }
body.touch #bottomLeft { left: 88px; bottom: 200px; }
body.touch #tutPanel { left: auto; right: 10px; top: 10px; }
body.touch .btn { min-height: 30px; }
body.touch .bb, body.touch .rbtn, body.touch .wbtn { min-height: 44px; }

/* phones: everything compact, panels on demand */
body.phone #realmCard { width: 228px; padding: 5px 8px 6px; top: 6px; left: 6px; }
body.phone .rc-head { gap: 7px; }
body.phone .rc-head .banner { width: 26px; height: 32px; font-size: 15px; }
body.phone .rc-name { font-size: 14px; }
body.phone .rc-title { display: none; }
body.phone .rc-stats { margin: 4px 0 2px; gap: 1px 8px; }
body.phone .stat { font-size: 11px; gap: 3px; } body.phone .stat b { font-size: 13px; } body.phone .stat small { font-size: 9.5px; }
body.phone .ic { width: 10px; height: 10px; }
body.phone .rc-actions { margin-top: 4px; gap: 4px; } body.phone .rc-actions .btn { padding: 2px 4px; font-size: 11px; min-height: 26px; }
body.phone #topCenter { top: 4px; padding: 3px 8px 4px; min-width: 120px; }
body.phone #phaseText { display: none; }
body.phone #clock { font-size: 15px; }
body.phone #spControls { position: static; justify-content: center; margin-top: 2px; }
body.phone #spControls .btn { min-height: 22px; padding: 1px 7px; }
body.phone #topRight { top: 6px; right: 6px; width: 214px; max-height: calc(100vh - 16px); }
body.phone .lbr { font-size: 11.5px; }
body.phone #touchBar { top: auto; bottom: 6px; left: 6px; grid-template-columns: repeat(3, 1fr); gap: 3px; padding: 4px; }
body.phone .tb { width: 42px; height: 36px; font-size: 15px; min-height: 0; }
body.phone .tb small { font-size: 8.5px; margin-top: 1px; }
body.phone #cmdPanel { left: 150px; right: 6px; bottom: 6px; max-height: 46vh; padding: 5px 8px 6px; }
body.phone.show-map #cmdPanel { right: 6px; }
body.phone #minimapBox { right: 6px; bottom: auto; top: 50%; transform: translateY(-50%); z-index: 5; }
body.phone #minimap { width: 210px; }
body.phone #bottomLeft { left: 6px; bottom: 132px; width: 250px; }
body.phone #logRows { height: 96px; font-size: 11.5px; }
body.phone .cmd-title { font-size: 14px; margin-bottom: 3px; }
body.phone .cmd-title small { font-size: 11px; }
body.phone .cmd-hint { font-size: 12px; line-height: 1.35; }
body.phone #cmdPanel .sub { font-size: 10.5px; margin-top: 3px; }
body.phone #cmdPanel .kv { font-size: 11.5px; padding: 1px 0; }
body.phone .buildbar { gap: 2px; }
body.phone .bb { padding: 2px 1px; min-height: 0; }
body.phone .bb img { width: 30px; height: 25px; }
body.phone .bb .c { font-size: 9.5px; }
body.phone .bb .k, body.phone .bb .nm { display: none; }
body.phone .rbtn { width: 76px; padding: 2px; min-height: 0; }
body.phone .rbtn img { width: 30px; height: 30px; }
body.phone .rbtn .nm { font-size: 10px; max-width: 72px; }
body.phone .rbtn .c { font-size: 10px; }
body.phone .ucard { width: 56px; }
body.phone .ucard img { width: 30px; height: 30px; }
body.phone .orders { gap: 4px; margin-top: 4px; }
body.phone .orders .btn { font-size: 11.5px; padding: 3px 7px; }
body.phone .wgrid { grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 3px; }
body.phone .wbtn { font-size: 10.5px; padding: 2px 5px; min-height: 34px; grid-template-columns: 16px 1fr auto; }
body.phone .wbtn .wic { font-size: 12px; }
body.phone .ring { font-size: 10.5px; gap: 5px; }
body.phone .ring label { width: 58px; } body.phone .ring small { width: 44px; }
body.phone .segs span { height: 10px; }
body.phone .place-row img, body.phone .bstat img { width: 50px; height: 40px; }
body.phone #toast { top: 50px; }
body.phone .toastmsg { font-size: 14px; max-width: 64vw; padding: 5px 16px; }
body.phone .toastmsg.long { font-size: 12.5px; }
body.phone #spawnHint { top: 50px; }
body.phone .sh-title { font-size: 17px; } body.phone .sh-sub { font-size: 11.5px; }
body.phone #tutPanel { width: 252px; top: 6px; right: 6px; padding: 6px 9px 8px; }
body.phone #tutPanel h4 { font-size: 15px; margin: 1px 0 3px; }
body.phone #tutPanel .tut-text { font-size: 12px; line-height: 1.35; max-height: 38vh; overflow-y: auto; }
body.phone #tutPanel .tut-btns { margin-top: 6px; }
body.phone #tooltip { max-width: 230px; font-size: 11.5px; padding: 5px 7px; }
body.phone #tooltip b { font-size: 13px; }
body.phone #alerts .alert { font-size: 11px; padding: 3px 7px; }
body.phone #modalBox { padding: 10px 12px; max-height: 94vh; width: 96vw; }
body.phone #modalBox h2 { font-size: 20px; }

/* turn the phone sideways */
#rotateHint { display: none; }
@media (orientation: portrait) {
  body.phone:not(.rh-off) #rotateHint { display: flex; position: fixed; inset: 0; z-index: 100; background: rgba(8,10,16,0.95); align-items: center; justify-content: center; text-align: center; color: var(--ink); padding: 30px; }
}
.rh-icon { font-size: 56px; color: var(--gold2); display: inline-block; animation: rhTurn 2.2s ease-in-out infinite; }
@keyframes rhTurn { 0%, 30% { transform: rotate(0); } 60%, 100% { transform: rotate(90deg); } }
.rh-t { font-size: 22px; color: var(--gold2); margin: 10px 0 4px; font-variant: small-caps; letter-spacing: 0.05em; }
.rh-s { color: var(--ink2); margin-bottom: 16px; font-style: italic; }

/* menus on small screens */
@media (max-width: 760px), (max-height: 520px) {
  .setup-grid, .lobby-grid { grid-template-columns: 1fr; gap: 10px; }
  .sheet { padding: 10px 12px 14px; max-height: 96vh; width: 98vw; }
  .sheet header h2 { font-size: 20px; }
  .sheet header { margin-bottom: 6px; padding-bottom: 6px; }
  .mp-top { grid-template-columns: 1fr; }
  .statgrid, .deeds { grid-template-columns: 1fr 1fr; }
  #scr-menu { padding: 2vh 5vw 34px; }
  .end-grid { grid-template-columns: 1fr; }
  .end-hero h1 { font-size: 30px; }
  .room { grid-template-columns: 70px 1fr 90px 70px; font-size: 13px; }
}
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
@media (max-height: 520px) {
  #scr-menu { padding: 10px 5vw 12px; justify-content: flex-start; }
  .title-block { margin-bottom: 8px; }
  .title-block .crest { display: none; }
  .title-block h1 { font-size: clamp(26px, 9vh, 40px); }
  .title-block .subtitle { font-size: 12px; letter-spacing: 0.12em; }
  .menu-buttons { width: min(560px, 90vw); display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
  .menu-buttons .btn.big { margin: 0; padding: 7px 12px; font-size: 15px; }
  .menu-buttons .btn.big small { font-size: 10.5px; }
  .menu-foot { position: static; margin-top: 8px; padding: 0; font-size: 11.5px; width: min(560px, 90vw); }
}
body.phone #spawnHint { display: none !important; }

/* ---------------------------------------------------------------- v2.3 full screen, browser bars and notches */
:root { --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px); --sal: env(safe-area-inset-left, 0px); --sar: env(safe-area-inset-right, 0px); }
/* the HUD keeps clear of notches and rounded corners; the map still fills the whole screen */
#hud { top: var(--sat); bottom: var(--sab); left: var(--sal); right: var(--sar); }
#tutArrow { position: fixed; }
/* screens scroll instead of clipping when they are taller than what the browser leaves visible */
.screen { align-items: flex-start; justify-content: flex-start; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: var(--sat) var(--sar) var(--sab) var(--sal); }
.screen > .sheet, .screen > .loading { margin: auto; }
.sheet { max-height: 92vh; max-height: 92dvh; }
#scr-menu { justify-content: flex-start; }
#scr-menu .title-block { margin-top: auto; }
#scr-menu .menu-buttons { margin-bottom: auto; }
/* the start button of a sheet is always in view */
.sheet { padding-bottom: 0; }
.sheet footer { position: sticky; bottom: 0; z-index: 3; margin: 14px -24px 0; padding: 10px 24px 16px; background: linear-gradient(180deg, rgba(18,22,31,0.75), rgba(16,20,28,0.98) 40%); border-top: 1px solid rgba(217,180,90,0.15); }
#modalBox { max-height: 88vh; max-height: 88dvh; }
@media (max-width: 760px), (max-height: 520px) {
  .sheet { max-height: 98dvh; padding-bottom: 0; }
  .sheet footer { margin: 8px -12px 0; padding: 7px 12px 9px; }
  .sheet footer .btn.big { padding: 9px 22px; font-size: 16px; }
}

/* full screen */
#fsBtn { display: none; }
body.touch.fs-native:not(.is-full) #fsBtn, body.touch.ios-help:not(.is-full) #fsBtn { display: block; }
#fsBtn { position: fixed; z-index: 60; top: calc(8px + var(--sat)); right: calc(8px + var(--sar)); padding: 6px 12px; font-size: 13px; }
#hud:not(.hidden) ~ #fsBtn { display: none !important; }
body.is-full .fs-tb small::after { content: ''; }
#fsHelp { display: none; }
body.fs-help #fsHelp { display: flex; position: fixed; inset: 0; z-index: 110; background: rgba(6,8,12,0.8); align-items: center; justify-content: center; padding: 20px; }
#fsHelp .panel { max-width: 420px; padding: 16px 20px; font-size: 14.5px; line-height: 1.45; }
#fsHelp h3 { margin: 0 0 8px; color: var(--gold2); font-weight: normal; font-variant: small-caps; font-size: 21px; }
#fsHelp ol { padding-left: 20px; margin: 8px 0 14px; }
#fsHelp b { color: var(--gold2); font-weight: normal; }
/* ten touch buttons: on phones a 4-row grid */
body.phone #touchBar { grid-template-columns: repeat(3, 1fr); }
body.phone #bottomLeft { bottom: 176px; }
body.touch.is-full .fs-tb { opacity: 0.6; }
.sheet > :last-child:not(footer) { margin-bottom: 18px; }

/* v2.5 zoom buttons, folding command panel, compact phone panel */
#zoomBtns { position: absolute; left: -48px; bottom: 4px; display: flex; flex-direction: column; gap: 5px; }
#zoomBtns .btn { width: 40px; height: 40px; padding: 0; font-size: 22px; line-height: 1; }
body.phone #zoomBtns { display: none; }
#cmdToggle { display: none; }
body.touch #cmdToggle { display: block; position: absolute; top: 3px; right: 3px; z-index: 3; min-height: 0; padding: 0 8px; font-size: 13px; }
body.cmd-min #cmdHead, body.cmd-min #cmdBody { display: none; }
body.cmd-min #cmdPanel { left: auto !important; width: auto; min-width: 0; padding: 18px 26px 2px 6px; }
body.cmd-min #cmdToggle { transform: rotate(180deg); }
body.phone #cmdPanel .help { display: none; }
body.phone #cmdPanel { max-height: 40vh; }
body.phone .cmd-hint { font-size: 11px; line-height: 1.3; }
body.phone .cmd-title { padding-right: 26px; }

/* v2.7 recruiting in batches */
.batchrow { display: flex; align-items: center; gap: 4px; margin: 2px 0 4px; }
.batchrow .btn.tiny { padding: 1px 8px; }
.batchrow .qcount { margin-left: auto; color: var(--gold2); }
.qchip { position: relative; }
.qchip .qn { position: absolute; right: 1px; top: 0; font-size: 11px; font-weight: normal; color: #fff4c4; text-shadow: 0 1px 2px #000; }

/* v2.7 every bottom panel can be folded away */
#cmdToggle { display: block; position: absolute; top: 3px; right: 3px; z-index: 3; min-height: 0; padding: 0 8px; font-size: 13px; }
.cmd-title { padding-right: 26px; }
.btn.fold { padding: 0 6px; font-size: 11px; line-height: 1.3; margin-left: 4px; vertical-align: 1px; }
body.log-min #logRows, body.log-min #logFilter, body.log-min #chatRow { display: none; }
body.log-min #logToggle { transform: rotate(180deg); }
#minimapBox { position: absolute; }
#mapToggle { position: absolute; top: -2px; left: -2px; z-index: 2; transform: translateY(-100%); }
body.map-min #minimap { display: none; }
body.map-min #minimapBox { padding: 0; border: 0; background: none; box-shadow: none; }
body.map-min #mapToggle { transform: translateY(-100%) rotate(180deg); }
body.map-min #zoomBtns { left: auto; right: 0; bottom: 4px; }

.cmd-title .lvl { color: var(--gold2); font-size: 13px; letter-spacing: 1px; }

/* v2.7 right-click a realm's city: its diplomacy menu */
#realmMenu { position: absolute; z-index: 45; min-width: 230px; padding: 8px; display: flex; flex-direction: column; gap: 4px; border-color: var(--gold); box-shadow: 0 8px 26px rgba(0,0,0,0.6); }
#realmMenu .rm-head { display: flex; gap: 8px; align-items: center; margin-bottom: 4px; padding-bottom: 6px; border-bottom: 1px solid rgba(217,180,90,0.2); }
#realmMenu .rm-head .banner { width: 24px; height: 29px; font-size: 13px; }
#realmMenu .rm-head b { display: block; color: var(--gold2); font-weight: normal; font-size: 15px; }
#realmMenu .rm-head small { color: var(--ink2); font-size: 12px; }
#realmMenu .btn { text-align: left; }
#realmMenu .rel { font-size: 11.5px; padding: 0 6px; border-radius: 9px; border: 1px solid; }

/* v2.7.1 locked recruits say why */
.rbtn.locked { opacity: 0.55; }
.rbtn .lockage { font-size: 11px; color: #e0b48a; white-space: nowrap; }

/* v2.8 folded panels leave a clear way back */
#showPanels { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); z-index: 30; padding: 6px 18px; font-size: 15px; border-color: var(--gold); color: var(--gold2); box-shadow: 0 0 16px rgba(217,180,90,0.55); }
#showPanels small { color: var(--ink2); font-size: 12px; }
body.touch #showPanels { bottom: 70px; }
.btn.unfold { font-size: 12.5px !important; padding: 2px 9px !important; line-height: 1.5 !important; border-color: var(--gold) !important; color: var(--gold2) !important; box-shadow: 0 0 8px rgba(217,180,90,0.45); white-space: nowrap; }
body.cmd-min #cmdToggle, body.log-min #logToggle { transform: none; }
body.cmd-min #cmdToggle { position: static; }
body.cmd-min #cmdPanel { padding: 4px 6px; }
body.map-min #mapToggle { transform: translateY(-100%); left: auto; right: 0; }

/* v2.8 invite link */
#lobbyLink { font-size: 13px; vertical-align: 3px; margin-left: 8px; }

/* v2.8 report a bug or idea */
#reportBox { position: fixed; inset: 0; z-index: 200; background: rgba(8,6,4,0.62); display: flex; align-items: center; justify-content: center; }
#reportBox .rp-card { width: min(520px, 94vw); padding: 16px 18px; display: flex; flex-direction: column; gap: 9px; }
#reportBox h2 { margin: 0; color: var(--gold2); font-weight: normal; }
#reportBox .sub { margin: 0; color: var(--ink2); font-size: 13.5px; }
#reportBox .rp-kinds { display: flex; gap: 16px; font-size: 14px; }
#reportBox textarea { min-height: 120px; resize: vertical; font: inherit; font-size: 14px; padding: 8px; background: rgba(0,0,0,0.35); color: var(--ink); border: 1px solid rgba(217,180,90,0.35); border-radius: 4px; }
#reportBox .rp-row { display: flex; gap: 8px; }
#reportBox .rp-row input { flex: 1; min-width: 0; padding: 6px 8px; font: inherit; font-size: 13.5px; background: rgba(0,0,0,0.35); color: var(--ink); border: 1px solid rgba(217,180,90,0.35); border-radius: 4px; }
#reportBox .rp-acts { display: flex; gap: 8px; align-items: center; justify-content: flex-end; }
#reportBox #rpMsg { margin-right: auto; color: #e8b98e; font-size: 13px; }
/* the folded orders panel sits centred at the bottom (it used to slide half off the left edge) */
body.cmd-min #cmdPanel, body.touch.cmd-min #cmdPanel, body.phone.cmd-min #cmdPanel { left: 50% !important; right: auto !important; transform: translateX(-50%) !important; width: auto !important; min-width: 0 !important; overflow: visible; }
body.cmd-min.log-min.map-min #cmdPanel { display: none; }

/* v2.8.1 sigils: fonts that have these symbols on every system */
.sigil, .banner { font-family: "Segoe UI Symbol", "Noto Sans Symbols 2", "Noto Sans Symbols", "Apple Symbols", "DejaVu Sans", "Segoe UI Emoji", var(--serif); }

/* v2.8.1 hall: colour teams, map preview, explained terms */
.lplayer { flex-wrap: wrap; }
.teamchips { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0 2px 34px; }
.tchip { font: inherit; font-size: 12px; padding: 2px 9px; border-radius: 11px; border: 1px solid var(--tc); color: #f3e6c8; background: rgba(0,0,0,0.25); cursor: pointer; opacity: 0.75; }
.tchip:hover:not([disabled]) { opacity: 1; }
.tchip.on { background: var(--tc); opacity: 1; box-shadow: 0 0 8px var(--tc); font-weight: bold; }
.tchip[disabled] { cursor: default; }
.tchip[disabled]:not(.on) { opacity: 0.35; }
.lobby-pv { position: relative; margin: 6px 0 8px; }
.lobby-pv canvas { width: 100%; height: auto; display: block; border-radius: 4px; }
.lobby-pv #lsReroll { position: absolute; right: 6px; bottom: 6px; }
#lsPreviewMsg { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--ink2); font-style: italic; }
#lobbySettings .hint, #scr-setup .hint { font-size: 12px; line-height: 1.35; margin-top: 3px; }

/* v2.9 flag designer */
.flagdesigner { display: flex; gap: 10px; align-items: flex-start; }
.flagdesigner #suFlagPv { width: 126px; height: 90px; flex: none; }
.fd-ctrls { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.fd-pats { display: flex; flex-wrap: wrap; gap: 3px; }
.fd-pat { padding: 2px; line-height: 0; border: 1px solid var(--goldA); border-radius: 3px; background: rgba(10,13,19,0.6); cursor: pointer; }
.fd-pat.on { border-color: var(--gold2); box-shadow: 0 0 6px rgba(217,180,90,0.6); }
.fd-pat canvas { width: 30px; height: 20px; }
.fd-line { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink2); }
.fd-line > span { flex: none; width: 86px; }
.fd-sw { gap: 3px; }
.fd-sw .swatch { width: 16px !important; height: 16px !important; font-size: 10px; display: flex; align-items: center; justify-content: center; color: var(--ink2); }
body.phone .flagdesigner { flex-direction: column; }

/* v2.9.3 the castle panel names each side of the walls, and the gate */
.segs span b { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-weight: normal; font-size: 9.5px; letter-spacing: 0.4px; color: #f3e6c8; text-shadow: 0 1px 2px #000, 0 0 3px #000; white-space: nowrap; pointer-events: none; }
.segs span.gate { border: 1px solid #f0c860; box-shadow: 0 0 5px rgba(240,200,96,0.6); }
.segs span.gate b { color: #ffe9a8; font-weight: bold; font-family: "Segoe UI Symbol", var(--serif); }
.segs-hint { margin: -1px 0 2px; font-size: 11px !important; }
body.phone .segs span b { font-size: 7.5px; }
body.phone .segs-hint { display: none; }

/* v2.10 the game is called Milord */
#scr-menu h1 { letter-spacing: 0.06em; }

/* v2.10 a realm's buildings at a glance */
.rbld { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 3px; margin: 5px 0 6px; }
.rbld .rb { display: flex; align-items: center; gap: 4px; padding: 2px 4px; border: 1px solid rgba(217,180,90,0.18); border-radius: 3px; background: rgba(0,0,0,0.18); font-size: 11.5px; min-width: 0; }
.rbld .rb img { width: 26px; height: 21px; flex: none; }
.rbld .rb span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink2); }
.rbld .rb b { color: var(--gold2); font-weight: normal; }
.rbld .rb b small { color: #e8c25a; margin-left: 2px; font-size: 10px; }

/* v2.12 recommended terms and the challenge rating */
.recbox { border: 1px solid rgba(217,180,90,0.35); border-radius: 5px; padding: 6px 8px; margin: 0 0 8px; background: rgba(60,46,18,0.25); }
.rec-h { color: var(--gold2); font-variant: small-caps; font-size: 14px; margin-bottom: 3px; }
.rec { display: flex; align-items: center; gap: 8px; padding: 3px 0; border-top: 1px solid rgba(217,180,90,0.12); }
.rec > div { flex: 1; min-width: 0; }
.rec b { display: block; font-weight: normal; color: var(--ink); font-size: 13.5px; }
.rec span { display: block; color: var(--ink2); font-size: 11.5px; }
.chal { margin-top: 5px; font-size: 12.5px; color: var(--ink2); }
.chal b { padding: 0 7px; border-radius: 9px; font-weight: normal; color: #1a140c; }
.chal-easy b { background: #8fd17a; } .chal-fair b { background: #e8c25a; } .chal-hard b { background: #e8894a; } .chal-brutal b { background: #e0503c; color: #fff; }
.chal span { margin-left: 4px; }

/* v2.13 batch 1: auto-train, pings, battle reports */
.autorow select { font: inherit; font-size: 12px; padding: 1px 4px; max-width: 170px; }
#pingBar { position: absolute; right: 8px; bottom: 236px; z-index: 6; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
#pingBtn.on { border-color: var(--gold2); color: var(--gold2); box-shadow: 0 0 8px rgba(217,180,90,0.6); }
#pingMenu { display: flex; flex-direction: column; gap: 3px; padding: 5px; }
#pingMenu.hidden { display: none; }
body.map-min #pingBar { bottom: 40px; }
body.phone #pingBar { bottom: auto; top: 120px; }
#logRows .battle { color: #f0d9a8; }

/* v2.13 vote to pause */
#voteBanner { position: absolute; top: 74px; left: 50%; transform: translateX(-50%); z-index: 40; padding: 6px 12px; font-size: 14px; color: var(--ink); border-color: var(--gold); white-space: nowrap; }
#voteBanner.hidden { display: none; }
#voteBanner small { color: var(--ink2); margin-left: 4px; }

/* v2.13.1 version and patch notes */
#verBtn { margin-top: 10px; font-size: 13px; padding: 3px 12px; position: relative; }
#verBtn b { font-weight: normal; color: var(--gold2); }
#verBtn.new::after { content: 'NEW'; position: absolute; top: -8px; right: -10px; font-size: 9.5px; padding: 1px 5px; border-radius: 8px; background: #d9473e; color: #fff; letter-spacing: 0.5px; }
#notesBox { position: fixed; inset: 0; z-index: 200; background: rgba(8,6,4,0.62); display: flex; align-items: center; justify-content: center; }
#notesBox .nb-card { width: min(640px, 94vw); max-height: 84vh; display: flex; flex-direction: column; padding: 14px 18px; }
#notesBox .nb-head { display: flex; align-items: baseline; gap: 10px; border-bottom: 1px solid rgba(217,180,90,0.25); padding-bottom: 6px; }
#notesBox .nb-head h2 { margin: 0; color: var(--gold2); font-weight: normal; }
#notesBox .nb-head span { color: var(--ink2); flex: 1; }
#notesBox .nb-body { overflow-y: auto; padding-right: 6px; }
#notesBox section { margin: 10px 0 4px; }
#notesBox section.latest h3 { color: var(--gold2); }
#notesBox h3 { margin: 0 0 4px; font-weight: normal; font-size: 16px; color: var(--ink); }
#notesBox h3 small { color: var(--ink2); font-size: 12px; margin-left: 6px; }
#notesBox ul { margin: 0; padding-left: 20px; }
#notesBox li { font-size: 13.5px; line-height: 1.45; color: var(--ink); margin: 2px 0; }

/* v2.14 saved wars and replays */
#savesBox { position: fixed; inset: 0; z-index: 200; background: rgba(8,6,4,0.62); display: flex; align-items: center; justify-content: center; }
#savesBox .sv-card { width: min(660px, 94vw); max-height: 84vh; overflow-y: auto; padding: 14px 18px; }
#savesBox h3 { margin: 12px 0 6px; font-weight: normal; color: var(--gold2); font-variant: small-caps; }
#savesBox .sv { display: flex; align-items: center; gap: 8px; padding: 5px 0; border-top: 1px solid rgba(217,180,90,0.14); }
#savesBox .sv .banner { width: 24px; height: 29px; font-size: 13px; flex: none; }
#savesBox .sv-t { flex: 1; min-width: 0; }
#savesBox .sv-t b { display: block; font-weight: normal; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#savesBox .sv-t small { color: var(--ink2); font-size: 11.5px; }

/* batch 3: cosmetics */
.fd-pat.locked, .swatch.locked { opacity: 0.38; cursor: not-allowed; filter: grayscale(0.5); }
.swatch.locked { display: inline-flex; align-items: center; justify-content: center; font-size: 10px; }
.fd-pat.premium { border-color: #c99a1e; }
.cosmetics { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.cos { display: flex; flex-direction: column; align-items: center; gap: 3px; width: 74px; padding: 5px 2px; border: 1px solid rgba(217,180,90,0.2); border-radius: 4px; }
.cos small { font-size: 11px; color: var(--dim); text-align: center; }
.cos.got { border-color: var(--gold); background: rgba(80,62,22,0.3); }
.cos.got small { color: var(--gold2); }
.cos.locked canvas { opacity: 0.35; filter: grayscale(0.7); }
.cos.premium { border-color: rgba(201,154,30,0.55); }

/* batch 3: the menu in two columns; campaign, daily, missions, friends */
#scr-menu .menu-buttons { width: min(860px, 94vw); display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; }
#scr-menu .menu-buttons .btn.big { margin: 0; padding: 9px 16px; font-size: 18px; }
.cp-wrap { display: grid; grid-template-columns: minmax(220px, 300px) 1fr; gap: 16px; min-height: 360px; }
.cp-list { display: flex; flex-direction: column; gap: 6px; }
.cp-card { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid rgba(217,180,90,0.25); border-radius: 4px; cursor: pointer; background: rgba(10,13,19,0.5); }
.cp-card b { flex: 1; font-weight: normal; color: var(--ink2); }
.cp-card.on { border-color: var(--gold2); box-shadow: 0 0 8px rgba(217,180,90,0.35); }
.cp-card.on b { color: var(--gold2); }
.cp-card.locked { opacity: 0.45; cursor: not-allowed; }
.cp-num { width: 34px; color: var(--gold); font-variant: small-caps; }
.cp-stars { color: var(--gold2); letter-spacing: 1px; white-space: nowrap; }
.cp-detail h3 { margin-top: 0; }
.cp-story { font-style: italic; color: var(--ink2); line-height: 1.5; }
.cp-terms { display: grid; gap: 4px; margin: 10px 0 14px; }
.cp-terms > div { display: flex; gap: 10px; border-bottom: 1px solid rgba(217,180,90,0.12); padding: 4px 0; }
.cp-terms span { width: 120px; color: var(--dim); flex: none; }
.cp-terms b { font-weight: normal; color: var(--ink); }
.cp-detail .btn.big { width: auto; display: inline-block; padding: 10px 34px; }
.dy-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.dy-head .btn.big { width: auto; margin: 0; padding: 10px 28px; }
.dy-date { color: var(--dim); font-variant: small-caps; }
.dy-twist { margin: 2px 0; color: var(--gold2); font-size: 22px; }
.dy-roll tr.me td { color: var(--gold2); }
.ms-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.ms-card { border: 1px solid rgba(217,180,90,0.25); border-radius: 4px; padding: 10px 12px; background: rgba(10,13,19,0.5); display: flex; flex-direction: column; gap: 6px; }
.ms-card.got { border-color: var(--gold); }
.ms-card b { color: var(--gold2); font-weight: normal; font-size: 18px; }
.ms-card p { margin: 0; color: var(--ink2); font-size: 14px; line-height: 1.4; flex: 1; }
.ms-top { display: flex; justify-content: space-between; }
.ms-tag { font-variant: small-caps; color: var(--dim); }
.ms-done { color: var(--gold2); }
.ms-goal { color: var(--ink); font-style: italic; }
.ms-card .btn { align-self: flex-start; }
#missionBox { position: absolute; top: 96px; left: 50%; transform: translateX(-50%); padding: 6px 14px; text-align: center; font-size: 14px; z-index: 30; pointer-events: none; max-width: 520px; }
#missionBox b { color: var(--gold2); font-weight: normal; }
#missionBox .ms-clock { margin-left: 8px; color: var(--ink); font-variant-numeric: tabular-nums; }
.mode-res { margin: 6px 0 10px; padding: 8px 12px; border: 1px solid var(--gold); border-radius: 4px; background: rgba(80,62,22,0.3); }
.mode-res.lost { border-color: rgba(200,80,60,0.6); background: rgba(80,22,22,0.25); }
.mode-btns { display: flex; gap: 8px; margin-top: 8px; }
.fr-me { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 6px; }
.fr-code { font-size: 30px; letter-spacing: 0.18em; color: var(--gold2); font-family: Consolas, monospace; }
.fr-add { display: flex; gap: 8px; align-items: center; margin: 12px 0; }
.fr-add input { width: 160px; text-transform: uppercase; letter-spacing: 0.1em; }
.fr-list { display: flex; flex-direction: column; gap: 4px; }
.fr-row { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border: 1px solid rgba(217,180,90,0.15); border-radius: 4px; }
.fr-row.on { border-color: rgba(217,180,90,0.45); }
.fr-dot { width: 10px; height: 10px; border-radius: 50%; background: #555; flex: none; }
.fr-row.on .fr-dot { background: #4cc06a; box-shadow: 0 0 6px #4cc06a; }
.fr-who { flex: 1; }
.fr-who b { font-weight: normal; color: var(--ink); }
.fr-who small { color: var(--dim); }
.fr-btns { display: flex; gap: 4px; }
#friendInvite { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 200; padding: 8px 14px; }
@media (max-width: 760px), (max-height: 560px) {
  .cp-wrap { grid-template-columns: 1fr; }
  .ms-list { grid-template-columns: 1fr; }
  #scr-menu .menu-buttons .btn.big { padding: 7px 12px; font-size: 15px; }
}

/* sign-in and the Royal Treasury */
#acctChip { position: absolute; top: 14px; right: 16px; max-width: 330px; padding: 8px 12px; z-index: 5; font-size: 14px; }
#acctChip b { color: var(--gold2); font-weight: normal; }
.ac-btns { display: flex; gap: 6px; align-items: center; margin-top: 6px; flex-wrap: wrap; }
.menu-foot .legal { font-size: 12px; }
.menu-foot .legal a { color: var(--dim); text-decoration: none; }
.menu-foot .legal a:hover { color: var(--gold2); }
.tr-test { background: rgba(140,100,20,0.35); border: 1px dashed var(--gold); padding: 6px 10px; border-radius: 4px; margin-bottom: 8px; color: var(--gold2); }
.tr-note { min-height: 20px; color: var(--gold2); margin: 6px 0; }
.tr-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.tr-item { border: 1px solid rgba(217,180,90,0.3); border-radius: 5px; padding: 10px; background: rgba(10,13,19,0.55); display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; }
.tr-item.bundle { grid-column: span 2; border-color: var(--gold2); background: rgba(60,46,14,0.45); }
.tr-item b { color: var(--gold2); font-weight: normal; font-size: 17px; }
.tr-item p { margin: 0; font-size: 13px; color: var(--ink2); flex: 1; }
.tr-item.owned { border-color: rgba(90,180,110,0.6); }
.tr-owned { color: #6fd08a; }
.tr-foot { margin-top: 12px; }
.tr-foot a { color: var(--gold2); }
@media (max-width: 760px) { .tr-grid { grid-template-columns: 1fr 1fr; } #acctChip { position: static; margin: 6px auto; } }

/* the army bar */
.grp.all b { color: var(--ink); }
.grp.on { border-color: var(--gold2); box-shadow: 0 0 6px rgba(217,180,90,0.6); }
.grp.new { color: var(--gold2); }
.grp i { font-style: normal; font-size: 9px; color: var(--dim); margin-left: 2px; padding: 0 2px; border-radius: 2px; }
.grp i:hover { color: #fff; background: rgba(180,50,40,0.8); }

/* the title screen: six small choices under the six main ones */
#scr-menu .menu-minor { position: relative; width: min(860px, 94vw); display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin-top: 10px; margin-bottom: auto; }
#scr-menu .menu-buttons { margin-bottom: 0; }
.menu-minor .btn { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 4px; font-size: 13px; background: rgba(20,24,33,0.72); color: var(--ink2); }
.menu-minor .btn i { font-style: normal; font-size: 18px; line-height: 1.1; }
.menu-minor .btn:hover { color: var(--gold2); }
.menu-rank { color: var(--dim); margin-left: 6px; }
@media (max-width: 760px), (max-height: 560px) { #scr-menu .menu-minor { grid-template-columns: repeat(3, 1fr); } .menu-minor .btn { flex-direction: row; justify-content: center; gap: 6px; } }
/* find a war */
.mm-box { border: 1px solid var(--gold); border-radius: 5px; padding: 10px 12px; margin-bottom: 12px; background: rgba(60,46,14,0.25); }
.mm-box h3 { margin-top: 0; }
.mm-btns { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.mm-btns .btn small { display: block; font-size: 11px; color: var(--dim); min-height: 13px; }
.mm-btns .btn.on { box-shadow: 0 0 10px rgba(217,180,90,0.8); border-color: var(--gold2); }
.mm-status { display: flex; align-items: center; gap: 10px; margin-top: 10px; padding: 8px; border-radius: 4px; background: rgba(10,13,19,0.6); }
.mm-status > div:not(.mm-spin) { flex: 1; }
.mm-spin { width: 18px; height: 18px; border: 2px solid rgba(217,180,90,0.25); border-top-color: var(--gold2); border-radius: 50%; animation: mmspin 0.9s linear infinite; flex: none; }
@keyframes mmspin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- the title screen: carved panels with gold emblems */
#scr-menu .menu-buttons .btn.big {
  display: grid; grid-template-columns: auto 1fr; align-items: center; column-gap: 14px;
  padding: 9px 18px 9px 11px; min-height: 66px; position: relative; overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 226, 150, 0.07), rgba(255, 226, 150, 0) 45%),
    linear-gradient(100deg, rgba(40, 33, 23, 0.95), rgba(19, 18, 17, 0.9) 70%);
  border: 1px solid rgba(217, 180, 90, 0.5); border-radius: 6px; color: var(--gold2);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45), inset 0 0 0 1px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 236, 190, 0.08);
  transition: border-color .15s, box-shadow .15s, transform .15s, background .15s;
}
#scr-menu .menu-buttons .btn.big::before {
  content: ''; position: absolute; inset: 3px; border: 1px solid rgba(217, 180, 90, 0.15); border-radius: 4px; pointer-events: none;
}
#scr-menu .menu-buttons .btn.big:hover {
  border-color: var(--gold2); transform: translateY(-1px);
  background:
    linear-gradient(180deg, rgba(255, 226, 150, 0.12), rgba(255, 226, 150, 0) 50%),
    linear-gradient(100deg, rgba(54, 44, 28, 0.96), rgba(24, 22, 19, 0.92) 70%);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.5), 0 0 16px rgba(217, 180, 90, 0.25), inset 0 0 0 1px rgba(0, 0, 0, 0.55);
}
#scr-menu .menu-buttons .btn.big:active { transform: translateY(0); }
.mb-ico {
  width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; color: var(--gold2); flex: none;
  background: radial-gradient(circle at 50% 35%, #3d311c, #14100a 72%);
  border: 1.5px solid var(--gold);
  box-shadow: inset 0 0 0 3px rgba(0, 0, 0, 0.55), inset 0 0 0 4px rgba(217, 180, 90, 0.3), 0 2px 6px rgba(0, 0, 0, 0.6);
  transition: box-shadow .15s, color .15s;
}
.mb-ico svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
#scr-menu .menu-buttons .btn.big:hover .mb-ico { color: #fff1c4; box-shadow: inset 0 0 0 3px rgba(0, 0, 0, 0.55), inset 0 0 0 4px rgba(242, 213, 138, 0.55), 0 0 12px rgba(242, 213, 138, 0.45); }
.mb-txt { display: block; font-size: 19px; font-variant: small-caps; letter-spacing: 0.05em; line-height: 1.15; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7); }
#scr-menu .menu-buttons .btn.big .mb-txt small { display: block; font-variant: normal; font-style: italic; letter-spacing: 0.02em; color: var(--ink2); font-size: 13px; margin-top: 3px; }
/* the tutorial, suggested to a newcomer: a gold glow and a ribbon instead of red */
#scr-menu .menu-buttons .btn.big.primary {
  border-color: var(--gold2);
  background:
    linear-gradient(180deg, rgba(255, 226, 150, 0.14), rgba(255, 226, 150, 0.02) 55%),
    linear-gradient(100deg, rgba(70, 54, 26, 0.96), rgba(26, 22, 16, 0.92) 70%);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45), 0 0 18px rgba(242, 213, 138, 0.3), inset 0 0 0 1px rgba(0, 0, 0, 0.55);
}
#scr-menu .menu-buttons .btn.big.primary::after {
  content: 'Start here'; position: absolute; top: 7px; right: 10px; padding: 1px 8px; border-radius: 9px;
  font-size: 10.5px; font-variant: normal; letter-spacing: 0.08em; text-transform: uppercase; color: #2a1d08; background: linear-gradient(180deg, #f6dc94, #c99a3a);
}
/* the six small ones */
#scr-menu .menu-minor .btn {
  display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 7px 4px 6px;
  font-size: 12.5px; font-variant: small-caps; letter-spacing: 0.05em; color: var(--ink2);
  background: linear-gradient(180deg, rgba(36, 31, 23, 0.9), rgba(17, 16, 15, 0.86));
  border: 1px solid rgba(217, 180, 90, 0.32); border-radius: 5px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 236, 190, 0.06);
}
#scr-menu .menu-minor .btn svg { width: 20px; height: 20px; fill: none; stroke: var(--gold); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; transition: stroke .15s; }
#scr-menu .menu-minor .btn:hover { color: var(--gold2); border-color: var(--gold); }
#scr-menu .menu-minor .btn:hover svg { stroke: var(--gold2); }
@media (max-width: 760px), (max-height: 560px) {
  #scr-menu .menu-buttons .btn.big { min-height: 50px; padding: 6px 12px 6px 8px; column-gap: 10px; }
  .mb-ico { width: 34px; height: 34px; }
  .mb-ico svg { width: 19px; height: 19px; }
  .mb-txt { font-size: 15px; }
  #scr-menu .menu-buttons .btn.big .mb-txt small { font-size: 10.5px; }
  #scr-menu .menu-minor .btn { flex-direction: row; justify-content: center; gap: 6px; }
  #scr-menu .menu-minor .btn svg { width: 16px; height: 16px; }
}
/* aid to an ally: a quarter, half or all */
.gift-row { display: flex; align-items: center; gap: 4px; margin: 3px 0; flex-wrap: wrap; }
.gift-row > span { min-width: 110px; color: var(--ink2); font-size: 13px; }
.gift-row .btn.small { padding: 3px 8px; }

/* the Age each realm has reached, as a numeral, on the leaderboard */
.lbr { grid-template-columns: 18px 12px 1fr 26px 40px 50px; }
.lbr .v.age { text-align: center; color: var(--gold2); font-variant: small-caps; letter-spacing: 0.04em; }
.lbh { gap: 12px; }

/* the title screen's one banner (only once an ad unit is set in js/ads.js, and never during a war) */
.menu-ad { width: min(728px, 92vw); margin: 14px 0 0; min-height: 90px; }
.menu-ad small { display: block; color: var(--dim); font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; margin-bottom: 3px; }
@media (max-height: 520px) { .menu-ad { display: none; } }

/* the lord's own page: the name and the account line */
.menu-me { cursor: pointer; border-radius: 4px; padding: 2px 4px; margin: -2px -4px; }
.menu-me:hover, .menu-me:focus-visible { color: var(--gold2); background: rgba(217,180,90,0.08); outline: none; }
.ac-me { background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; }
.ac-me:hover b { text-decoration: underline; }
.pf-name { margin: 6px 0 4px; }
.pf-name label { display: block; color: var(--dim); font-size: 13px; margin-bottom: 4px; }
.pf-row { display: flex; gap: 8px; align-items: center; }
.pf-row input { flex: 1; max-width: 320px; font: inherit; font-size: 18px; padding: 6px 10px; background: rgba(0,0,0,0.35); color: var(--ink, #f1e6cc); border: 1px solid rgba(217,180,90,0.35); border-radius: 4px; }
.pf-row input:focus { outline: none; border-color: var(--gold2); }
.pf-foot { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; margin-top: 4px; }
.pf-acct { margin-top: 16px; padding-top: 12px; border-top: 1px solid rgba(217,180,90,0.2); display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; color: var(--dim); font-size: 14px; }

/* a notice that says where: click it to go there */
#hud #toast .toastmsg.go { pointer-events: auto; cursor: pointer; }
.toastmsg.go:hover { filter: brightness(1.18); }
.toastmsg.go small { display: block; font-size: 12px; opacity: 0.75; margin-top: 2px; letter-spacing: 0.04em; }
.alert.panel { cursor: pointer; }

/* multiplayer: ping to the host, under the war clock */
.netping { font-size: 11.5px; color: var(--dim); letter-spacing: 0.03em; text-align: center; margin-top: -2px; }
.netping.good { color: #a9dc8a; } .netping.fair { color: #e8c25a; } .netping.poor { color: #ff8f78; }

/* the army limit reached */
#stCompanies.full { color: #ff9f86; }
