/* Mage Arena: a full-bleed WebGL arena with menus and a HUD floating over it. One committed dark-fantasy look. */
:root {
  --ink: #fff6e6;
  --muted: #d9c9ae;
  --dim: #a8987f;
  --panel: rgba(28, 22, 36, 0.86);
  --panel-2: rgba(48, 38, 60, 0.9);
  --edge: rgba(242, 184, 74, 0.38);
  --gold: #f2b84a;
  --ally: #4fa3ff;
  --enemy: #ff5a4a;
  --hp: #3fc35a;
  --mana: #3d7cff;
  --font-display: "Lilita One", "Trebuchet MS", system-ui, sans-serif;
  --font-body: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { background: #1b1622; color: var(--ink); font: 700 14px/1.4 var(--font-body); overflow: hidden; -webkit-user-select: none; user-select: none; }
canvas#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 400; letter-spacing: 0.02em; margin: 0; }
small { color: var(--dim); font-weight: 700; }
.dim { color: var(--muted); }

/* ---------- screens ---------- */
#screen { position: fixed; inset: 0; overflow-y: auto; padding: 32px 16px; display: flex; justify-content: center; align-items: flex-start; }
#screen.home, #screen.lobby { background: radial-gradient(ellipse at center, rgba(20, 14, 28, 0.35), rgba(20, 14, 28, 0.75)); }
#screen.hidden { display: none; }
.panel { background: var(--panel); border: 1px solid var(--edge); border-radius: 18px; padding: 24px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45); backdrop-filter: blur(6px); }
.panel.wide { width: min(1120px, 100%); }
.panel.queue { width: min(460px, 100%); text-align: center; margin-top: 18vh; display: grid; gap: 12px; }
.hero h1 { font-size: 46px; color: var(--gold); text-shadow: 0 3px 0 #7a4a12; }
.hero p { color: var(--muted); margin: 6px 0 18px; max-width: 640px; }
.row { display: flex; gap: 16px; align-items: flex-end; flex-wrap: wrap; justify-content: space-between; margin-bottom: 18px; }
.name { display: grid; gap: 4px; color: var(--muted); }
.name input { font: inherit; color: var(--ink); background: rgba(0, 0, 0, 0.35); border: 1px solid var(--edge); border-radius: 10px; padding: 10px 12px; width: 240px; }
.go { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.btn { font: 800 15px var(--font-body); color: var(--ink); background: var(--panel-2); border: 1px solid var(--edge); border-radius: 12px; padding: 11px 18px; cursor: pointer; }
.btn:hover:not(:disabled) { border-color: var(--gold); }
.btn.primary { background: linear-gradient(#f6c45a, #d98e24); color: #2b1a06; border-color: #ffd889; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: 0.55; cursor: default; }
.timer { font-family: var(--font-display); font-size: 20px; color: var(--gold); min-width: 130px; text-align: right; }

/* ---------- build editor ---------- */
.bsec { margin-top: 18px; }
.bsec h3 { font-size: 19px; margin-bottom: 8px; }
.bsec h3 small { font-family: var(--font-body); font-size: 13px; margin-left: 8px; }
.schools { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.school { font: inherit; color: var(--ink); display: grid; gap: 4px; justify-items: center; padding: 10px 6px; border-radius: 12px; cursor: pointer;
  background: color-mix(in srgb, var(--c) 12%, rgba(0, 0, 0, 0.35)); border: 2px solid color-mix(in srgb, var(--c) 30%, transparent); }
.school span:first-child { font-family: var(--font-display); font-size: 17px; color: var(--c); }
.school.on { border-color: var(--c); background: color-mix(in srgb, var(--c) 26%, rgba(0, 0, 0, 0.35)); box-shadow: 0 0 18px color-mix(in srgb, var(--c) 40%, transparent); }
.school:disabled { opacity: 0.38; cursor: default; }
.school .mini { display: flex; gap: 3px; }
.talents { display: grid; gap: 6px; }
.trow { display: grid; grid-template-columns: 110px repeat(3, minmax(0, 1fr)); gap: 6px; align-items: stretch; }
.tname { color: var(--muted); align-self: center; }
.tal { font: inherit; color: var(--ink); text-align: left; display: flex; gap: 8px; align-items: center; padding: 8px 10px; border-radius: 10px; cursor: pointer; background: rgba(0, 0, 0, 0.3); border: 1px solid rgba(255, 255, 255, 0.08); }
.tal.on { border-color: var(--gold); background: rgba(242, 184, 74, 0.16); }
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 22px; }
.stat { display: grid; grid-template-columns: 150px 1fr 34px 48px; gap: 10px; align-items: center; }
.stat input { accent-color: var(--gold); width: 100%; }
.stat em { font-style: normal; color: var(--gold); text-align: right; }
.book { display: flex; flex-wrap: wrap; gap: 6px; }

.ic { --c: #ccc; width: 40px; height: 40px; flex: none; display: inline-grid; place-items: center; font-size: 22px; border-radius: 9px;
  background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--c) 70%, #fff 10%), color-mix(in srgb, var(--c) 35%, #120c18) 75%);
  border: 2px solid color-mix(in srgb, var(--c) 70%, #000); box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.5); }
.ic.sm { width: 24px; height: 24px; font-size: 13px; border-radius: 6px; border-width: 1px; }
.ic.passive { border-style: dashed; opacity: 0.8; }
.badge { --c: #ccc; display: inline-block; font: 800 11px var(--font-body); color: #140e18; background: var(--c); border-radius: 6px; padding: 1px 6px; vertical-align: middle; }

#tip { position: fixed; z-index: 50; max-width: 300px; pointer-events: none; background: rgba(16, 12, 22, 0.96); border: 1px solid var(--edge); border-radius: 10px; padding: 9px 11px; font-weight: 600; color: var(--muted); box-shadow: 0 8px 26px rgba(0, 0, 0, 0.5); }
#tip b { font-weight: 900; }
.tip-meta { color: var(--dim); font-size: 12px; margin: 2px 0 4px; }
#toast { position: fixed; z-index: 40; left: 50%; top: 22%; transform: translateX(-50%); color: #ff6a5a; font: 900 18px var(--font-body); text-shadow: 0 2px 4px #000; pointer-events: none; }

/* ---------- lobby ---------- */
.lhead { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.lhead h2 { font-size: 32px; color: var(--gold); }
.vs { display: grid; grid-template-columns: 1fr auto 1fr; gap: 16px; align-items: center; margin: 20px 0; }
.vsx { font-family: var(--font-display); font-size: 28px; color: var(--muted); }
.team { display: grid; gap: 6px; padding: 12px; border-radius: 14px; background: rgba(0, 0, 0, 0.25); }
.team.mine { border: 1px solid color-mix(in srgb, var(--ally) 50%, transparent); }
.team.theirs { border: 1px solid color-mix(in srgb, var(--enemy) 50%, transparent); }
.team h4 { font-size: 16px; color: var(--muted); }
.seat { display: flex; gap: 6px; align-items: center; padding: 6px 8px; border-radius: 8px; background: rgba(255, 255, 255, 0.04); }
.seat.you { background: rgba(242, 184, 74, 0.14); }
.seat span { flex: 1; }
.seat em { color: var(--dim); font-style: normal; }
.rdy { color: var(--hp); }
.tables { display: grid; gap: 14px; }
table.stbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.stbl th { text-align: right; color: var(--dim); font-weight: 800; padding: 4px 8px; border-bottom: 1px solid rgba(255, 255, 255, 0.1); }
table.stbl td { text-align: right; padding: 5px 8px; border-bottom: 1px solid rgba(255, 255, 255, 0.05); font-variant-numeric: tabular-nums; }
table.stbl th:first-child, table.stbl td:first-child { text-align: left; }
table.stbl tr.you td { color: var(--gold); }
details.edit { margin-top: 18px; border-top: 1px solid rgba(255, 255, 255, 0.08); padding-top: 12px; }
details.edit summary { cursor: pointer; font-family: var(--font-display); font-size: 18px; }
details.edit summary small { font-family: var(--font-body); font-size: 13px; margin-left: 6px; }

/* ---------- HUD: every widget is placed by layout.ts ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; }
#hud > * { pointer-events: auto; }
#hud #announce, #hud .edit-grid { pointer-events: none; }
.w { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
#hud:not(.editing) .w.none { visibility: hidden; }
#hud:not(.editing) .w.bar-off { display: none; }
.topbar { display: flex; gap: 18px; padding: 6px 16px; border-radius: 12px; background: var(--panel); border: 1px solid var(--edge); font-weight: 800; white-space: nowrap; }
#h-time { font-family: var(--font-display); color: var(--gold); font-size: 18px; line-height: 1.2; }
.frames { display: grid; gap: 8px; width: 230px; }
.uf { background: var(--panel); border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 10px; padding: 6px 8px 7px; cursor: pointer; position: relative; width: 230px; }
.unitw .uf { width: 250px; }
.uf.ph, .tot.ph { color: var(--dim); text-align: center; min-height: 40px; display: grid; place-items: center; border-style: dashed; }
.uf.me { border-color: color-mix(in srgb, var(--gold) 60%, transparent); }
.uf.ally { border-left: 3px solid var(--ally); }
.uf.enemy { border-left: 3px solid var(--enemy); }
.uf.targeted { outline: 2px solid #fff; }
.uf.focused { box-shadow: 0 0 0 2px #c48cff; }
.uf.dead { opacity: 0.45; }
.uf-top { display: flex; gap: 4px; align-items: center; margin-bottom: 3px; }
.uf-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.uf-name small { font-size: 10px; }
.uf-trink { font-size: 11px; padding: 0 4px; border-radius: 5px; background: rgba(111, 224, 138, 0.25); }
.uf-trink.used { background: rgba(255, 90, 74, 0.3); }
.hp { position: relative; height: 16px; background: rgba(0, 0, 0, 0.55); border-radius: 4px; overflow: hidden; }
.hp i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(#5fe07a, #2a9c45); transition: width 0.1s; }
.enemy .hp i { background: linear-gradient(#ff7a6a, #c2382c); }
.hp s { position: absolute; top: 0; bottom: 0; background: rgba(255, 255, 255, 0.55); text-decoration: none; }
.hp span { position: absolute; inset: 0; text-align: center; font-size: 11px; line-height: 16px; text-shadow: 0 1px 2px #000; }
.mp { height: 5px; margin-top: 2px; background: rgba(0, 0, 0, 0.55); border-radius: 3px; overflow: hidden; }
.mp i { display: block; height: 100%; background: var(--mana); }
.uf-cast { position: relative; height: 13px; margin-top: 3px; background: rgba(0, 0, 0, 0.5); border-radius: 3px; overflow: hidden; visibility: hidden; }
.uf-cast i { position: absolute; inset: 0 auto 0 0; opacity: 0.85; }
.uf-cast span { position: absolute; inset: 0; font-size: 10px; line-height: 13px; padding-left: 4px; text-shadow: 0 1px 2px #000; }
.uf-cc { visibility: hidden; position: absolute; right: 8px; top: 26px; font-size: 11px; color: #ffd36a; font-weight: 900; text-shadow: 0 1px 2px #000; }
.auras { display: flex; flex-wrap: wrap; gap: 2px; margin-top: 3px; min-height: 20px; }
.au { --c: #ccc; position: relative; width: 20px; height: 20px; font-size: 11px; display: grid; place-items: center; border-radius: 4px; background: color-mix(in srgb, var(--c) 35%, #0d0912); border: 1px solid var(--c); }
.au.debuff { border-color: #ff5a4a; }
.au.cc { border: 2px solid #ffd36a; }
.au em { position: absolute; right: -2px; bottom: -3px; font: 900 9px var(--font-body); font-style: normal; text-shadow: 0 0 2px #000, 0 0 2px #000; }
.tot { width: 150px; background: var(--panel); border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 9px; padding: 5px 7px; cursor: pointer; font-size: 12px; }
.tot.ally { border-left: 3px solid var(--ally); } .tot.enemy { border-left: 3px solid var(--enemy); }
.tot .hp { height: 12px; } .tot .hp span { line-height: 12px; font-size: 10px; }
.castbar .cb { position: relative; width: 300px; height: 20px; background: rgba(0, 0, 0, 0.6); border: 1px solid var(--edge); border-radius: 6px; overflow: hidden; visibility: hidden; }
.castbar .cb i { position: absolute; inset: 0 auto 0 0; }
.castbar .cb span { position: absolute; inset: 0; text-align: center; line-height: 20px; font-size: 12px; text-shadow: 0 1px 2px #000; }
.loc-in { min-width: 220px; min-height: 10px; display: grid; justify-items: center; gap: 4px; text-align: center; }
.loc-in.on, .loc-in.demo { padding: 8px 18px 10px; border-radius: 14px; background: rgba(20, 14, 26, 0.72); border: 1px solid rgba(255, 211, 106, 0.5); }
.loc-in .ic { width: 58px; height: 58px; font-size: 32px; }
.loc-in b { font: 400 22px var(--font-display); color: #ffd36a; text-shadow: 0 2px 0 #000; }
.loc-in em { font: 900 18px var(--font-body); font-style: normal; }
.loc-bar { display: block; width: 160px; height: 5px; background: rgba(0, 0, 0, 0.5); border-radius: 3px; overflow: hidden; }
.loc-bar i { display: block; height: 100%; background: #ffd36a; }
.bar .bar-body { display: grid; gap: 5px; padding: 7px; background: var(--panel); border: 1px solid var(--edge); border-radius: 14px; }
.ab { position: relative; padding: 0; border: 0; background: none; cursor: pointer; width: 46px; height: 46px; }
.ab .ic { width: 46px; height: 46px; font-size: 24px; }
.ab.empty { border-radius: 9px; background: rgba(0, 0, 0, 0.25); visibility: hidden; }
#hud.editing .ab.empty, #hud.binding .ab.empty { visibility: visible; border: 1px dashed rgba(255, 255, 255, 0.25); }
.ab em { position: absolute; left: 3px; top: 1px; font: 900 11px var(--font-body); font-style: normal; color: #fff; text-shadow: 0 0 3px #000, 0 0 3px #000; pointer-events: none; }
.ab .cd { --k: 0; position: absolute; inset: 0; border-radius: 9px; pointer-events: none; background: conic-gradient(rgba(0, 0, 0, 0.72) calc(var(--k) * 360deg), transparent 0); }
.ab .cdt { position: absolute; inset: 0; display: grid; place-items: center; font: 900 17px var(--font-body); color: #fff; text-shadow: 0 0 4px #000; pointer-events: none; }
.ab .chg { position: absolute; right: 3px; bottom: 1px; font: 900 12px var(--font-body); text-decoration: none; color: #fff; text-shadow: 0 0 3px #000; pointer-events: none; }
.ab.bad .ic { filter: saturate(0.4) brightness(0.7); box-shadow: inset 0 0 0 40px rgba(200, 30, 30, 0.35); }
.ab.locked .ic { filter: grayscale(1) brightness(0.5); }
.ab.queued .ic, .ab.kindled .ic { box-shadow: 0 0 0 2px #fff, 0 0 16px 4px var(--gold); }
#hud.binding .ab:hover { outline: 2px solid var(--gold); border-radius: 9px; }
#hud.binding .ab em { color: var(--gold); }
.meter { width: 240px; background: var(--panel); border: 1px solid var(--edge); border-radius: 12px; padding: 6px; font-size: 12px; }
.m-head { display: flex; gap: 4px; margin-bottom: 4px; }
.m-head button { flex: 1; font: 800 11px var(--font-body); color: var(--dim); background: rgba(0, 0, 0, 0.3); border: 0; border-radius: 6px; padding: 3px; cursor: pointer; }
.m-head button.on { color: var(--ink); background: rgba(242, 184, 74, 0.25); }
.m-row { position: relative; display: flex; justify-content: space-between; padding: 2px 6px; margin-top: 2px; border-radius: 4px; overflow: hidden; background: rgba(0, 0, 0, 0.3); }
.m-row i { position: absolute; inset: 0 auto 0 0; opacity: 0.45; }
.m-row.ally i { background: var(--ally); } .m-row.enemy i { background: var(--enemy); } .m-row.me i { background: var(--gold); }
.m-row span, .m-row b { position: relative; text-shadow: 0 1px 2px #000; }
.minimap canvas { display: block; width: 180px; height: 180px; }
#announce { position: absolute; top: 28%; left: 0; right: 0; text-align: center; font: 400 72px var(--font-display); color: var(--gold); text-shadow: 0 4px 0 #7a4a12, 0 0 30px rgba(0, 0, 0, 0.6); opacity: 0; transition: opacity 0.2s; }
#announce.show { opacity: 1; }
#announce.big.win { color: #ffd76a; }
#announce.big.lose { color: #ff7a6a; text-shadow: 0 4px 0 #6a1a12; }
.hud-btns { position: absolute; right: 14px; bottom: 14px; display: flex; gap: 6px; }
.hud-btns > * { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--panel); border: 1px solid var(--edge); color: var(--gold); font-weight: 900; cursor: pointer; font-size: 15px; padding: 0; }
#help { cursor: help; }

/* ---------- edit mode ---------- */
.edit-grid { position: absolute; inset: 0; background-image:
  linear-gradient(rgba(255, 255, 255, 0.07) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, 0.07) 1px, transparent 1px),
  linear-gradient(rgba(242, 184, 74, 0.35) 1px, transparent 1px), linear-gradient(90deg, rgba(242, 184, 74, 0.35) 1px, transparent 1px);
  background-size: 16px 16px, 16px 16px, 100% 50%, 50% 100%; background-position: 0 0, 0 0, 0 calc(50% - 0.5px), calc(50% - 0.5px) 0; background-color: rgba(10, 6, 16, 0.25); }
.edit-bar { position: absolute; bottom: 34%; left: 50%; transform: translateX(-50%); z-index: 20; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: center; max-width: 92vw;
  padding: 8px 12px; border-radius: 12px; background: rgba(16, 12, 22, 0.95); border: 1px solid var(--gold); }
.edit-bar span { color: var(--muted); font-size: 12px; }
.btn.sm { padding: 6px 10px; font-size: 12px; border-radius: 9px; }
#hud.editing .w { outline: 1px dashed rgba(242, 184, 74, 0.7); outline-offset: 2px; }
#hud.editing .w.w-hidden { opacity: 0.35; }
#hud.editing .w.w-drag { outline: 2px solid var(--gold); }
.w-handle { position: absolute; left: 0; bottom: 100%; margin-bottom: 4px; display: flex; gap: 6px; align-items: center; white-space: nowrap; padding: 2px 8px; border-radius: 7px; background: var(--gold); color: #2b1a06; font: 900 11px var(--font-body); cursor: grab; z-index: 5; }
.w-handle button { font: 900 11px var(--font-body); border: 0; border-radius: 5px; padding: 0 5px; background: rgba(0, 0, 0, 0.18); color: #2b1a06; cursor: pointer; }
.w-extra { display: flex; gap: 3px; align-items: center; }
.w-extra:empty { display: none; }
.side-panel { position: absolute; left: 50%; top: 12%; transform: translateX(-50%); z-index: 21; width: 380px; max-height: 60vh; overflow: auto; padding: 14px; border-radius: 14px; background: rgba(16, 12, 22, 0.96); border: 1px solid var(--gold); }
.side-panel h4 { font-size: 18px; color: var(--gold); }
.side-panel p { color: var(--muted); font-size: 12px; margin: 4px 0 10px; }
.book-list { display: grid; gap: 4px; }
.book-row { display: flex; gap: 8px; align-items: center; padding: 3px; border-radius: 8px; cursor: grab; }
.book-row:hover { background: rgba(255, 255, 255, 0.06); }
.book-row.placed span { color: var(--dim); }
.bind-list { display: grid; gap: 4px; margin-bottom: 10px; }
.bind-row { font: inherit; color: var(--ink); display: flex; justify-content: space-between; padding: 6px 8px; border-radius: 8px; background: rgba(0, 0, 0, 0.3); border: 1px solid transparent; cursor: pointer; }
.bind-row.picking { border-color: var(--gold); }
kbd { font: 900 12px var(--font-body); color: var(--gold); }
.drag-ghost { position: fixed; z-index: 60; pointer-events: none; opacity: 0.85; }
.drag-ghost .ic { width: 46px; height: 46px; font-size: 24px; }

/* ---------- nameplates and combat text ---------- */
#plates, #floaters { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.plate { position: absolute; left: 0; top: 0; width: 120px; text-align: center; display: flex; flex-direction: column; align-items: stretch; }
.plate .pa { display: flex; justify-content: center; gap: 2px; margin-bottom: 2px; min-height: 0; }
.plate.pa-below .pa { order: 9; margin: 2px 0 0; }
.plate .au { width: 18px; height: 18px; font-size: 10px; }
.plate .pb, .plate .pc { margin: 0 12px; }
.plate .pn { font-size: 11px; font-weight: 900; text-shadow: 0 1px 2px #000, 0 0 4px #000; white-space: nowrap; }
.plate.enemy .pn { color: #ffb0a6; }
.plate.ally .pn { color: #b6dcff; }
.plate.self .pn, .plate.self .pb, .plate.self .pa { display: none; }
.plate .pb { position: relative; height: 7px; background: rgba(0, 0, 0, 0.6); border-radius: 3px; overflow: hidden; border: 1px solid rgba(0, 0, 0, 0.6); }
.plate .pb i { position: absolute; inset: 0 auto 0 0; background: var(--hp); }
.plate.enemy .pb i { background: var(--enemy); }
.plate .pb s { position: absolute; top: 0; bottom: 0; right: 0; background: rgba(255, 255, 255, 0.6); }
.plate .pc { visibility: hidden; position: relative; height: 10px; margin-top: 2px; background: rgba(0, 0, 0, 0.6); border-radius: 3px; overflow: hidden; }
.plate .pc i { position: absolute; inset: 0 auto 0 0; background: #ffcb5a; }
.plate .pc span { position: absolute; inset: 0; font-size: 8px; line-height: 10px; color: #fff; text-shadow: 0 1px 1px #000; white-space: nowrap; }
.plate.targeted .pb { border-color: #fff; }
.plate.dead { opacity: 0.4; }
.fl { position: absolute; left: 0; top: 0; font: 900 18px var(--font-body); text-shadow: 0 2px 3px #000, 0 0 4px #000; white-space: nowrap; }
.fl.hit { color: #fff; }
.fl.dot { color: #ffd19a; font-size: 14px; }
.fl.crit { color: #ffd23a; font-size: 26px; }
.fl.taken { color: #ff6a5a; }
.fl.heal { color: #6fe08a; }
.fl.cc { color: #e9c8ff; font-size: 15px; }
.fl.zz { color: #cfe0ff; font-size: 16px; }

@media (max-width: 760px) {
  .schools { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .trow { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr; }
  .stat { grid-template-columns: 110px 1fr 30px 44px; }
  .vs { grid-template-columns: 1fr; }
}
