:root {
  --navy-0: #070c1a;
  --navy-1: #0e1730;
  --navy-2: #18264a;
  --royal: #24407e;
  --gold: #e0b24a;
  --gold-light: #f7dc8c;
  --gold-dark: #9a7224;
  --text: #efe6cf;
  --muted: #a9b1c7;
  --danger: #ff8a78;
  --ok: #8fe07a;
  --display: "Cinzel", Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--navy-0);
  color: var(--text);
  font-family: Georgia, "Times New Roman", serif;
  overflow: hidden;
}

.hidden { display: none !important; }

/* ---------------------------------------------------------------- Menu shell */

#menu-shell {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 55% at 50% 32%, rgba(80, 120, 210, 0.35) 0%, transparent 70%),
    radial-gradient(ellipse at 50% 40%, var(--royal) 0%, #122247 40%, var(--navy-0) 100%);
}
/* Vignette */
#menu-shell::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 180px 40px rgba(0, 0, 0, 0.85);
}

#embers {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.shell-inner {
  position: relative;
  z-index: 1;
  height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 16px 40px;
}

#logo {
  display: block;
  width: auto;
  max-width: min(980px, 100%);
  max-height: 52vh;
  margin: auto 0 -1vh; /* top auto + footer auto centres the group vertically */
  filter: drop-shadow(0 14px 30px rgba(0, 0, 0, 0.75));
  transition: max-height 0.35s ease;
  animation: rise-in 0.9s ease-out both;
  user-select: none;
  -webkit-user-drag: none;
}
#menu-shell:not([data-screen="menu"]) #logo { max-height: 26vh; }
#menu-shell[data-screen="lobby"] #logo { max-height: 13vh; } /* the lobby has the most on it */

.menu-screen {
  width: 100%;
  display: flex;
  justify-content: center;
  animation: rise-in 0.5s ease-out both;
}

.shell-footer {
  margin-top: auto;
  padding-top: 20px;
  font-family: var(--display);
  font-size: 12px;
  letter-spacing: 0.12em;
  color: rgba(169, 177, 199, 0.6);
}

@keyframes rise-in {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

/* ---------------------------------------------------------------- Panels */

.panel {
  position: relative;
  width: 100%;
  max-width: 360px;
  padding: 26px 28px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: linear-gradient(180deg, rgba(24, 38, 74, 0.94), rgba(10, 17, 36, 0.96));
  border: 2px solid var(--gold-dark);
  border-radius: 4px;
  box-shadow:
    0 0 0 1px #000,
    0 0 0 4px #13203f,
    0 0 0 5px rgba(224, 178, 74, 0.55),
    0 20px 50px rgba(0, 0, 0, 0.7);
}
.panel.wide { max-width: 520px; }
/* Inner hairline border */
.panel::after {
  content: "";
  position: absolute;
  inset: 6px;
  border: 1px solid rgba(224, 178, 74, 0.22);
  border-radius: 2px;
  pointer-events: none;
}
/* Gold diamond ornament on the top edge */
.panel::before {
  content: "";
  position: absolute;
  top: -9px;
  left: 50%;
  width: 14px;
  height: 14px;
  transform: translateX(-50%) rotate(45deg);
  background: linear-gradient(135deg, var(--gold-light), var(--gold-dark));
  border: 1px solid #000;
  box-shadow: 0 0 8px rgba(224, 178, 74, 0.6);
}

.panel-title {
  margin: 0;
  text-align: center;
  font-family: var(--display);
  font-weight: 900;
  font-size: 26px;
  letter-spacing: 0.06em;
  background: linear-gradient(180deg, #fff3c4 0%, var(--gold) 55%, #a8761f 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 1px rgba(0, 0, 0, 0.8));
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span {
  font-family: var(--display);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold);
}

input {
  padding: 10px 12px;
  font: inherit;
  font-size: 16px;
  color: var(--text);
  background: linear-gradient(180deg, #060b18, #0d1630);
  border: 1px solid var(--gold-dark);
  border-radius: 3px;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.7);
  outline: none;
}
input:focus {
  border-color: var(--gold);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.7), 0 0 0 2px rgba(224, 178, 74, 0.25);
}

.server-settings summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  list-style: none;
}
.server-settings summary::-webkit-details-marker { display: none; }
.server-settings summary::before { content: "▸ "; }
.server-settings[open] summary::before { content: "▾ "; }
.server-settings summary:hover { color: var(--gold-light); }
.server-settings .field { margin-top: 10px; }

/* ---------------------------------------------------------------- Buttons */

button {
  padding: 10px 18px;
  font-family: var(--display);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--gold-light);
  text-shadow: 0 1px 0 #000, 0 0 8px rgba(0, 0, 0, 0.6);
  background: linear-gradient(180deg, #2f509a 0%, #1a2f63 55%, #13234b 100%);
  border: 2px solid var(--gold-dark);
  border-radius: 3px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    inset 0 -2px 0 rgba(0, 0, 0, 0.35),
    0 3px 0 #060b18,
    0 5px 12px rgba(0, 0, 0, 0.5);
  cursor: pointer;
  transition: filter 0.12s, box-shadow 0.12s, transform 0.06s, color 0.12s;
}
button:hover:not(:disabled) {
  color: #fff6d2;
  border-color: var(--gold);
  filter: brightness(1.15);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.3),
    inset 0 -2px 0 rgba(0, 0, 0, 0.35),
    0 3px 0 #060b18,
    0 0 16px rgba(240, 200, 90, 0.45);
}
button:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5), 0 1px 0 #060b18;
}
button:disabled { opacity: 0.45; cursor: default; filter: saturate(0.4); }
button:focus-visible { outline: 2px solid var(--gold-light); outline-offset: 2px; }

button.big { padding: 14px 18px; font-size: 21px; letter-spacing: 0.1em; }
button.secondary {
  color: #e6d7ae;
  background: linear-gradient(180deg, #454b5a 0%, #2c313d 55%, #222630 100%);
  border-color: #7d6a45;
}
button.small { padding: 5px 12px; font-size: 13px; }

.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > button { flex: 1; }

/* ---------------------------------------------------------------- Lists */

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  min-height: 64px;
  max-height: 240px;
  overflow-y: auto;
  background: rgba(4, 8, 18, 0.65);
  border: 1px solid rgba(224, 178, 74, 0.35);
  border-radius: 3px;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.6);
}
.list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(224, 178, 74, 0.12);
}
.list li:last-child { border-bottom: none; }
.list li:not(.empty):hover { background: rgba(224, 178, 74, 0.07); }
.list li.empty { color: var(--muted); justify-content: center; font-style: italic; }

.swatch { display: inline-block; width: 12px; height: 12px; margin-right: 6px; border-radius: 2px; vertical-align: -1px; }
.ready { color: var(--ok); font-family: var(--display); font-weight: 700; font-size: 13px; letter-spacing: 0.06em; }
.not-ready { color: var(--muted); font-family: var(--display); font-size: 13px; letter-spacing: 0.06em; }

.muted { color: var(--muted); margin: 0; text-align: center; font-size: 14px; }
.muted strong { color: var(--gold-light); }
.status { margin: 0; text-align: center; font-size: 14px; color: var(--danger); }
.status:empty { display: none; }

/* ---------------------------------------------------------------- Game */

#screen-game { position: fixed; inset: 0; }
#game-canvas { display: block; width: 100%; height: 100%; cursor: default; }

.hud {
  position: absolute;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 12px;
  font-size: 14px;
  background: linear-gradient(180deg, rgba(24, 38, 74, 0.92), rgba(10, 17, 36, 0.92));
  border-color: var(--gold-dark);
  border-style: solid;
  border-width: 0;
  pointer-events: none;
}
.hud button { pointer-events: auto; }
#hud-top { top: 0; border-bottom-width: 2px; font-family: var(--display); font-weight: 700; }
#hud-food { pointer-events: auto; display: flex; align-items: center; gap: 6px; font-size: 15px; color: #f3dc9a; margin-left: 18px; }
#hud-metal { pointer-events: auto; display: flex; align-items: center; gap: 6px; font-size: 15px; color: #dfe6ec; margin-left: 18px; }
#hud-metal.hidden { display: none; }
#hud-metal .icon { fill: #9aa7b3; stroke: #e6edf2; stroke-width: 1.2; stroke-linejoin: round; }
#hud-metal .icon path + path { fill: #c5d0d9; }
#btn-leave-game { margin-left: 8px; }
/* Settings: a gear in the corner of the menu screens, and in the game's top bar */
.settings-button { position: absolute; top: 14px; right: 14px; z-index: 5; width: 40px; height: 40px; padding: 0; display: flex; align-items: center; justify-content: center; }
.settings-button .icon, .settings-button-game .icon { width: 20px; height: 20px; fill: currentColor; stroke: none; }
.settings-button-game { margin-left: 14px; width: 32px; padding: 0; display: inline-flex; align-items: center; justify-content: center; align-self: stretch; }
.panel.modal-panel.settings-panel { max-width: 480px; width: 100%; display: flex; flex-direction: column; gap: 14px; }
.settings-group { display: flex; flex-direction: column; gap: 10px; }
.volume { display: grid; grid-template-columns: 150px 1fr 44px; align-items: center; gap: 12px; font-size: 14px; color: var(--text); }
.volume input[type="range"] { width: 100%; height: 22px; margin: 0; padding: 0; background: none; border: none; box-shadow: none; accent-color: var(--gold); cursor: pointer; }
.volume b { font: 700 13px var(--display); color: var(--gold-light); text-align: right; }
.settings-footer { justify-content: flex-end; }
@media (max-width: 480px) { .volume { grid-template-columns: 1fr 44px; } .volume span { grid-column: 1 / -1; } }
/* Game time, at the right of the top bar */
#hud-clock { margin-left: auto; pointer-events: auto; display: flex; align-items: center; gap: 6px; font-size: 15px; color: var(--gold-light); font-variant-numeric: tabular-nums; }
#hud-clock .icon { fill: none; stroke: var(--gold-light); stroke-width: 1.8; stroke-linecap: round; }
#hud-food .icon { fill: none; stroke: #e8c25a; stroke-width: 1.6; }
#hud-food .icon path + path { fill: #e8c25a; stroke: none; }
#hud-pop { margin-left: auto; }
#hud-pop { pointer-events: auto; display: flex; align-items: center; gap: 6px; font-size: 15px; color: var(--gold-light); }
.icon { width: 20px; height: 20px; fill: currentColor; flex: none; }

/* Panels shared by the side panel and the command panel */
#side-panel, #command-panel {
  position: absolute;
  background: linear-gradient(180deg, rgba(24, 38, 74, 0.94), rgba(10, 17, 36, 0.94));
  border: 2px solid var(--gold-dark);
  border-radius: 4px;
  box-shadow: 0 0 0 1px #000, 0 8px 24px rgba(0, 0, 0, 0.6);
}

/* Side panel (spells / buildings): icon tabs over a grid of icon buttons */
#side-panel { top: 44px; right: 10px; display: flex; flex-direction: column; }
.tabs { display: flex; border-bottom: 2px solid var(--gold-dark); }

/* Shaman display: portrait (click: select, right-click: go to) and a big health bar */
#shaman-box { display: flex; align-items: center; gap: 8px; padding: 8px; border-bottom: 2px solid var(--gold-dark); }
#shaman-portrait { width: 60px; height: 60px; padding: 0; flex: none; display: flex; align-items: center; justify-content: center; }
#shaman-portrait canvas { width: 54px; height: 54px; pointer-events: none; }
#shaman-portrait.dead > canvas { opacity: 0.35; filter: grayscale(1); }
#shaman-portrait canvas.live { width: 60px; height: 60px; }
#shaman-portrait canvas.still, #shaman-portrait.dead canvas.live { display: none; }
#shaman-portrait.dead canvas.still { display: block; }
/* Our shaman's been hurt: the portrait and health bar flash red */
#shaman-box.hurt #shaman-portrait { animation: shaman-hurt 0.7s ease-out; }
#shaman-box.hurt .shaman-hp { animation: shaman-hurt-glow 0.7s ease-out; }
#shaman-box.hurt .shaman-hp > div { animation: shaman-hurt-fill 0.7s ease-out; }
@keyframes shaman-hurt {
  0%, 35% { border-color: #ff4a3a; box-shadow: inset 0 0 0 40px rgba(210, 30, 20, 0.45), 0 0 0 2px #ff4a3a, 0 0 16px rgba(255, 60, 40, 0.9); }
}
@keyframes shaman-hurt-glow {
  0%, 35% { box-shadow: 0 0 0 2px #ff4a3a, 0 0 12px rgba(255, 60, 40, 0.9); }
}
@keyframes shaman-hurt-fill {
  0%, 35% { background: #ff3a2a; }
}

.shaman-hp { position: relative; flex: 1; height: 18px; background: rgba(0, 0, 0, 0.6); border: 1px solid #000; box-shadow: 0 0 0 1px var(--gold-dark); }
.shaman-hp > div { height: 100%; width: 100%; background: #5fd35a; }
/* Waiting to respawn: the bar fills blue; held up by a damaged town center it smoulders
   (dull ember, slow drifting stripes) and a burning town center shows on the portrait. */
#shaman-box.respawning .shaman-hp > div { background: #5aa8f0; }
#shaman-box.slowed .shaman-hp > div {
  background: repeating-linear-gradient(-45deg, #b4471d 0 6px, #7a2a12 6px 12px);
  background-size: 17px 17px;
  animation: smoulder 1.6s linear infinite;
}
#shaman-box.slowed .shaman-hp { box-shadow: 0 0 0 1px #c0501e, 0 0 8px rgba(230, 90, 30, 0.6); }
@keyframes smoulder { to { background-position: 17px 0; } }
#shaman-portrait { position: relative; }
.tc-badge { display: none; position: absolute; right: -6px; bottom: -6px; width: 26px; height: 26px; border-radius: 50%; background: rgba(40, 12, 6, 0.9); border: 1px solid #c0501e; box-shadow: 0 0 8px rgba(255, 110, 30, 0.8); pointer-events: none; animation: flicker 0.9s ease-in-out infinite alternate; }
.tc-badge canvas { width: 22px !important; height: 22px !important; margin: 1px; }
#shaman-box.slowed .tc-badge { display: block; }
@keyframes flicker { from { box-shadow: 0 0 5px rgba(255, 110, 30, 0.6); } to { box-shadow: 0 0 12px rgba(255, 150, 40, 1); } }
.shaman-hp > span {
  position: absolute;
  inset: 0;
  font: 700 11px/18px Georgia, serif;
  text-align: center;
  color: #fff;
  text-shadow: 0 1px 2px #000;
}
.tab {
  flex: 1;
  display: flex;
  justify-content: center;
  padding: 6px;
  border: none;
  border-radius: 0;
  box-shadow: none;
  background: rgba(0, 0, 0, 0.35);
  color: var(--muted);
}
.tab + .tab { border-left: 1px solid rgba(224, 178, 74, 0.35); }
.tab.active { background: linear-gradient(180deg, #2f509a 0%, #1a2f63 100%); color: var(--gold-light); }
.tab:hover:not(.active) { color: var(--gold-light); filter: none; box-shadow: none; }
.tab:active:not(:disabled) { transform: none; box-shadow: none; }
.tab-body { padding: 8px; }
.icon-grid { display: grid; grid-template-columns: repeat(3, 52px); gap: 6px; }
/* Build menu groups: a small heading over each row of buildings */
.build-group + .build-group { margin-top: 8px; }
.build-group .group-title {
  margin: 0 0 5px;
  padding-bottom: 3px;
  border-bottom: 1px solid rgba(224, 178, 74, 0.3);
  font-family: var(--display);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--gold-light);
  text-shadow: 0 1px 0 #000;
}

/* Square AoE-style buttons: a picture, details in the tooltip */
.icon-btn {
  position: relative;
  width: 52px;
  height: 52px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.icon-btn canvas { width: 46px; height: 46px; pointer-events: none; }
.icon-btn.active { border-color: var(--gold-light); box-shadow: 0 0 0 1px var(--gold-light), 0 0 14px rgba(240, 200, 90, 0.5); }
.icon-btn .badge {
  position: absolute;
  top: -7px;
  right: -7px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border: 1px solid #000;
  border-radius: 9px;
  background: #b3341f;
  color: #fff;
  font: 700 11px/16px Georgia, serif;
  letter-spacing: 0;
  text-align: center;
}

/* Spell buttons: a pip at the top for each shot it holds (lit for each in hand), the
   charge in progress along the bottom: a sweep of light running along it while it
   charges, all of it grey while it doesn't. The whole card goes dark grey only when it's
   neither charging nor holding a shot; it glows when it's full. */
.spell-btn .pips { position: absolute; top: 3px; left: 0; right: 0; z-index: 2; display: flex; justify-content: center; gap: 3px; pointer-events: none; }
.spell-btn .pips span { width: 8px; height: 8px; border-radius: 50%; border: 1px solid #0b1424; background: rgba(0, 0, 0, 0.55); box-shadow: inset 0 0 0 1px rgba(160, 200, 240, 0.35); }
.spell-btn .pips span.on { background: radial-gradient(circle at 35% 35%, #ffffff, #8fd2ff 55%, #2f86d8); box-shadow: 0 0 5px rgba(120, 200, 255, 0.95); }
.spell-btn .charge { position: absolute; left: 4px; right: 4px; bottom: 3px; height: 5px; border-radius: 2px; overflow: hidden; background: rgba(0, 0, 0, 0.65); pointer-events: none; z-index: 2; }
.spell-btn .charge > div { position: relative; height: 100%; width: 0; overflow: hidden; background: linear-gradient(90deg, #2f7fe0, #8fd2ff); }
.spell-btn.charging .charge { box-shadow: 0 0 6px rgba(120, 200, 255, 0.55); }
.spell-btn.charging .charge > div { box-shadow: 0 0 6px rgba(140, 210, 255, 0.9); }
.spell-btn.charging .charge > div::after {
  content: ''; position: absolute; top: 0; bottom: 0; width: 18px; left: -18px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0));
  animation: spell-sweep 1.3s linear infinite;
}
@keyframes spell-sweep { to { left: 100%; } }
.spell-btn.full .charge > div { background: #bfe6ff; }
.spell-btn.paused .charge { background: #2a2d31; box-shadow: none; }
.spell-btn.paused .charge > div { background: #6b7076; box-shadow: none; }
.spell-btn.dormant { background: linear-gradient(180deg, #3a3d42, #24262a); border-color: #55595f; box-shadow: none; }
.spell-btn.dormant canvas { filter: grayscale(1) brightness(0.55); }
.spell-btn.dormant .pips span { box-shadow: none; }
.spell-btn.full { border-color: #bfe6ff; box-shadow: 0 0 9px 2px rgba(140, 210, 255, 0.55), inset 0 0 8px rgba(140, 210, 255, 0.3); }
/* The Spells tab flashes red while mana's going to waste */
.tab.wasting { animation: mana-waste 0.9s ease-in-out infinite; }
@keyframes mana-waste { 0%, 100% { color: var(--muted); background: rgba(0, 0, 0, 0.35); } 50% { color: #ff5a46; background: rgba(150, 24, 16, 0.55); box-shadow: inset 0 0 8px rgba(255, 70, 50, 0.7); } }

/* Command panel (bottom left): portrait, then HP / training buttons / queue */
#command-panel { left: 10px; bottom: 10px; display: flex; flex-direction: column; gap: 6px; padding: 8px; max-width: calc(100% - 260px); }
#cp-title {
  font-family: var(--display);
  font-weight: 700;
  font-size: 14px;
  color: var(--gold-light);
  text-shadow: 0 1px 0 #000;
  padding-bottom: 5px;
  border-bottom: 1px solid rgba(224, 178, 74, 0.35);
}
#cp-title:empty { display: none; }
.cp-main { display: flex; gap: 10px; }
#cp-portrait canvas {
  display: block;
  width: 64px;
  height: 64px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--gold-dark);
}
#cp-body { display: flex; flex-direction: column; justify-content: center; gap: 8px; min-width: 0; }
.cp-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.hp { width: 120px; height: 6px; background: rgba(0, 0, 0, 0.6); border: 1px solid #000; }
.hp > div { height: 100%; background: #5fd35a; }
.hp-text { font: 12px Georgia, serif; color: var(--text); }

/* Several units selected: a grid of small portraits with HP bars */
.unit-grid { display: flex; flex-wrap: wrap; gap: 3px; max-width: 420px; }
.unit-grid button { position: relative; width: 34px; height: 38px; padding: 0; }
.unit-grid canvas { width: 30px; height: 30px; pointer-events: none; }
.unit-grid .hp { position: absolute; left: 2px; right: 2px; bottom: 2px; width: auto; height: 3px; border: none; }

/* Training queue: the unit in training shows progress and time left */
.queue { display: flex; gap: 4px; align-items: flex-end; }
.queue button { position: relative; width: 34px; height: 34px; padding: 0; }
.queue button canvas { width: 28px; height: 28px; pointer-events: none; }
.queue button.current { width: 46px; height: 46px; }
.queue button.current canvas { width: 36px; height: 36px; }
.queue .bar { position: absolute; left: 2px; right: 2px; bottom: 2px; height: 4px; background: rgba(0, 0, 0, 0.6); pointer-events: none; }
.queue .bar > div { height: 100%; background: var(--gold); }
.queue .left {
  position: absolute;
  top: 1px;
  right: 3px;
  font: 700 11px Georgia, serif;
  letter-spacing: 0;
  color: #fff;
  text-shadow: 0 1px 2px #000;
  pointer-events: none;
}
.queue button.blocked .bar > div { background: #d0503a; }
.queue .empty { width: 34px; height: 34px; border: 1px dashed rgba(224, 178, 74, 0.28); border-radius: 3px; }
.queue .empty.current { width: 46px; height: 46px; }

/* Research buttons (and research in a queue): a blue-edged button with an arrow badge */
.icon-btn.research, .queue button.research { border-color: #6fa6dc; }
.icon-btn.research::before {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 7px solid #9fd0ff;
  filter: drop-shadow(0 1px 0 #000);
  pointer-events: none;
}

/* Build buttons for buildings we can't place yet (they need another building first) */
.icon-btn.locked canvas { opacity: 0.35; filter: grayscale(1); }

/* Lobby: players and colours on the left, the map on the right */
.panel.wide.lobby-panel { max-width: 1060px; }
.lobby-columns { display: flex; gap: 20px; flex-wrap: wrap; align-items: flex-start; }
.lobby-left { flex: 1.15 1 280px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.lobby-map { flex: 1 1 260px; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.lobby-you { flex: 1 1 250px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.lobby-left > .section-label { align-self: flex-start; }
#lobby-players { max-height: none; overflow: visible; } /* (never a scroll bar: as tall as it needs) */
#map-preview { width: 100%; height: auto; }
#map-preview { max-width: 100%; background: rgba(4, 8, 18, 0.65); border: 1px solid rgba(224, 178, 74, 0.35); border-radius: 3px; }
#map-name { font-family: var(--display); font-weight: 700; color: var(--gold-light); }
#map-description { font-size: 12px; }
.colour-picker { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
#colour-swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.colour { width: 26px; height: 26px; padding: 0; border-radius: 50%; border: 2px solid rgba(0, 0, 0, 0.6); box-shadow: none; }
.colour.taken { opacity: 0.45; }
.colour.active { border-color: #fff; box-shadow: 0 0 0 2px var(--gold); opacity: 1; }
.swatch.clash { box-shadow: 0 0 0 2px var(--danger); }


/* Lobby sections */
.section-label { font-family: var(--display); font-size: 13px; letter-spacing: 0.06em; color: var(--gold-light); text-align: left; }
.lobby-map { text-align: center; }
.lobby-map .section-label { align-self: flex-start; }

/* Spell loadout summary: a slot per tier, loudly marked until they're all chosen */
#loadout-summary { display: flex; flex-direction: column; gap: 8px; padding: 10px; border: 1px solid rgba(224, 178, 74, 0.25); border-radius: 3px; background: rgba(4, 8, 18, 0.45); }
#loadout-summary.incomplete { border-color: rgba(255, 138, 120, 0.7); box-shadow: 0 0 12px rgba(255, 120, 90, 0.25); }
.loadout-head { display: flex; justify-content: space-between; align-items: baseline; }
#loadout-count { font-family: var(--display); font-size: 12px; letter-spacing: 0.05em; }
#loadout-count.needed { color: var(--danger); }
#loadout-slots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.loadout-slot { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 4px 7px; font-size: 12px; }
.loadout-slot canvas { width: 44px; height: 44px; pointer-events: none; }
.loadout-slot .slot-tier { font-size: 10px; color: var(--muted); letter-spacing: 0.08em; }
.loadout-slot .slot-label { font-size: 12px; }
.loadout-slot.empty { background: rgba(0, 0, 0, 0.35); border-style: dashed; border-color: rgba(255, 138, 120, 0.7); color: var(--danger); }
.slot-empty { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; font: 700 26px var(--display); color: var(--danger); }
button.attention { animation: attention 1.4s ease-in-out infinite; }
@keyframes attention {
  0%, 100% { box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), 0 3px 0 #060b18, 0 0 0 rgba(240, 200, 90, 0); }
  50% { box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), 0 3px 0 #060b18, 0 0 18px rgba(240, 200, 90, 0.75); }
}
.icon.lock { width: 15px; height: 15px; vertical-align: -2px; margin-right: 4px; }

/* Picker popup: list on the left, picture, details and a big button on the right */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(3, 6, 14, 0.72); }
.panel.modal-panel { max-width: 820px; max-height: calc(100vh - 32px); overflow: auto; }
.modal-close { position: absolute; top: 12px; right: 12px; width: 34px; height: 34px; padding: 0; font-size: 22px; line-height: 1; }
.picker-body { display: grid; grid-template-columns: 260px 1fr; gap: 18px; min-height: 0; }
.picker-list { display: flex; flex-direction: column; gap: 12px; max-height: 440px; overflow-y: auto; padding-right: 4px; }
.picker-group { display: flex; flex-direction: column; gap: 5px; }
.picker-group-head { display: flex; justify-content: space-between; align-items: center; padding: 4px 2px; font-family: var(--display); font-size: 13px; color: var(--gold-light); border-bottom: 1px solid rgba(224, 178, 74, 0.3); }
.picker-badge { font-size: 11px; padding: 2px 7px; border-radius: 9px; letter-spacing: 0.04em; }
.picker-group.todo .picker-badge { color: #fff; background: #a8331f; animation: attention 1.4s ease-in-out infinite; }
.picker-group.done .picker-badge { color: var(--ok); background: rgba(90, 180, 80, 0.15); }
.picker-group.todo { padding: 4px; border: 1px dashed rgba(255, 138, 120, 0.55); border-radius: 3px; }
.picker-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px 10px; text-align: left; font-size: 14px; letter-spacing: 0.03em; }
.picker-item canvas { width: 36px; height: auto; max-height: 36px; flex: none; pointer-events: none; }
.picker-item-name { flex: 1; }
.picker-item.selected { border-color: var(--gold-light); box-shadow: 0 0 0 1px var(--gold-light), 0 0 12px rgba(240, 200, 90, 0.4); }
.picker-check { color: var(--ok); font-weight: 700; }
.picker-players { display: inline-flex; align-items: center; gap: 4px; font: 700 13px Georgia, serif; letter-spacing: 0; color: var(--text); }
.picker-players svg, .picker-players .icon { width: 15px; height: 15px; }
.picker-players.over { color: #ff7a66; }
.picker-cost { display: inline-flex; align-items: center; gap: 4px; font: 700 13px Georgia, serif; letter-spacing: 0; color: var(--text); }
.picker-cost .icon { width: 14px; height: 14px; color: #7cc4ff; }
.picker-detail { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.picker-art { width: 100%; aspect-ratio: 4 / 3; background: rgba(4, 8, 18, 0.7); border: 1px solid rgba(224, 178, 74, 0.45); border-radius: 3px; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.picker-art canvas, .picker-art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.picker-body.hidden, .picker-overview.hidden { display: none; }
/* The spell picker's overview: a big card for each tier */
.picker-overview { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.tier-card { display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 1px solid rgba(224, 178, 74, 0.35); border-radius: 4px; background: rgba(4, 8, 18, 0.45); min-width: 0; }
.tier-card.todo { border-style: dashed; border-color: rgba(255, 138, 120, 0.7); box-shadow: 0 0 12px rgba(255, 120, 90, 0.2); }
.tier-card-head { font: 700 13px var(--display); letter-spacing: 0.1em; text-transform: uppercase; color: var(--gold-light); text-align: center; }
.tier-card-art { width: 100%; aspect-ratio: 4 / 3; background: rgba(4, 8, 18, 0.7); border: 1px solid rgba(224, 178, 74, 0.45); border-radius: 3px; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.tier-card-art canvas, .tier-card-art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tier-card-empty { font: 700 54px var(--display); color: rgba(255, 138, 120, 0.7); }
.tier-card-name { font: 700 18px var(--display); color: var(--gold-light); text-align: center; }
.tier-card-text { margin: 0; flex: 1; font-size: 13px; line-height: 1.4; color: var(--text); }
.tier-card-stats { display: flex; justify-content: center; gap: 14px; }
.tier-card-stats .stat { display: inline-flex; align-items: center; gap: 5px; font: 700 14px var(--display); color: var(--gold-light); }
.tier-card-stats .stat .icon { width: 16px; height: 16px; }
.tier-card button { width: 100%; }
.picker-footer #picker-done { margin-left: auto; }
@media (max-width: 760px) { .picker-overview { grid-template-columns: 1fr; } }
#picker-name { font-family: var(--display); font-weight: 700; font-size: 22px; color: var(--gold-light); }
#picker-description { margin: 0; font: 14px/1.45 Georgia, serif; color: var(--text); }
#picker-stats { display: flex; flex-wrap: wrap; gap: 6px; }
#picker-stats .stat { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px 4px 8px; border: 1px solid rgba(224, 178, 74, 0.35); border-radius: 14px; background: rgba(0, 0, 0, 0.3); cursor: default; }
#picker-stats .stat .icon { width: 18px; height: 18px; color: var(--gold); }
#picker-stats .stat.mana .icon { color: #7cc4ff; } /* blue, like the charge bars */
#picker-stats .stat b { font: 700 15px Georgia, serif; color: var(--text); }
.picker-footer { justify-content: flex-end; }
.picker-footer > button { flex: 0 0 auto; min-width: 140px; }
@media (max-width: 640px) {
  .picker-body { grid-template-columns: 1fr; }
  .picker-list { max-height: 220px; }
}

/* Players knocked out, in the top bar */
#hud-players .player-name { text-shadow: 0 1px 0 #000, 0 0 6px rgba(0, 0, 0, 0.8); }
#hud-players .out { opacity: 0.45; text-decoration: line-through; }


/* Spectating banner and news toasts */
#spectator-banner {
  position: absolute;
  top: 52px;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 18px;
  font-family: var(--display);
  font-weight: 700;
  color: var(--gold-light);
  background: rgba(10, 17, 36, 0.9);
  border: 1px solid var(--gold-dark);
  border-radius: 3px;
  pointer-events: none;
}
/* A game to rejoin (games list), and reconnecting after a lost connection */
.seat-banner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  text-align: center;
  color: var(--gold-light);
  background: rgba(36, 64, 126, 0.35);
  border: 1px solid var(--gold-dark);
  border-radius: 3px;
}
#reconnecting {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(7, 12, 26, 0.6);
  z-index: 50;
}
.panel.reconnect-panel { max-width: 360px; width: calc(100% - 32px); }
.reconnect-panel .row { justify-content: center; }

#toasts { position: absolute; top: 92px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
.toast {
  padding: 8px 16px;
  font-family: var(--display);
  font-weight: 700;
  font-size: 15px;
  color: #fff;
  text-shadow: 0 1px 2px #000;
  background: linear-gradient(180deg, rgba(120, 30, 20, 0.92), rgba(70, 14, 10, 0.92));
  border: 1px solid var(--gold-dark);
  border-radius: 3px;
  transition: opacity 0.7s;
}
.toast.fading { opacity: 0; }
/* A tribe knocked out: a big banner, the name in its colour */
.toast.big {
  padding: 12px 30px;
  font-size: 28px;
  letter-spacing: 0.04em;
  border: 2px solid var(--gold);
  box-shadow: 0 0 24px rgba(var(--tint, 255, 255, 255), 0.6), 0 6px 18px rgba(0, 0, 0, 0.6);
  animation: toast-slam 0.45s cubic-bezier(0.2, 1.5, 0.4, 1);
}
.toast.big .name { text-shadow: 0 2px 0 #000, 0 0 10px rgba(0, 0, 0, 0.9); }
@keyframes toast-slam { from { opacity: 0; transform: scale(1.6); } to { opacity: 1; transform: none; } }

/* ...and its colour flickers over everyone's screen for a moment, like coloured lightning */
#elim-flash { --tint: 255, 255, 255; position: absolute; inset: 0; z-index: 7; pointer-events: none; }
#elim-flash.hidden { display: none; }
#elim-flash::before, #elim-flash::after { content: ''; position: absolute; inset: 0; }
#elim-flash::before { background: rgba(var(--tint), 0.55); animation: elim-flicker 0.75s steps(1, end) forwards; }
#elim-flash::after { background: radial-gradient(ellipse at center, transparent 30%, rgba(var(--tint), 0.9) 100%); mix-blend-mode: screen; animation: elim-flicker 0.75s 0.04s steps(1, end) forwards; }
@keyframes elim-flicker {
  0% { opacity: 0.9; }
  8% { opacity: 0.1; }
  14% { opacity: 1; }
  22% { opacity: 0; }
  30% { opacity: 0.7; }
  36% { opacity: 0.15; }
  46% { opacity: 0.55; }
  58% { opacity: 0; }
  66% { opacity: 0.3; }
  74%, 100% { opacity: 0; }
}

/* In the event feed: a tribe knocked out (as big as a tier 3 spell, in its colour) */
.feed-item.elim {
  font: 700 16px/1.25 var(--display);
  padding: 9px 16px 9px 8px;
  border: 2px solid rgb(var(--tint));
  background: linear-gradient(90deg, rgba(var(--tint), 0.38), rgba(10, 14, 28, 0.92) 75%);
  overflow: hidden;
  animation: feed-in-big 0.55s cubic-bezier(0.2, 1.5, 0.4, 1), feed-blaze 0.9s ease-in-out infinite alternate;
}
.feed-item.elim svg { width: 40px; height: 40px; }
.feed-item.elim::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 35%, rgba(255, 255, 255, 0.35) 50%, transparent 65%);
  transform: translateX(-100%);
  animation: feed-shimmer 2.2s ease-in-out infinite;
  pointer-events: none;
}

/* Game over: results over the (frozen) battlefield */
#game-over {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, rgba(5, 8, 18, 0.55), rgba(5, 8, 18, 0.85));
  z-index: 20;
}
#game-over.hidden { display: none; }
/* Most of the screen: the banner, then the winner (or the stats, or the graph), then the buttons */
.panel.game-over-panel {
  width: min(1100px, calc(100% - 32px));
  height: min(820px, calc(100% - 32px));
  max-width: none;
  display: flex;
  flex-direction: column;
  gap: 0;
  text-align: center;
  animation: go-panel-in 0.5s ease-out;
}
.go-banner {
  margin: 4px 0 6px;
  font: 700 clamp(44px, 8vh, 76px)/1 var(--display);
  letter-spacing: 0.08em;
  color: var(--gold-light);
  text-shadow: 0 3px 0 #000, 0 0 28px rgba(240, 200, 90, 0.75), 0 0 6px rgba(255, 230, 160, 0.9);
  animation: go-banner-in 0.9s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}
#go-body { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; justify-content: center; }
#go-winner { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 0; flex: 1; }
#go-winner.hidden { display: none; }
#go-shaman { flex: 1 1 auto; min-height: 0; height: 100%; max-height: 440px; max-width: 100%; aspect-ratio: 1 / 1; animation: go-rise 0.8s 0.25s ease-out both; }
#go-winner-name {
  font: 700 clamp(32px, 6vh, 56px)/1.1 var(--display);
  letter-spacing: 0.04em;
  text-shadow: 0 3px 0 #000, 0 0 20px rgba(0, 0, 0, 0.9);
  animation: go-rise 0.8s 0.45s ease-out both;
}
#go-winner-name { text-align: center; }
#go-winner-name.team { font-size: clamp(24px, 4.5vh, 42px); }
#go-winner-name .go-and { color: var(--gold-light); }
#go-winner .muted { margin: 6px 0 0; font-size: 15px; animation: go-rise 0.8s 0.6s ease-out both; }
.go-buttons { display: flex; justify-content: center; gap: 14px; padding-top: 14px; margin-top: 10px; border-top: 1px solid rgba(224, 178, 74, 0.25); }
.go-buttons button { min-width: 190px; }
.go-buttons button.active { color: #fff6d2; border-color: var(--gold); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 0 16px rgba(240, 200, 90, 0.55); }
button.danger {
  color: #ffe6d6;
  background: linear-gradient(180deg, #b0413a 0%, #82271f 55%, #651c17 100%);
  border-color: #d08a5e;
}
@keyframes go-panel-in { from { opacity: 0; transform: scale(0.94); } to { opacity: 1; transform: none; } }
@keyframes go-banner-in { 0% { opacity: 0; transform: scale(0.5); } 60% { opacity: 1; transform: scale(1.08); } 100% { transform: scale(1); } }
@keyframes go-rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }

/* Our panels fade away as the game ends */
#side-panel, #command-panel { transition: opacity 0.6s; }
#side-panel.hud-gone, #command-panel.hud-gone { opacity: 0; pointer-events: none; }

#go-stats { width: 100%; margin: 8px 0; border-collapse: collapse; table-layout: fixed; font: 14px Georgia, serif; }
#go-stats th, #go-stats td { padding: 5px 8px; border-bottom: 1px solid rgba(224, 178, 74, 0.2); }
#go-stats th:first-child { width: 175px; white-space: nowrap; }
/* Names wrap rather than push the table wider than the panel */
#go-stats tr:first-child th { font: 13px/1.3 var(--display); color: var(--gold-light); text-align: center; overflow-wrap: anywhere; vertical-align: bottom; }
#go-stats th { text-align: left; font-weight: normal; color: var(--muted); }
#go-stats td { text-align: center; color: var(--text); white-space: nowrap; }
/* The best of each row: picked out in a gold lozenge */
#go-stats .best { display: inline-block; padding: 0 6px; border-radius: 3px; color: #1b1406; font-weight: 700; background: linear-gradient(#f3d77d, #d9b04a); box-shadow: 0 0 0 1px #7a5a12, 0 0 6px rgba(240, 200, 90, 0.55); }
/* Spells cast: the total, then each spell's count with its icon */
#go-stats .go-spells { display: inline-flex; flex-direction: column; align-items: center; gap: 3px; max-width: 100%; }
#go-stats .go-spell-kinds { display: inline-flex; flex-wrap: wrap; justify-content: center; gap: 2px 0; white-space: nowrap; }
#go-stats .go-spell-kinds > * { display: inline-flex; align-items: center; gap: 2px; padding: 0 5px; }
#go-stats .go-spell-kinds > * + * { border-left: 1px solid rgba(224, 178, 74, 0.35); }
#go-stats .go-spells > b { text-transform: uppercase; font-size: 12px; letter-spacing: 0.03em; }
#go-stats .go-spells img { width: 16px; height: 16px; border-radius: 2px; }
#go-stats .crown { color: var(--gold); }
/* More than four players: smaller print, and names only broken between words */
#go-stats.many { font-size: 13px; }
#go-stats.many th:first-child { width: 140px; }
#go-stats.many th, #go-stats.many td { padding: 5px 4px; }
#go-stats.many tr:first-child th { font-size: 11px; overflow-wrap: normal; word-break: normal; hyphens: auto; }
#go-stats.hidden { display: none; }

/* The timeline: everyone's share of the followers, 100% top to bottom at every moment */
#go-timeline { position: relative; margin: 8px 0; }
#go-timeline.hidden { display: none; }
#go-legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 16px; margin-bottom: 8px; font: 700 13px var(--display); }
#go-legend span { display: inline-flex; align-items: center; gap: 6px; }
#go-legend i { width: 14px; height: 10px; border-radius: 2px; }
#go-graph { display: block; width: 100%; height: 350px; cursor: crosshair; }
#go-graph-tip {
  position: absolute;
  z-index: 2;
  min-width: 150px;
  padding: 6px 10px;
  font: 12px/1.45 Georgia, serif;
  text-align: left;
  color: var(--text);
  background: rgba(10, 14, 28, 0.95);
  border: 1px solid var(--gold-dark);
  border-radius: 3px;
  pointer-events: none;
  white-space: nowrap;
}
#go-graph-tip.hidden { display: none; }
#go-graph-tip .tip-head { font: 700 13px var(--display); color: var(--gold-light); margin-bottom: 2px; }
#go-graph-tip .row { display: flex; justify-content: space-between; gap: 14px; }
#go-graph-tip .row b { font-weight: 700; }

/* Tooltips (in our style, not the browser's) */
#tooltip {
  position: fixed;
  z-index: 100;
  max-width: 240px;
  padding: 6px 10px 7px;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(24, 38, 74, 0.97), rgba(10, 17, 36, 0.97));
  border: 1px solid var(--gold-dark);
  border-radius: 3px;
  box-shadow: 0 0 0 1px #000, 0 6px 18px rgba(0, 0, 0, 0.6);
}
#tooltip[hidden] { display: none; }
#tooltip .tip-title { font-family: var(--display); font-weight: 700; font-size: 13px; color: var(--gold-light); text-shadow: 0 1px 0 #000; }
#tooltip .tip-text { margin-top: 2px; font: 12px/1.35 Georgia, serif; color: var(--text); }
#tooltip .tip-text[hidden] { display: none; }
#tooltip .tip-title[hidden] { display: none; }
#tooltip .tip-title[hidden] + .tip-text { margin-top: 0; }
/* A row of icons with numbers (farm and outpost hover tips) */
#tooltip .tip-stats { display: flex; gap: 14px; align-items: center; font: 700 14px var(--display); color: var(--gold-light); }
#tooltip .tip-stats span { display: flex; align-items: center; gap: 5px; }
#tooltip .tip-stats svg { width: 17px; height: 17px; flex: none; }
#tooltip .tip-cost { margin-top: 5px; }
#tooltip .tip-cost .tip-time { color: var(--muted); font: 12px Georgia, serif; }
#tooltip .tip-text > div + div { margin-top: 4px; }
/* A contested mining outpost: why it's slowed */
#tooltip .tip-contested { font: 12px/1.35 Georgia, serif; color: #ffb3a0; }
#tooltip .tip-stats + .tip-contested { margin-top: 5px; }
#tooltip .tip-contested b { display: block; font: 700 13px var(--display); color: #ff6f5a; }

/* Event feed: news down the left for everyone. Each entry's in its spell's light
   (--tint, "r,g,b"); the bigger the spell, the louder the entry. */
#event-feed {
  position: absolute;
  top: 52px;
  left: 10px;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  max-width: min(360px, calc(100% - 20px));
  pointer-events: none;
}
.feed-item {
  --tint: 150, 210, 255;
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 5px;
  font: 13px/1.25 Georgia, serif;
  color: var(--text);
  background: rgba(10, 14, 28, 0.86);
  border: 1px solid rgba(var(--tint), 0.4);
  border-left: 3px solid rgb(var(--tint));
  border-radius: 3px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  cursor: pointer;
  pointer-events: auto;
  animation: feed-in 0.35s ease-out;
  transition: opacity 0.5s, transform 0.5s;
}
.feed-item:hover { filter: brightness(1.25); }
.feed-item canvas, .feed-item svg { width: 24px; height: 24px; flex: none; border-radius: 2px; }
.feed-item .feed-name { font-weight: 700; text-shadow: 0 1px 0 #000, 0 0 5px rgba(0, 0, 0, 0.9); }
.feed-item b { color: rgb(var(--tint)); }
.feed-item .feed-count { font-weight: 700; color: rgb(var(--tint)); }
.feed-item.bump { animation: feed-bump 0.3s ease-out; }
.feed-item.leaving { opacity: 0; transform: translateX(-24px); }
/* Tier 2: bigger, and glowing */
.feed-item.tier-2 { font-size: 14px; padding: 6px 12px 6px 6px; box-shadow: 0 0 12px rgba(var(--tint), 0.5), 0 2px 8px rgba(0, 0, 0, 0.5); }
.feed-item.tier-2 canvas { width: 32px; height: 32px; }
/* Tier 3: big, blazing and shimmering */
.feed-item.tier-3 {
  font: 700 16px/1.25 var(--display);
  padding: 9px 16px 9px 8px;
  border: 2px solid rgb(var(--tint));
  background: linear-gradient(90deg, rgba(var(--tint), 0.38), rgba(10, 14, 28, 0.92) 75%);
  overflow: hidden;
  animation: feed-in-big 0.55s cubic-bezier(0.2, 1.5, 0.4, 1), feed-blaze 0.9s ease-in-out infinite alternate;
}
.feed-item.tier-3 canvas { width: 46px; height: 46px; }
.feed-item.tier-3::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 35%, rgba(255, 255, 255, 0.35) 50%, transparent 65%);
  transform: translateX(-100%);
  animation: feed-shimmer 2.2s ease-in-out infinite;
  pointer-events: none;
}
/* A shaman slain */
.feed-item.kill { --tint: 235, 80, 65; font-size: 14px; padding: 5px 12px 5px 6px; box-shadow: 0 0 10px rgba(var(--tint), 0.4), 0 2px 8px rgba(0, 0, 0, 0.5); }
.feed-item.kill svg { width: 28px; height: 28px; }
@keyframes feed-in { from { opacity: 0; transform: translateX(-30px); } to { opacity: 1; transform: none; } }
@keyframes feed-in-big { from { opacity: 0; transform: translateX(-40px) scale(0.85); } to { opacity: 1; transform: none; } }
@keyframes feed-bump { 50% { transform: scale(1.06); } }
@keyframes feed-blaze {
  from { box-shadow: 0 0 10px rgba(var(--tint), 0.55), 0 2px 8px rgba(0, 0, 0, 0.5); }
  to { box-shadow: 0 0 28px rgba(var(--tint), 1), inset 0 0 10px rgba(var(--tint), 0.6); }
}
@keyframes feed-shimmer { 0%, 40% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }

/* A tier 3 spell flashed up across the screen: its light round the edges, and its name */
#spell-alert { --tint: 255, 255, 255; position: absolute; inset: 0; z-index: 6; pointer-events: none; }
#spell-alert.hidden { display: none; }
#spell-alert .sa-vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(var(--tint), 0.5) 100%);
  animation: sa-flash 2.8s ease-out forwards;
}
#spell-alert .sa-text {
  position: absolute;
  top: 22%;
  left: 0;
  right: 0;
  text-align: center;
  font: 700 40px/1.1 var(--display);
  letter-spacing: 0.04em;
  color: #fff;
  text-shadow: 0 0 20px rgba(var(--tint), 1), 0 0 6px rgba(var(--tint), 1), 0 2px 0 #000;
  animation: sa-text 3.2s ease-out forwards;
}
#spell-alert .sa-who { display: block; margin-bottom: 4px; font-size: 20px; letter-spacing: 0.02em; }
@keyframes sa-flash { 0% { opacity: 0; } 10% { opacity: 1; } 100% { opacity: 0; } }
@keyframes sa-text {
  0% { opacity: 0; transform: scale(0.7); }
  12% { opacity: 1; transform: scale(1.08); }
  22% { transform: scale(1); }
  78% { opacity: 1; }
  100% { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  #logo, .menu-screen { animation: none; }
  .spell-btn.charging .charge > div::after { animation: none; display: none; }
  .tab.wasting { animation: none; color: #ff5a46; background: rgba(150, 24, 16, 0.55); }
  .game-over-panel, .go-banner, #go-shaman, #go-winner-name, #go-winner .muted { animation: none; }
  .feed-item, .feed-item.tier-3, .feed-item.tier-3::after, .feed-item.elim, .feed-item.elim::after { animation: none; }
  #elim-flash::before, #elim-flash::after { animation: none; opacity: 0; }
  #spectator-board .sb-spell.charging .sb-bar > span, #spectator-board .sb-spell.ult canvas { animation: none; }
}

/* The lobby is the busiest screen: keep it compact so it fits without scrolling. */
#screen-lobby .panel { gap: 10px; padding-top: 20px; padding-bottom: 16px; }
#lobby-players li { padding: 7px 12px; }
.loadout-slot { padding: 4px 4px 5px; gap: 1px; }
.loadout-slot canvas, .slot-empty { width: 36px; height: 36px; }
.slot-empty { font-size: 22px; }

/* Lobby: computer players (the host can add, recolour and remove them) */
#lobby-players li.empty { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
#lobby-players .add-ai { padding: 3px 9px; font-size: 12px; }
#lobby-players .ai-status { display: flex; align-items: center; gap: 8px; }
#lobby-players .remove-ai { padding: 1px 7px; font-size: 11px; line-height: 16px; }
#lobby-players .swatch.clickable { cursor: pointer; }
/* Lobby: each player's team (click yours to change it) */
#lobby-players li > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#lobby-players .player-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.team-badge { padding: 1px 8px; border: 1px solid currentColor; border-radius: 10px; background: rgba(4, 8, 18, 0.5); font: 700 11px var(--display); letter-spacing: 0.06em; text-transform: uppercase; line-height: 16px; white-space: nowrap; }
button.team-badge { cursor: pointer; box-shadow: none; min-width: 0; }
button.team-badge:hover { background: rgba(224, 178, 74, 0.12); }
.team-badge.none { color: var(--muted); border-style: dashed; }
.team-badge.t1 { color: #f0c860; }
.team-badge.t2 { color: #7ab8f0; }
.team-badge.t3 { color: #84d68a; }
.team-badge.t4 { color: #ee8fb4; }
/* (and a player's team in the results table) */
.team-tag { font: 700 10px var(--display); letter-spacing: 0.05em; padding: 0 4px; border: 1px solid currentColor; border-radius: 6px; vertical-align: 1px; }
.team-tag.t1 { color: #f0c860; }
.team-tag.t2 { color: #7ab8f0; }
.team-tag.t3 { color: #84d68a; }
.team-tag.t4 { color: #ee8fb4; }
#lobby-team-spawns { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); cursor: pointer; }
#lobby-team-spawns.hidden { display: none; }
#lobby-team-spawns input { accent-color: var(--gold); }
#lobby-team-spawns input:disabled { cursor: default; }

/* Lobby: the spectators line under the players */
#lobby-spectators { display: flex; align-items: center; gap: 8px; margin: 6px 0 10px; font-size: 13px; }
#lobby-spectators .names { flex: 1; color: var(--text); }
#lobby-spectators button { padding: 3px 9px; font-size: 12px; }
.colour-picker.hidden, #loadout-summary.hidden { display: none; }
#hud-top .spectator-hidden { display: none !important; }

/* Spectator scoreboard: a compact panel in the top right */
#spectator-board {
  position: absolute;
  top: 52px;
  right: 10px;
  width: 300px;
  z-index: 5;
  padding: 0;
  font: 13px/1.3 Georgia, serif;
  color: var(--text);
  background: rgba(10, 14, 28, 0.88);
  border: 1px solid var(--gold-dark);
  border-radius: 3px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
  pointer-events: auto;
}
#spectator-board.hidden { display: none; }
#spectator-board .sb-head {
  display: flex;
  width: 100%;
  justify-content: space-between;
  align-items: center;
  padding: 5px 10px;
  border: none;
  border-radius: 0;
  background: rgba(224, 178, 74, 0.12);
  box-shadow: none;
  font: 700 13px var(--display);
  letter-spacing: 0.08em;
  color: var(--gold-light);
  text-transform: uppercase;
}
#spectator-board .sb-head:hover { filter: brightness(1.2); }
#spectator-board.folded #sb-body { display: none; }
/* Never taller than the screen (it scrolls); with lots of tribes, only the main lines */
#spectator-board #sb-body { max-height: calc(100vh - 100px); overflow-y: auto; }
#spectator-board.compact .sb-detail { display: none; }
#spectator-board.compact .sb-tribe { padding-top: 4px; padding-bottom: 5px; }
#spectator-board.folded .sb-arrow { transform: rotate(-90deg); }
/* Each tribe: a strip of its colour down the side; click it to go to its town */
#spectator-board .sb-tribe {
  padding: 6px 10px 7px 9px;
  border-top: 1px solid rgba(224, 178, 74, 0.18);
  border-left: 4px solid var(--tribe, #888);
  cursor: pointer;
}
#spectator-board .sb-tribe:hover { background: rgba(255, 255, 255, 0.05); }
#spectator-board .sb-tribe.eliminated { opacity: 0.45; }
#spectator-board .sb-name { display: flex; align-items: center; gap: 6px; font: 700 15px var(--display); color: var(--tribe, var(--gold-light)); text-shadow: 0 1px 0 #000, 0 0 6px rgba(0, 0, 0, 0.8); }
#spectator-board .sb-label { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
#spectator-board .sb-out { font: 12px Georgia, serif; color: #e07b6a; text-transform: uppercase; }
#spectator-board .sb-out[hidden] { display: none; }
#spectator-board .sb-line { display: flex; align-items: center; gap: 9px; margin-top: 4px; white-space: nowrap; }
#spectator-board .sb-stat { display: inline-flex; align-items: center; gap: 3px; }
#spectator-board .sb-stat svg { width: 15px; height: 15px; flex: none; }
#spectator-board .sb-val { font-weight: 700; color: #f3e6c4; }
#spectator-board .sb-split { color: var(--muted); font-size: 12px; }
#spectator-board .sb-key { color: var(--muted); font-size: 12px; }
#spectator-board .sb-combat { gap: 14px; }
/* Spells: icon, charges, bar */
#spectator-board .sb-spells { gap: 8px; }
#spectator-board .sb-spell { display: inline-flex; align-items: center; gap: 3px; }
#spectator-board .sb-spell canvas { width: 22px; height: 22px; border-radius: 2px; }
#spectator-board .sb-charges { font-weight: 700; color: #cfe8ff; min-width: 8px; text-align: right; }
#spectator-board .sb-bar { width: 42px; height: 5px; background: rgba(0, 0, 0, 0.6); border: 1px solid rgba(0, 0, 0, 0.8); }
#spectator-board .sb-bar > span { display: block; height: 100%; width: 0; background: #7cc4ff; }
#spectator-board .sb-spell.full .sb-bar > span { background: #b6e0ff; }
/* Charging: the bar pulses. No shots in hand: the icon's greyed out. A tier 3 spell
   that's ready: its icon glows in the spell's light (--tint). */
#spectator-board .sb-spell { --tint: 150, 210, 255; }
#spectator-board .sb-spell.charging .sb-bar > span { animation: sb-charge 1.4s ease-in-out infinite; }
#spectator-board .sb-spell.empty canvas { filter: grayscale(1) brightness(0.7); }
#spectator-board .sb-spell.ult canvas { animation: sb-ult 1.6s ease-in-out infinite; }
@keyframes sb-charge {
  0%, 100% { box-shadow: 0 0 2px rgba(124, 196, 255, 0.5); filter: brightness(1); }
  50% { box-shadow: 0 0 7px rgba(160, 220, 255, 1); filter: brightness(1.5); }
}
@keyframes sb-ult {
  0%, 100% { filter: drop-shadow(0 0 2px rgba(var(--tint), 0.7)); }
  50% { filter: drop-shadow(0 0 7px rgba(var(--tint), 1)) brightness(1.15); }
}
#spectator-board .sb-spell.paused .sb-bar > span { background: repeating-linear-gradient(-45deg, #8a939c 0 2px, #5a626a 2px 4px); }

/* A computer player's chip icon, in front of their name */
.ai-tag { display: inline-flex; align-items: center; margin-right: 4px; color: #8fd0ff; vertical-align: -0.14em; pointer-events: auto; }
.ai-icon { width: 1em; height: 1em; filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.7)); }

/* The tutorial (js/tutorial.js). A line someone's saying: big, low in the middle, the
   game paused behind it; a task's line: smaller, top left, while the game carries on
   (the event feed moves down out of its way). Rex speaks from the left, the Red Shaman
   from the right. */
#tut-popup {
  position: absolute;
  left: 50%;
  bottom: 18%;
  transform: translateX(-50%);
  z-index: 12;
  display: flex;
  align-items: flex-end;
  gap: 14px;
  width: min(780px, calc(100% - 32px));
  padding: 14px 18px 14px 14px;
  background: linear-gradient(180deg, rgba(24, 38, 74, 0.97), rgba(10, 17, 36, 0.97));
  border: 2px solid var(--gold-dark);
  border-radius: 4px;
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  animation: tut-in 0.25s ease-out;
}
#tut-popup.red { flex-direction: row-reverse; padding: 14px 14px 14px 18px; border-color: #a33a2c; }
#tut-popup.task { left: 10px; top: 52px; bottom: auto; transform: none; width: min(420px, calc(100% - 20px)); padding: 10px 12px 10px 10px; gap: 10px; align-items: flex-start; }
/* The speaker stands at the side, from the popup's bottom edge up past its top. */
#tut-popup { padding-left: 236px; min-height: 220px; align-items: center; }
#tut-popup.red { padding-left: 18px; padding-right: 236px; }
#tut-popup.task { padding-left: 132px; min-height: 96px; width: min(470px, calc(100% - 20px)); }
.tut-portrait { position: absolute; left: 8px; bottom: 0; width: 220px; height: calc(100% + 56px); display: flex; align-items: flex-end; justify-content: center; pointer-events: none; }
#tut-popup.red .tut-portrait { left: auto; right: 8px; }
#tut-popup.task .tut-portrait { left: 4px; width: 124px; height: calc(100% + 22px); }
.tut-portrait img { max-width: 100%; max-height: 100%; object-fit: contain; object-position: bottom; filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.65)); }
.tut-stand-in { display: none; width: 88%; height: auto; max-height: 100%; fill: #3b5aa8; stroke: var(--gold); stroke-width: 2; opacity: 0.85; }
#tut-popup.red .tut-stand-in { fill: #b8402f; }
.tut-portrait.no-image img { display: none; }
.tut-portrait.no-image .tut-stand-in { display: block; }
.tut-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
#tut-name { font: 700 15px var(--display); letter-spacing: 0.06em; color: var(--gold-light); }
#tut-popup.red #tut-name { color: #ff9a86; }
#tut-text { font-size: 17px; line-height: 1.45; color: var(--text); }
#tut-popup.task #tut-text { font-size: 14px; }
#tut-checklist { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 3px; font-size: 14px; color: var(--muted); }
#tut-checklist li::before { content: '☐ '; color: var(--gold); }
#tut-checklist li.done { color: var(--ok); }
#tut-checklist li.done::before { content: '☑ '; color: var(--ok); }
#tut-counter { font: 700 14px var(--display); color: var(--gold-light); }
#tut-hint { font-size: 14px; font-style: italic; color: #ffe2a0; border-top: 1px solid rgba(224, 178, 74, 0.3); padding-top: 6px; }
.tut-buttons { display: flex; justify-content: flex-end; gap: 8px; }
.tut-buttons:empty, #tut-popup.task .tut-buttons:has(#tut-next.hidden):has(#tut-showme.hidden) { display: none; }
#tut-next:disabled { opacity: 0.45; }
#screen-game.tutorial #event-feed { top: 220px; }
@keyframes tut-in { from { opacity: 0; translate: 0 10px; } }

/* The jump-cut: black, with a line of text, fading in and out. */
#tut-fade { position: absolute; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; background: #000; opacity: 0; pointer-events: none; transition: opacity 0.6s ease; }
#tut-fade.on { opacity: 1; pointer-events: auto; }
#tut-fade-text { font: 700 clamp(24px, 4vw, 40px) var(--display); letter-spacing: 0.08em; color: var(--gold-light); text-shadow: 0 0 24px rgba(240, 200, 90, 0.5); }

/* What the tutorial wants clicked next glows; what it doesn't want yet is greyed out. */
.tut-glow { position: relative; z-index: 3; box-shadow: 0 0 0 2px #f7dc8c, 0 0 16px 4px rgba(247, 220, 140, 0.85) !important; animation: tut-glow 1.1s ease-in-out infinite; }
@keyframes tut-glow { 50% { box-shadow: 0 0 0 2px #fff3c4, 0 0 26px 8px rgba(247, 220, 140, 1); } }
.tut-later { opacity: 0.35; filter: grayscale(0.85); }
@media (max-width: 640px) {
  #tut-popup { padding-left: 112px; }
  #tut-popup.red { padding-right: 112px; }
  .tut-portrait { width: 100px; }
  #tut-text { font-size: 15px; }
}
#tut-popup.task { top: 70px; } /* (room above for the speaker to poke out) */
#tut-popup.red.task { padding-left: 12px; padding-right: 132px; }
#tut-popup.red.task .tut-portrait { right: 4px; }

/* Performance flags: tiny labels in the bottom right, each only while there's trouble */
#perf-flags { position: absolute; right: 6px; bottom: 5px; z-index: 8; display: flex; gap: 4px; pointer-events: none; }
#perf-flags span { display: none; padding: 2px 5px; border-radius: 3px; font: 700 9px/1.2 system-ui, sans-serif; letter-spacing: 0.04em; text-transform: uppercase; color: #fff; background: rgba(170, 34, 24, 0.85); }
#perf-flags span.on { display: inline-block; }
