/* The battlefield: full screen 3D view with a slim HUD. */
.bf { position: fixed; inset: 0; z-index: 40; background: #0e0b08; user-select: none; -webkit-user-select: none; touch-action: none; }
.bf-canvas { position: absolute; inset: 0; }
.bf-canvas canvas { display: block; width: 100%; height: 100%; }
.bf.moving .bf-canvas { cursor: crosshair; }
.bf-top {
  position: absolute; left: 0; right: 0; top: 0; display: flex; align-items: center; gap: 12px; padding: 6px 10px;
  padding-top: max(6px, env(safe-area-inset-top)); background: linear-gradient(rgba(20, 15, 10, .92), rgba(20, 15, 10, .7));
  border-bottom: 1px solid var(--line); pointer-events: auto;
}
.bf-res { display: flex; gap: 12px; flex-wrap: wrap; }
.bf-r { display: flex; align-items: center; gap: 5px; font-weight: 700; font-variant-numeric: tabular-nums; }
.bf-r svg { width: 20px; height: 20px; display: block; }
/* how many villagers are bringing this resource in */
.bf-w { font-style: normal; font-size: .82em; min-width: 1.5em; padding: 0 3px; text-align: center; line-height: 1.45; border: 1px solid rgba(201, 162, 74, .55); border-radius: 3px; background: rgba(0, 0, 0, .35); color: var(--gold2); }
.bf-w.none { color: var(--muted); border-color: rgba(201, 162, 74, .2); }
.bf-title { flex: 1; text-align: center; min-width: 0; display: flex; flex-direction: column; line-height: 1.15; }
.bf-title b { font-family: var(--head); color: var(--gold2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bf-clock { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.bf-status { font-size: 12px; color: #f0b36a; font-weight: 600; }
.bf-status.hidden { display: none; }
.bf-buttons { display: flex; gap: 6px; }
.bf-minimap { display: block; width: 160px; height: 160px; border-radius: 3px; cursor: pointer; touch-action: none; }
.bf-anchor { position: fixed; width: 32px; height: 32px; margin: -16px 0 0 -16px; pointer-events: none; z-index: 45; filter: drop-shadow(0 1px 2px rgba(0,0,0,.6)); }
.bf-anchor svg { display: block; }
.bf-box {position: fixed; border: 1px solid #f0d27a; background: rgba(240, 210, 122, .12); pointer-events: none; z-index: 45; }
.bf-hint {
  position: absolute; right: 10px; bottom: 198px; max-width: 380px; display: flex; gap: 8px; align-items: center;
  background: rgba(20, 15, 10, .88); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font-size: 14px; color: var(--muted);
}
.bf-turn { display: none; }
@media (max-width: 760px), (max-height: 460px) {
  .bf-top { gap: 8px; padding: 4px 8px; }
  .bf-res { gap: 8px; font-size: 14px; }
  .bf-r svg { width: 16px; height: 16px; }
  .bf-title { display: none; }
  .bf-buttons { margin-left: auto; }
  .bf-hint { left: 8px; right: 8px; bottom: 132px; max-width: none; font-size: 13px; }
}
@media (orientation: portrait) and (max-width: 760px) {
  .bf-turn { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(10, 8, 6, .9); z-index: 2; padding: 24px; text-align: center; }
  .bf-turn > div { display: flex; flex-direction: column; gap: 10px; align-items: center; }
  .bf-turn b { font-family: var(--head); color: var(--gold2); font-size: 20px; }
  .bf-turn span { color: var(--muted); }
  .bf-res { font-size: 13px; gap: 6px; }
  .bf-buttons .btn { padding: 4px 8px; font-size: 13px; }
}
.bf-loading { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; background: rgba(14, 11, 8, .92); }
.bf-loading > div { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.bf-loading b { font-family: var(--head); color: var(--gold2); font-size: 22px; }
.bf-loading span { color: var(--muted); }

/* building and training buttons */
.bf-build { display: flex; gap: 6px; flex-wrap: wrap; }
.bf-bbtn {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 5px 8px; border-radius: 8px; cursor: pointer;
  background: linear-gradient(#3a2e22, #2b2219); border: 1px solid var(--line2); color: var(--text); min-width: 84px;
}
.bf-bbtn:hover { border-color: var(--gold); }
.bf-bbtn b { font-size: 13px; }
.bf-bbtn.poor { opacity: .55; }
.bf-bbtn.poor .bf-cost { color: #ff9a8a; }
.bf-costs { display: flex; gap: 6px; }
.bf-cost { display: inline-flex; align-items: center; gap: 2px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.bf-cost svg { width: 13px; height: 13px; display: block; }
.bf-queue { display: flex; gap: 4px; flex-wrap: wrap; }
.bf-q { position: relative; overflow: hidden; background: #17110c; border: 1px solid var(--line2); color: var(--text); border-radius: 6px; padding: 4px 8px; font-size: 12px; cursor: pointer; }
.bf-q small { color: #ff9a8a; }
.bf-qbar { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--gold); }
.bf-r.full b { color: #ff9a8a; }
@media (max-width: 760px), (max-height: 460px) {
  .bf-bbtn { min-width: 70px; padding: 4px 6px; }
}
/* ages, locked buttons, the end of the game */
.bf-age { font-family: var(--head); font-size: 13px; color: var(--gold2); border: 1px solid var(--line2); border-radius: 6px; padding: 1px 8px; white-space: nowrap; }
.bf-bbtn.locked { opacity: .5; }
.bf-lock { font-size: 11px; color: var(--muted); }
.bf-bbtn.age { border-color: var(--gold); background: linear-gradient(#4a3a20, #2e2416); }
.bf-end { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(10, 8, 6, .55); z-index: 5; }
.bf-end > div { display: flex; flex-direction: column; align-items: center; gap: 10px; background: rgba(28, 22, 17, .95); border: 1px solid var(--gold); border-radius: 14px; padding: 26px 34px; box-shadow: 0 20px 60px #000; text-align: center; }
.bf-end b { font-family: var(--head); font-size: 44px; letter-spacing: .08em; color: var(--gold2); }
.bf-end.lost b { color: #e0705f; }
.bf-end span { color: var(--muted); }
@media (max-width: 760px), (max-height: 460px) { .bf-age { display: none; } .bf-end b { font-size: 32px; } }

/* ---------- relics: the scoreboard, the hold-all countdown, the results ---------- */
.bf-score { position: absolute; top: 52px; right: 10px; z-index: 3; min-width: 168px; max-width: 220px; background: rgba(20, 16, 12, .82);
  border: 1px solid rgba(201, 162, 74, .35); border-radius: 10px; padding: 6px 8px; font-size: 12.5px; pointer-events: none; }
.bf-score:empty { display: none; }
.bf-shead { font-family: var(--head); color: var(--gold2); font-size: 12px; margin-bottom: 4px; white-space: nowrap; }
.bf-srow { display: flex; align-items: center; gap: 6px; padding: 1px 0; color: var(--text); }
.bf-srow span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bf-srow b { font-variant-numeric: tabular-nums; color: var(--gold2); }
.bf-srow em { font-style: normal; display: flex; align-items: center; gap: 2px; color: #f2c14e; font-weight: 700; }
.bf-srow.me span { color: var(--gold2); font-weight: 700; }
.bf-srow.out { opacity: .5; text-decoration: line-through; }
.bf-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; border: 1px solid rgba(0, 0, 0, .6); flex: none; margin-right: 4px; vertical-align: -1px; }
/* the Artifacts a Town Hall keeps, on its card */
.bf-relics { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 2px; }
.bf-relic { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px 1px 4px; border: 1px solid rgba(201, 162, 74, .45); border-radius: 10px; background: rgba(0, 0, 0, .3); font-size: 13px; color: var(--gold2); white-space: nowrap; }
.bf-gem { display: inline-block; width: 8px; height: 8px; background: #f2c14e; transform: rotate(45deg); box-shadow: 0 0 6px #f2c14e; margin: 0 3px; }
.bf-hold { position: absolute; top: 56px; left: 50%; transform: translateX(-50%); z-index: 4; padding: 8px 16px; border-radius: 10px;
  background: rgba(120, 24, 18, .92); border: 1px solid #e0705f; color: #fff2e6; font-weight: 700; font-size: 14px; white-space: nowrap; box-shadow: 0 6px 24px #000; }
.bf-hold.mine { background: rgba(110, 82, 18, .94); border-color: var(--gold2); }
.bf-hold.hidden { display: none; }
.bf-results { border-collapse: collapse; margin: 6px 0; font-size: 14px; }
.bf-results th { color: var(--muted); font-weight: 600; font-size: 12px; padding: 2px 10px; text-align: right; }
.bf-results td { padding: 4px 10px; text-align: right; font-variant-numeric: tabular-nums; border-top: 1px solid rgba(201, 162, 74, .15); }
.bf-results td:nth-child(2), .bf-results th:nth-child(2) { text-align: left; }
.bf-results tr.me td { color: var(--gold2); font-weight: 700; }
@media (max-width: 760px), (max-height: 460px) {
  .bf-score { top: 44px; right: 6px; min-width: 0; max-width: 150px; font-size: 11px; padding: 4px 6px; }
  .bf-srow:nth-child(n+5) { display: none; }
  .bf-hold { top: 46px; font-size: 12px; padding: 5px 10px; }
  .bf-results { font-size: 12px; } .bf-results td, .bf-results th { padding: 2px 6px; }
  .bf-end > div { padding: 14px 16px; gap: 6px; max-height: 94vh; overflow: auto; }
}
.bf-left { display: flex; align-items: center; gap: 6px; font-weight: 700; }
.bf-left .svg svg { width: 18px; height: 18px; display: block; }
.bf-left small { font-weight: 400; color: var(--muted); }
/* the Controls settings window */
.bf-set { position: absolute; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; background: rgba(8, 6, 4, .55); padding: 12px; }
.bf-set-box {
  width: min(520px, 100%); max-height: calc(100% - 8px); overflow: auto; background: rgba(24, 18, 12, .98); border: 1px solid var(--line2);
  border-radius: 12px; box-shadow: 0 10px 40px rgba(0, 0, 0, .6); display: flex; flex-direction: column;
}
.bf-set-head { padding: 12px 16px; border-bottom: 1px solid var(--line); }
.bf-set-head b { font-family: var(--head); color: var(--gold2); font-size: 18px; }
.bf-set-rows { display: flex; flex-direction: column; padding: 6px 16px; }
.bf-set-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 9px 0; border-bottom: 1px solid rgba(255, 255, 255, .06); cursor: pointer; }
.bf-set-row:last-child { border-bottom: 0; }
.bf-set-name { display: flex; flex-direction: column; min-width: 0; }
.bf-set-name small { color: var(--muted); font-size: 12px; }
.bf-set-ctl { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.bf-set-ctl input[type=range] { width: 150px; accent-color: #d9b45a; }
.bf-set-ctl input[type=checkbox] { width: 20px; height: 20px; accent-color: #d9b45a; }
.bf-set-ctl select { max-width: 210px; background: #1b140d; color: inherit; border: 1px solid var(--line2); border-radius: 6px; padding: 5px 6px; font: inherit; font-size: 13px; }
.bf-set-val { width: 42px; text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; }
.bf-set-sec { font-family: var(--head); color: var(--gold2); font-size: 13px; letter-spacing: .08em; text-transform: uppercase; padding: 12px 0 2px; }
.bf-set-sec:first-child { padding-top: 6px; }
.bf-set-box { max-height: 100%; overflow-y: auto; }
.bf-set-foot { display: flex; justify-content: space-between; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--line); }
@media (max-width: 760px), (max-height: 460px) {
  .bf-set-row { padding: 6px 0; }
  .bf-set-ctl input[type=range] { width: 110px; }
  .bf-set-head { padding: 8px 12px; }
  .bf-set-rows { padding: 2px 12px; }
  .bf-set-foot { padding: 8px 12px; }
}
.bf-gear { display: inline-flex; align-items: center; gap: 5px; }
.bf-gear .svg svg { display: block; }
@media (max-width: 760px), (max-height: 460px) { .bf-gear-t { display: none; } }

/* ---------- the bar along the bottom: command card, selection, minimap ---------- */
.bf-bar {
  position: absolute; left: 0; right: 0; bottom: 0; height: 188px; z-index: 3; display: flex; gap: 10px; padding: 8px 10px;
  padding-bottom: max(8px, env(safe-area-inset-bottom)); box-sizing: border-box;
  background: linear-gradient(#2a2017, #17110b); border-top: 2px solid #8a6a2c; box-shadow: 0 -6px 24px rgba(0, 0, 0, .55);
}
.bf-cmd, .bf-info, .bf-mini { background: rgba(0, 0, 0, .28); border: 1px solid var(--line2); border-radius: 6px; padding: 5px; box-sizing: border-box; }
.bf-cmd { flex: none; width: 322px; display: grid; grid-template-columns: repeat(5, 58px); grid-auto-rows: 50px; gap: 4px; align-content: start; overflow-y: auto; scrollbar-width: none; }
.bf-info { flex: 1; min-width: 0; overflow: hidden; display: flex; }
.bf-mini { flex: none; display: flex; align-items: center; }
.bf-cb {
  position: relative; padding: 0; overflow: hidden; border-radius: 5px; cursor: pointer; color: #f2e6c8;
  background: linear-gradient(#4a3a28, #2b2118); border: 1px solid #77603a; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .12);
}
.bf-cb:hover { border-color: var(--gold2); filter: brightness(1.15); }
.bf-cb:active { transform: translateY(1px); }
.bf-cb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.bf-cb > .svg { position: absolute; inset: 0 0 12px 0; display: flex; align-items: center; justify-content: center; }
.bf-cb > .svg svg { width: 24px; height: 24px; display: block; }
/* Artifact Reforged's pixel-art button pictures: on a parchment tile, as they sat on white there */
.bf-cb > .px { position: absolute; inset: 0 0 12px 0; display: flex; align-items: center; justify-content: center; }
.bf-cb > .px img { position: static; width: 34px; height: 34px; object-fit: contain; background: #efe6cf; border-radius: 4px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .45); }
.bf-cb.on > .px img { background: #ffe9a8; }
.bf-cb kbd { position: absolute; left: 2px; top: 2px; font: 700 10px/1 var(--body, sans-serif); color: #fff; background: rgba(0, 0, 0, .62); border-radius: 3px; padding: 2px 3px; }
.bf-cb-foot { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; gap: 3px; padding: 1px 1px 2px; background: rgba(12, 9, 6, .78);
  font-size: 10px; line-height: 1.1; font-weight: 700; white-space: nowrap; }
.bf-cb-foot .bf-cost { font-size: 10px; gap: 1px; color: #f2e6c8; }
.bf-cb-foot .bf-cost svg { width: 9px; height: 9px; }
.bf-cb-foot.lock { color: #c9b891; font-weight: 600; font-size: 9px; }
.bf-cb.poor img { filter: grayscale(.6) brightness(.6); }
.bf-cb.poor .bf-cost { color: #ff9a8a; }
.bf-cb.locked img { filter: grayscale(1) brightness(.4); }
.bf-cb.on { border-color: var(--gold2); background: linear-gradient(#7a5f22, #4a3814); }
.bf-cb.on.red { border-color: #e0705f; background: linear-gradient(#7a2a20, #461712); }
.bf-cb.gold { border-color: var(--gold2); background: linear-gradient(#6a5220, #3c2e14); }
.bf-cb.age { border-color: var(--gold2); background: linear-gradient(#6a5220, #3c2e14); color: #ffe08a; }
/* the tip that shows over a button */
.bf-tip { position: fixed; z-index: 46; width: 260px; box-sizing: border-box; display: flex; flex-direction: column; gap: 4px; padding: 8px 10px; pointer-events: none;
  background: rgba(20, 15, 10, .97); border: 1px solid #8a6a2c; border-radius: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, .6); font-size: 13px; color: var(--muted); }
.bf-tip.hidden { display: none; }
.bf-tip b { color: var(--gold2); font-size: 14px; display: flex; justify-content: space-between; gap: 8px; }
.bf-tip kbd { font: 700 11px/1.4 var(--body, sans-serif); color: #fff; background: rgba(255, 255, 255, .14); border-radius: 3px; padding: 0 5px; }
.bf-tip-lock { color: #f0b36a; }
/* who is selected */
.bf-card { display: flex; gap: 12px; align-items: flex-start; min-width: 0; padding: 4px; }
.bf-port { flex: none; width: 96px; height: 96px; border: 2px solid #8a6a2c; border-radius: 6px; overflow: hidden; background: #120d08; display: flex; align-items: center; justify-content: center; }
.bf-port img { width: 100%; height: 100%; object-fit: cover; display: block; }
.bf-port.res svg { width: 56px; height: 56px; display: block; }
.bf-card-main { display: flex; flex-direction: column; gap: 5px; min-width: 0; flex: 1; max-width: 420px; }
.bf-card-main > b { font-family: var(--head); color: var(--gold2); font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bf-card-main > b small { font-family: var(--body, sans-serif); font-size: 12px; color: #e0705f; }
.bf-hprow { display: flex; align-items: center; gap: 8px; }
.bf-hprow small { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.bf-hp { display: block; flex: 1; max-width: 200px; height: 8px; background: #0a0705; border: 1px solid #4a3a24; border-radius: 4px; overflow: hidden; }
.bf-hp i { display: block; height: 100%; }
.bf-hp i.good { background: #58b84a; } .bf-hp i.mid { background: #d9b02e; } .bf-hp i.low { background: #d24a35; }
.bf-hp.build i { background: var(--gold2); }
.bf-stats { display: flex; gap: 14px; }
.bf-stat { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums; }
.bf-stat .svg svg { width: 14px; height: 14px; display: block; color: #c9b891; }
.bf-doing { font-size: 13px; color: var(--muted); }
.bf-many { display: flex; flex-direction: column; gap: 5px; padding: 4px; min-width: 0; }
.bf-group { display: flex; flex-wrap: wrap; gap: 3px; }
.bf-unit { position: relative; width: 38px; height: 44px; padding: 0; border: 1px solid #77603a; border-radius: 4px; overflow: hidden; background: #120d08; cursor: pointer; }
.bf-unit:hover { border-color: var(--gold2); }
.bf-unit img { width: 100%; height: 38px; object-fit: cover; display: block; }
.bf-unit .bf-hp { position: absolute; left: 0; right: 0; bottom: 0; height: 5px; max-width: none; border: 0; border-radius: 0; }
.bf-more { align-self: center; color: var(--muted); font-weight: 700; padding: 0 6px; }
.bf-info .bf-queue { margin-top: 2px; }
.bf-info .bf-q { width: 36px; height: 36px; padding: 0; display: flex; align-items: center; justify-content: center; color: #ffe08a; }
.bf-info .bf-q img { width: 100%; height: 100%; object-fit: cover; display: block; }
.bf-info .bf-q .svg svg { width: 20px; height: 20px; display: block; }
.bf-info .bf-q small { position: absolute; left: 40px; top: 10px; white-space: nowrap; }
.bf-info .bf-q:first-child { overflow: visible; }
.bf-info .bf-q:hover { border-color: #e0705f; }

/* phones: no solid bar. The minimap sits in the corner; a chip for the selection and one row of buttons beside it */
@media (max-width: 760px), (max-height: 460px) {
  .bf-bar {
    left: 6px; right: 6px; bottom: 6px; height: auto; padding: 0; margin-bottom: env(safe-area-inset-bottom); background: none; border: 0; box-shadow: none;
    display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "mini info" "mini cmd"; gap: 4px 6px; align-items: end; pointer-events: none;
  }
  .bf-bar > * { pointer-events: auto; background: rgba(20, 15, 10, .9); }
  .bf-mini { grid-area: mini; padding: 3px; }
  .bf-minimap { width: 108px; height: 108px; }
  .bf-info { grid-area: info; justify-self: start; max-width: 100%; padding: 3px 6px 3px 3px; }
  .bf-cmd { grid-area: cmd; width: auto; justify-self: start; max-width: 100%; gap: 4px; display: flex; overflow-x: auto; overflow-y: hidden; padding: 4px; touch-action: pan-x; scrollbar-width: none; }
  .bf-cmd::-webkit-scrollbar { display: none; }
  .bf-cmd:empty, .bf-info:empty { display: none; }
  .bf-cb { flex: none; width: 54px; height: 50px; }
  .bf-card { gap: 8px; padding: 0; align-items: center; }
  .bf-port { width: 44px; height: 44px; border-width: 1px; }
  .bf-port.res svg { width: 28px; height: 28px; }
  .bf-card-main { gap: 2px; }
  .bf-card-main > b { font-size: 14px; }
  .bf-stats { display: none; }
  .bf-hp { min-width: 70px; height: 6px; }
  .bf-doing, .bf-hprow small { font-size: 11.5px; }
  .bf-doing { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .bf-many { padding: 0; gap: 2px; }
  .bf-many > .bf-doing { display: none; }
  .bf-group { flex-wrap: nowrap; overflow-x: auto; touch-action: pan-x; scrollbar-width: none; }
  .bf-unit { flex: none; width: 32px; height: 38px; }
  .bf-unit img { height: 33px; }
  .bf-info .bf-q { width: 30px; height: 30px; }
  .bf-info .bf-q small { left: 34px; top: 8px; }
}

/* defeated and looking round: the way back in */
.bf-again { position: absolute; top: 58px; left: 50%; transform: translateX(-50%); z-index: 4; box-shadow: 0 6px 24px #000; }
.bf-end > div > span { max-width: 420px; }

/* ---------- combat groups: numbered chips above the bar (under the top bar on phones) ---------- */
.bf-groups { position: absolute; left: 10px; bottom: 196px; z-index: 3; display: flex; gap: 5px; flex-wrap: wrap; max-width: 60%; }
.bf-groups:empty { display: none; }
.bf-sq { display: flex; align-items: baseline; gap: 5px; min-width: 40px; height: 34px; padding: 0 9px; box-sizing: border-box; border-radius: 6px; cursor: pointer;
  background: rgba(20, 15, 10, .88); color: var(--text); border: 1px solid var(--line2); font: 700 15px/32px var(--body, sans-serif); }
.bf-sq b { color: var(--gold2); font-size: 16px; }
.bf-sq small { color: var(--muted); font-size: 12px; font-weight: 500; }
.bf-sq.on { border-color: var(--gold2); box-shadow: inset 0 0 0 1px var(--gold); background: rgba(58, 44, 28, .95); }
.bf-sq.act { color: var(--gold2); font-size: 13px; }
.bf-sq:hover { border-color: var(--gold); }
@media (max-width: 760px), (max-height: 460px) {
  .bf-groups { left: 6px; top: 44px; bottom: auto; max-width: calc(100% - 170px); gap: 4px; }
  .bf-sq { min-width: 36px; height: 32px; padding: 0 7px; line-height: 30px; }
}

/* the Artifacts' powers you hold, beside your age */
.bf-powers { display: inline-flex; gap: 5px; align-items: center; margin-left: 6px; }
.bf-powers:empty { display: none; }
.bf-powers .bf-gem { width: 9px; height: 9px; }

/* the Market: send resources to another player */
.bf-trib { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; font-size: 12px; margin-top: 3px; }
.bf-trib-to { background: #2a1f14; color: #efe6d4; border: 1px solid #6b5636; border-radius: 4px; font: inherit; padding: 1px 3px; max-width: 110px; }
.bf-trib-b { background: #3a2c1c; border: 1px solid #6b5636; border-radius: 4px; padding: 2px; width: 26px; height: 24px; cursor: pointer; }
.bf-trib-b .svg, .bf-trib-b svg { width: 18px; height: 18px; display: block; }
.bf-trib-b:hover { border-color: #f2c14e; }
.bf-xp { color: #f2c14e; font-weight: 600; }

/* ---------- chat on the battlefield (client/js/game/chat.js) ---------- */
.bf-chat-btn { position: relative; display: inline-flex; align-items: center; gap: 5px; }
.bf-chat-btn .svg svg { display: block; }
.bf-chat-n { min-width: 16px; height: 16px; box-sizing: border-box; padding: 0 4px; border-radius: 999px;
  background: var(--red2); color: #fff; font: 700 11px/16px var(--body, sans-serif); font-style: normal; text-align: center; }
.bf-chat-n.hidden { display: none; }
.bf-chat { position: absolute; left: 10px; bottom: 196px; z-index: 6; width: 420px; max-width: calc(100% - 20px); height: 300px; max-height: calc(100% - 260px);
  min-width: 240px; min-height: 150px; box-sizing: border-box; display: flex; flex-direction: column; isolation: isolate;
  border: 1px solid transparent; user-select: text; -webkit-user-select: text; touch-action: auto; }
/* the window's backing is drawn apart from its contents, so it can be made see-through (Settings) without fading the writing */
.bf-chat::before { content: ""; position: absolute; inset: -1px; z-index: -1; pointer-events: none; opacity: var(--chat-back, .9);
  background: rgb(20, 15, 10); border: 1px solid var(--line2); border-radius: 8px; box-shadow: 0 8px 28px rgba(0, 0, 0, .6); }
.bf-chat .msg { text-shadow: 0 1px 2px #000, 0 0 3px #000; }
/* the corner that resizes it: top-right on a desktop (the window is pinned bottom-left), bottom-right on a phone */
.bf-chat-grip { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; z-index: 2; cursor: nesw-resize; touch-action: none;
  background: linear-gradient(45deg, transparent 50%, var(--gold2) 50%, var(--gold2) 58%, transparent 58%, transparent 68%, var(--gold2) 68%, var(--gold2) 76%, transparent 76%); opacity: .75; }
.bf-chat-grip:hover { opacity: 1; }
.bf-chat.hidden { display: none; }
.bf-chat-head { display: flex; align-items: center; gap: 6px; padding: 6px 22px 0 8px; }
.bf-chat-tabs { flex: 1; min-width: 0; padding: 0; flex-wrap: wrap; }
.bf-chat-x { font-size: 20px; line-height: 1; padding: 0 8px; height: 28px; }
.bf-chat .chat-log { padding: 6px 10px; gap: 3px; }
.bf-chat .msg { font-size: 15px; }
.bf-chat .chat-form { padding: 6px 8px; gap: 6px; }
.bf-chat .chat-form input { padding: 6px 10px; font-size: 16px; }
/* the last few lines, over the map for a moment */
.bf-feed { position: absolute; left: 10px; bottom: 238px; z-index: 3; width: 440px; max-width: 46%; display: flex; flex-direction: column; gap: 3px; align-items: flex-start; pointer-events: none; }
.bf-feed-line { background: rgba(14, 10, 7, .78); border-radius: 4px; padding: 3px 8px; animation: bf-feed 12s linear forwards; }
.bf-feed-line .msg { display: inline; font-size: 15px; text-shadow: 0 1px 2px #000; }
.bf-feed-line .time { display: none; }
.bf-feed-room { color: var(--gold2); font-weight: 700; font-size: 13px; margin-right: 6px; }
@keyframes bf-feed { 0%, 85% { opacity: 1; } 100% { opacity: 0; } }
@media (max-width: 760px), (max-height: 460px) {
  .bf-chat { left: 6px; top: 42px; bottom: auto; width: 360px; max-width: calc(100% - 12px); height: 190px; max-height: calc(100% - 50px); }
  .bf-chat .msg, .bf-feed-line .msg { font-size: 14px; }
  .bf-chat-grip { top: auto; bottom: -6px; width: 26px; height: 26px; cursor: nwse-resize; transform: scaleY(-1); }
  .bf-feed { left: 6px; top: 82px; bottom: auto; max-width: 56%; }
}
@media (orientation: portrait) and (max-width: 760px) {
  .bf-chat { height: 300px; }
}

/* numbers raised by upgrades: the added part in green; on a phone (where the numbers row is hidden) a "+" by the name */
.bf-plus { color: #7fd66b; font-style: normal; font-weight: 700; margin-left: 3px; }
.bf-up { display: inline-block; margin-left: 6px; min-width: 15px; height: 15px; border-radius: 3px; background: #2f6b2a; color: #d9ffcf; font: 700 13px/15px var(--body, sans-serif); font-style: normal; text-align: center; vertical-align: 2px; }

/* under attack: the minimap's frame flashes red while a fight is marked on it */
.bf-mini.alarm { animation: bf-alarm .5s steps(1, end) infinite; }
@keyframes bf-alarm { 0% { box-shadow: 0 0 0 3px #ff2a1a, 0 0 22px 4px rgba(255, 42, 26, .85); } 50% { box-shadow: 0 0 0 0 transparent; } }
@media (prefers-reduced-motion: reduce) { .bf-mini.alarm { animation: none; box-shadow: 0 0 0 3px #ff2a1a; } }

/* ---- alliances ---- */
.bf-ally-btn.on { box-shadow: inset 0 0 0 1px var(--gold); }
.bf-ally .bf-set-box { width: min(560px, 100%); }
.bf-ally-rows { gap: 8px; padding-bottom: 12px; user-select: text; }
.bf-ally-hint, .bf-ally-note, .bf-ally-wait { margin: 0; color: var(--muted); font-size: 13px; }
.bf-ally-hint { color: var(--text); font-size: 14px; padding-top: 8px; }
.bf-ally-wait { color: #f2c14e; padding-top: 8px; }
.bf-ally-team { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; background: rgba(0, 0, 0, .22); }
.bf-ally-thead { display: flex; align-items: center; gap: 8px; }
.bf-ally-thead b { font-family: var(--head); color: var(--gold2); }
.bf-ally-thead small { margin-left: auto; color: var(--muted); }
.bf-ally-members { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 13px; }
.bf-ally-members > span, .bf-ally-name { display: inline-flex; align-items: center; gap: 5px; }
.bf-ally-tag { font-style: normal; font-size: 11px; font-weight: 700; letter-spacing: .04em; padding: 0 6px; border-radius: 999px; border: 1px solid var(--line2); color: var(--muted); white-space: nowrap; }
.bf-ally-tag.clan { color: #f3dca0; border-color: #8b6a2c; }
.bf-ally-tag.wait { color: #f2c14e; border-color: #8b6a2c; }
.bf-ally-form { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.bf-ally-form input[type=text] { flex: 1; min-width: 110px; background: #1b140d; color: inherit; border: 1px solid var(--line2); border-radius: 6px; padding: 7px 9px; font: inherit; font-size: 14px; }
.bf-ally-form.wide input[type=text]:first-child { flex: 2; min-width: 160px; }
.bf-ally-check { display: flex; align-items: flex-start; gap: 8px; font-size: 14px; cursor: pointer; padding: 3px 0; }
.bf-ally-check input { width: 18px; height: 18px; flex: none; accent-color: #d9b45a; margin: 1px 0 0; }
.bf-ally-list { display: flex; flex-direction: column; }
.bf-ally-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px solid rgba(255, 255, 255, .06); }
.bf-ally-who { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; min-width: 0; }
.bf-ally-who small { flex-basis: 100%; color: var(--muted); font-size: 12px; }
.bf-ally-acts { display: flex; gap: 6px; flex: none; }
.bf-ally-ais { display: flex; flex-wrap: wrap; gap: 6px; }
.bf-ally-ais .btn { display: inline-flex; align-items: center; gap: 6px; }
.bf-ally-leave { display: flex; flex-direction: column; align-items: flex-start; gap: 5px; padding-top: 10px; }
.bf-steam { color: var(--muted); font-weight: 400; }
.bf-srow span.pal { color: #9fe0a6; }
.bf-srow.side { border-bottom: 1px solid var(--line); margin-bottom: 2px; padding-bottom: 2px; }
.bf-srow.side span { font-family: var(--head); color: var(--gold2); }
