* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg, #050a08);
  color: var(--fg, #7fff9f);
  font-family: var(--font, "JetBrains Mono", ui-monospace, monospace);
  -webkit-font-smoothing: antialiased;
}

/* ── theme tokens ──────────────────────────────────────────── */
body.theme-crt {
  --bg: #050a08;
  --fg: #7fff9f;
  --fg-dim: rgba(127, 255, 159, 0.55);
  --accent: #caffd0;
  --border: rgba(127, 255, 159, 0.25);
  --panel: rgba(5, 20, 10, 0.55);
  --panel-strong: rgba(5, 20, 10, 0.92);
  --shadow-glow: 0 0 6px rgba(127, 255, 159, 0.6);
  --font: "VT323", "Courier New", monospace;
  --letter: 1.5px;
  --scanline-opacity: 0.18;
}
body.theme-minimal {
  --bg: #fafaf7;
  --fg: #1a1a1a;
  --fg-dim: rgba(26, 26, 26, 0.55);
  --accent: #1a1a1a;
  --border: rgba(0, 0, 0, 0.1);
  --panel: rgba(255, 255, 255, 0.85);
  --panel-strong: #ffffff;
  --shadow-glow: 0 1px 4px rgba(0, 0, 0, 0.06);
  --font: "JetBrains Mono", ui-monospace, monospace;
  --letter: 0.5px;
  --scanline-opacity: 0;
}
body.theme-cyber {
  --bg: #0a0014;
  --fg: #ff4dd2;
  --fg-dim: rgba(255, 77, 210, 0.55);
  --accent: #5be7ff;
  --border: rgba(125, 45, 255, 0.45);
  --panel: rgba(20, 5, 30, 0.6);
  --panel-strong: rgba(20, 5, 30, 0.95);
  --shadow-glow: 0 0 8px rgba(91, 231, 255, 0.6);
  --font: "JetBrains Mono", ui-monospace, monospace;
  --letter: 1.5px;
  --scanline-opacity: 0.08;
}
body.theme-ascii {
  --bg: #000000;
  --fg: #39ff14;
  --fg-dim: rgba(57, 255, 20, 0.55);
  --accent: #aaffaa;
  --border: rgba(57, 255, 20, 0.35);
  --panel: rgba(0, 16, 0, 0.7);
  --panel-strong: rgba(0, 12, 0, 0.95);
  --shadow-glow: 0 0 6px rgba(57, 255, 20, 0.6);
  --font: "JetBrains Mono", ui-monospace, monospace;
  --letter: 1px;
  --scanline-opacity: 0.12;
}
body.theme-pop {
  --bg: #ffe6c4;
  --fg: #3a1a1a;
  --fg-dim: rgba(58, 26, 26, 0.6);
  --accent: #e63946;
  --border: #3a1a1a;
  --panel: #fff4d6;
  --panel-strong: #fff4d6;
  --shadow-glow: 3px 3px 0 #3a1a1a;
  --font: "Press Start 2P", "Courier New", monospace;
  --font-body: "JetBrains Mono", ui-monospace, monospace;
  --letter: 0.5px;
  --scanline-opacity: 0;
}
body { --font-body: var(--font); }
body.theme-pop .feed-list,
body.theme-pop .tooltip,
body.theme-pop .detail,
body.theme-pop .seg button,
body.theme-pop .ctrl-label,
body.theme-pop .feed-label,
body.theme-pop .stat-label,
body.theme-pop .status-line { font-family: var(--font-body); }

/* ── canvas ────────────────────────────────────────────────── */
#game {
  display: block;
  width: 100vw;
  height: 100vh;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  cursor: default;
}

/* ── HUD ───────────────────────────────────────────────────── */
.hud {
  position: fixed;
  z-index: 5;
  pointer-events: none;
  font-family: var(--font);
  letter-spacing: var(--letter);
}
.hud-tl { top: 18px; left: 22px; }
.hud-tr { top: 18px; right: 22px; text-align: right; pointer-events: auto; }
.hud-bl { bottom: 18px; left: 22px; max-width: 380px; }

.title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.pihole-icon {
  width: 38px;
  height: 38px;
  filter: drop-shadow(0 0 6px rgba(0, 0, 0, 0.35));
  flex-shrink: 0;
}
.title-line {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.title {
  font-size: 26px;
  font-weight: 700;
  color: var(--accent);
  text-shadow: var(--shadow-glow);
  text-transform: uppercase;
  line-height: 1;
}
.version-pill {
  font-size: 9px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--fg-dim);
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 3px;
  font-family: var(--font-body, var(--font));
  white-space: nowrap;
}
.version-pill:empty { display: none; }
.subtitle {
  font-size: 10px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--fg-dim);
  margin-top: 4px;
}
body.theme-pop .title { font-size: 18px; }
body.theme-minimal .title { font-size: 18px; font-weight: 600; text-shadow: none; letter-spacing: -0.5px; }

.stat-row {
  display: flex;
  flex-direction: column;
  margin-top: 8px;
}
.stat-label {
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--fg-dim);
}
.stat-val {
  font-size: 20px;
  font-weight: 700;
  color: var(--fg);
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}
body.theme-crt .stat-val { font-size: 24px; text-shadow: var(--shadow-glow); }
body.theme-pop .stat-val { font-size: 16px; color: var(--accent); }

/* ── status + selectors (top-right) ────────────────────────── */
.status-line {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--fg);
  margin-bottom: 10px;
}
body.theme-pop .status-line { box-shadow: var(--shadow-glow); }
.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #ffd166;
  box-shadow: 0 0 8px currentColor;
  color: #ffd166;
}
.status-dot.live { background: #5fff9e; color: #5fff9e; }
.status-dot.demo { background: #ffd166; color: #ffd166; }

.ctrl-group {
  display: flex; align-items: center; justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}
.ctrl-label {
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--fg-dim);
}
.seg {
  display: inline-flex;
  background: var(--panel);
  border: 1px solid var(--border);
}
body.theme-pop .seg { box-shadow: var(--shadow-glow); }
.seg button {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--fg-dim);
  font-family: var(--font);
  font-size: 10px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  padding: 6px 10px;
  cursor: pointer;
  transition: color .12s, background .12s;
}
.seg button:hover { color: var(--fg); }
.seg button.active {
  color: var(--bg);
  background: var(--accent);
  text-shadow: none;
}
body.theme-pop .seg button.active { color: #fff4d6; background: var(--accent); }
body.theme-minimal .seg button.active { background: #1a1a1a; color: #fafaf7; }

/* ── feed (bottom-left) ────────────────────────────────────── */
.hud-bl {
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 10px 12px;
  min-width: 260px;
}
body.theme-pop .hud-bl { box-shadow: var(--shadow-glow); }
.feed-label {
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--fg-dim);
  margin-bottom: 6px;
}
.feed-list { list-style: none; }
.feed-list li {
  display: grid;
  grid-template-columns: 14px 84px 1fr;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  color: var(--fg);
  padding: 2px 0;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  animation: feedIn .25s ease-out;
}
.feed-list li .x { color: var(--accent); }
.feed-list li .cat {
  font-size: 9px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--fg-dim);
}
.feed-list li .dom {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
@keyframes feedIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── tooltip / detail ──────────────────────────────────────── */
.tooltip {
  position: fixed;
  z-index: 8;
  pointer-events: none;
  background: var(--panel-strong);
  border: 1px solid var(--border);
  padding: 6px 9px;
  font-family: var(--font);
  font-size: 10px;
  color: var(--fg);
  max-width: 220px;
  letter-spacing: 0.5px;
}
body.theme-pop .tooltip { box-shadow: var(--shadow-glow); }
.tt-domain {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tt-meta {
  margin-top: 2px;
  font-size: 9px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--fg-dim);
}

.detail {
  position: fixed;
  z-index: 9;
  right: 22px;
  bottom: 18px;
  width: 260px;
  background: var(--panel-strong);
  border: 1px solid var(--border);
  padding: 12px 14px;
  font-family: var(--font);
  font-size: 11px;
  color: var(--fg);
  letter-spacing: 0.5px;
}
body.theme-pop .detail { box-shadow: var(--shadow-glow); }
.detail-head {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.detail-domain {
  flex: 1;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  word-break: break-all;
  line-height: 1.25;
}
.detail-close {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--fg-dim);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
.detail-close:hover { color: var(--fg); }
.detail-grid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 10px;
  font-size: 10px;
}
.detail-grid dt {
  color: var(--fg-dim);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  font-size: 9px;
}
.detail-grid dd { color: var(--fg); }
.detail-badge {
  margin-top: 12px;
  padding: 5px 8px;
  background: var(--accent);
  color: var(--bg);
  text-align: center;
  font-size: 10px;
  letter-spacing: 2px;
  font-weight: 700;
}
body.theme-pop .detail-badge { color: #fff4d6; }
body.theme-minimal .detail-badge { background: #1a1a1a; color: #fafaf7; }

/* ── scanlines (only meaningful on glow themes) ────────────── */
.scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 7;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255,255,255,0.03) 0,
    rgba(255,255,255,0.03) 1px,
    transparent 1px,
    transparent 3px
  );
  mix-blend-mode: overlay;
  opacity: var(--scanline-opacity);
}
