/* Pistons of War UI.
   Menu: the "Option A" design, dark panels with one accent colour per nation.
   In game: Age of Empires 2 layout (resources top left, command panel bottom
   left, selected unit bottom centre, minimap bottom right) in a dieselpunk
   skin after Aran's reference: copper frames with bolts, oxblood leather
   plaques with gear medallions, gauges and a parchment telegraph log.
   Barlow Condensed for labels and numbers, Barlow for text, Special Elite
   for telegrams. */

:root {
  --font-label: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", sans-serif;
  --font-text: "Barlow", "Segoe UI", "Helvetica Neue", sans-serif;
  --text: #ececec;
  --muted: #a8a8a8;
  --soft: #c9c9c9;
  --good: #6be04e;
  --warn: #f2c14e;
  --bad: #ff4a30;
  --font-type: "Special Elite", "Courier New", monospace;
  --sidebar: 304px;
  /* Brass and iron for the in-game skin. */
  --brass-hi: #f3d9a0;
  --brass: #b88d4a;
  --brass-mid: #8c6630;
  --brass-lo: #4e3517;
  --iron: #1d1915;
  --iron-2: #27211b;
  --iron-hi: #3a3128;
  --engrave: #d7b77a;
  --paper: #ecdfbf;
  --ink: #2b2116;
}

[data-faction="de"], [data-faction="none"] { --accent: #ffb81c; --line: #4a535c; --panel: rgba(24,28,32,0.95); --panel-solid: #181c20; --cameo: #2b3137; }
[data-faction="fr"] { --accent: #79c2ff; --line: #3a4c78; --panel: rgba(17,24,43,0.95); --panel-solid: #11182b; --cameo: #1f2b4a; }
[data-faction="ru"] { --accent: #ff5a36; --line: #6a2a20; --panel: rgba(34,13,10,0.95); --panel-solid: #220d0a; --cameo: #3a1712; }
[data-faction="uk"] { --accent: #e9c35c; --line: #3b5274; --panel: rgba(14,22,36,0.95); --panel-solid: #0e1624; --cameo: #1a2a44; }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: #0b0b0c;
  color: var(--text);
  font-family: var(--font-text);
  font-size: 14px;
  overflow: hidden;
  user-select: none;
}

button, select, input { font: inherit; color: inherit; }
button:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--accent, #ffb81c); outline-offset: 2px; }
button { transition: border-color 0.12s, background-color 0.12s, color 0.12s, filter 0.12s; }
h1, h2, h3 { margin: 0; }
.hidden { display: none !important; }

kbd {
  display: inline-block;
  padding: 0 5px;
  border: 1px solid #4a535c;
  border-bottom-width: 2px;
  background: #121417;
  font-family: var(--font-label);
  font-weight: 600;
  font-size: 13px;
}

.tiny {
  font-family: var(--font-label);
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
}

.btn-primary, .btn-ghost {
  height: 56px;
  padding: 0 30px;
  font-family: var(--font-label);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  cursor: pointer;
}
.btn-primary {
  border: 0;
  background: var(--accent);
  color: #111;
  clip-path: polygon(14px 0, 100% 0, 100% calc(100% - 14px), calc(100% - 14px) 100%, 0 100%, 0 14px);
}
.btn-primary:hover { filter: brightness(1.12); }
.btn-primary:active, .nav-item.primary:active { filter: brightness(0.92); transform: translateY(1px); }
.btn-ghost { border: 1px solid var(--line); background: transparent; color: var(--text); font-weight: 600; font-size: 18px; letter-spacing: 1.5px; }
.btn-ghost:hover { border-color: var(--accent); color: #fff; }

/* ---------------- Menu ----------------
   Concept A (Aran, 2026-11-02): riveted gunmetal panels with brass corner
   brackets, parchment plates with glass dome lamps (amber when selected), the
   stamped Pistons of War logo, and a slow pan over a real battle behind.
   Textures in assets/menu (made with fal from the concept). */

#menu {
  --amber: #ffb53a;
  --amber-glow: 0 0 0 2px #ffb53a, 0 0 14px 2px rgba(255,170,40,0.75), 0 0 34px rgba(255,140,20,0.35);
  --steel: url("assets/menu/panel.png") 56 fill / 26px stretch;
  --steel-sm: url("assets/menu/panel.png") 56 fill / 12px stretch;
  --steel-ring: url("assets/menu/panel.png") 56 / 12px stretch;
  --paper: url("assets/menu/paper.jpg") center / cover;
  --accent: var(--amber);
  position: fixed;
  inset: 0;
  overflow: auto;
  display: flex;
  gap: 48px;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 48px;
  background: #120e0b;
  isolation: isolate;
}
.menu-backdrop {
  position: fixed;
  inset: -4%;
  z-index: -1;
  background:
    radial-gradient(ellipse at 60% 40%, rgba(255,140,60,0.10), transparent 60%),
    linear-gradient(90deg, rgba(10,7,5,0.82) 0%, rgba(10,7,5,0.45) 34%, rgba(10,7,5,0.25) 60%, rgba(10,7,5,0.5) 100%),
    url("assets/menu/backdrop.jpg") center / cover no-repeat;
  filter: sepia(0.35) saturate(0.9) brightness(0.8) contrast(1.05);
  animation: menu-pan 70s ease-in-out infinite alternate;
}
@keyframes menu-pan {
  from { transform: scale(1.04) translate(-1.5%, 0.5%); }
  to { transform: scale(1.1) translate(1.5%, -1%); }
}
@media (prefers-reduced-motion: reduce) { .menu-backdrop { animation: none; } }

.menu-intro { width: 360px; flex: none; display: flex; flex-direction: column; gap: 14px; }
.menu-intro .logo { margin: 0; line-height: 0; }
.menu-intro .logo img { width: 100%; height: auto; filter: drop-shadow(0 10px 18px rgba(0,0,0,0.6)); }
.menu-nav { display: flex; flex-direction: column; gap: 10px; padding: 6px 4px; }
.menu-version { position: fixed; right: 18px; bottom: 12px; z-index: 1; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; pointer-events: none; font-size: 12px; letter-spacing: 0.04em; color: rgba(239, 226, 196, 0.62); text-shadow: 0 1px 2px rgba(0,0,0,0.8); font-variant-numeric: tabular-nums; }
.menu-version p { margin: 0; }
.menu-update { display: flex; align-items: center; gap: 10px; pointer-events: auto; font-size: 14px; color: #ffd27a; }
.menu-update.hidden { display: none; }
#menu .menu-update .btn-primary { height: 40px; padding: 0 16px; font-size: 15px; }
#menu .mp-msg .btn-primary { flex: none; }
.mp-msg { display: flex; align-items: center; gap: 14px; justify-content: space-between; }
.mp-msg.hidden { display: none; }
#menu .nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 64px;
  padding: 0 10px 0 14px;
  border: 12px solid transparent;
  border-image: var(--steel-sm);
  background: none;
  font-family: var(--font-label);
  font-size: 25px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #3a2614;
  cursor: pointer;
  box-shadow: 0 6px 14px rgba(0,0,0,0.45);
}
#menu .nav-item > span {
  flex: 1;
  align-self: stretch;
  margin: -4px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--paper);
  box-shadow: inset 0 0 0 2px rgba(40,26,12,0.55), inset 0 2px 6px rgba(0,0,0,0.35);
  text-shadow: 0 1px 0 rgba(255,240,210,0.5);
}
#menu .nav-item::after {
  content: "";
  flex: none;
  width: 38px;
  height: 38px;
  background: url("assets/menu/dome.png") center / contain no-repeat;
}
#menu .nav-item:hover:not(.on) > span { filter: brightness(1.06); }
#menu .nav-item:hover:not(.on)::after { filter: brightness(1.4); }
#menu .nav-item.on { box-shadow: var(--amber-glow), 0 6px 14px rgba(0,0,0,0.45); }
#menu .nav-item.on > span { filter: sepia(0.25) brightness(1.08) saturate(1.2); }
#menu .nav-item.on::after { background-image: url("assets/menu/dome-on.png"); filter: drop-shadow(0 0 8px rgba(255,170,40,0.9)); }
#menu .nav-item:active { transform: translateY(1px); }

.setup { width: min(800px, 100%); display: flex; flex-direction: column; gap: 22px; padding: 28px; }
.setup-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.setup-head h2 { font-family: var(--font-label); font-size: 30px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: #fff; }
.setup-head span { font-family: var(--font-label); font-size: 13px; letter-spacing: 2px; text-transform: uppercase; color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 8px; }
.label { font-family: var(--font-label); font-size: 12px; letter-spacing: 2px; text-transform: uppercase; color: var(--muted); }
.label.accent { color: var(--accent); font-size: 13px; }

#menu .setup {
  width: min(860px, 100%);
  gap: 20px;
  padding: 18px 22px 22px;
  position: relative;
  border: 26px solid transparent;
  border-image: var(--steel);
  background: none;
  box-shadow: 0 18px 44px rgba(0,0,0,0.6);
}
#menu .setup-head { justify-content: center; flex-direction: column; align-items: center; gap: 0; }
#menu .setup-head h2 {
  font-size: 46px;
  letter-spacing: 2px;
  background: linear-gradient(180deg, #f8e2a6 0%, #d9a650 55%, #8f6327 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 2px 0 #1a120a) drop-shadow(0 0 1px #000);
}
#menu .setup-head span { color: #c9b48a; }
#menu .label { color: #e2cfa2; text-shadow: 0 1px 2px #000; font-size: 14px; letter-spacing: 1.5px; font-weight: 600; }
#menu .label.accent {
  align-self: flex-start;
  padding: 6px 14px;
  background: var(--paper);
  color: #3a2614;
  text-shadow: none;
  font-size: 18px;
  font-weight: 700;
  transform: rotate(-0.6deg);
  box-shadow: 0 3px 8px rgba(0,0,0,0.5);
}
#menu .hint { font-size: 13px; color: #c9b48a; text-shadow: 0 1px 2px #000; }

#menu select, #menu input[type="number"], #menu input[type="text"] {
  height: 46px;
  border: 0;
  background: var(--paper);
  color: #2f1f10;
  box-shadow: 0 0 0 3px #4d4a47, 0 0 0 5px #2a2826, inset 0 2px 6px rgba(0,0,0,0.3);
  font-size: 19px;
}
#menu input::placeholder { color: #7a6448; }
#menu select option { background: #efe2c2; color: #2f1f10; }
/* A guest sees the host's map choice as plain text, like the other players' rows. */
#menu .mp-map-row select:disabled, #menu .mp-map-row input:disabled { appearance: none; background: rgba(16,13,10,0.55); color: #f1e3c0; opacity: 1; cursor: default; font-family: var(--font-label); font-weight: 600; }

#menu .segmented { height: 46px; border: 0; gap: 4px; }
#menu .segmented.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
#menu .segmented button {
  border: 8px solid transparent;
  border-image: var(--steel-sm);
  border-image-width: 8px;
  background: none;
  color: #ead7ad;
  font-size: 18px;
  text-shadow: 0 1px 2px #000;
}
#menu .segmented button:hover:not(.on) { color: #fff; }
#menu .segmented button.on { border-image: var(--steel-ring); border-image-width: 8px; color: #3a2614; text-shadow: none; background: var(--paper); background-clip: padding-box; box-shadow: var(--amber-glow); }

#menu .btn-primary, #menu .btn-ghost {
  height: 62px;
  padding: 0 34px;
  border: 12px solid transparent;
  border-image: var(--steel-ring);
  clip-path: none;
  font-size: 24px;
  letter-spacing: 1.5px;
}
#menu .btn-primary {
  background: linear-gradient(180deg, #ffd27a, #f0a12a 60%, #c9761a);
  background-clip: padding-box;
  color: #2a1606;
  text-shadow: 0 1px 0 rgba(255,230,170,0.6);
  box-shadow: var(--amber-glow), 0 8px 18px rgba(0,0,0,0.5);
}
#menu .btn-primary:hover { filter: brightness(1.08); }
#menu .btn-primary:disabled, #menu .btn-ghost:disabled { filter: grayscale(0.85) brightness(0.7); box-shadow: 0 8px 18px rgba(0,0,0,0.5); cursor: not-allowed; }
#menu .btn-ghost { background: var(--paper); background-clip: padding-box; color: #3a2614; }
#menu .btn-ghost:hover { filter: brightness(1.08); color: #1e1208; }

/* Settings: brass lever sliders and toggle switches. */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 28px; }
#menu input.lever { -webkit-appearance: none; appearance: none; width: 100%; height: 34px; background: transparent; box-shadow: none; }
#menu input.lever::-webkit-slider-runnable-track { height: 10px; border-radius: 5px; background: #17130f; box-shadow: inset 0 2px 4px #000, 0 0 0 3px #4d4a47, 0 0 0 5px #2a2826; }
#menu input.lever::-moz-range-track { height: 10px; border-radius: 5px; background: #17130f; box-shadow: inset 0 2px 4px #000, 0 0 0 3px #4d4a47; }
#menu input.lever::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 34px; margin-top: -12px; border-radius: 3px; background: linear-gradient(90deg, #7a5420, #f3d48a 45%, #b8862f 60%, #6c4a1b); box-shadow: 0 2px 4px #000; cursor: pointer; }
#menu input.lever::-moz-range-thumb { width: 20px; height: 34px; border: 0; border-radius: 3px; background: linear-gradient(90deg, #7a5420, #f3d48a 45%, #b8862f 60%, #6c4a1b); box-shadow: 0 2px 4px #000; cursor: pointer; }
.set-toggle { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.set-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.set-toggle .switch {
  position: relative; flex: none; width: 46px; height: 46px; border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #e9cd8a, #a77b33 55%, #5a3e17 100%);
  box-shadow: 0 0 0 3px #2a2826, 0 3px 6px rgba(0,0,0,0.6);
}
.set-toggle .switch::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 10px; height: 26px; margin: -24px 0 0 -5px; border-radius: 5px;
  background: linear-gradient(90deg, #6c4a1b, #f6dc9a 50%, #8a6224); box-shadow: 0 2px 3px rgba(0,0,0,0.7);
  transform-origin: 50% 24px; transform: rotate(-28deg); transition: transform 0.15s;
}
.set-toggle input:checked + .switch::after { transform: rotate(28deg); }
.set-toggle input:checked + .switch { box-shadow: 0 0 0 3px #2a2826, 0 0 12px rgba(255,170,40,0.7); }
.set-toggle input:focus-visible + .switch { outline: 2px solid var(--amber); outline-offset: 3px; }

.faction-cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.faction-card {
  display: flex;
  flex-direction: column;
  padding: 0;
  background: #121417;
  border: 1px solid #3a4148;
  overflow: hidden;
  cursor: pointer;
  text-align: left;
}
.faction-card:hover { border-color: var(--card-accent); }
.faction-card.active { background: #1d2126; border: 2px solid var(--card-accent); }
.faction-card .pic { position: relative; height: 104px; background: var(--card-bg); }
.faction-card .pic::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: var(--card-accent); }
.flag { display: block; border-radius: 2px; box-shadow: 0 0 0 1.5px #8a6a2c, 0 2px 6px rgba(0,0,0,0.55); }
.faction-card .card-flag { display: block; width: 100%; height: 100%; filter: saturate(0.85) brightness(0.9); transition: filter 0.2s; }
.faction-card:hover .card-flag, .faction-card.active .card-flag { filter: none; }
.faction-detail .title { display: flex; align-items: center; gap: 10px; }
.faction-detail .title-flag { width: 36px; height: 24px; flex: none; }
.faction-card .txt { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px 12px; }
.faction-card .country { font-family: var(--font-label); font-size: 12px; letter-spacing: 2px; text-transform: uppercase; color: var(--card-accent); }
.faction-card .name { font-family: var(--font-label); font-size: 18px; font-weight: 700; line-height: 1.05; text-transform: uppercase; color: #fff; }
.faction-card .tag { font-size: 12px; color: #b9b9b9; }

.faction-detail {
  display: flex;
  gap: 18px;
  padding: 16px 18px;
  background: rgba(255,255,255,0.03);
  border: 1px solid #3a4148;
}
.faction-detail .main { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.faction-detail .title { font-family: var(--font-label); font-size: 22px; font-weight: 700; text-transform: uppercase; color: #fff; }
.faction-detail .motto { font-style: italic; color: var(--accent); }
.faction-detail .body { font-size: 13px; line-height: 1.5; color: var(--soft); }
.faction-detail .divider { width: 1px; background: #3a4148; }
.faction-detail .side { width: 220px; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.faction-detail .side .label { margin-top: 4px; }

.setup-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
select, input[type="number"], input[type="text"] {
  height: 44px;
  padding: 0 10px;
  background: #0f1113;
  border: 1px solid #4a535c;
  color: #fff;
  font-family: var(--font-label);
  font-size: 17px;
  font-weight: 600;
  width: 100%;
}
.segmented { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); height: 44px; border: 1px solid #4a535c; }
.segmented button { border: 0; background: transparent; color: var(--soft); font-family: var(--font-label); font-size: 16px; font-weight: 600; text-transform: uppercase; cursor: pointer; }
.segmented button.on { background: var(--accent); color: #111; font-weight: 700; }
.setup-actions { display: flex; justify-content: flex-end; gap: 12px; flex-wrap: wrap; }
.setup-row.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
/* Skirmish: map, seed and Start on one line. */
.setup-row.launch { grid-template-columns: minmax(0, 1fr) 150px auto; align-items: end; }
@media (max-width: 760px) { .setup-row.launch { grid-template-columns: 1fr; } }

/* Player rows (skirmish and online lobby): colour, who, nation, team. */
.slots { display: flex; flex-direction: column; gap: 10px; }
.slot { display: grid; grid-template-columns: 12px minmax(0, 1.35fr) minmax(0, 1fr) minmax(0, 0.75fr); gap: 14px; align-items: center; }
.slot .swatch { width: 12px; height: 34px; background: var(--pc, #888); box-shadow: 0 0 0 2px #2a2826, inset 0 -6px 8px rgba(0,0,0,0.25); }
.slot.closed .swatch { background: transparent; box-shadow: inset 0 0 0 2px #4d4a47; }
.slot.closed .slot-nation, .slot.closed .slot-team { visibility: hidden; }
.slot-head { margin-bottom: -2px; }
.slot-head span { font-family: var(--font-label); font-size: 12px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted); padding-left: 2px; }
.slot-cell { height: 38px; display: flex; align-items: center; padding: 0 12px; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-family: var(--font-label); font-size: 17px; font-weight: 600; color: #f1e3c0; background: rgba(16,13,10,0.55); box-shadow: 0 0 0 3px #4d4a47, 0 0 0 5px #2a2826; }
.slot-cell.muted { color: #a8977a; font-weight: 500; font-style: italic; }
.slot-cell:empty { visibility: hidden; }
.slot.me .slot-cell:nth-child(2) { color: #ffd27a; }
#menu .slot select { height: 38px; font-size: 17px; }
#menu .slot-head span { color: #c9b48a; text-shadow: 0 1px 2px #000; font-weight: 600; }

.nav-item:not(.primary) svg { display: none; }

/* Multiplayer lobby */
.mp-form { display: flex; flex-direction: column; gap: 18px; }
.mp-row { align-items: end; grid-template-columns: minmax(0, 1fr) auto; }
.mp-map-row { grid-template-columns: minmax(0, 1fr) 150px; align-items: end; }
.mp-host-btn .btn-primary { height: 44px; padding: 0 18px; font-size: 17px; clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px); }
.mp-or { display: flex; align-items: center; gap: 12px; font-family: var(--font-label); font-size: 12px; letter-spacing: 2px; text-transform: uppercase; color: var(--muted); }
.mp-or::before, .mp-or::after { content: ""; flex: 1; height: 1px; background: #3a4148; }
.mp-join { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px; align-items: end; }
.mp-join .btn-ghost, .mp-link .btn-ghost { height: 44px; font-size: 16px; padding: 0 20px; }
#mp-code { text-transform: uppercase; letter-spacing: 6px; }
.mp-wait { display: flex; flex-direction: column; gap: 18px; }
.mp-wait .setup-actions { align-items: center; }
.mp-link { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px; align-items: center; }
#mp-link { font-family: var(--font-text); font-size: 15px; font-weight: 500; user-select: all; }
.mp-status { display: flex; gap: 12px; align-items: center; color: var(--soft); font-size: 15px; line-height: 1.5; }
.mp-status b { font-family: var(--font-label); font-size: 20px; letter-spacing: 4px; color: var(--accent); }
.mp-msg { padding: 10px 14px; border-left: 3px solid #ff5a36; background: rgba(255,90,54,0.1); color: #ffd2c6; font-size: 14px; }
.spinner { flex: none; width: 18px; height: 18px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

/* ---------------- Game ---------------- */

/* Copper, brass and oxblood leather, after Aran's reference. */
#game {
  position: fixed;
  inset: 0;
  font-family: var(--font-text);
  --copper-hi: #f6c48a;
  --copper: #c07a3e;
  --copper-mid: #8e4f22;
  --copper-lo: #4a2410;
  --leather: #7a1e14;
  --leather-lo: #3c0c07;
  --cream: #f6e6c4;
  --wood: #2a1a10;
  --gear: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cdefs%3E%3ClinearGradient id='g' x1='0' y1='0' x2='1' y2='1'%3E%3Cstop offset='0' stop-color='%23f2b878'/%3E%3Cstop offset='.45' stop-color='%23a8622c'/%3E%3Cstop offset='1' stop-color='%234a2410'/%3E%3C/linearGradient%3E%3C/defs%3E%3Cpath fill='url(%23g)' stroke='%232a1408' stroke-width='1.5' fill-rule='evenodd' d='M44.8%2010.3%20L46.2%202.1%20L53.8%202.1%20L55.2%2010.3%20L65.3%2013.0%20L70.7%206.7%20L77.2%2010.4%20L74.4%2018.3%20L81.7%2025.6%20L89.6%2022.8%20L93.3%2029.3%20L87.0%2034.7%20L89.7%2044.8%20L97.9%2046.2%20L97.9%2053.8%20L89.7%2055.2%20L87.0%2065.3%20L93.3%2070.7%20L89.6%2077.2%20L81.7%2074.4%20L74.4%2081.7%20L77.2%2089.6%20L70.7%2093.3%20L65.3%2087.0%20L55.2%2089.7%20L53.8%2097.9%20L46.2%2097.9%20L44.8%2089.7%20L34.7%2087.0%20L29.3%2093.3%20L22.8%2089.6%20L25.6%2081.7%20L18.3%2074.4%20L10.4%2077.2%20L6.7%2070.7%20L13.0%2065.3%20L10.3%2055.2%20L2.1%2053.8%20L2.1%2046.2%20L10.3%2044.8%20L13.0%2034.7%20L6.7%2029.3%20L10.4%2022.8%20L18.3%2025.6%20L25.6%2018.3%20L22.8%2010.4%20L29.3%206.7%20L34.7%2013.0%20Z%20M50%2034a16%2016%200%201%200%200.01%200Z'/%3E%3Ccircle cx='50' cy='50' r='26' fill='none' stroke='%232a1408' stroke-width='3' opacity='.5'/%3E%3C/svg%3E");
}

#viewport { position: absolute; inset: 0; overflow: hidden; container-type: inline-size; }
#view { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: default; }
/* AoE2 context cursors (scripts/make-cursors.mjs). The copper pointer is used
   everywhere in a match, HUD included; over the map it changes to show what a
   right-click would do (Input.cursorFor). The minimap keeps the game cursor
   too, with the attack or target cursor while attack-moving or casting
   (Minimap.draw sets its data-cursor). */
#game, #game * { cursor: url(assets/cursors/default.png) 3 2, default; cursor: -webkit-image-set(url(assets/cursors/default.png) 1x, url(assets/cursors/default@2x.png) 2x) 3 2, default; cursor: image-set(url(assets/cursors/default.png) 1x, url(assets/cursors/default@2x.png) 2x) 3 2, default; }
#game .bbtn.locked { cursor: url(assets/cursors/invalid.png) 16 16, default; cursor: -webkit-image-set(url(assets/cursors/invalid.png) 1x, url(assets/cursors/invalid@2x.png) 2x) 16 16, default; cursor: image-set(url(assets/cursors/invalid.png) 1x, url(assets/cursors/invalid@2x.png) 2x) 16 16, default; }
#game [data-cursor="default"] { cursor: url(assets/cursors/default.png) 3 2, default; cursor: -webkit-image-set(url(assets/cursors/default.png) 1x, url(assets/cursors/default@2x.png) 2x) 3 2, default; cursor: image-set(url(assets/cursors/default.png) 1x, url(assets/cursors/default@2x.png) 2x) 3 2, default; }
#game [data-cursor="move"] { cursor: url(assets/cursors/move.png) 3 2, default; cursor: -webkit-image-set(url(assets/cursors/move.png) 1x, url(assets/cursors/move@2x.png) 2x) 3 2, default; cursor: image-set(url(assets/cursors/move.png) 1x, url(assets/cursors/move@2x.png) 2x) 3 2, default; }
#game [data-cursor="attack"] { cursor: url(assets/cursors/attack.png) 16 16, default; cursor: -webkit-image-set(url(assets/cursors/attack.png) 1x, url(assets/cursors/attack@2x.png) 2x) 16 16, default; cursor: image-set(url(assets/cursors/attack.png) 1x, url(assets/cursors/attack@2x.png) 2x) 16 16, default; }
#game [data-cursor="target"] { cursor: url(assets/cursors/target.png) 16 16, default; cursor: -webkit-image-set(url(assets/cursors/target.png) 1x, url(assets/cursors/target@2x.png) 2x) 16 16, default; cursor: image-set(url(assets/cursors/target.png) 1x, url(assets/cursors/target@2x.png) 2x) 16 16, default; }
#game [data-cursor="repair"] { cursor: url(assets/cursors/repair.png) 6 6, default; cursor: -webkit-image-set(url(assets/cursors/repair.png) 1x, url(assets/cursors/repair@2x.png) 2x) 6 6, default; cursor: image-set(url(assets/cursors/repair.png) 1x, url(assets/cursors/repair@2x.png) 2x) 6 6, default; }
#game [data-cursor="build"] { cursor: url(assets/cursors/build.png) 7 7, default; cursor: -webkit-image-set(url(assets/cursors/build.png) 1x, url(assets/cursors/build@2x.png) 2x) 7 7, default; cursor: image-set(url(assets/cursors/build.png) 1x, url(assets/cursors/build@2x.png) 2x) 7 7, default; }
#game [data-cursor="harvest"] { cursor: url(assets/cursors/harvest.png) 16 20, default; cursor: -webkit-image-set(url(assets/cursors/harvest.png) 1x, url(assets/cursors/harvest@2x.png) 2x) 16 20, default; cursor: image-set(url(assets/cursors/harvest.png) 1x, url(assets/cursors/harvest@2x.png) 2x) 16 20, default; }
#game [data-cursor="invalid"] { cursor: url(assets/cursors/invalid.png) 16 16, default; cursor: -webkit-image-set(url(assets/cursors/invalid.png) 1x, url(assets/cursors/invalid@2x.png) 2x) 16 16, default; cursor: image-set(url(assets/cursors/invalid.png) 1x, url(assets/cursors/invalid@2x.png) 2x) 16 16, default; }
/* Waypoints (Shift): the normal move pointer stays, with the ghost 3D flag on the ground under it (Input.updateCursor). */
#game #view[data-cursor="waypoint"] { cursor: url(assets/cursors/move.png) 3 2, default; cursor: -webkit-image-set(url(assets/cursors/move.png) 1x, url(assets/cursors/move@2x.png) 2x) 3 2, default; cursor: image-set(url(assets/cursors/move.png) 1x, url(assets/cursors/move@2x.png) 2x) 3 2, default; }
#game.spectating #buildpanel, #game.spectating #mapblock .gauge, #game.spectating .plate { display: none; }

/* A thick copper frame with bolts in the corners and dark wood-and-iron inside. */
.copper {
  position: relative;
  background:
    radial-gradient(130% 90% at 50% 0%, rgba(255,190,120,0.08), transparent 60%),
    repeating-linear-gradient(90deg, rgba(0,0,0,0.06) 0 2px, transparent 2px 7px),
    linear-gradient(180deg, #33200f, #1c120a);
  border: 6px solid transparent;
  border-image: linear-gradient(150deg, var(--copper-hi) 0%, var(--copper) 18%, var(--copper-lo) 45%, var(--copper-mid) 65%, var(--copper-hi) 85%, var(--copper) 100%) 1;
  box-shadow: inset 0 0 0 2px rgba(0,0,0,0.65), inset 0 3px 14px rgba(0,0,0,0.7), 0 12px 30px rgba(0,0,0,0.6);
}
.copper::before {
  content: "";
  position: absolute;
  inset: -6px;
  pointer-events: none;
  --bolt: radial-gradient(circle at 40% 35%, #ffe2b8 0 1.4px, var(--copper) 2.6px, var(--copper-lo) 4px, rgba(0,0,0,0.6) 4.6px, transparent 5.2px);
  background: var(--bolt) left 0 top 0 / 12px 12px no-repeat, var(--bolt) right 0 top 0 / 12px 12px no-repeat,
    var(--bolt) left 0 bottom 0 / 12px 12px no-repeat, var(--bolt) right 0 bottom 0 / 12px 12px no-repeat;
  z-index: 3;
}
/* Oxblood leather: buttons and plates. */
.leather {
  background:
    radial-gradient(120% 140% at 30% 20%, rgba(255,140,110,0.22), transparent 55%),
    repeating-radial-gradient(circle at 20% 30%, rgba(0,0,0,0.05) 0 1px, transparent 1px 3px),
    linear-gradient(180deg, var(--leather), var(--leather-lo));
}

/* ---------- top bar: gunmetal plates with amber nixie readouts ---------- */

/* Painted skin (Meshy, after Aran's concept 7): a riveted gunmetal plate
   with brass corners (9-slice), brass medallions for the resource icons,
   dark glass windows in brass bezels, and round brass push buttons. */
.tb-plate {
  position: absolute;
  top: 6px;
  display: flex;
  align-items: center;
  height: 62px;
  padding: 0 22px;
  border: 22px solid transparent;
  border-image: url(assets/hud/tb-plate.png) 88 92 fill / 22px 24px stretch;
  border-width: 0 0;
  filter: drop-shadow(0 6px 10px rgba(0,0,0,0.55));
  white-space: nowrap;
  z-index: 2;
}
#topbar { right: 8px; gap: 8px; padding: 0 20px 0 22px; }
.nixie {
  font-family: var(--font-label);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 1px;
  color: #ffb24a;
  text-shadow: 0 0 4px rgba(255,140,40,0.85), 0 0 12px rgba(255,110,20,0.45);
}
.tb-window {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 36px;
  min-width: 64px;
  padding: 0 12px;
  border: 7px solid transparent;
  border-image: url(assets/hud/tb-window.png) 34 36 fill / 7px 8px stretch;
  border-width: 0;
}
#clock { display: inline-flex; align-items: center; justify-content: center; height: 36px; min-width: 70px; padding: 0 12px; font-size: 22px; border-image: url(assets/hud/tb-window.png) 34 36 fill / 7px 8px stretch; }
.tb-btn {
  width: 38px;
  height: 38px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: url(assets/hud/tb-button.png) center / contain no-repeat;
  color: #f2dcb0;
  cursor: pointer;
  filter: drop-shadow(0 2px 2px rgba(0,0,0,0.6));
}
.tb-btn:hover { filter: drop-shadow(0 2px 2px rgba(0,0,0,0.6)) brightness(1.25); }
.tb-btn:active { transform: translateY(1px); }
.tb-btn.on { color: #ffb24a; }
.tb-btn svg { filter: drop-shadow(0 1px 0 rgba(0,0,0,0.8)); }

/* The game menu under the menu button. */
.tb-menu {
  position: absolute;
  top: 70px;
  right: 14px;
  width: 290px;
  padding: 16px 18px;
  display: grid;
  gap: 6px;
  border: 22px solid transparent;
  border-image: url(assets/hud/tb-plate.png) 88 92 fill / 22px 24px stretch;
  border-width: 0;
  filter: drop-shadow(0 8px 14px rgba(0,0,0,0.6));
  z-index: 5;
}
.tb-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  height: 38px;
  padding: 0 12px;
  border: 0;
  border-image: url(assets/hud/tb-window.png) 34 36 fill / 7px 8px stretch;
  background: none;
  color: #f2dcb0;
  font-family: var(--font-label);
  font-size: 17px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}
.tb-row:hover { filter: brightness(1.3); }
.tb-row b { font-size: 18px; }
.tb-row kbd { font-size: 12px; padding: 0 4px; border: 1px solid #8a6a3a; border-radius: 3px; color: #c9b08a; }
.tb-row.quit span { color: #ffb6a0; }
.tb-row[aria-pressed="true"] b, .tb-row.on b { color: #ffd27a; }
.tb-btn[aria-expanded="true"] { color: #ffb24a; }

#sound-panel {
  position: fixed;
  z-index: 6;
  width: 240px;
  padding: 12px 14px;
  display: grid;
  gap: 10px;
  padding: 18px 20px;
  border-image: url(assets/hud/tb-plate.png) 88 92 fill / 22px 24px stretch;
  filter: drop-shadow(0 8px 14px rgba(0,0,0,0.6));
  color: #f3e3c0;
  font-family: var(--font-label);
  font-size: 15px;
}
#sound-panel .row { display: flex; align-items: center; gap: 10px; }
#sound-panel .row > span:first-child { min-width: 56px; }
#sound-panel input[type="range"] { flex: 1; accent-color: #d9a25a; }
#sound-panel input[type="checkbox"] { accent-color: #d9a25a; width: 16px; height: 16px; }
#sound-panel .track { justify-content: space-between; font-size: 13px; color: #c9b08a; }
#sound-panel .track button { border: 1px solid var(--copper-mid); background: #2a170c; color: #f3e3c0; font: inherit; padding: 2px 8px; }
#sound-panel kbd { font-size: 12px; padding: 0 4px; border: 1px solid var(--copper-mid); border-radius: 3px; }

/* ---------- resources (top left) ---------- */

.hud { z-index: 2; }

#sidebar {
  left: 8px;
  gap: 10px;
  padding: 0 22px 0 18px;
}
.plate {
  position: relative;
  display: flex;
  align-items: center;
  gap: 4px;
}
.plate .medallion {
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: url(assets/hud/tb-medal.png) center / contain no-repeat;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.6));
  flex: none;
}
.plate .medallion svg { width: 25px; height: 25px; filter: drop-shadow(0 0 3px rgba(255,200,140,0.25)); }
.plate-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
#oil, #aether, #steel, #unitcount { font-size: 23px; white-space: nowrap; transition: color 0.2s; }
.plate .tb-window { min-width: 78px; }
.plate.army .tb-window { min-width: 92px; }
#aether { color: #d9b8ff; text-shadow: 0 0 4px rgba(190,130,255,0.85), 0 0 12px rgba(150,90,255,0.45); }
#steel { color: #e2e8ee; text-shadow: 0 0 4px rgba(200,220,255,0.6), 0 0 10px rgba(160,190,230,0.35); }
.reserve.full #oil { color: #ff7a3a; }
#aether-rate { font-family: var(--font-label); font-size: 13px; font-weight: 700; color: #b48cff; white-space: nowrap; }
#aether-rate:empty { display: none; }
.bbtn .bcost .ae { font-style: normal; color: #d8c4ff; margin-left: 3px; }
.bbtn .bcost .st { font-style: normal; color: #c8d2dc; margin-left: 3px; }
#unitcount.full { color: #ff5a3a; }
#oil.down { color: #fff4d6; }
/* Short of it for a click: the resource flashes red and wiggles. */
.plate.short { animation: short 0.6s ease-out; }
.plate.short .nixie, .plate.short #oil, .plate.short #aether, .plate.short #steel { color: #ff6a50; text-shadow: 0 0 4px rgba(255,80,50,0.9), 0 0 12px rgba(255,60,30,0.5); }
@keyframes short {
  20% { transform: translateX(-4px); filter: brightness(1.6) saturate(1.4); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-3px); filter: brightness(1.6) saturate(1.4); }
  80% { transform: translateX(2px); }
}
@keyframes blink { 50% { opacity: 0.45; } }
.spec { display: flex; gap: 24px; padding: 6px 12px; }
.spec:empty { display: none; }
.spec .spec-row { font-family: var(--font-label); font-size: 15px; font-weight: 700; text-transform: uppercase; color: var(--cream); }
.spec .spec-row small { display: block; font-size: 12px; color: #c9b38e; letter-spacing: 0.5px; font-weight: 500; }

/* ---------- field telegraph (under the resources) ---------- */

.parchment {
  background:
    radial-gradient(140% 100% at 50% 0%, rgba(255,255,255,0.35), transparent 60%),
    radial-gradient(circle at 85% 90%, rgba(120,70,20,0.25), transparent 40%),
    #e9d6ac;
  border: 4px solid transparent;
  border-image: linear-gradient(150deg, var(--copper-hi), var(--copper) 25%, var(--copper-lo) 50%, var(--copper) 75%, var(--copper-hi)) 1;
  box-shadow: inset 0 0 18px rgba(110,60,15,0.45), 0 8px 20px rgba(0,0,0,0.55);
}
#toasts-wrap {
  position: absolute;
  left: 10px;
  top: 76px;
  width: min(400px, calc(100% - 20px));
  padding: 8px 10px 4px;
  pointer-events: none;
}
#toasts-wrap:has(#toasts:empty) { display: none; }
#toasts { display: flex; flex-direction: column; gap: 2px; }
.toast {
  display: flex;
  align-items: baseline;
  gap: 6px;
  color: #2b1a0c;
  font-family: var(--font-type);
  font-size: 14px;
  line-height: 1.3;
  animation: toast-in 0.25s ease-out, toast-out 0.8s ease-in 7.2s forwards;
}
.toast .msg::before { content: "[Telegraph] "; color: #7a4a1c; }
.toast.bad .msg { color: #8e1a0e; }
.toast.bad .msg::before { content: "[Urgent] "; color: #b3261e; }
.toast .times { font-family: var(--font-label); font-weight: 700; color: #7a4a1c; }
.toast:not(:last-child) { opacity: 0.7; }
.telegraph-head { margin-top: 4px; padding-top: 2px; border-top: 1px solid rgba(90,50,15,0.4); font-family: var(--font-label); font-size: 12px; font-weight: 700; letter-spacing: 1px; color: #7a4a1c; }
@keyframes toast-in { from { opacity: 0; transform: translateX(-10px); } }
@keyframes toast-out { to { opacity: 0; } }

/* ---------- tutorial (objective card top right, ring on the map) ---------- */

#tutorial {
  position: absolute;
  right: 10px;
  top: 76px;
  width: min(340px, calc(100% - 20px));
  padding: 10px 14px 12px;
  color: #2b1a0c;
  font-family: var(--font-type);
  font-size: 14px;
  line-height: 1.35;
  animation: toast-in 0.25s ease-out;
  z-index: 1; /* under the game menu and the rest of the HUD */
}
#tutorial .tut-step { font-family: var(--font-label); font-size: 12px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: #7a4a1c; }
#tutorial h3 { margin: 2px 0 6px; font-family: var(--font-label); font-size: 22px; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase; color: #3a2210; }
#tutorial p { margin: 0 0 8px; }
.tut-goals { list-style: none; margin: 0; padding: 6px 0 0; border-top: 1px solid rgba(90,50,15,0.4); display: flex; flex-direction: column; gap: 5px; }
.tut-goals li { display: flex; align-items: flex-start; gap: 8px; font-weight: 600; }
.tut-goals li.done { color: #4f6b2a; text-decoration: line-through; text-decoration-color: rgba(79,107,42,0.6); }
.tut-goals .box { flex: none; width: 16px; height: 16px; margin-top: 1px; border: 2px solid #7a4a1c; background: rgba(255,255,255,0.35); display: grid; place-items: center; }
.tut-goals li.done .box { border-color: #4f6b2a; color: #4f6b2a; }
.tut-goals .box svg { width: 14px; height: 14px; }
#tutorial .tut-btn { margin-top: 8px; height: 38px; padding: 0 22px; font-family: var(--font-label); font-size: 17px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; }
.tut-marker {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: none;
  border: 3px solid #ffb53a;
  border-radius: 50%;
  box-shadow: 0 0 12px 2px rgba(255,170,40,0.75), inset 0 0 12px 2px rgba(255,170,40,0.5);
  animation: tut-pulse 1.4s ease-in-out infinite;
}
.tut-marker::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: calc(100% + 4px);
  width: 0;
  height: 0;
  margin-left: -12px;
  border: 12px solid transparent;
  border-top: 20px solid #ffb53a;
  filter: drop-shadow(0 0 4px rgba(255,140,20,0.9));
  animation: tut-bob 1.4s ease-in-out infinite;
}
/* Points along the screen edge at a marker that is off screen; click to go there. */
.tut-pointer {
  position: absolute;
  left: 0;
  top: 0;
  width: 44px;
  height: 44px;
  margin: -22px 0 0 -22px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  z-index: 1;
}
.tut-pointer span {
  position: absolute;
  left: 8px;
  top: 6px;
  width: 0;
  height: 0;
  border: 16px solid transparent;
  border-left: 30px solid #ffb53a;
  border-right: 0;
  filter: drop-shadow(0 0 5px rgba(255,140,20,0.9));
  animation: tut-nudge 1.4s ease-in-out infinite;
}
@keyframes tut-nudge { 50% { transform: translateX(6px); } }
@keyframes tut-pulse { 50% { border-color: #ffe0a0; box-shadow: 0 0 20px 4px rgba(255,190,80,0.85), inset 0 0 16px 4px rgba(255,190,80,0.6); } }
@keyframes tut-bob { 50% { transform: translateY(-10px); } }

/* ---------- command panel (bottom left) ---------- */

#game { --bar-h: 236px; --cmd-w: 430px; --map-w: 250px; }
#buildpanel {
  position: absolute;
  left: 10px;
  bottom: 10px;
  width: var(--cmd-w);
  height: var(--bar-h);
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px 8px;
}
#buildpanel .gear { position: absolute; background: var(--gear) center / contain no-repeat; pointer-events: none; filter: drop-shadow(0 4px 6px rgba(0,0,0,0.6)); z-index: -1; }
#buildpanel .gear-a { width: 110px; height: 110px; right: -34px; top: -52px; animation: spin 40s linear infinite; }
#buildpanel .gear-b { width: 64px; height: 64px; right: 62px; top: -36px; animation: spin 23s linear infinite reverse; }
@keyframes spin { to { transform: rotate(360deg); } }

.tabs { display: flex; gap: 8px; padding-left: 18px; }
.tab {
  position: relative;
  height: 38px;
  flex: 1;
  min-width: 0;
  padding: 0 8px 0 26px;
  display: flex;
  align-items: center;
  border: 3px solid transparent;
  border-image: linear-gradient(150deg, var(--copper-hi), var(--copper) 25%, var(--copper-lo) 50%, var(--copper) 75%, var(--copper-hi)) 1;
  background:
    radial-gradient(120% 140% at 30% 20%, rgba(255,140,110,0.22), transparent 55%),
    linear-gradient(180deg, #6d1a11, #320a06);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.6), 0 4px 10px rgba(0,0,0,0.5);
  color: var(--cream);
  cursor: pointer;
}
.tab.train:not(.shown), .tab.build:not(.shown) { display: none; }
.tabs.hidden { display: none; }
.tab .medal {
  position: absolute;
  left: -24px;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gear) center / contain no-repeat;
  filter: drop-shadow(0 3px 4px rgba(0,0,0,0.6));
  color: var(--cream);
}
.tab .medal svg { width: 22px; height: 22px; padding: 3px; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #6d1a11, #2a0703); }
.tab .tab-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font-label); font-size: 15px; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase; text-shadow: 0 2px 0 rgba(0,0,0,0.6); }
.tab .key { position: absolute; right: 3px; top: 0; font-family: var(--font-label); font-size: 10px; font-weight: 700; color: rgba(246,230,196,0.55); }
.tab:hover { filter: brightness(1.18); }
.tab.active {
  background: radial-gradient(120% 140% at 30% 20%, rgba(255,200,150,0.35), transparent 55%), linear-gradient(180deg, #b22c1a, #5a1209);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.6), 0 0 14px rgba(255,120,60,0.45);
}
.tab.active .tab-label { color: #fff3d6; }
.tab.active .medal { animation: spin 6s linear infinite; }
.tab.active .medal svg { animation: spin 6s linear infinite reverse; }
.tab .badge {
  position: absolute;
  right: -8px;
  top: -9px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: radial-gradient(circle at 35% 30%, #ffe08a, #c98a1c);
  border: 2px solid var(--copper-lo);
  color: #2a1408;
  font-family: var(--font-label);
  font-size: 12px;
  font-weight: 700;
  z-index: 1;
}

#tab-extra:empty { display: none; }
.toggle { height: 28px; border: 2px solid var(--copper-mid); background: linear-gradient(180deg, #4a2a16, #1c0f08); color: var(--cream); font-family: var(--font-label); font-size: 13px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; cursor: pointer; }
.toggle.on { border-color: #ffd98a; color: #ffd98a; }

/* The grid of cameos, like the AoE2 command card. */
.build-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  grid-auto-rows: 74px;
  gap: 8px;
  align-content: start;
  overflow-y: auto;
  padding: 3px;
  scrollbar-width: thin;
  scrollbar-color: var(--copper-mid) transparent;
}
.bbtn {
  position: relative;
  padding: 0;
  overflow: hidden;
  border: 3px solid transparent;
  border-image: linear-gradient(150deg, var(--copper-hi), var(--copper) 25%, var(--copper-lo) 50%, var(--copper) 75%, var(--copper-hi)) 1;
  background: radial-gradient(circle at 50% 35%, #8a2417, #2a0703);
  box-shadow: inset 0 0 10px rgba(0,0,0,0.7);
  cursor: pointer;
}
.bbtn .thumb { position: absolute; inset: 0 0 6px 0; }
.bbtn .bimg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.bbtn .bprog { position: absolute; inset: 0; display: none; background: conic-gradient(rgba(0,0,0,0) 0 calc(var(--p, 0) * 1turn), rgba(10,5,3,0.65) 0); }
.bbtn.building .bprog { display: block; }
.bbtn .bname {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 6px;
  padding: 8px 2px 1px;
  background: linear-gradient(rgba(0,0,0,0), rgba(20,8,4,0.92) 55%);
  font-family: var(--font-label);
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1.05;
  text-transform: uppercase;
  text-align: center;
  color: var(--cream);
}
.bbtn .bcost { position: absolute; left: 0; top: 0; padding: 0 4px; background: rgba(20,8,4,0.8); font-family: var(--font-label); font-size: 12px; font-weight: 700; color: #ffd98a; }
.bbtn .bcount { position: absolute; right: 3px; top: 0; font-family: var(--font-label); font-size: 17px; font-weight: 700; color: #fff; text-shadow: 0 1px 2px #000, 0 0 4px #000; }
.bbtn .bar { position: absolute; left: 0; right: 0; bottom: 0; height: 6px; background: #0c0705; }
.bbtn .bar i { display: block; height: 100%; width: calc(var(--p, 0) * 100%); background: linear-gradient(180deg, #ffe58a, #d39b1c); }
.bbtn.ready .bar i { width: 100%; background: linear-gradient(180deg, #a6f58a, #3fae2a); }
.bbtn .bpct { position: absolute; left: 0; right: 0; top: 18px; text-align: center; font-family: var(--font-label); font-size: 17px; font-weight: 700; color: #fff; text-shadow: 0 1px 3px #000; font-variant-numeric: tabular-nums; }
.bbtn .bready { position: absolute; inset: 0 0 6px; display: none; align-items: center; justify-content: center; background: rgba(10,30,5,0.35); font-family: var(--font-label); font-size: 15px; font-weight: 700; letter-spacing: 2px; text-transform: uppercase; color: #c8ffb0; text-shadow: 0 0 6px #3fae2a, 0 1px 2px #000; animation: blink 0.9s steps(2) infinite; }
.bbtn.ready .bready { display: flex; }
.bbtn .block { position: absolute; right: 3px; top: 3px; display: none; width: 14px; height: 14px; color: var(--cream); }
.bbtn .block svg { width: 100%; height: 100%; }
.bbtn:hover:not(.locked) { filter: brightness(1.2); }
.bbtn:active:not(.locked) { transform: translateY(1px); }
.bbtn.active-q, .bbtn.ready, .bbtn.placing { box-shadow: inset 0 0 10px rgba(0,0,0,0.7), 0 0 12px rgba(255,190,90,0.7); }
.bbtn.locked { cursor: not-allowed; }
.bbtn.locked .thumb { filter: grayscale(1) brightness(0.5); }
.bbtn.locked .block { display: block; }
.bbtn.locked .bcount { display: none; }
.bbtn.locked .bname, .bbtn.locked .bcost { opacity: 0.55; }
.bbtn.poor:not(.locked) .bcost { color: #ff6a50; }
/* Can't afford: greyed out, as AoE2 does; the price stays red. */
.bbtn.poor:not(.locked) .thumb { filter: grayscale(0.9) brightness(0.55); }
.bbtn.poor:not(.locked) .bname { opacity: 0.6; }
/* Research buttons: a flask badge, and a steady "Done" once researched. */
.bbtn.research .rflask { position: absolute; right: 3px; bottom: 3px; width: 16px; height: 16px; padding: 1px; border-radius: 50%; background: rgba(20,12,4,0.75); color: #9fd8ff; z-index: 2; }
.bbtn.research .rflask svg { width: 100%; height: 100%; }
.bbtn.research.done .bready { animation: none; }
.bbtn.research.done .bcost { opacity: 0.4; text-decoration: line-through; }
.bbtn.research.done { cursor: default; }
.bbtn.busy { filter: brightness(0.6); }
.bbtn.nope { animation: nope 0.32s ease-in-out; }
/* A refused click (too dear, locked) pops the card red for a moment. */
.bbtn::after { content: ''; position: absolute; inset: 0; z-index: 3; background: rgba(240, 40, 20, 0.6); opacity: 0; pointer-events: none; }
.bbtn.nope::after { animation: nope-red 0.6s ease-out; }
@keyframes nope-red {
  0%, 25% { opacity: 1; }
  100% { opacity: 0; }
}
@keyframes nope {
  20% { transform: translateX(-4px); filter: brightness(1.3); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-3px); filter: brightness(1.3); }
  80% { transform: translateX(2px); }
}
.build-hint { font-size: 11.5px; line-height: 1.3; color: #d8c6a2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- map (bottom right) ---------- */

#mapblock { position: absolute; right: 10px; bottom: 10px; width: var(--map-w); }
.radar-block { display: flex; gap: 6px; padding: 6px; height: var(--bar-h); }
.power-bar { position: relative; width: 14px; flex: none; padding: 2px; background: #0c0705; box-shadow: inset 0 2px 5px rgba(0,0,0,0.9), 0 0 0 2px var(--copper-mid); }
#power-segs { display: flex; flex-direction: column; gap: 2px; height: calc(100% - 22px); }
#power-segs span { flex: 1; background: rgba(255,255,255,0.06); }
#power-segs span.on { background: linear-gradient(90deg, #3aa12a, #8fec6c, #3aa12a); }
#power-used { position: absolute; left: -3px; right: -3px; height: 2px; background: #fff; box-shadow: 0 0 3px #000; transition: bottom 0.3s; }
.power-bar .bolt { position: absolute; left: 0; right: 0; bottom: 2px; height: 18px; color: #ffd34d; display: flex; justify-content: center; }
.power-bar .bolt svg { width: 12px; height: 12px; }
#game.low-power #power-segs span.on { background: var(--bad); animation: blink 0.8s steps(2) infinite; }
.radar { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.radar-title { text-align: center; font-family: var(--font-label); font-size: 13px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; color: var(--cream); background: linear-gradient(180deg, #5a3a1c, #2a170a); box-shadow: 0 0 0 1px var(--copper-mid); }
.radar-glass { position: relative; flex: 1; min-height: 0; background: #18251a; overflow: hidden; box-shadow: inset 0 0 18px rgba(0,0,0,0.9), 0 0 0 2px var(--copper-mid); }
.radar-glass::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(110% 80% at 25% 10%, rgba(255,255,255,0.1), transparent 45%), radial-gradient(closest-side, transparent 78%, rgba(0,0,0,0.4)); }
#minimap { display: block; width: 100%; height: 100%; object-fit: fill; }
#mapblock .gauge { position: absolute; left: -44px; top: -50px; z-index: 4; }
.dial { width: 88px; height: 88px; display: block; filter: drop-shadow(0 4px 6px rgba(0,0,0,0.6)); }
.dial-rim { fill: #6b3a18; stroke: var(--copper-hi); stroke-width: 2.5; }
.dial-face { fill: #f1e3c2; stroke: #3a1d0a; stroke-width: 1; }
.dial-ticks line { stroke: #3b2310; stroke-width: 1.4; }
.dial-red { fill: none; stroke: #c0281c; stroke-width: 5; }
.dial-word { font-family: var(--font-label); font-size: 7px; font-weight: 700; letter-spacing: 1px; fill: #5a3a1c; text-anchor: middle; }
.needle { transform-origin: 32px 32px; transition: transform 0.6s cubic-bezier(.3,1.6,.5,1); }
.needle path { fill: #9a1a10; }
.hub { fill: var(--copper-lo); stroke: var(--copper-hi); stroke-width: 1; }
#game.low-power .needle { animation: shudder 0.15s linear infinite alternate; }
@keyframes shudder { to { translate: 0.5px 0; } }

/* ---------- selected unit (bottom centre) ---------- */

.selection {
  position: absolute;
  left: calc(var(--cmd-w) + 24px);
  bottom: 10px;
  width: min(620px, calc(100% - var(--cmd-w) - var(--map-w) - 48px));
  height: calc(var(--bar-h) - 40px);
  display: flex;
  gap: 14px;
  padding: 10px 12px;
}
.selection .portrait { position: relative; width: 140px; height: 100%; flex: none; overflow: hidden; background: radial-gradient(circle at 50% 35%, #8a2417, #2a0703); box-shadow: 0 0 0 3px var(--copper-mid), 0 0 0 4px var(--copper-lo), inset 0 0 14px rgba(0,0,0,0.75); }
.selection .portrait img { width: 100%; height: 100%; object-fit: cover; display: block; }
.selection .portrait .count { position: absolute; left: 0; top: 0; padding: 0 8px; background: linear-gradient(180deg, var(--copper-hi), var(--copper)); color: #2a1408; font-family: var(--font-label); font-size: 17px; font-weight: 700; }
.selection .info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.selection .title { display: flex; flex-direction: column; gap: 2px; }
.selection h3 { font-family: var(--font-label); font-size: 23px; font-weight: 700; color: var(--cream); line-height: 1; text-shadow: 0 2px 0 rgba(0,0,0,0.6); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.selection .role { font-family: var(--font-label); font-size: 13px; letter-spacing: 1.5px; text-transform: uppercase; color: #e0a96a; }
.selection.enemy h3 { color: #ffb4a3; }
.selection.enemy .role { color: #ff7a60; }
.selection .hp { display: flex; align-items: center; gap: 8px; }
.selection .hp::before { content: "Health"; font-family: var(--font-label); font-size: 15px; font-weight: 600; color: var(--cream); }
.selection .pips { flex: 1; min-width: 70px; max-width: 220px; display: flex; padding: 2px; background: #0c0705; box-shadow: inset 0 1px 3px rgba(0,0,0,0.9), 0 0 0 2px var(--copper-mid); }
.selection .pips span { flex: 1; height: 12px; background: rgba(255,255,255,0.05); }
.selection .pips.good span.on { background: linear-gradient(180deg, #a6f58a, #3fae2a 60%, #2a7a1c); }
.selection .pips.warn span.on { background: linear-gradient(180deg, #ffe58a, #d39b1c 60%, #8a5a0c); }
.selection .pips.bad span.on { background: linear-gradient(180deg, #ff9a7a, #c02a18 60%, #7a1408); }
.selection .hp-text { font-family: var(--font-label); font-size: 15px; font-weight: 700; color: var(--cream); font-variant-numeric: tabular-nums; }
.selection .stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.selection .stat { display: flex; flex-direction: column; padding: 2px 8px; min-width: 0; background: rgba(0,0,0,0.4); box-shadow: 0 0 0 1px var(--copper-mid); }
.selection .stat .k { font-family: var(--font-label); font-size: 10px; letter-spacing: 1.5px; text-transform: uppercase; color: #c9a06a; }
.selection .stat .v { font-family: var(--font-label); font-size: 16px; font-weight: 700; color: var(--cream); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.selection .note { font-size: 13px; line-height: 1.35; color: #d8c6a2; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.selection .info.split { flex-direction: row; gap: 12px; }
.selection .info.split .col { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.selection .info.split .pips { min-width: 40px; }
.selection .info.split .hp::before { display: none; }
.selection .info.split .hp-text { white-space: nowrap; font-size: 14px; }
/* Stats become one column of rows, AoE2 style, next to the production column. */
.selection .info.split .stats { grid-template-columns: 1fr; gap: 3px; }
.selection .info.split .stat { flex-direction: row; justify-content: space-between; align-items: baseline; gap: 6px; padding: 1px 6px; }
.selection .info.split .stat .v { font-size: 14px; }
.selection .pqueue { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 5px; padding-left: 12px; border-left: 1px solid rgba(201,160,106,0.25); }
.selection .pq-now { display: flex; align-items: center; gap: 8px; }
.selection .pq-text { display: flex; flex-direction: column; min-width: 0; font-family: var(--font-label); line-height: 1.1; }
.selection .pq-what { font-size: 14px; font-weight: 600; color: var(--cream); white-space: nowrap; }
.selection .pq-name { font-size: 16px; font-weight: 700; color: var(--cream); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.selection .pq-pct { color: #ffd77a; font-variant-numeric: tabular-nums; }
.selection .pqueue.waiting .pq-pct { color: #ff9a7a; font-size: 12px; }
.selection .pq-bar { display: block; height: 10px; padding: 2px; background: #0c0705; box-shadow: inset 0 1px 3px rgba(0,0,0,0.9), 0 0 0 2px var(--copper-mid); }
.selection .pq-bar i { display: block; height: 100%; width: calc(var(--p, 0) * 100%); background: linear-gradient(180deg, #ffe58a, #d39b1c 60%, #8a5a0c); }
.selection .pq-row { display: flex; flex-wrap: wrap; gap: 5px; }
.selection .pq-tile { position: relative; flex: none; width: 40px; height: 40px; padding: 0; border: 0; cursor: pointer; overflow: hidden;
  background: radial-gradient(circle at 50% 35%, #8a2417, #2a0703);
  box-shadow: inset 2px 2px 0 rgba(255,214,150,0.35), inset -2px -2px 0 rgba(0,0,0,0.6), 0 0 0 2px var(--copper-mid), 0 0 0 3px var(--copper-lo), 0 2px 4px rgba(0,0,0,0.6); }
.selection .pq-tile.now { width: 48px; height: 48px; box-shadow: inset 2px 2px 0 rgba(255,230,170,0.45), inset -2px -2px 0 rgba(0,0,0,0.6), 0 0 0 2px var(--copper-hi), 0 0 0 3px var(--copper-lo), 0 2px 5px rgba(0,0,0,0.7); }
.selection .pq-tile img { position: absolute; inset: 3px; width: calc(100% - 6px); height: calc(100% - 6px); object-fit: cover; display: block; }
.selection .pq-tile::after { content: ""; position: absolute; inset: 0; pointer-events: none; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.7), inset 0 0 8px rgba(0,0,0,0.55); }
.selection .pq-tile:hover { filter: brightness(1.15); }
.selection .pq-tile:hover::before { content: "\00d7"; position: absolute; right: 2px; top: -3px; z-index: 3; font: 700 18px/1 var(--font-label); color: #ff8a6a; text-shadow: 0 1px 2px #000; }
/* What is left to make darkens the portrait from the top, AoE2 style. */
.selection .pq-veil { position: absolute; left: 3px; right: 3px; top: 3px; height: calc((100% - 6px) * (1 - var(--p, 0))); background: rgba(10,5,2,0.55); z-index: 1; pointer-events: none; }
.selection .pq-n { position: absolute; left: 3px; top: 0; z-index: 2; font-family: var(--font-label); font-size: 24px; font-weight: 700; line-height: 1; color: #f4ead2;
  -webkit-text-stroke: 1px #1a0d05; text-shadow: 2px 2px 0 #1a0d05, 0 0 4px rgba(0,0,0,0.8); }
.selection .pq-tile .rflask { position: absolute; right: 2px; bottom: 2px; z-index: 2; width: 14px; height: 14px; padding: 1px; border-radius: 50%; background: rgba(20,12,4,0.75); color: #9fd8ff; }
.selection .pq-tile .rflask svg { width: 100%; height: 100%; }
.selection .groups { display: flex; flex-wrap: wrap; gap: 6px; }
.selection .chip { position: relative; width: 58px; height: 44px; padding: 0; overflow: hidden; cursor: pointer; border: 0; background: radial-gradient(circle at 50% 35%, #8a2417, #2a0703); box-shadow: 0 0 0 2px var(--copper-mid); }
.selection .chip:hover { box-shadow: 0 0 0 2px var(--copper-hi); }
.selection .chip img { width: 100%; height: 100%; object-fit: cover; display: block; }
.selection .chip b { position: absolute; right: 3px; bottom: 0; font-family: var(--font-label); font-size: 15px; color: #fff; text-shadow: 0 1px 2px #000; }
.selection .actions { flex: none; display: grid; grid-template-columns: repeat(2, 50px); grid-auto-rows: 50px; gap: 8px; align-content: start; padding-top: 2px; }
.ability {
  position: relative;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: 3px solid transparent;
  border-image: linear-gradient(150deg, var(--copper-hi), var(--copper) 25%, var(--copper-lo) 50%, var(--copper) 75%, var(--copper-hi)) 1;
  background: radial-gradient(120% 140% at 30% 20%, rgba(255,140,110,0.25), transparent 55%), linear-gradient(180deg, #8a2417, #3c0c07);
  color: #ffd98a;
  cursor: pointer;
}
.ability svg { width: 20px; height: 20px; }
.ability .key { position: absolute; left: 2px; top: 0; font-family: var(--font-label); font-size: 10px; font-weight: 700; color: rgba(246,230,196,0.6); }
.ability .lbl { font-family: var(--font-label); font-size: 10px; letter-spacing: 0.5px; text-transform: uppercase; color: var(--cream); line-height: 1; }
.ability:hover { filter: brightness(1.2); }
/* The faction ability (BFME style): wider, with a charge sweep while it fills
   and a glow once it is ready to cast. */
.ability.power { grid-column: span 2; width: auto; overflow: hidden; }
.ability.power::before { content: ""; position: absolute; inset: 0; background: conic-gradient(transparent calc(var(--cd) * 360deg), rgba(0,0,0,0.6) 0); pointer-events: none; }
.ability.power.charging { cursor: default; filter: saturate(0.5); }
.ability.power.charging:hover { filter: saturate(0.5); }
.ability.power.ready { box-shadow: 0 0 10px rgba(255,210,120,0.7); animation: power-ready 1.6s ease-in-out infinite; }
.ability.power .cd { position: absolute; right: 3px; top: 1px; font-family: var(--font-label); font-size: 10px; font-weight: 700; color: var(--cream); }
@keyframes power-ready { 50% { box-shadow: 0 0 18px rgba(255,210,120,0.95); } }
@media (prefers-reduced-motion: reduce) { .ability.power.ready { animation: none; } }
.ability:active { transform: translateY(1px); }
/* A toggle that is running (Auto Scout): lit brass like the active stance. */
.ability.on { background: radial-gradient(120% 140% at 30% 20%, rgba(255,224,138,0.45), transparent 60%), linear-gradient(180deg, #b8862e, #5a3a0c); color: #2a1408; box-shadow: 0 0 8px rgba(255,200,90,0.55); }
.ability.on .lbl { color: #2a1408; }
/* Stances, AoE2 style: a row of small icon buttons under the actions; the active one glows brass. */
.selection .side { flex: none; display: flex; flex-direction: column; justify-content: space-between; gap: 8px; }
.selection .stances { display: flex; gap: 4px; align-items: center; margin-top: auto; }
.selection .stances-k { font-family: var(--font-label); font-size: 10px; letter-spacing: 1.5px; text-transform: uppercase; color: #c9a06a; margin-right: 2px; writing-mode: vertical-rl; transform: rotate(180deg); }
.stance { position: relative; width: 32px; height: 32px; padding: 0; display: flex; align-items: center; justify-content: center; cursor: pointer; border: 2px solid transparent; border-image: linear-gradient(150deg, var(--copper-hi), var(--copper) 25%, var(--copper-lo) 50%, var(--copper) 75%, var(--copper-hi)) 1; background: linear-gradient(180deg, #4a2a18, #1e0f08); color: #c9a06a; }
.stance svg { width: 17px; height: 17px; }
.stance .key { position: absolute; left: 1px; top: -1px; font-family: var(--font-label); font-size: 9px; font-weight: 700; color: rgba(246,230,196,0.55); }
.stance:hover { filter: brightness(1.25); }
.stance.on { background: radial-gradient(120% 140% at 30% 20%, rgba(255,224,138,0.45), transparent 60%), linear-gradient(180deg, #b8862e, #5a3a0c); color: #2a1408; box-shadow: 0 0 8px rgba(255,200,90,0.55); }
.stance.on .key { color: rgba(255,243,208,0.85); }


.paused {
  position: absolute;
  left: 50%;
  top: 38%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 16px 48px;
  pointer-events: none;
}
.paused span { font-family: var(--font-label); font-size: 42px; font-weight: 700; letter-spacing: 9px; text-transform: uppercase; color: var(--cream); line-height: 1; text-shadow: 0 2px 0 #000; }
.paused small { font-family: var(--font-label); font-size: 13px; letter-spacing: 2px; text-transform: uppercase; color: #e0a96a; }

/* ---------- smaller windows ---------- */

@media (max-height: 820px) {
  #game { --bar-h: 206px; --map-w: 220px; }
  .build-grid { grid-auto-rows: 58px; gap: 6px; }
  #buildpanel { gap: 6px; padding-top: 8px; }
  .tab { height: 34px; }
  .dial { width: 74px; height: 74px; }
  #mapblock .gauge { left: -36px; top: -42px; }
}
@media (max-height: 640px) {
  #game { --bar-h: 180px; --map-w: 190px; }
  .build-hint { display: none; }
}
@container (max-width: 1280px) {
  #game { --cmd-w: 380px; }
  .build-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .selection .portrait { width: 110px; }
}
@container (max-width: 1060px) {
  #game { --cmd-w: 330px; --map-w: 200px; }
  .tab .tab-label { font-size: 13px; }
  .selection .portrait { display: none; }
  .selection .stats { display: none; }
}
@container (max-width: 860px) {
  #game { --cmd-w: 290px; --map-w: 170px; }
  .build-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tab .tab-label, .tab .key { display: none; }
  .tab { padding: 0; justify-content: center; }
  .selection .actions { grid-template-columns: repeat(2, 42px); grid-auto-rows: 42px; }
  .ability .lbl { display: none; }
  #mapblock .gauge { display: none; }
}


/* ---------------- Tooltip and overlays ---------------- */

.tooltip {
  --accent: #ffb81c;
  position: fixed;
  max-width: 290px;
  padding: 10px 12px;
  background: linear-gradient(180deg, var(--iron-2), var(--iron));
  border: 2px solid var(--brass-mid);
  box-shadow: 0 0 0 1px var(--brass-lo), 0 10px 24px rgba(0,0,0,0.55);
  font-size: 12px;
  line-height: 1.45;
  color: #e6dcc6;
  pointer-events: none;
  z-index: 50;
}
.tooltip h4 { margin: 0 0 2px; font-family: var(--font-label); font-weight: 700; font-size: 17px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--brass-hi); }
.tooltip .tt-role { font-family: var(--font-label); color: var(--accent); text-transform: uppercase; letter-spacing: 1px; font-size: 12px; margin-bottom: 4px; }
.tooltip .tt-req { color: #ff8f7a; margin-top: 6px; font-weight: 600; }
.tooltip .tt-ok { color: #a8e890; margin-top: 6px; font-weight: 600; }
.tooltip .tt-stats { color: #f2e6cc; margin-top: 6px; font-family: var(--font-label); font-size: 13px; letter-spacing: 0.3px; }
.tooltip .tt-hint { margin-top: 8px; padding-top: 6px; border-top: 1px solid var(--brass-lo); font-size: 11px; color: #a89c84; }

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
  padding: 16px;
}
.overlay-card {
  max-width: 600px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  padding: 28px;
  background: rgba(20,23,27,0.97);
  border: 1px solid #4a535c;
  line-height: 1.55;
  clip-path: polygon(24px 0, 100% 0, 100% calc(100% - 24px), calc(100% - 24px) 100%, 0 100%, 0 24px);
  --accent: #ffb81c;
}
/* In game, overlays wear the brass skin too. */
#game .overlay-card, #help.in-game .overlay-card {
  clip-path: none;
  background: linear-gradient(180deg, var(--iron-2), var(--iron));
  border: 3px solid transparent;
  border-image: linear-gradient(155deg, var(--brass-hi) 0%, var(--brass) 22%, var(--brass-lo) 48%, var(--brass-mid) 70%, var(--brass-hi) 100%) 1;
  box-shadow: 0 16px 40px rgba(0,0,0,0.6);
}
#game .overlay-card { --accent: inherit; }
.overlay-card h2 { font-family: var(--font-label); font-size: 32px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: #fff; margin-bottom: 8px; }
#game .overlay-card h2 { color: var(--brass-hi); }
.overlay-card ul { padding-left: 18px; color: var(--soft); }
#help .overlay-card { max-width: 860px; }
.keys { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 32px; margin-top: 8px; }
.keys h3 { font-family: var(--font-label); font-size: 13px; font-weight: 600; letter-spacing: 2px; text-transform: uppercase; color: var(--accent); margin-bottom: 8px; }
.keys dl { display: grid; grid-template-columns: max-content 1fr; gap: 7px 14px; margin: 0; font-size: 13px; line-height: 1.4; }
.keys dt { white-space: nowrap; color: #fff; }
.keys dd { margin: 0; color: var(--soft); }
.help-tip { margin: 16px 0 0; padding: 10px 12px; border-left: 3px solid var(--accent); background: rgba(255,255,255,0.04); font-size: 13px; color: var(--soft); }
@media (max-width: 760px) { .keys { grid-template-columns: 1fr; } }
#end-title[data-result="won"] { color: var(--accent) !important; }
#end-title[data-result="lost"] { color: var(--bad) !important; }
.overlay-card b { color: #fff; font-weight: 600; }
.overlay-actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
#end-stats { display: grid; grid-template-columns: 1fr repeat(7, auto); gap: 6px 16px; text-align: right; margin-top: 14px; padding: 12px 14px; background: #0f0d0b; box-shadow: inset 0 2px 6px rgba(0,0,0,0.85), 0 0 0 1px var(--brass-lo); font-family: var(--font-label); font-size: 17px; font-variant-numeric: tabular-nums; }
#end-stats .side { text-align: left; color: var(--pc, inherit); font-weight: 700; text-shadow: 0 1px 0 #000, 0 0 4px #000; }
#end-stats .tot { font-weight: 700; color: #fff; }
#end-stats > span:nth-child(8n+1) { text-align: left; }
#end-stats .h { font-family: var(--font-label); letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted); font-size: 12px; }

/* Concept A overrides for the nation cards, the nation sheet and the lobby. */
#menu .faction-cards { gap: 14px; }
#menu .faction-card {
  border: 10px solid transparent;
  border-image: var(--steel-sm);
  border-image-width: 10px;
  background: none;
  overflow: visible;
  box-shadow: 0 6px 12px rgba(0,0,0,0.45);
}
#menu .faction-card .pic { height: 96px; background: #222; box-shadow: 0 0 0 2px #8f6a2f, 0 0 0 4px #3a2a14; }
#menu .faction-card .pic::after { content: none; }
#menu .faction-card .txt { padding: 8px 4px 2px; align-items: center; text-align: center; background: linear-gradient(180deg, #2a2724, #1a1816); margin-top: 6px; }
#menu .faction-card .name { font-size: 20px; color: #f1dfb4; }
#menu .faction-card .tag { color: #b8a581; }
#menu .faction-card:hover:not(.active) { filter: brightness(1.1); }
#menu .faction-card.active { border: 10px solid transparent; border-image: var(--steel-sm); border-image-width: 10px; box-shadow: var(--amber-glow), 0 6px 12px rgba(0,0,0,0.45); }
#menu .faction-card.active .name { color: var(--amber); }
#menu .faction-detail {
  border: 0;
  padding: 16px 22px;
  background: var(--paper);
  color: #2f1f10;
  box-shadow: inset 0 0 30px rgba(120,80,30,0.25);
  clip-path: polygon(0 3%, 1% 0, 30% 2%, 60% 0, 99% 1%, 100% 6%, 99.5% 50%, 100% 96%, 98% 100%, 55% 98%, 20% 100%, 1% 99%, 0 94%, 0.6% 50%);
}
#menu .faction-detail .title { color: #2f1f10; font-size: 26px; }
#menu .faction-detail .motto { color: #6b4316; }
#menu .faction-detail .body { color: #3f2c18; font-size: 14px; }
#menu .faction-detail .divider { background: rgba(60,40,20,0.35); }
#menu .faction-detail .side { color: #2f1f10; font-size: 15px; }
#menu .faction-detail .label { color: #6b4b28; text-shadow: none; font-weight: 700; }
#menu .mp-or { color: #e2cfa2; font-size: 15px; text-shadow: 0 1px 2px #000; }
#menu .mp-or::before, #menu .mp-or::after { height: 6px; background: linear-gradient(180deg, #e2c27a, #8f6a2f); box-shadow: 0 1px 2px #000; }
#menu #mp-code { letter-spacing: 12px; text-transform: uppercase; font-size: 24px; text-align: center; background: #1b1714; color: #ffcf6a; text-shadow: 0 0 6px rgba(255,170,40,0.6); }
#menu .mp-host-btn .btn-primary { height: 62px; font-size: 20px; padding: 0 18px; clip-path: none; }
#menu .mp-status, #menu .mp-msg { color: #ead7ad; text-shadow: 0 1px 2px #000; }

/* Tutorial page: the briefing line beside Start tutorial. */
.tut-brief { display: flex; align-items: center; gap: 22px; }
.tut-brief p { flex: 1; margin: 0; font-size: 15px; line-height: 1.5; color: #ead7ad; text-shadow: 0 1px 2px #000; }
.tut-brief b { color: var(--amber, #ffb53a); font-weight: 600; }
.tut-brief .btn-primary { flex: none; }
@media (max-width: 760px) { .tut-brief { flex-direction: column; align-items: stretch; } }

/* Watch AI vs AI: the matchup (each team's flags, VS between) and the seats,
   whose nations are picked from a row of flags (or ? for Random). */
.matchup { display: flex; align-items: center; justify-content: center; gap: 18px; flex-wrap: wrap; min-height: 112px; }
.mu-side { display: flex; gap: 12px; }
.mu-plate { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 120px; font-family: var(--font-label); font-size: 17px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: #f1dfb4; text-shadow: 0 1px 2px #000; }
.mu-flag { width: 120px; height: 76px; border: 8px solid transparent; border-image: var(--steel-sm); border-image-width: 8px; box-shadow: 0 6px 12px rgba(0,0,0,0.45); position: relative; }
.mu-flag::after { content: ""; position: absolute; left: 0; right: 0; bottom: -2px; height: 5px; background: var(--pc); box-shadow: 0 0 6px var(--pc); }
.mu-pic { display: flex; width: 100%; height: 100%; }
.mu-vs { font-family: var(--font-label); font-size: 40px; font-weight: 700; text-transform: uppercase; letter-spacing: 2px; background: linear-gradient(180deg, #f8e2a6 0%, #d9a650 55%, #8f6327 100%); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; filter: drop-shadow(0 2px 0 #1a120a); padding-bottom: 26px; }
.random-flag { align-items: center; justify-content: center; background: repeating-linear-gradient(135deg, #2a2622 0 8px, #221f1c 8px 16px); color: #e2c27a; font-family: var(--font-label); font-weight: 700; font-size: 34px; line-height: 1; }
.chip-slots .slot { grid-template-columns: 12px minmax(0, 1fr) 384px minmax(0, 0.7fr); }
.nation-chips { display: flex; gap: 6px; }
.nation-chip { display: flex; flex-direction: column; align-items: center; gap: 3px; width: 72px; padding: 4px 4px 3px; border: 0; background: #1b1816; box-shadow: 0 0 0 2px #4d4a47, 0 0 0 4px #2a2826; cursor: pointer; font-family: var(--font-label); font-size: 12px; font-weight: 600; letter-spacing: 0.5px; text-transform: uppercase; color: #b8a581; }
.nation-chip .chip-flag { display: flex; width: 64px; height: 32px; filter: saturate(0.7) brightness(0.75); }
.nation-chip .random-flag { font-size: 22px; }
.nation-chip:hover .chip-flag { filter: none; }
.nation-chip:hover { color: #f1dfb4; }
.nation-chip.on { background: #2a2420; color: var(--amber, #ffb53a); box-shadow: 0 0 0 2px var(--amber, #ffb53a), 0 0 12px rgba(255,160,30,0.55); }
.nation-chip.on .chip-flag { filter: none; }
.chip-slots .slot.closed .nation-chips { visibility: hidden; }
.nation-chip-gap { width: 72px; flex: none; }

/* Laptop-height screens: tighten the menu so Start stays in view. */
@media (max-height: 940px) and (min-width: 1101px) {
  #menu { padding: 24px 40px; gap: 40px; }
  .menu-intro { width: 300px; gap: 10px; }
  #menu .nav-item { height: 54px; font-size: 21px; }
  #menu .nav-item::after { width: 32px; height: 32px; }
  #menu .setup { gap: 14px; padding: 10px 18px 16px; }
  #menu .setup-head h2 { font-size: 38px; }
  #menu .faction-card .pic { height: 74px; }
  .faction-detail { padding: 10px 16px; }
  #menu .btn-primary, #menu .btn-ghost { height: 54px; }
}

@media (max-width: 1100px) {
  #menu { flex-direction: column; align-items: stretch; padding: 24px 16px; gap: 20px; }
  .menu-intro { width: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .menu-intro .logo { width: 240px; }
  .menu-nav { flex: 1; min-width: 260px; }
}
@media (max-width: 760px) {
  .settings-grid { grid-template-columns: 1fr; }
  .faction-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .setup-row { grid-template-columns: 1fr; }
  .faction-detail { flex-direction: column; }
  .faction-detail .divider { display: none; }
}

/* Player vs player: stalled-on-peer notice and the connection badge. */
.net-wait {
  position: absolute; left: 50%; top: 84px; transform: translateX(-50%);
  display: flex; gap: 10px; align-items: center; padding: 10px 16px;
  background: linear-gradient(180deg, #6d1a11, #320a06); border: 3px solid var(--copper, #c07a3e); color: var(--cream, #fff);
  font-family: var(--font-label); font-size: 16px; letter-spacing: 1px; text-transform: uppercase;
  pointer-events: none; z-index: 20;
}
.net-drop {
  position: absolute; left: 50%; top: 84px; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 10px; align-items: center; padding: 12px 18px;
  max-width: min(560px, calc(100vw - 32px));
  background: linear-gradient(180deg, #6d1a11, #320a06); border: 3px solid var(--copper, #c07a3e); color: var(--cream, #fff);
  font-family: var(--font-label); font-size: 16px; letter-spacing: 1px; text-align: center;
  z-index: 21;
}
.net-drop p { display: flex; gap: 10px; align-items: center; margin: 0; }
.net-drop-btns { display: flex; gap: 10px; }
.net-drop-btns:not(:has(button:not(.hidden))) { display: none; }
.net-drop .btn-primary, .net-drop .btn-ghost { height: 36px; padding: 0 14px; font-size: 14px; }
#menu .nav-item.rejoin span { color: #8a1c0f; }
.net-badge.bad { background: #6d1a11; border-color: var(--copper, #c07a3e); color: var(--cream, #fff); }
.net-badge {
  /* Under the banner, clear of the minimap. */
  position: absolute; right: 12px; top: 62px; padding: 4px 10px;
  background: rgba(0,0,0,0.55); border: 1px solid var(--line); color: var(--soft);
  font-family: var(--font-label); font-size: 12px; letter-spacing: 1.5px; text-transform: uppercase;
  pointer-events: none;
}
@media (max-width: 760px) { .mp-join, .mp-link { grid-template-columns: 1fr; } }

.mp-msg.info { border-left-color: var(--accent); background: rgba(255,255,255,0.06); color: var(--soft); }


/* ---------- live score (above the minimap, AoE2 style) ---------- */
.scoreboard {
  position: absolute; right: 0; bottom: calc(100% + 8px); z-index: 5;
  width: max-content; min-width: calc(100% - 52px);
  display: grid; grid-template-columns: 1fr repeat(4, 0) auto; column-gap: 0;
  padding: 4px 8px 5px;
  background: linear-gradient(180deg, rgba(51,32,15,0.92), rgba(28,18,10,0.92));
  border: 3px solid transparent;
  border-image: linear-gradient(150deg, var(--copper-hi) 0%, var(--copper) 18%, var(--copper-lo) 45%, var(--copper-mid) 65%, var(--copper-hi) 85%, var(--copper) 100%) 1;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.6), 0 6px 16px rgba(0,0,0,0.55);
  font-family: var(--font-label); font-variant-numeric: tabular-nums;
  pointer-events: auto; cursor: default;
}
.scoreboard.hidden { display: none; }
.scoreboard .sc-head, .scoreboard .sc-row { display: contents; }
.scoreboard .sc-head > span { font-size: 10.5px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; color: var(--copper-hi); opacity: 0.85; padding-bottom: 2px; border-bottom: 1px solid rgba(246,196,138,0.25); margin-bottom: 2px; }
.scoreboard .sc-col { overflow: hidden; width: 0; padding: 0; text-align: right; color: #d8c6a2; font-size: 13px; white-space: nowrap; }
.scoreboard .sc-tot { text-align: right; padding-left: 12px; font-size: 15px; font-weight: 700; color: var(--cream); white-space: nowrap; }
.scoreboard .sc-row > * { padding-top: 1px; padding-bottom: 1px; line-height: 17px; }
.scoreboard .sc-name { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 15px; font-weight: 700; color: var(--pc); text-shadow: 0 1px 0 #000, 0 0 3px #000, 0 0 6px rgba(0,0,0,0.8); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scoreboard .sc-name span { overflow: hidden; text-overflow: ellipsis; }
.scoreboard .sc-pip { flex: none; width: 9px; height: 9px; background: var(--pc); box-shadow: 0 0 0 1px #000, 0 0 0 2px rgba(246,196,138,0.5); transform: rotate(45deg); }
.scoreboard .sc-row.me .sc-tot { color: #fff; }
.scoreboard .sc-row.out > * { opacity: 0.45; text-decoration: line-through; }
/* Hover (or a click, which pins it) opens the breakdown: the panel grows to the left. */
.scoreboard:hover, .scoreboard.open { grid-template-columns: 1fr repeat(4, auto) auto; }
.scoreboard:hover .sc-col, .scoreboard.open .sc-col { width: auto; padding-left: 12px; }
#game.spectating .scoreboard { min-width: 100%; }
#endscreen .overlay-card { max-width: 720px; }


/* ================= AoE2 bottom bar: gunmetal and brass =================
   A painted skin after Aran's concept A, the way AoE2 does it: Meshy painted
   the bar with every slot empty (assets/hud/skin-*), and the live panels sit
   in its slots. The command panel and the info panel stretch as 9-slices.
   The map panel keeps its shape and sits over the minimap, whose diamond
   shows through the hole. No grille: the info panel butts against the
   command panel (Aran). */

#game {
  --side-h: 268px; --cmd-h: 282px; --info-h: 226px; --grille-h: 212px;
  --cmd-w: 310px; --map-w: 276px; --info-w: 480px; --gap: 0px; --wing: 46px;
  --brass-hi: #ffe7a8; --brass: #c79a45; --brass-lo: #5e4114;
}

.hudbar {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 1;
  height: var(--grille-h); background: none; pointer-events: none;
}
.hudbar .hb-paper { pointer-events: auto; }
#game.spectating .hudbar .hb-paper { display: none; }

/* Command panel: bottom left. The image is drawn 43px deep at the edges, but
   the content starts 25px in, where the recess begins. */
#buildpanel {
  left: 0; bottom: 0; width: var(--cmd-w); height: var(--cmd-h);
  padding: 4px 4px 2px; gap: 6px;
  border: 25px solid transparent;
  border-image: url("assets/hud/skin-left.png") 100 fill / 43px / 0 stretch;
  background: none; box-shadow: none;
}
#buildpanel::before, #buildpanel .gear, #buildpanel .build-hint { display: none; }
#buildpanel .tabs { padding-left: 0; gap: 6px; }
/* Plain tabs: no cog medallion or Tab hint (Aran). */
#buildpanel .tab .medal, #buildpanel .tab .key { display: none; }
#buildpanel .tab { padding: 0 8px; justify-content: center; }
/* A unit's commands: square buttons in the left panel, as in AoE2. */
.cmd-grid { display: grid; grid-template-columns: repeat(4, 56px); grid-auto-rows: 56px; gap: 7px; padding: 4px; align-content: start; }
.cmd-grid:empty, #buildpanel .build-grid:empty { display: none; }
.cmd-grid .actions, .cmd-grid .stances { display: contents; }
.cmd-grid .ability, .cmd-grid .stance { width: 56px; height: 56px; }
.cmd-grid .ability.power { width: auto; }
.cmd-grid .ability svg, .cmd-grid .stance svg { width: 24px; height: 24px; }
.cmd-grid .stance .key { font-size: 10px; left: 3px; top: 1px; }
#buildpanel .tab { height: 30px; }
#buildpanel .build-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); grid-auto-rows: 56px; gap: 7px; padding: 4px; scrollbar-color: var(--brass-lo) transparent; }
/* Production cards: a riveted brass bezel with corner brackets, painted in
   assets/hud/card-frame.png (the Mac app draws the same picture). The
   portrait sits under a glass sheen; price tag, count disc and name plate
   sit on top of the frame. */
#buildpanel .bbtn {
  border: 0; border-radius: 4px;
  background: radial-gradient(120% 90% at 50% 30%, #6a7272, #2c3234 60%, #15191b);
  box-shadow: 0 2px 5px rgba(0,0,0,0.65);
}
#buildpanel .bbtn::before {
  content: ''; position: absolute; inset: 0; z-index: 2; pointer-events: none;
  border: 14px solid transparent;
  border-image: url("assets/hud/card-frame.png") 56 / 14px / 0 stretch;
  transition: filter 0.12s;
}
#buildpanel .bbtn .thumb { inset: 3px; border-radius: 3px; overflow: hidden; }
#buildpanel .bbtn .thumb::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(155deg, rgba(255,250,230,0.22), rgba(255,250,230,0.04) 38%, rgba(0,0,0,0) 52%, rgba(0,0,0,0.3));
  box-shadow: inset 0 0 8px rgba(0,0,0,0.75);
}
/* Pure AoE2 (Aran): no name or price on the card, just the picture; both
   are in the hover hint. A too dear card still greys out. */
#buildpanel .bbtn .bname, #buildpanel .bbtn .bcost { display: none; }
/* Queue count on a brass disc over the top right bracket. */
#buildpanel .bbtn .bcount {
  right: 2px; top: 2px; z-index: 3;
  min-width: 18px; height: 18px; padding: 0 3px; border-radius: 9px;
  background: radial-gradient(circle at 40% 30%, #8a2a1a, #3a0c06);
  box-shadow: 0 0 0 1.5px #d4aa62, 0 0 0 2.5px #2a1a08, 0 1px 3px rgba(0,0,0,0.7);
  font-size: 12px; line-height: 18px; text-align: center; color: #fff4d6;
}
#buildpanel .bbtn .bcount:empty { display: none; }
#buildpanel .bbtn .block { z-index: 3; right: 4px; top: 4px; filter: drop-shadow(0 1px 1px #000); }
#buildpanel .bbtn .rflask { z-index: 3; right: 2px; bottom: 2px; box-shadow: 0 0 0 1px #b88d4a; }
/* Progress: a slim gauge inside the bottom of the bezel, only while busy. */
#buildpanel .bbtn .bar { left: 5px; right: 5px; bottom: 4px; height: 3px; z-index: 2; background: rgba(0,0,0,0.75); opacity: 0; }
#buildpanel .bbtn.building .bar, #buildpanel .bbtn.ready .bar { opacity: 1; }
#buildpanel .bbtn .bprog, #buildpanel .bbtn .bready { border-radius: 3px; }
#buildpanel .bbtn .bpct { z-index: 1; }
#buildpanel .bbtn::after { z-index: 4; border-radius: 4px; }
#buildpanel .bbtn:hover:not(.locked) { filter: none; box-shadow: 0 0 9px 2px rgba(255,205,120,0.5), 0 2px 5px rgba(0,0,0,0.65); }
#buildpanel .bbtn:hover:not(.locked)::before { filter: brightness(1.3) saturate(1.1); }
#buildpanel .bbtn:hover:not(.locked):not(.poor) .thumb { filter: brightness(1.12); }
#buildpanel .bbtn.active-q, #buildpanel .bbtn.ready, #buildpanel .bbtn.placing { box-shadow: 0 0 10px 3px rgba(255,190,90,0.75), 0 2px 5px rgba(0,0,0,0.65); }
/* Too dear or locked: the brass dulls along with the portrait. */
#buildpanel .bbtn.poor:not(.locked)::before { filter: grayscale(0.7) brightness(0.72); }
#buildpanel .bbtn.locked::before { filter: grayscale(1) brightness(0.55); }
/* Tutorial: the card or tab the current step wants pressed pulses amber,
   like the ring on the map (src/client/tutorial.js). */
#buildpanel .bbtn.tut-hi, #buildpanel .tab.tut-hi { animation: tut-hi 1.1s ease-in-out infinite; z-index: 1; }
#buildpanel .bbtn.tut-hi .thumb { animation: tut-hi-glow 1.1s ease-in-out infinite; }
@keyframes tut-hi {
  0%, 100% { box-shadow: 0 0 0 3px #ffb53a, 0 0 8px 3px rgba(255,170,40,0.6); outline: 2px solid rgba(255,181,58,0); outline-offset: 2px; }
  50% { box-shadow: 0 0 0 3px #ffe29a, 0 0 20px 8px rgba(255,170,40,1); outline: 2px solid rgba(255,181,58,0.9); outline-offset: 5px; }
}
@keyframes tut-hi-glow { 0%, 100% { filter: brightness(1); } 50% { filter: brightness(1.35); } }
#buildpanel .tab, .selection .ability, .selection .pq-tile, .selection .chip {
  border-image: linear-gradient(150deg, var(--brass-hi), var(--brass) 25%, var(--brass-lo) 55%, var(--brass) 80%, var(--brass-hi)) 1;
}
#buildpanel .tab { background: radial-gradient(120% 140% at 30% 20%, rgba(255,255,255,0.12), transparent 55%), linear-gradient(180deg, #4a5157, #1e2226); }
#buildpanel .tab.active { background: radial-gradient(120% 140% at 30% 20%, rgba(255,140,110,0.22), transparent 55%), linear-gradient(180deg, #6d1a11, #320a06); }

/* Info panel: the painted parchment, just right of the command panel (Aran
   asked for it further left). The empty sheet in the grille shows when
   nothing is selected, as in AoE2. */
.hudbar .hb-paper, .selection {
  position: absolute; bottom: 0; top: auto;
  left: calc(var(--cmd-w) + var(--gap)); right: auto;
  width: min(var(--info-w), calc(100cqw - var(--cmd-w) - var(--gap) - var(--map-w) - var(--wing) - 20px)); margin: 0;
  height: var(--info-h);
  border: 24px solid transparent; border-left-width: 22px; border-right-width: 22px;
  border-image: url("assets/hud/skin-middle.png") 78 175 fill / 38px 85px / 0 stretch;
  background: none; box-shadow: none;
}
.selection::before { display: none; }
.selection { padding: 10px 16px; gap: 14px; }
/* Room round the portrait picture, inside its frame (Aran). */
.selection .portrait img { position: absolute; inset: 5px; width: calc(100% - 10px); height: calc(100% - 10px); }
.selection .portrait { width: 96px; box-shadow: 0 0 0 2px var(--brass), 0 0 0 3px var(--brass-lo), inset 0 0 14px rgba(0,0,0,0.75); }
/* AoE2 proportions: the name across the top, a small portrait under it with
   the health bar below, and the stats beside it. The rest is parchment. */
.selection { display: grid; grid-template-columns: 96px minmax(0, 1fr) auto auto; grid-template-rows: auto auto auto 1fr; column-gap: 14px; row-gap: 5px; align-content: start; }
.selection .portrait { grid-column: 1; grid-row: 2; height: 96px; }
.selection .info, .selection .info .col, .selection .info.split .col { display: contents; }
.selection .info .title { grid-column: 1 / 3; grid-row: 1; flex-direction: row; align-items: baseline; gap: 10px; }
.selection .info .hp { grid-column: 1; grid-row: 3; flex-direction: column; align-items: stretch; gap: 2px; }
.selection .info .hp::before { display: none; }
.selection .info .pips { min-width: 0; max-width: none; }
.selection .pips span { height: 8px; }
.selection .info .stats { grid-column: 2; grid-row: 2; grid-template-columns: repeat(2, minmax(0, 150px)); gap: 4px; align-content: start; }
.selection .info .note, .selection .info .groups { grid-column: 2; grid-row: 2 / 5; align-self: start; }
.selection .info .stats ~ .note, .selection .info .stats ~ .groups { grid-row: 3 / 5; }
.selection .pqueue { grid-column: 2; grid-row: 2; padding-left: 0; border-left: 0; max-width: 300px; }
/* Stores sit at the bottom, under the queue (Aran). */
.selection .info .stats.stores { grid-column: 2; grid-row: 3; align-self: start; }
/* No queue: the stores sit low beside the portrait, ending level with the health. */
.selection:not(:has(.pqueue)) .info .stats.stores { grid-row: 2 / 4; align-self: end; }
/* A compact queue so it and the stores fit beside the portrait. */
.selection .pqueue { gap: 4px; }
.selection .pq-tile { width: 34px; height: 34px; }
.selection .pq-tile.now { width: 42px; height: 42px; }
.selection .pq-n { font-size: 19px; }
.selection .pq-bar { height: 8px; }
.selection .pqueue .pq-text { flex-direction: row; align-items: baseline; gap: 8px; }
.selection .pqueue .pq-row { flex-wrap: nowrap; align-items: flex-end; overflow: hidden; }
.selection .side { grid-column: 4; grid-row: 1 / -1; }
.selection .stat { padding: 1px 6px; }
.selection .stat .k { font-size: 9px; }
.selection .stat .v { font-size: 14px; }
.selection .hp-text { font-size: 13px; }
.selection .note { font-size: 12px; }
.selection .role { font-size: 11px; }
/* Unit stats: icon and number, AoE2 style. */
.selection .info .stats:has(.istat) { grid-template-columns: 1fr; gap: 6px; }
.selection .istat { display: flex; align-items: center; gap: 8px; color: #5a4020; }
.selection .istat svg { width: 22px; height: 22px; }
.selection .istat .v { font-family: var(--font-label); font-size: 17px; font-weight: 700; color: #2b1a0c; }
/* Stores: a row of boxes per good, like the rows under the health bar. */
.selection .info .stats.stores { grid-template-columns: 1fr; gap: 4px; }
.selection .info.split .store .boxes i { width: 8px; }
.selection .info.split .store .k { width: 40px; }
.selection .store { display: flex; align-items: center; gap: 8px; }
.selection .store .k { width: 46px; font-family: var(--font-label); font-size: 11px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: #7a5a30; }
.selection .store .boxes { display: flex; gap: 2px; padding: 2px; background: #2a2016; box-shadow: inset 0 1px 3px rgba(0,0,0,0.9), 0 0 0 1px #5e4114; }
.selection .store .boxes i { width: 12px; height: 10px; background: rgba(255,255,255,0.06); }
.selection .store .boxes i.on { background: linear-gradient(180deg, var(--hi), var(--lo)); }
.selection .portrait .count { background: linear-gradient(180deg, var(--brass-hi), var(--brass)); }
.selection h3 { font-family: Georgia, "Times New Roman", serif; font-size: 20px; color: #2b1a0c; text-shadow: none; }
.selection .role { color: #8a4a1c; }
.selection.enemy h3 { color: #8a1a0c; }
.selection.enemy .role { color: #a83a20; }
.selection .hp::before, .selection .hp-text { color: #2b1a0c; }
.selection .pips, .selection .pq-bar { background: #2a2016; box-shadow: inset 0 1px 3px rgba(0,0,0,0.9), 0 0 0 1px #5e4114; }
.selection .info { gap: 4px; }
.selection .stat { background: rgba(110,70,25,0.08); box-shadow: 0 0 0 1px rgba(110,75,30,0.35); }
.selection .stat .k { color: #7a5a30; }
.selection .stat .v { color: #2b1a0c; }
.selection .info.split .stats { gap: 2px; }
.selection .info.split .stat { padding: 0 6px; }
.selection .info.split .stat .v { font-size: 13px; }
.selection .note { color: #4a3620; }
.selection .pqueue { border-left: 0; }
.selection .pq-what, .selection .pq-name { color: #2b1a0c; }
.selection .pq-pct { color: #8a4a0c; }
.selection .pqueue.waiting .pq-pct { color: #a8281c; }
.selection .stances-k { color: #7a5a30; }
.selection .groups .chip { box-shadow: 0 0 0 2px var(--brass-lo); }
/* Several selected: a portrait per unit (one per squad), AoE2 style, filling
   the space the big portrait and stats use for one unit. */
.selection.multi .info .unitgrid { grid-column: 1 / 3; grid-row: 2 / 5; align-self: start; }
.selection .unitgrid { --s: 40px; display: flex; flex-wrap: wrap; align-content: flex-start; gap: 4px; max-height: 148px; overflow: hidden; }
.selection .ut { position: relative; flex: none; width: var(--s); height: var(--s); padding: 0; border: 0; cursor: pointer; overflow: hidden;
  background: radial-gradient(circle at 50% 35%, #8a2417, #2a0703);
  box-shadow: inset 2px 2px 0 rgba(255,214,150,0.35), inset -2px -2px 0 rgba(0,0,0,0.6), 0 0 0 1px var(--brass-lo); }
.selection .ut img { position: absolute; inset: 2px 2px 6px; width: calc(100% - 4px); height: calc(100% - 8px); object-fit: cover; display: block; }
.selection .ut:hover { filter: brightness(1.2); box-shadow: inset 2px 2px 0 rgba(255,230,170,0.45), inset -2px -2px 0 rgba(0,0,0,0.6), 0 0 0 2px var(--brass-hi); }
.selection .ut b { position: absolute; left: 2px; top: 0; font: 700 13px/1 var(--font-label); color: #f4ead2; text-shadow: 1px 1px 0 #1a0d05, 0 0 3px #000; }
.selection .ut .uhp { position: absolute; left: 2px; right: 2px; bottom: 1px; height: 4px; background: #1a120a; }
.selection .ut .uhp::after { content: ""; position: absolute; inset: 0; width: calc(var(--hp) * 100%); }
.selection .ut .uhp.good::after { background: #4fbf3a; }
.selection .ut .uhp.warn::after { background: #d9a531; }
.selection .ut .uhp.bad::after { background: #c8402c; }
.selection .ut.more { display: grid; place-items: center; cursor: default; font: 700 13px/1 var(--font-label); color: #2b1a0c; background: rgba(110,70,25,0.15); }

/* Map panel: the painted panel sits over the minimap. Its diamond hole is
   75% of the panel's width, centred, and its four glass domes are buttons
   (centres measured from the 600x582 image). */
#mapblock { right: 0; bottom: 0; width: calc(var(--map-w) + var(--wing)); height: var(--side-h); }
#mapblock::after {
  content: ""; position: absolute; inset: 0 0 0 var(--wing); z-index: 2; pointer-events: none;
  background: url("assets/hud/skin-right.png") center / 100% 100% no-repeat;
}
/* A gunmetal wing on the map panel's left holds the power bar. */
#mapblock::before {
  content: ""; position: absolute; left: 0; top: 14px; bottom: 0; width: calc(var(--wing) + 60px); z-index: 0; pointer-events: none;
  border: 43px solid transparent; border-image: url("assets/hud/skin-left.png") 100 fill / 43px / 0 stretch;
}
#mapblock .radar-block { position: absolute; inset: 0 0 0 var(--wing); height: auto; padding: 0; background: none; border: 0; box-shadow: none; display: block; }
#mapblock .radar-title { display: none; }
#mapblock .radar { position: absolute; inset: 0; display: block; }
#mapblock .radar-glass { position: absolute; left: 12.5%; width: 75%; top: 11.3%; height: 77.3%; background: #0c0e0d; box-shadow: none; overflow: visible; }
#mapblock .radar-glass::after { display: none; }
.mm-btn {
  position: absolute; z-index: 3; width: 13%; aspect-ratio: 1; height: auto; padding: 0; border: 0; border-radius: 50%;
  translate: -50% -50%; display: grid; place-items: center; cursor: pointer;
  background: none; color: rgba(255,255,255,0.85);
}
.mm-btn svg { width: 46%; height: 46%; opacity: 0.6; filter: drop-shadow(0 1px 1px rgba(0,0,0,0.9)); }
.mm-btn:hover { box-shadow: 0 0 10px 3px rgba(160,210,255,0.65); }
.mm-btn.tr:hover { box-shadow: 0 0 10px 3px rgba(255,200,90,0.7); }
.mm-btn:hover svg { opacity: 1; }
.mm-btn:active { translate: -50% calc(-50% + 1px); }
.mm-btn.tl { left: 18.6%; top: 18.3%; }
.mm-btn.tr { left: 81.6%; top: 17.9%; }
.mm-btn.bl { left: 18.8%; top: 81.3%; }
.mm-btn.br { left: 81.5%; top: 81.4%; }
/* Power: just the bar, in the wing left of the map (Aran dropped the dial;
   it stays in the page, hidden, as ui.js still drives it). */
#mapblock .gauge { display: none; }
#mapblock .power-bar { position: absolute; right: calc(100% + var(--wing) - 36px); bottom: 44px; height: calc(var(--side-h) - 100px); width: 12px; z-index: 3; box-shadow: inset 0 2px 5px rgba(0,0,0,0.9), 0 0 0 2px var(--brass-lo); }
.scoreboard { border-image: linear-gradient(150deg, var(--brass-hi), var(--brass) 18%, var(--brass-lo) 45%, var(--brass) 70%, var(--brass-hi)) 1; background: linear-gradient(180deg, rgba(40,44,48,0.92), rgba(18,20,23,0.92)); }

@media (max-height: 820px) {
  #game { --side-h: 240px; --cmd-h: 252px; --info-h: 204px; --grille-h: 190px; --map-w: 248px; }
  #buildpanel .build-grid { grid-auto-rows: 48px; }
  .selection .portrait { width: 84px; height: 84px; }
  .selection { grid-template-columns: 84px minmax(0, 1fr) auto auto; }
}
@media (max-height: 640px) {
  #game { --side-h: 200px; --cmd-h: 222px; --info-h: 172px; --grille-h: 160px; --map-w: 206px; }
  #buildpanel .build-grid { grid-auto-rows: 38px; }
}
@container (max-width: 1400px) {
  #game { --cmd-w: 300px; }
}
@container (max-width: 1180px) {
  #game { --cmd-w: 290px; --map-w: 240px; }
}
@container (max-width: 860px) {
  #game { --cmd-w: 260px; --map-w: 200px; --gap: 0px; --wing: 0px; }
  #mapblock .power-bar, #mapblock::before { display: none; }
}

/* Get the Mac app page. */
.dl-lead { margin: 0; font-size: 16px; line-height: 1.5; color: #e8dcc0; text-shadow: 0 1px 2px #000; max-width: 62ch; }
.dl-steps { margin: 0; padding-left: 22px; display: grid; gap: 6px; font-size: 15px; line-height: 1.45; color: #e8dcc0; text-shadow: 0 1px 2px #000; }
.dl-steps kbd { font-size: 12px; padding: 0 5px; border: 1px solid #8a6a3a; border-radius: 3px; color: #f1dfb6; }
#menu input.dl-cmd[type="text"] { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 15px; cursor: text; }
#menu a.btn-ghost, #menu a.btn-primary { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.dl-os { display: grid; gap: 20px; }
.dl-other { align-self: flex-start; background: none; border: 0; padding: 0; color: #ffcf7a; font: 600 15px var(--font-body, inherit); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; text-shadow: 0 1px 2px #000; }
.dl-other:hover { color: #fff; }
