:root {
  --bg: #0f1526;
  --panel: #1a2740;
  --panel2: #24375a;
  --fg: #eef5ff;
  --muted: #a7bbde;
  --accent: #56d9ff;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--fg);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.topbar {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: 1.25rem 2rem;
  border-bottom: 1px solid #222a38;
}
.topbar h1 {
  margin: 0;
  font-size: 1.5rem;
  letter-spacing: 0.1em;
  color: var(--accent);
}
.topbar .sub { color: var(--muted); }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
  padding: 2rem;
  max-width: 1100px;
  margin: 0 auto;
}

.card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: var(--panel);
  border: 1px solid #222a38;
  border-radius: 8px;
  padding: 1.25rem;
  min-height: 160px;
  text-decoration: none;
  color: var(--fg);
  transition: transform 80ms ease, border-color 80ms ease, background 80ms ease;
}
.card.playable:hover {
  border-color: var(--accent);
  background: var(--panel2);
  transform: translateY(-2px);
}
.card.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.card-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}
.card-desc {
  color: var(--muted);
  margin: 0.5rem 0 1rem;
  flex: 1;
}
.card-tag {
  align-self: flex-start;
  font-size: 0.75rem;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 2px 6px;
}
.card.disabled .card-tag {
  color: var(--muted);
  border-color: var(--muted);
}

.footer {
  text-align: center;
  color: var(--muted);
  padding: 1rem;
  font-size: 0.8rem;
}

/* ---- arena game ---- */
.game-root {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  background: radial-gradient(circle at 50% 20%, #1a2f5a 0%, #111a31 45%, #0b1122 100%);
  overflow: hidden;
}
#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--fg);
}

.hud [hidden] {
  display: none !important;
}

.hud .respawn-indicator {
  position: absolute;
  left: 50%;
  top: 48%;
  transform: translate(-50%, -50%);
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid #86bfff;
  background: rgba(16, 28, 49, 0.86);
  color: #eaf4ff;
  font-size: 16px;
  font-weight: 700;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
  pointer-events: none;
}

.hud .panel-tl,
.hud .panel-tr,
.hud .panel-bl,
.hud .panel-br {
  position: absolute;
  background: rgba(18, 31, 54, 0.72);
  border: 1px solid #335585;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 12px;
  pointer-events: auto;
}
.hud .panel-tl { top: 12px; left: 12px; min-width: 180px; }
.hud .panel-tr { top: 12px; right: 12px; min-width: 180px; }
.hud .panel-bl { bottom: 12px; left: 12px; min-width: 200px; }
.hud .panel-br { bottom: 12px; right: 12px; min-width: 220px; }

.hud .hp-center-panel {
  position: absolute;
  left: 50%;
  bottom: 104px;
  transform: translateX(-50%);
  min-width: 360px;
  background: rgba(18, 31, 54, 0.74);
  border: 1px solid #3a67a5;
  border-radius: 8px;
  padding: 8px 12px 10px;
  pointer-events: auto;
}

.hud .buff-stack {
  position: absolute;
  left: 50%;
  bottom: 178px;
  transform: translateX(-50%);
  width: 220px;
  pointer-events: none;
}

.hud .home-office-objective {
  position: absolute;
  left: 12px;
  bottom: 12px;
  min-width: 178px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid #4e79bb;
  background: rgba(16, 28, 49, 0.86);
  box-shadow: 0 0 18px rgba(58, 109, 180, 0.22);
  pointer-events: none;
}

.hud .home-office-objective .ho-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #9fd7ff;
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.hud .home-office-objective .ho-goal {
  font-size: 10px;
  letter-spacing: 0;
  color: #cfe6ff;
  opacity: 0.75;
  text-transform: none;
}

.hud .home-office-objective .ho-leaderboard {
  list-style: none;
  margin: 5px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 178px;
}

.hud .home-office-objective .ho-leaderboard li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: #d8ebff;
  padding: 1px 4px;
  border-radius: 4px;
  line-height: 1.25;
}

.hud .home-office-objective .ho-leaderboard li.me {
  background: rgba(86, 180, 255, 0.18);
  color: #f5fbff;
}

.hud .home-office-objective .ho-leaderboard li.lead {
  color: #ffe89a;
}

.hud .home-office-objective .ho-leaderboard .ho-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hud .home-office-objective .ho-leaderboard .ho-count {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.hud .home-office-objective .ho-channel {
  margin-top: 6px;
  font-size: 11px;
  color: #ffe7a3;
}

.hud .active-buffs {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  margin: 0;
}

.hud .active-buffs:empty {
  display: none;
}

.hud .buff-status-text {
  display: none;
}

.hud .buff-row {
  position: relative;
  width: 100%;
  height: 18px;
  border-radius: 8px;
  background: rgba(12, 19, 31, 0.8);
  border: 1px solid rgba(170, 206, 255, 0.45);
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

.hud .buff-row-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  opacity: 0.45;
  pointer-events: none;
}

.hud .buff-row-text {
  position: relative;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  z-index: 2;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  color: #f0f7ff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
}

.hud .cast-bar-wrap {
  position: absolute;
  left: 0;
  right: 0;
  top: -22px;
  display: flex;
  justify-content: center;
  pointer-events: none;
}

.hud .cast-bar-track {
  position: relative;
  width: 72%;
  height: 14px;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid #b985ff;
  background: rgba(23, 15, 39, 0.86);
  box-shadow: 0 0 14px rgba(185, 133, 255, 0.34);
}

.hud .cast-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #d294ff, #ff89c9);
  transition: width 70ms linear;
}

.hud .buff-indicator {
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  line-height: 1;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid #7ef5ff;
  color: #d5fbff;
  background: rgba(40, 122, 145, 0.7);
  box-shadow: 0 0 12px rgba(126, 245, 255, 0.35);
}

.hud .hp-bar {
  position: relative;
  height: 18px;
  background: #261733;
  border: 1px solid #5a2c7d;
  border-radius: 3px;
  overflow: hidden;
  margin-top: 0;
}
.hud .hp-fill {
  height: 100%;
  background: linear-gradient(to right, #ff4f8c, #ff9d4d);
  width: 100%;
  transition: width 120ms ease;
}

.hud .hp-shield-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 0;
  background: linear-gradient(to right, #ffe8fb, #ffc6ea);
  opacity: 0;
  transition: left 120ms ease, width 120ms ease, opacity 120ms ease;
  pointer-events: none;
}

.hud .mp-bar {
  position: relative;
  height: 14px;
  background: #11203a;
  border: 1px solid #2c5fa0;
  border-radius: 3px;
  overflow: hidden;
  margin-top: 6px;
}
.hud .mp-fill {
  height: 100%;
  background: linear-gradient(to right, #4d8bff, #56d9ff);
  width: 100%;
  transition: width 120ms ease;
}

.hud .bar-value {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  line-height: 1;
  color: #f6fbff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.75);
  pointer-events: none;
}

.hud .minimap-panel {
  padding: 7px;
  min-width: 0;
}
.hud #minimap {
  display: block;
  width: 240px;
  height: 144px;
  background: #0a1426;
  border: 1px solid #2c5fa0;
  border-radius: 4px;
  image-rendering: pixelated;
}

.hud .cd {
  height: 6px;
  background: #1f2f4a;
  border: 1px solid #3a67a5;
  border-radius: 3px;
  overflow: hidden;
  margin-top: 4px;
}
.hud .cd-fill {
  height: 100%;
  background: var(--accent);
  width: 100%;
}

.hud .row { display: flex; justify-content: space-between; gap: 8px; }
.hud .muted { color: var(--muted); }

.hud .killfeed {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 180px;
  overflow: hidden;
}
.hud .kf-row {
  font-size: 12px;
  color: var(--muted);
}
.hud .kf-row b { color: var(--fg); }
.hud .kf-kill b.victim { color: var(--danger); }

.hud .ability-bar {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  pointer-events: auto;
}

.hud .spellbook-toggle {
  position: absolute;
  left: calc(50% + 226px);
  bottom: 16px;
  width: 26px;
  height: 168px;
  border: 1px solid #4f73b2;
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(47, 71, 114, 0.92), rgba(21, 32, 54, 0.92));
  color: #d8ebff;
  font: inherit;
  cursor: pointer;
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.hud .spellbook-toggle:hover {
  border-color: #89b8ff;
  background: linear-gradient(180deg, rgba(64, 95, 144, 0.95), rgba(28, 42, 70, 0.95));
}

.hud .spellbook-toggle .sb-toggle-glyph {
  font-size: 18px;
  line-height: 1;
  color: #c8e0ff;
  transition: transform 180ms ease;
  display: inline-block;
}

.hud .spellbook-toggle.open .sb-toggle-glyph {
  transform: rotate(180deg);
}

.hud .home-office-objective .gold-floating {
  margin-top: 6px;
  min-width: 0;
  text-align: left;
  border: 1px solid #4f73b2;
  border-radius: 6px;
  background: rgba(19, 30, 52, 0.9);
  color: #d8ebff;
  font-size: 11px;
  padding: 4px 6px;
}

.hud .spellbook-panel {
  position: absolute;
  left: calc(50% + 258px);
  bottom: 16px;
  --sb-cell-size: 74px;
  width: max-content;
  max-width: calc(100vw - 12px);
  background: rgba(18, 31, 54, 0.88);
  border: 1px solid #6f8bc1;
  border-radius: 8px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: auto;
  overflow: hidden;
  transform-origin: left center;
  transition: transform 180ms ease, opacity 180ms ease;
}

.hud .spellbook-panel[hidden] {
  display: flex !important;
  pointer-events: none;
  transform: scaleX(0);
  opacity: 0;
}

.hud .spellbook-panel .sb-stats {
  display: grid;
  width: 100%;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.hud .spellbook-panel .sb-stat {
  width: auto;
  padding: 4px 5px;
  border: 1px solid #4a6eae;
  border-radius: 6px;
  background: rgba(29, 45, 75, 0.95);
  color: #e3f2ff;
  font: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}

.hud .spellbook-panel .sb-stat .sb-name {
  font-size: 11px;
  color: #e4f1ff;
}

.hud .spellbook-panel .sb-stat .sb-lvl {
  font-size: 10px;
  color: #b7d5ff;
}

.hud .spellbook-panel .sb-stat:hover {
  border-color: #89b8ff;
}

.hud .spellbook-panel .sb-stat.disabled {
  opacity: 0.55;
  cursor: default;
}

.hud .spellbook-panel .sb-grid {
  display: grid;
  grid-template-columns: repeat(var(--sb-spell-cols, 5), var(--sb-cell-size));
  grid-auto-rows: var(--sb-cell-size);
  gap: 6px;
}

.hud .spellbook-panel .sb-spell {
  border: 1px solid #3f5f98;
  border-radius: 6px;
  background: linear-gradient(180deg, rgba(52, 77, 121, 0.86), rgba(23, 35, 58, 0.9));
  padding: 5px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: var(--sb-cell-size);
  min-width: var(--sb-cell-size);
  height: var(--sb-cell-size);
  justify-content: space-between;
  overflow: hidden;
}

.hud .spellbook-panel .sb-spell.sb-upgrade {
  cursor: pointer;
  border-color: #4a6eae;
  background: rgba(29, 45, 75, 0.95);
  color: #e3f2ff;
}

.hud .spellbook-panel .sb-spell.sb-upgrade.disabled {
  opacity: 0.55;
  cursor: default;
}

.hud .spellbook-panel .sb-spell[draggable="true"] {
  cursor: grab;
}

.hud .spellbook-panel .sb-spell:hover {
  border-color: #89b8ff;
}

.hud .spellbook-panel .sb-spell.dragging {
  opacity: 0.55;
}

.hud .spellbook-panel .sb-spell.locked {
  filter: grayscale(0.5);
  opacity: 0.8;
}

.hud .spellbook-panel .sb-spell-top {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
}

.hud .spellbook-panel .sb-name {
  display: block;
  width: 100%;
  font-size: 10px;
  color: #e4f1ff;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hud .spellbook-panel .sb-lvl {
  font-size: 10px;
  color: #b7d5ff;
  text-align: center;
}

@media (max-width: 980px) {
  .hud .spellbook-panel {
    left: 12px;
    right: auto;
    bottom: 100px;
    width: calc(100vw - 24px);
    max-height: 46vh;
    overflow-x: auto;
  }
  .hud .ability-bar {
    left: 12px;
    transform: none;
    bottom: 12px;
  }
  .hud .spellbook-toggle {
    left: auto;
    right: 12px;
    bottom: 12px;
    width: 26px;
    height: 132px;
  }
  .hud .ability-slot {
    width: 64px;
    height: 64px;
  }
  .hud .home-office-objective {
    bottom: 84px;
    min-width: 146px;
  }
}

.hud .ability-slot {
  position: relative;
  width: 78px;
  height: 78px;
  border: 1px solid #3a5582;
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(48,74,118,0.88), rgba(20,31,55,0.88));
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.03);
  overflow: hidden;
}

.hud .ability-slot .key {
  position: absolute;
  top: 6px;
  left: 8px;
  font-size: 12px;
  font-weight: 700;
  color: #9fe8ff;
}

.hud .ability-slot .label {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 7px;
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #d5e7ff;
}

.hud .ability-slot.active {
  border-color: #5ce3ff;
  box-shadow: 0 0 0 1px rgba(92,227,255,0.38), 0 0 18px rgba(92,227,255,0.24);
}

.hud .ability-slot.empty {
  border-style: dashed;
  border-color: #466089;
}

.hud .ability-slot.drag-over {
  border-color: #7bffad;
  box-shadow: 0 0 0 1px rgba(123,255,173,0.48), 0 0 18px rgba(123,255,173,0.26);
}

.hud .ability-slot.targeting {
  border-color: #7bffad;
  box-shadow: 0 0 0 1px rgba(123,255,173,0.48), 0 0 18px rgba(123,255,173,0.26);
}

.hud .ability-slot.disabled {
  filter: grayscale(0.5);
  opacity: 0.65;
}

.hud .ability-slot .cd-mask {
  position: absolute;
  inset: 0;
  background: rgba(8, 16, 30, 0.58);
  transform-origin: bottom;
  transform: scaleY(0);
  transition: transform 80ms linear;
  pointer-events: none;
}

.name-modal {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  pointer-events: auto;
}
.name-modal .box {
  background: var(--panel);
  border: 1px solid #222a38;
  border-radius: 8px;
  padding: 1.5rem;
  min-width: 260px;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.name-modal input {
  background: var(--bg);
  color: var(--fg);
  border: 1px solid #222a38;
  border-radius: 4px;
  padding: 8px 10px;
  font: inherit;
}
.name-modal button {
  background: var(--accent);
  color: #052;
  border: 0;
  border-radius: 4px;
  padding: 8px 10px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.name-modal .char-models {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.name-modal .char-model {
  width: 100%;
  height: 36px;
  border-radius: 8px;
  border: 2px solid rgba(255,255,255,0.22);
  padding: 0;
  background: #456;
  cursor: pointer;
}
.name-modal .char-model[data-model="0"] { background: #58c7ff; }
.name-modal .char-model[data-model="1"] { background: #ff7b7b; }
.name-modal .char-model[data-model="2"] { background: #7be39a; }
.name-modal .char-model[data-model="3"] { background: #ffd26b; }
.name-modal .char-model.active {
  border-color: #ffffff;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.22);
}
.name-modal button:hover { filter: brightness(1.1); }
