:root {
  /* "Midnight Command" — deep, premium dark with cool undertones */
  --void: #02050a;
  --deep: #070b12;
  --surface: #121923;
  --raised: #1a2330;
  --elevated: #243041;

  /* Accent system: electric indigo → warm highlights */
  --flame: #8ab4ff;
  --ember: #c2d4ff;
  --cyan: #6ee7f9;
  --ice: #d8fbff;
  --violet: #c4b5fd;

  --success: #34d399;
  --danger: #fb7185;
  --warning: #facc15;
  --gold: #fbbf24;

  --text-primary: #f8fbff;
  --text-secondary: #c7d2e0;
  --text-ghost: #94a3b8;

  --border: rgba(255,255,255,.14);
  --border-lit: rgba(138,180,255,.34);
  --glass: rgba(9,13,20,.94);
  --glass-lite: rgba(12,18,28,.82);

  --r: 12px;
  --r-sm: 8px;
  --r-lg: 20px;

  --font-head: 'Inter', sans-serif;
  --font-body: 'Chakra Petch', sans-serif;
  --font-mono: 'Azeret Mono', monospace;

  --nav-w: 68px;
  --mob-panel-h: 44px;
  --status-foot-min-h: calc(26px + env(safe-area-inset-bottom));
  --status-foot-h: var(--status-foot-min-h);
  --status-foot-offset: var(--status-foot-h);
  --dashboard-bottom-offset: var(--status-foot-offset);
  --page-footer-clearance: 8px;
  --footer-safe-boundary: calc(var(--status-foot-offset) + var(--page-footer-clearance));

  /* New: accent glow tokens */
  --glow-accent: rgba(138,180,255,.18);
  --glow-cyan: rgba(110,231,249,.14);
  --glow-danger: rgba(251,113,133,.16);
  --glow-success: rgba(52,211,153,.16);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: var(--font-body);
  background: var(--void);
  color: var(--text-primary);
  color-scheme: dark;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Scrollbar — thinner, accent-colored */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--deep); }
::-webkit-scrollbar-thumb { background: rgba(99,102,241,.25); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--flame); }

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
a { text-decoration: none; color: inherit; }
input::placeholder, textarea::placeholder { color: var(--text-ghost); opacity: 1; }
::selection { background: rgba(138,180,255,.48); color: #04111f; }

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--ice);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(110,231,249,.16);
}

/* ═══════ AMBIENT BACKGROUND ═══════ */
.site-tooltip {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 5000;
  max-width: min(360px, calc(100vw - 24px));
  min-width: 160px;
  padding: 12px 13px;
  border: 1px solid rgba(138,180,255,.24);
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,0) 38%),
    linear-gradient(135deg, rgba(138,180,255,.14), rgba(110,231,249,.06) 46%, rgba(9,13,20,.96));
  box-shadow:
    0 18px 48px rgba(0,0,0,.48),
    inset 0 1px 0 rgba(255,255,255,.06),
    0 0 0 1px rgba(255,255,255,.02);
  backdrop-filter: blur(16px) saturate(135%);
  -webkit-backdrop-filter: blur(16px) saturate(135%);
  pointer-events: none;
  opacity: 0;
  transform: translate3d(0, 10px, 0) scale(.98);
  transform-origin: top left;
  transition: opacity .14s ease, transform .14s ease;
}
.site-tooltip.visible {
  opacity: 1;
  transform: translate3d(0, 0, 0) scale(1);
}
.site-tooltip::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  background: linear-gradient(90deg, rgba(138,180,255,.55), rgba(110,231,249,.18), transparent);
  opacity: .9;
}
.site-tooltip-inner {
  display: grid;
  gap: 8px;
}
.site-tooltip-title {
  font-family: var(--font-head);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ember);
  line-height: 1.2;
}
.site-tooltip-body {
  display: grid;
  gap: 6px;
}
.site-tooltip-line,
.site-tooltip-row {
  font-size: 12px;
  line-height: 1.35;
}
.site-tooltip-line {
  color: var(--text-secondary);
}
.site-tooltip-row {
  display: grid;
  grid-template-columns: minmax(0, max-content) minmax(0, 1fr);
  align-items: baseline;
  gap: 12px;
}
.site-tooltip-key {
  color: var(--text-ghost);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  white-space: nowrap;
}
.site-tooltip-value {
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 11px;
  text-align: right;
  word-break: break-word;
}

.ambient {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
}
.ambient-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(165px);
  opacity: .07;
  animation: drift 25s ease-in-out infinite alternate;
}
.orb-1 { width: 700px; height: 700px; background: #4f46e5; top: -250px; right: -150px; animation-delay: 0s; }
.orb-2 { width: 500px; height: 500px; background: #06b6d4; bottom: -200px; left: -100px; animation-delay: -8s; }
.orb-3 { width: 400px; height: 400px; background: #7c3aed; top: 50%; left: 25%; animation-delay: -16s; }
@keyframes drift {
  0% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(40px, -25px) scale(1.08); }
  66% { transform: translate(-25px, 35px) scale(.92); }
  100% { transform: translate(15px, 15px) scale(1.03); }
}

/* Dot grid pattern overlay — subtle tech feel */
.hex-grid {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  opacity: .018;
  background-image: radial-gradient(circle, rgba(255,255,255,.4) 1px, transparent 1px);
  background-size: 24px 24px;
}

/* ═══════ ICON NAV RAIL (left) ═══════ */
.nav-rail {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--nav-w);
  background: rgba(12,16,24,.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-right: 1px solid rgba(255,255,255,.05);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 18px 0;
  z-index: 100;
}
.nav-rail::after {
  content: '';
  position: absolute;
  top: 0; right: 0; width: 1px; height: 100%;
  background: linear-gradient(180deg, var(--flame) 0%, transparent 30%, transparent 70%, var(--cyan) 100%);
  opacity: .15;
}

.nav-brand {
  width: 42px; height: 42px;
  border-radius: var(--r);
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  display: grid; place-items: center;
  margin-bottom: 28px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(99,102,241,.25);
}
.nav-brand::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,.2), transparent 60%);
}
.nav-brand svg { position: relative; z-index: 1; }

.nav-btn {
  width: 44px; height: 44px;
  border-radius: var(--r);
  display: grid; place-items: center;
  margin-bottom: 6px;
  color: var(--text-ghost);
  transition: all .2s cubic-bezier(.4,0,.2,1);
  position: relative;
}
.nav-btn:hover { color: var(--text-primary); background: rgba(255,255,255,.05); }
.nav-btn.active {
  color: var(--flame);
  background: var(--glow-accent);
}
.nav-btn.active::before {
  content: '';
  position: absolute;
  left: -1px; top: 10px; bottom: 10px;
  width: 3px;
  border-radius: 0 4px 4px 0;
  background: var(--flame);
  box-shadow: 0 0 12px var(--flame);
}
.nav-sep {
  width: 26px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--border), transparent);
  margin: 14px 0;
}

.nav-user {
  margin-top: auto;
  width: 38px; height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #22d3ee);
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700; color: #fff;
  cursor: pointer;
  position: relative;
  box-shadow: 0 2px 12px rgba(99,102,241,.2);
  transition: box-shadow .2s;
}
.nav-user:hover { box-shadow: 0 2px 20px rgba(99,102,241,.35); }
.nav-user::after {
  content: '';
  position: absolute;
  bottom: -2px; right: -2px;
  width: 11px; height: 11px;
  border-radius: 50%;
  background: var(--success);
  border: 2px solid var(--deep);
  box-shadow: 0 0 6px var(--success);
}

/* ═══════ MAIN LAYOUT — DASHBOARD GRID ═══════ */
.dashboard {
  margin-left: var(--nav-w);
  height: calc(100vh - var(--dashboard-bottom-offset));
  height: calc(100dvh - var(--dashboard-bottom-offset));
  display: grid;
  grid-template-rows: auto 1fr;
  grid-template-columns: 1fr;
  position: relative;
  z-index: 1;
}

/* ═══════ HUD — MAIN CONTENT AREA ═══════ */
.hud {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: auto 1fr;
  gap: 0;
  overflow: hidden;
  min-height: 0;  /* prevent grid blowout */
}

/* ── TOP STAT STRIP (spans all 3 cols) ── */
.stat-strip {
  grid-column: 1 / -1;
  background: linear-gradient(180deg, var(--deep) 0%, rgba(12,16,24,.6) 100%);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: stretch;
  height: 88px;
  border-bottom: 1px solid var(--border);
}

.stat-cell {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 10px 16px;
  border-right: 1px solid var(--border);
  position: relative;
  overflow: hidden;
  transition: background .25s ease;
}
.stat-cell:last-child { border-right: none; }
.stat-cell:hover { background: rgba(255,255,255,.02); }

.stat-cell::after {
  content: '';
  position: absolute;
  bottom: 0; left: 15%; right: 15%;
  height: 2px;
  border-radius: 2px 2px 0 0;
  opacity: 0;
  transition: opacity .3s;
}
.stat-cell:hover::after { opacity: .7; }
.stat-cell.cell-chain::after { background: var(--gold); box-shadow: 0 0 12px var(--gold); }
.stat-cell.cell-timer::after { background: var(--success); box-shadow: 0 0 12px var(--success); }
.stat-cell.cell-war::after { background: var(--danger); box-shadow: 0 0 12px var(--danger); }
.stat-cell.cell-members::after { background: var(--cyan); box-shadow: 0 0 12px var(--cyan); }
.stat-cell.cell-attacks::after { background: var(--violet); box-shadow: 0 0 12px var(--violet); }

.stat-icon {
  font-size: 15px;
  margin-bottom: 5px;
  opacity: .45;
  filter: grayscale(.3);
}
.stat-number {
  font-family: var(--font-head);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.5px;
}
.stat-number.huge { font-size: 30px; }
.stat-number.large { font-size: 26px; }
.stat-number.medium { font-size: 22px; }

.stat-label {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-ghost);
  margin-top: 5px;
}

.clr-gold { color: #f59e0b; text-shadow: 0 0 24px rgba(245,158,11,.2); }
.clr-green { color: #34d399; text-shadow: 0 0 24px rgba(52,211,153,.2); }
.clr-red { color: #fb7185; text-shadow: 0 0 24px rgba(251,113,133,.2); }
.clr-cyan { color: #22d3ee; text-shadow: 0 0 24px rgba(34,211,238,.2); }
.clr-violet { color: #a78bfa; text-shadow: 0 0 24px rgba(167,139,250,.2); }
.clr-flame { color: #818cf8; text-shadow: 0 0 24px rgba(129,140,248,.2); }
.clr-dim { color: var(--text-ghost); }
.clr-ember { color: var(--ember); }
.clr-ice { color: var(--ice); }

/* War scoreboard inside stat cell */
.war-mini {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  justify-content: center;
}
.war-mini-team { text-align: center; }
.war-mini-name { font-size: 9px; font-weight: 600; color: var(--text-secondary); letter-spacing: .5px; }
.war-mini-score {
  font-family: var(--font-head);
  font-size: 24px;
  font-weight: 900;
  line-height: 1.1;
}
.war-mini-vs {
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--text-ghost);
}
.war-meta-mini { font-size: 9px; color: var(--text-ghost); text-align: center; margin-top: 2px; }

/* ═══════ THREE COLUMNS ═══════ */
.col {
  background: var(--surface);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;   /* prevent grid blowout from long content */
  min-height: 0;
  border-right: 1px solid var(--border);
}
.col:last-child { border-right: none; }

.col-head {
  height: 40px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 10px;
  background: linear-gradient(180deg, var(--deep), rgba(12,16,24,.5));
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.col-title {
  font-family: var(--font-head);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-secondary);
}
.col-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 99px;
  margin-left: auto;
  letter-spacing: .5px;
}
.badge-flame { background: var(--glow-accent); color: var(--flame); border: 1px solid rgba(99,102,241,.2); }
.badge-cyan { background: var(--glow-cyan); color: var(--cyan); border: 1px solid rgba(34,211,238,.15); }
.badge-green { background: var(--glow-success); color: var(--success); border: 1px solid rgba(52,211,153,.15); }

.col-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

/* ═══════ MEMBER ROWS ═══════ */
.m-row {
  display: grid;
  grid-template-columns: 8px 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 9px 14px;
  border-radius: var(--r-sm);
  margin-bottom: 2px;
  transition: all .15s ease;
  cursor: default;
}
.m-row:hover { background: var(--raised); box-shadow: 0 1px 4px rgba(0,0,0,.1); }

.m-dot { width: 8px; height: 8px; border-radius: 50%; transition: all .3s; }
.m-dot.on { background: var(--success); box-shadow: 0 0 8px var(--success); }
.m-dot.idle { background: var(--warning); box-shadow: 0 0 4px rgba(251,191,36,.2); }
.m-dot.off { background: var(--text-ghost); }

.m-info { min-width: 0; }
.m-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-role { font-size: 10px; color: var(--text-ghost); margin-top: 1px; }

.m-energy {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--gold);
}
.m-add {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border);
  display: grid; place-items: center;
  font-size: 14px; color: var(--text-ghost);
  transition: all .2s cubic-bezier(.4,0,.2,1);
}
.m-add:hover { border-color: var(--flame); color: var(--flame); background: var(--glow-accent); box-shadow: 0 0 14px rgba(99,102,241,.2); }

/* ═══════ TRACKER CARDS ═══════ */
.t-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  border-radius: var(--r);
  margin-bottom: 5px;
  background: var(--raised);
  border: 1px solid var(--border);
  transition: all .2s cubic-bezier(.4,0,.2,1);
}
.t-card:hover { border-color: rgba(255,255,255,.08); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,.15); }
.t-card.t-active {
  border-color: rgba(99,102,241,.4);
  background: linear-gradient(135deg, rgba(99,102,241,.08), var(--raised));
  box-shadow: 0 0 28px rgba(99,102,241,.08), inset 0 1px 0 rgba(99,102,241,.12);
}

.t-rank {
  width: 30px; height: 30px;
  border-radius: var(--r-sm);
  display: grid; place-items: center;
  font-family: var(--font-mono);
  font-size: 12px; font-weight: 700;
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-ghost);
}
.t-card.t-active .t-rank {
  background: linear-gradient(135deg, #6366f1, #a78bfa);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 0 14px rgba(99,102,241,.35);
}

.t-info { flex: 1; min-width: 0; }
.t-name { font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t-meta { font-size: 10px; color: var(--text-ghost); margin-top: 2px; }

.t-stats { display: flex; gap: 16px; }
.t-stat { text-align: center; }
.t-stat-val { font-family: var(--font-mono); font-size: 14px; font-weight: 700; }
.t-stat-lbl { font-size: 8px; font-weight: 600; letter-spacing: 1.5px; text-transform: uppercase; color: var(--text-ghost); margin-top: 1px; }

.watcher-badge {
  font-size: 9px; font-weight: 700; padding: 3px 10px;
  border-radius: 99px;
  background: linear-gradient(135deg, #6366f1, #a78bfa);
  color: #fff; letter-spacing: .5px;
  box-shadow: 0 2px 8px rgba(99,102,241,.25);
}

/* ═══════ ATTACK LOG ENTRIES ═══════ */
.atk {
  padding: 9px 14px;
  border-radius: var(--r-sm);
  margin-bottom: 3px;
  background: var(--raised);
  border-left: 3px solid transparent;
  transition: all .15s ease;
}
.atk:hover { background: var(--elevated); transform: translateX(2px); }
.atk.atk-ours { border-left-color: var(--flame); }
.atk.atk-enemy { border-left-color: var(--danger); }

.atk-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 3px; }
.atk-time { font-family: var(--font-mono); font-size: 10px; color: var(--text-ghost); font-weight: 500; }
.atk-chain { font-family: var(--font-mono); font-size: 10px; color: var(--gold); font-weight: 700; }
.atk-body { font-size: 12px; line-height: 1.4; }
.atk-body strong { font-weight: 600; color: #fff; }
.atk-result { font-size: 11px; font-weight: 600; margin-top: 2px; }

.attack-feed-loading {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
  font-family: var(--font-head);
  font-size: clamp(28px, 4vw, 48px);
  font-weight: 800;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: var(--text-secondary);
}
