:root {
  --bg: #08111f;
  --panel: rgba(15, 23, 42, 0.82);
  --panel-border: rgba(148, 163, 184, 0.18);
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-2: #a78bfa;
  --success: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --shadow: 0 24px 70px rgba(2, 6, 23, 0.35);
  --radius: 24px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(56, 189, 248, 0.18), transparent 22%),
    radial-gradient(circle at top right, rgba(167, 139, 250, 0.18), transparent 25%),
    linear-gradient(180deg, #020617, var(--bg));
  min-height: 100vh;
}
.hidden { display: none !important; }
.app-shell { max-width: 1380px; margin: 0 auto; padding: 24px; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px;
}
.topbar h1 { margin: 2px 0 0; font-size: clamp(1.25rem, 2vw, 2rem); }
.eyebrow {
  margin: 0; text-transform: uppercase; letter-spacing: .18em; color: var(--accent); font-size: .72rem; font-weight: 700;
}
.panel {
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--radius);
  box-shadow: var(--shadow); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
}
.hero {
  display: grid; grid-template-columns: 1.2fr .8fr; gap: 20px; padding: 24px; margin-bottom: 20px;
}
.hero h2 { margin: 8px 0 10px; font-size: clamp(1.5rem, 3vw, 2.5rem); }
.hero-stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px;
}
.stat-card, .mini-card, .metric-card, .challenge-card {
  border: 1px solid rgba(148, 163, 184, 0.14); border-radius: 20px; background: rgba(15, 23, 42, 0.74);
}
.stat-card { padding: 18px; display: flex; flex-direction: column; gap: 8px; justify-content: center; }
.stat-card span, .mini-card span, .label { color: var(--muted); font-size: .82rem; }
.stat-card strong, .mini-card strong { font-size: 1rem; }
.muted { color: var(--muted); }
.tiny { font-size: .82rem; }
.section-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px;
}
.section-head.compact { margin-bottom: 14px; }
#homeView .panel:last-child { padding: 24px; }
.category-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px;
}
.category-btn {
  padding: 20px; border: 1px solid rgba(56, 189, 248, 0.22); background: linear-gradient(180deg, rgba(15, 23, 42, 0.9), rgba(2, 6, 23, 0.9));
  color: var(--text); border-radius: 22px; cursor: pointer; text-align: left; transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.category-btn:hover { transform: translateY(-2px); border-color: rgba(56, 189, 248, 0.48); box-shadow: 0 16px 38px rgba(15, 23, 42, 0.35); }
.category-btn h4 { margin: 10px 0 6px; font-size: 1.1rem; }
.category-btn p { margin: 0; color: var(--muted); }
.badge, .status-pill {
  display: inline-flex; align-items: center; justify-content: center; min-height: 38px; padding: 0 14px;
  border-radius: 999px; font-size: .86rem; font-weight: 700; border: 1px solid transparent;
}
.badge.online, .status-pill.good { background: rgba(34, 197, 94, 0.14); color: #86efac; border-color: rgba(34, 197, 94, 0.28); }
.badge.offline, .status-pill.warn { background: rgba(245, 158, 11, 0.14); color: #fde68a; border-color: rgba(245, 158, 11, 0.28); }
.status-pill.neutral { background: rgba(148, 163, 184, 0.14); color: #cbd5e1; border-color: rgba(148, 163, 184, 0.26); }
.ghost {
  border: 1px solid rgba(148, 163, 184, 0.22); background: rgba(15, 23, 42, 0.75); color: var(--text);
  border-radius: 999px; padding: 10px 14px; cursor: pointer;
}
.view.active { display: block; }
.play-layout {
  display: grid; grid-template-columns: minmax(320px, 380px) minmax(0, 1fr); gap: 20px;
}
.play-sidebar { padding: 20px; }
.stage-panel {
  padding: 20px; display: flex; flex-direction: column;
}
.stage-head {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 14px;
}
.challenge-card { padding: 20px; margin-bottom: 16px; text-align: center; }
.target-label {
  min-height: 88px; display: grid; place-items: center; margin: 10px 0; border-radius: 22px;
  font-size: clamp(2.2rem, 5vw, 4rem); font-weight: 900; letter-spacing: .04em;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.18), rgba(167, 139, 250, 0.18));
  border: 1px solid rgba(56, 189, 248, 0.18);
}
.progress-info {
  display: flex; justify-content: space-between; align-items: center; margin-top: 8px;
}
.metric-card { padding: 18px; margin-bottom: 16px; }
.predicted { font-size: 2.1rem; font-weight: 900; margin: 8px 0 10px; }
.percent-row { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 10px; font-size: .95rem; }
.progress { width: 100%; height: 14px; background: rgba(30, 41, 59, .85); border-radius: 999px; overflow: hidden; }
.progress > div { height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .18s ease; }
.metric-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.mini-card { padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.diag-card {
  padding: 14px 16px;
  border-radius: 20px;
  background: rgba(2, 6, 23, 0.38);
  border: 1px solid rgba(148, 163, 184, 0.14);
  margin-bottom: 16px;
}
.diag-list { display: grid; gap: 8px; margin-top: 8px; }
.diag-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: .86rem;
  color: var(--muted);
}
.chk {
  min-width: 86px;
  text-align: center;
  border-radius: 999px;
  padding: 4px 10px;
  border: 1px solid transparent;
  font-size: .74rem;
  font-weight: 800;
  letter-spacing: .02em;
}
.chk.pending { background: rgba(148, 163, 184, 0.14); color: #cbd5e1; border-color: rgba(148, 163, 184, 0.26); }
.chk.active { background: rgba(56, 189, 248, 0.14); color: #7dd3fc; border-color: rgba(56, 189, 248, 0.3); }
.chk.ok { background: rgba(34, 197, 94, 0.14); color: #86efac; border-color: rgba(34, 197, 94, 0.28); }
.chk.warn { background: rgba(245, 158, 11, 0.14); color: #fde68a; border-color: rgba(245, 158, 11, 0.28); }
.chk.error { background: rgba(239, 68, 68, 0.14); color: #fca5a5; border-color: rgba(239, 68, 68, 0.28); }
.notes { padding: 14px 16px; border-radius: 20px; background: rgba(2, 6, 23, 0.38); border: 1px solid rgba(148, 163, 184, 0.14); color: var(--muted); }
.notes ul { margin: 8px 0 0 18px; padding: 0; }
.stage {
  position: relative;
  border-radius: 28px;
  overflow: hidden;
  background: #020617;
  width: 100%;
  max-width: 920px;
  aspect-ratio: 16 / 9;
  min-height: clamp(280px, 52vh, 440px);
  border: 1px solid rgba(148, 163, 184, 0.18);
}
#stageCanvas {
  width: 100%; height: 100%; display: block; background: linear-gradient(180deg, rgba(8, 15, 28, 0.8), rgba(3, 7, 18, 0.95));
}
.popup {
  position: absolute; left: 50%; top: 48px; transform: translateX(-50%);
  background: rgba(34, 197, 94, 0.18); border: 1px solid rgba(34, 197, 94, 0.35);
  color: #dcfce7; font-weight: 800; padding: 14px 18px; border-radius: 999px; font-size: 1rem;
  box-shadow: 0 20px 40px rgba(2, 6, 23, .28); z-index: 3;
}
@media (max-width: 1080px) {
  .hero, .play-layout { grid-template-columns: 1fr; }
  .hero-stats { grid-template-columns: 1fr; }
  .stage { max-width: 100%; min-height: clamp(260px, 44vh, 360px); }
}
@media (max-width: 720px) {
  .app-shell { padding: 16px; }
  .topbar { flex-wrap: wrap; }
  .metric-grid { grid-template-columns: 1fr; }
  .stage { min-height: clamp(220px, 40vh, 320px); }
}
