/* Siege of Champions UI kit. Components every screen is built from; tokens only. */
* { box-sizing: border-box; }
html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-0);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--t-m);
  line-height: 1.3;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
#game { position: absolute; inset: 0; }
canvas { display: block; image-rendering: pixelated; }
[hidden] { display: none !important; }
/* Scrollbars match the panels instead of the browser default. */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border: 2px solid var(--bg-1); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--you-deep); }
::-webkit-scrollbar-corner { background: transparent; }
h1, h2, h3, .head { font-family: var(--font-head); font-weight: 700; letter-spacing: 0; margin: 0; }
h1 { font-size: var(--t-display); line-height: 1; }
h2 { font-size: var(--t-xl); }
h3 { font-size: var(--t-l); }
p { margin: 0; }
.dim { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.xs { font-size: var(--t-xs); }
.sm { font-size: var(--t-s); }
.md { font-size: var(--t-m); }
.lg { font-size: var(--t-l); }
.xl { font-size: var(--t-xl); }
.num { font-variant-numeric: tabular-nums; font-weight: 700; }
.c-you { color: var(--you); }
.c-ally { color: var(--ally); }
.c-enemy { color: var(--enemy); }
.c-phys { color: var(--physical); }
.c-magic { color: var(--magic); }
.c-true { color: var(--true); }
.c-mana { color: var(--mana); }
.c-hp { color: var(--hp); }
.c-ready { color: var(--ready); }
.row { display: flex; align-items: center; gap: var(--s2); }
.col { display: flex; flex-direction: column; gap: var(--s2); }
.grow { flex: 1; }
.center { text-align: center; }
.eyebrow { font-size: var(--t-xs); font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-dim); }

/* Rich text vocabulary (text-clarity.ts) — same meanings as everywhere else */
.clarity-physical { color: var(--physical); }
.clarity-magic { color: var(--magic); }
.clarity-health { color: var(--hp); }
.clarity-mana { color: var(--mana); }
.clarity-shield { color: var(--shield); }
.clarity-gold { color: var(--you); }
.clarity-bonus { color: var(--ready); }
.clarity-negative { color: var(--enemy); }
.clarity-neutral { color: inherit; }
[class*='clarity-champion-'] { color: var(--text); font-style: normal; font-weight: 700; }
em[class*='clarity-'] { font-style: normal; }

/* Panel */
.panel {
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 0 0 2px var(--bg-0), 0 8px 24px var(--shadow);
}
.panel.you { border-color: var(--you); }
.panel-title {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: var(--t-l);
  padding: var(--s3) var(--s4);
  border-bottom: 2px solid var(--line);
  display: flex;
  align-items: center;
  gap: var(--s3);
}

/* Buttons — primary, secondary, quiet; a disabled button always carries a reason */
.btn {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: var(--t-m);
  color: var(--text);
  background: var(--bg-3);
  border: 2px solid var(--line-strong);
  border-radius: var(--radius);
  padding: var(--s3) var(--s5);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  white-space: nowrap;
}
.btn:is(:hover, .virtual-hover):not(:disabled) { border-color: var(--text-dim); }
.btn.primary {
  background: linear-gradient(var(--you-light), var(--you-deep));
  color: var(--ink);
  border-color: var(--you-light);
  font-size: var(--t-l);
  padding: var(--s4) var(--s6);
  box-shadow: 0 0 0 2px var(--you-edge), 0 0 24px var(--you-glow);
}
.btn.primary:is(:hover, .virtual-hover):not(:disabled) { filter: brightness(1.08); border-color: var(--you-light); }
.btn.big { font-size: var(--t-xl); padding: var(--s5) var(--s7); }
.btn.small { font-size: var(--t-s); padding: var(--s2) var(--s4); }
.btn.quiet { background: transparent; border-color: var(--line); color: var(--text-dim); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; box-shadow: none; filter: grayscale(0.6); }
.why { font-size: var(--t-xs); color: var(--text-dim); margin-top: var(--s1); }
.key {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: var(--t-xs);
  color: var(--text);
  background: var(--bg-0);
  border: 1px solid var(--line-strong);
  padding: 0 var(--s1);
  border-radius: var(--radius);
  line-height: 20px;
  display: inline-block;
  min-width: 22px;
  text-align: center;
}
.input {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: var(--t-m);
  color: var(--text);
  background: var(--bg-0);
  border: 2px solid var(--line-strong);
  padding: var(--s3) var(--s4);
  border-radius: var(--radius);
  outline: none;
}
.input:focus { border-color: var(--you); }

/* Tabs */
.tabs { display: flex; gap: var(--s1); border-bottom: 2px solid var(--line); }
.tab {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: var(--t-m);
  padding: var(--s3) var(--s4);
  color: var(--text-dim);
  background: transparent;
  border: 2px solid transparent;
  border-bottom: none;
  margin-bottom: -2px;
}
.tab.on { color: var(--text); background: var(--bg-2); border-color: var(--line); border-bottom: 2px solid var(--bg-2); }

/* Slot — one icon box, every state */
.slot {
  --size: 64px;
  width: var(--size);
  height: var(--size);
  position: relative;
  background: var(--bg-0);
  border: 2px solid var(--line-strong);
  border-radius: var(--radius);
  flex: none;
  padding: 0;
  color: var(--text);
}
.slot > img { width: 100%; height: 100%; display: block; image-rendering: pixelated; pointer-events: none; }
.slot.empty { border-style: dashed; border-color: var(--line); background: var(--scrim); }
.slot .k {
  position: absolute;
  left: -2px;
  top: -2px;
  font-weight: 700;
  font-size: var(--t-xs);
  background: var(--bg-0);
  border: 1px solid var(--line-strong);
  padding: 0 var(--s1);
  line-height: 18px;
  z-index: 2;
}
.slot .badge {
  position: absolute;
  right: -7px;
  top: -7px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 2px solid var(--bg-0);
  z-index: 2;
}
.slot .badge svg { width: 13px; height: 13px; }
.slot .cost-tag {
  position: absolute;
  right: 2px;
  bottom: 1px;
  font-weight: 700;
  font-size: var(--t-xs);
  color: var(--mana);
  text-shadow: 0 0 3px var(--bg-0), 0 0 3px var(--bg-0);
  z-index: 2;
}
.slot .count {
  position: absolute;
  right: 2px;
  bottom: 1px;
  font-weight: 700;
  font-size: var(--t-xs);
  text-shadow: 0 0 3px var(--bg-0), 0 0 3px var(--bg-0);
}
.slot .charges {
  position: absolute;
  right: -6px;
  top: -6px;
  min-width: 20px;
  height: 20px;
  padding: 0 var(--s1);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: var(--t-xs);
  background: var(--bg-0);
  border: 2px solid var(--line-strong);
  border-radius: 10px;
  z-index: 3;
}
/* A charge refilling while one is still banked: the icon stays bright and usable. Only a thin green ring fills around
 * the border and a small corner timer counts, so it never reads as the dark full-icon sweep of a real cooldown. */
.slot .recharge {
  position: absolute;
  inset: -4px;
  padding: 3px;
  border-radius: calc(var(--radius) + 3px);
  background: conic-gradient(var(--ready) 0 var(--rdone, 0%), color-mix(in srgb, var(--ready) 18%, transparent) var(--rdone, 0%) 100%);
  -webkit-mask: linear-gradient(var(--bg-0) 0 0) content-box, linear-gradient(var(--bg-0) 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(var(--bg-0) 0 0) content-box exclude, linear-gradient(var(--bg-0) 0 0);
  z-index: 1;
  pointer-events: none;
}
.slot .recharge-t {
  position: absolute;
  left: 3px;
  bottom: 1px;
  font-weight: 700;
  font-size: var(--t-xs);
  color: var(--ready);
  text-shadow: 0 0 3px var(--bg-0), 0 0 3px var(--bg-0);
  z-index: 2;
  pointer-events: none;
}
/* Charges banked: the pill lights up; at zero it stays dim beside the normal cooldown. */
.slot:not(.cd) .charges { border-color: var(--ready); color: var(--ready); box-shadow: 0 0 6px color-mix(in srgb, var(--ready) 60%, transparent); }
.slot.cd::before {
  content: '';
  position: absolute;
  inset: 0;
  background: conic-gradient(transparent 0 var(--done, 40%), var(--cooldown-shade) var(--done, 40%) 100%);
  z-index: 1;
}
.slot.cd::after {
  content: attr(data-cd);
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: var(--t-l);
  text-shadow: 0 0 4px var(--bg-0);
  z-index: 1;
}
.slot.nomana::before { content: ''; position: absolute; inset: 0; background: var(--mana-tint); mix-blend-mode: multiply; }
.slot.nomana { border-color: var(--mana); }
.slot.unlearned > img { filter: grayscale(1) brightness(0.45); }
.slot.ready { border-color: var(--text); }
.slot.aiming { border-color: var(--you); box-shadow: 0 0 0 2px var(--you), 0 0 16px var(--you-glow); }
.slot.poor > img { filter: grayscale(0.85) brightness(0.5); }
.slot.poor { border-color: var(--bg-2); }
.slot.locked > img { filter: grayscale(1) brightness(0.35); }
.slot.sel { border-color: var(--you); box-shadow: 0 0 0 2px var(--you), 0 0 18px var(--you-glow); }
.slot.ownedpart { border-color: var(--owned); }
.slot.building { border-color: var(--ally); box-shadow: 0 0 0 2px var(--ally), 0 0 16px var(--ally-glow); }
button.slot:is(:hover, .virtual-hover) { border-color: var(--text); }
.b-owned { background: var(--owned); color: var(--bg-0); }
.b-rec { background: var(--you); color: var(--ink); }
.b-lock { background: var(--locked); color: var(--text); }
.pips { display: flex; gap: 3px; justify-content: center; margin-top: var(--s1); }
.pips i { width: 9px; height: 9px; background: var(--bg-3); border: 1px solid var(--line-strong); }
.pips i.on { background: var(--levelup); border-color: var(--levelup); }
.plus {
  position: absolute;
  left: 50%;
  top: -28px;
  transform: translateX(-50%);
  width: 30px;
  height: 22px;
  background: var(--levelup);
  color: var(--ink);
  font-weight: 700;
  font-size: var(--t-m);
  display: grid;
  place-items: center;
  border: none;
  border-radius: var(--radius);
  box-shadow: 0 0 10px var(--levelup-glow);
  padding: 0;
  z-index: 3;
}

/* Shop tile = slot + price (+ name) */
.tile { display: flex; flex-direction: column; align-items: center; gap: 2px; width: 84px; background: none; border: none; padding: 0; color: var(--text); }
.tile .price { font-weight: 700; font-size: var(--t-s); color: var(--you); }
.tile.poor .price, .tile.locked .price { color: var(--text-faint); }
.tile .nm { font-size: var(--t-xs); color: var(--text-dim); text-align: center; line-height: 1.1; height: 31px; overflow: hidden; }
.tile:is(:hover, .virtual-hover) .slot { border-color: var(--text); }

/* Portrait */
.portrait {
  --size: 64px;
  width: var(--size);
  height: var(--size);
  position: relative;
  border: 2px solid var(--line-strong);
  background: var(--bg-2);
  flex: none;
}
.portrait > img { width: 100%; height: 100%; image-rendering: pixelated; display: block; }
/* Storm Warden portrait eye lightning: six native frames stacked over the portrait, one shown at a time (70 ms each). */
.storm-eyes { position: absolute; inset: var(--eyes-inset, 0); pointer-events: none; }
.storm-eyes > img {
  position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; opacity: 0;
  animation: storm-eye-frame 420ms steps(1, end) infinite;
}
.storm-eyes-host { position: relative; display: inline-block; line-height: 0; --eyes-inset: 2px; }
@keyframes storm-eye-frame {
  0% { opacity: 1; }
  16.6% { opacity: 0; }
}
@media (prefers-reduced-motion: reduce) { .storm-eyes > img { animation: none; } .storm-eyes > img:first-child { opacity: 1; } }
.portrait.ally { border-color: var(--ally); }
.portrait.enemy { border-color: var(--enemy); }
.portrait.you { border-color: var(--you); }
.portrait .lvl {
  position: absolute;
  right: -4px;
  bottom: -4px;
  font-weight: 700;
  font-size: var(--t-xs);
  background: var(--bg-0);
  border: 1px solid var(--line-strong);
  min-width: 22px;
  text-align: center;
  line-height: 18px;
}
.portrait.dead > img, .portrait.unseen > img { filter: grayscale(1) brightness(0.4); }
.portrait.dead::after {
  content: attr(data-respawn);
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: var(--t-l);
  color: var(--text);
  text-shadow: 0 0 4px var(--bg-0);
}
.portrait .ult {
  position: absolute;
  left: -5px;
  bottom: -5px;
  width: 14px;
  height: 14px;
  transform: rotate(45deg);
  border: 2px solid var(--bg-0);
  background: var(--locked);
}
.portrait .ult.cooling { background: var(--mana); }
.portrait .ult.on { background: var(--ready); box-shadow: 0 0 8px var(--ready); }

/* Bar — ticks every 100, heavy every 1000 (set --max) */
.bar { position: relative; height: 18px; background: var(--bg-0); border: 1px solid var(--bg-0); outline: 1px solid var(--line); overflow: hidden; }
.bar > i { position: absolute; left: 0; top: 0; bottom: 0; width: var(--v, 70%); background: var(--hp); }
.bar.mana > i { background: var(--mana); }
.bar.ally > i { background: var(--ally); }
.bar.enemy > i { background: var(--enemy); }
.bar.xp > i { background: var(--levelup); }
.bar > s { position: absolute; top: 0; bottom: 0; left: var(--v, 70%); width: var(--sh, 0%); background: var(--shield); }
.bar.ticks::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(90deg, transparent 0 calc(100% * 1000 / var(--max) - 2px), var(--bg-0) calc(100% * 1000 / var(--max) - 2px) calc(100% * 1000 / var(--max))),
    repeating-linear-gradient(90deg, transparent 0 calc(100% * 100 / var(--max) - 1px), var(--scrim) calc(100% * 100 / var(--max) - 1px) calc(100% * 100 / var(--max)));
}
.bar .val {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: var(--t-xs);
  text-shadow: 0 0 3px var(--bg-0), 0 0 3px var(--bg-0);
  z-index: 1;
  white-space: nowrap;
}
.bar.thin { height: 8px; }
.bar.mid { height: 12px; }

/* Stat line — icon, value, label */
.stat { display: flex; align-items: center; gap: var(--s2); font-size: var(--t-s); }
.stat svg { width: 18px; height: 18px; flex: none; }
.stat b { font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .lbl { color: var(--text-dim); }
.ico { width: 18px; height: 18px; display: inline-block; vertical-align: -3px; flex: none; }

/* Tooltip — the only one (positioned by Floating UI) */
.tip {
  position: fixed;
  left: 0;
  top: 0;
  z-index: var(--z-toast);
  width: max-content;
  max-width: 400px;
  background: var(--bg-0);
  border: 2px solid var(--line-strong);
  padding: var(--s3) var(--s4);
  box-shadow: 0 10px 30px var(--shadow);
  font-size: var(--t-s);
  pointer-events: none;
}
.tip h4 { margin: 0 0 var(--s1); font-size: var(--t-m); display: flex; gap: var(--s3); justify-content: space-between; }
.tip .rule { height: 1px; background: var(--line); margin: var(--s2) 0; }
.tip table { border-collapse: collapse; font-size: var(--t-xs); width: 100%; }
.tip td, .tip th { padding: 2px var(--s2) 2px 0; text-align: left; }
.tip th { color: var(--text-dim); }

/* Chips & badges */
.chip {
  font-weight: 700;
  font-size: var(--t-xs);
  padding: 2px var(--s2);
  border: 1px solid var(--line-strong);
  background: var(--bg-2);
  border-radius: var(--radius);
  color: var(--text-dim);
  white-space: nowrap;
}
.chip.on { color: var(--ink); background: var(--you); border-color: var(--you); }
button.chip { cursor: pointer; }
.badge-you { font-weight: 700; font-size: var(--t-xs); color: var(--ink); background: var(--you); padding: 0 var(--s1); }

/* Toast */
#toast {
  position: fixed;
  left: 50%;
  top: 140px;
  transform: translateX(-50%);
  z-index: var(--z-toast);
  padding: var(--s2) var(--s5);
  background: var(--panel);
  border: 2px solid var(--line-strong);
  font-size: var(--t-m);
  font-weight: 700;
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
  max-width: 720px;
  text-align: center;
}
#toast.show { opacity: 1; }

/* Software cursor and capture prompts (settings.ts) */
:root {
  --arena-cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='32' viewBox='0 0 28 32'%3E%3Cpath d='M3 2v25l7-7 5 10 5-3-5-9 10-1z' fill='%23f4c440' stroke='%23060812' stroke-width='3' stroke-linejoin='round'/%3E%3Cpath d='m6 7 13 8-9 1-4 5z' fill='%23ffe89a'/%3E%3C/svg%3E") 3 2;
}
canvas { cursor: default; }
.arena-software-cursor {
  display: none;
  position: fixed;
  top: -2px;
  left: -3px;
  width: 28px;
  height: 32px;
  pointer-events: none;
  z-index: 99999;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='32'%3E%3Cpath d='M3 2v25l7-7 5 10 5-3-5-9 10-1z' fill='%23f4c440' stroke='%23060812' stroke-width='3' stroke-linejoin='round'/%3E%3Cpath d='m6 7 13 8-9 1-4 5z' fill='%23ffe89a'/%3E%3C/svg%3E");
}
.arena-cursor-locked .arena-software-cursor { display: block; }
/* Hovering your own fountain stall: a coin-purse cursor says the click opens the shop. */
:root {
  --shop-cursor-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='32' viewBox='0 0 28 32'%3E%3Cpath d='M9 3h10l-3 5h-4z' fill='%23d09622' stroke='%23060812' stroke-width='2' stroke-linejoin='round'/%3E%3Cpath d='M11 8h6c6 3 9 9 8 15-1 5-5 7-11 7S4 28 3 23C2 17 5 11 11 8z' fill='%23f4c440' stroke='%23060812' stroke-width='2.5' stroke-linejoin='round'/%3E%3Cpath d='M10 9h8' stroke='%23060812' stroke-width='2'/%3E%3Ccircle cx='14' cy='20' r='4.5' fill='%23ffe89a' stroke='%239a6414' stroke-width='1.5'/%3E%3C/svg%3E");
  --shop-cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='32' viewBox='0 0 28 32'%3E%3Cpath d='M9 3h10l-3 5h-4z' fill='%23d09622' stroke='%23060812' stroke-width='2' stroke-linejoin='round'/%3E%3Cpath d='M11 8h6c6 3 9 9 8 15-1 5-5 7-11 7S4 28 3 23C2 17 5 11 11 8z' fill='%23f4c440' stroke='%23060812' stroke-width='2.5' stroke-linejoin='round'/%3E%3Cpath d='M10 9h8' stroke='%23060812' stroke-width='2'/%3E%3Ccircle cx='14' cy='20' r='4.5' fill='%23ffe89a' stroke='%239a6414' stroke-width='1.5'/%3E%3C/svg%3E") 14 16;
}
.arena-shop-hover canvas { cursor: var(--shop-cursor), pointer; }
.arena-shop-hover .arena-software-cursor { background: var(--shop-cursor-image); top: -16px; left: -14px; }
.capture-resume {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: var(--z-modal);
  display: flex;
  gap: var(--s2);
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 520px;
  padding: var(--s1) var(--s2);
  background: var(--panel);
  border: 1px solid var(--you);
}

/* Body-level states */
body.champion-fallen #game canvas { filter: grayscale(0.85) brightness(0.6); }
body.champion-fallen #minimap { filter: none; }
