:root {
  --bg: #07090d;
  --panel: rgba(13, 17, 26, .86);
  --panel-2: rgba(22, 28, 41, .92);
  --line: rgba(140, 170, 210, .18);
  --fg: #e7edf6;
  --muted: #8d9ab0;
  --ally: #35e0ff;
  --enemy: #ff3d5a;
  --prep: #4fd1a5;
  --dash: #ffd43b;
  --blast: #ff7a3d;
  --energy: #b48cff;
  --hp: #4fe07a;
  --shield: #cfe3ff;
  --title: 'Cinzel', 'Trajan Pro', Georgia, serif;
  --ui: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--fg); font: 14px/1.35 var(--ui); -webkit-tap-highlight-color: transparent; }
#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
button { font: inherit; color: inherit; }

/* Top bar */
#top { position: fixed; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 12px; padding: calc(10px + env(safe-area-inset-top)) 14px 10px; pointer-events: none;
  background: linear-gradient(180deg, rgba(5,7,11,.85), rgba(5,7,11,0)); }
#top > * { pointer-events: auto; }
.brand { font: 800 18px var(--title); letter-spacing: .08em; text-transform: uppercase; background: linear-gradient(180deg, #fff, #9fc9ff); -webkit-background-clip: text; background-clip: text; color: transparent; white-space: nowrap; }
#turninfo { flex: 1; text-align: center; font: 700 13px var(--title); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#turninfo b { color: var(--fg); }
#turninfo .short { display: none; }
#turninfo .s0 { color: var(--ally); } #turninfo .s1 { color: var(--enemy); }
.tools { display: flex; gap: 6px; }
.ibtn { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; font-size: 17px; display: grid; place-items: center; backdrop-filter: blur(6px); }
.ibtn:hover { border-color: rgba(53,224,255,.5); }
#quality { font: 700 11px var(--ui); letter-spacing: .06em; }
#quality[data-q="low"] { color: var(--muted); }

/* Floating unit labels */
#labels { position: fixed; inset: 0; pointer-events: none; }
.ulabel { position: absolute; left: 0; top: 0; transform: translate(-50%, -100%); display: flex; flex-direction: column; align-items: center; gap: 2px; white-space: nowrap; will-change: transform; }
.ulabel .nm { font: 600 11px var(--ui); color: var(--fg); text-shadow: 0 1px 2px #000, 0 0 6px #000; display: flex; gap: 4px; align-items: center; }
.ulabel .tm { font-size: 9px; }
.ulabel.t0 .tm { color: var(--ally); } .ulabel.t1 .tm { color: var(--enemy); }
.bar { width: 44px; height: 5px; border-radius: 3px; background: rgba(0,0,0,.65); border: 1px solid rgba(255,255,255,.18); overflow: hidden; position: relative; }
.bar i { position: absolute; inset: 0 auto 0 0; background: var(--hp); }
.ulabel.t1 .bar i { background: #ff5a6e; }
.bar.en { height: 2px; width: 34px; border: 0; margin-left: 12px; }
.bar s { position: absolute; top: 0; bottom: 0; right: 0; background: var(--shield); opacity: .85; text-decoration: none; }
.ulabel .pip { display: flex; align-items: center; gap: 3px; }
.ulabel .pip .tm { font-size: 9px; text-shadow: 0 0 3px #000; }
.ulabel .full { display: none; }
.ulabel.focus .full { display: inline; } .ulabel.focus .nm.full { display: flex; }
.ulabel.focus { z-index: 2; }
.bar.en i { background: var(--energy); }
.ulabel.dead { opacity: .55; } .ulabel.dead .nm::after { content: '✝'; color: var(--muted); }
.ulabel.ghost { opacity: .7; } .ulabel.ghost .nm { color: var(--muted); font-style: italic; }
.ulabel.me .pip::before { content: '▼'; color: var(--ally); font-size: 8px; text-shadow: 0 0 3px #000; }
.ulabel.me .bar.en { margin-left: 21px; }

/* Kit panel */
#kit { position: fixed; right: 12px; top: 64px; width: 320px; max-height: calc(100% - 80px); overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px; backdrop-filter: blur(10px); box-shadow: 0 20px 50px rgba(0,0,0,.5); }
#kit .hd { display: flex; gap: 10px; align-items: center; }
#kit .portrait { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 24px; background: var(--panel-2); border: 2px solid var(--ally); flex: none; }
#kit.t1 .portrait { border-color: var(--enemy); border-radius: 4px; transform: rotate(0); }
#kit h2 { margin: 0; font: 700 17px var(--title); letter-spacing: .04em; }
#kit .role { color: var(--muted); font-size: 12px; text-transform: capitalize; }
#kit .close { margin-left: auto; align-self: flex-start; background: none; border: 0; color: var(--muted); font-size: 20px; cursor: pointer; padding: 0 4px; }
#kit .stats { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 8px; align-items: center; margin: 12px 0 8px; font-size: 12px; color: var(--muted); }
#kit .stats .bar { width: 100%; height: 8px; }
#kit .stats b { color: var(--fg); font-variant-numeric: tabular-nums; }
#kit .statuses { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.chip { font-size: 11px; padding: 2px 7px; border-radius: 99px; background: var(--panel-2); border: 1px solid var(--line); }
.abil { display: grid; grid-template-columns: 28px 1fr auto; gap: 2px 10px; padding: 9px 10px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); margin-top: 6px; position: relative; overflow: hidden; }
.abil::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--ph); }
.abil .key { grid-row: span 2; width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; font: 700 12px var(--ui); background: rgba(0,0,0,.35); border: 1px solid var(--line); }
.abil .nm { font-weight: 600; }
.abil .ph { font: 700 10px var(--ui); letter-spacing: .1em; text-transform: uppercase; color: var(--ph); justify-self: end; }
.abil .meta { grid-column: 2 / 4; font-size: 11.5px; color: var(--muted); }
.abil.ult { border-color: rgba(180,140,255,.4); }
.abil.ult.ready { box-shadow: inset 0 0 18px rgba(180,140,255,.35); }
.abil.cd { opacity: .55; }
.abil .cdn { position: absolute; right: 10px; bottom: 8px; font: 700 11px var(--ui); color: var(--fg); background: rgba(0,0,0,.5); padding: 1px 6px; border-radius: 6px; }
#kit .cats { margin-top: 10px; font-size: 12px; color: var(--muted); }
#kit .cats .chip.used { opacity: .4; text-decoration: line-through; }

#tileinfo { position: fixed; left: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; font-size: 12px; color: var(--muted); backdrop-filter: blur(6px); }
#tileinfo b { color: var(--fg); text-transform: capitalize; }

#loading { position: fixed; inset: 0; display: grid; place-items: center; font: 700 16px var(--title); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); background: var(--bg); transition: opacity .4s; z-index: 5; }
#loading.done { opacity: 0; pointer-events: none; }

@media (max-width: 640px) {
  .brand { font-size: 0; width: 18px; height: 18px; background: none; -webkit-background-clip: border-box; background-clip: border-box; }
  .brand::before { content: '◆'; font-size: 18px; color: var(--ally); }
  #turninfo { font-size: 12px; }
  #turninfo .long { display: none; } #turninfo .short { display: inline; }
  .ibtn { width: 34px; height: 34px; }
  #kit { left: 8px; right: 8px; top: auto; bottom: calc(8px + env(safe-area-inset-bottom)); width: auto; max-height: 52%; padding: 12px; }
  #kit .abil { padding: 7px 9px; }
  #tileinfo { bottom: auto; top: 58px; left: 8px; }
}
