:root {
  --bg: #0b1020;
  --panel: #131a30;
  --panel-2: #1a2342;
  --line: #2a3560;
  --text: #e6ebff;
  --muted: #8d97c2;
  --accent: #4fd1c5;
  --good: #48bb78;
  --bad: #f56565;
  --warn: #ecc94b;
  --mono: ui-monospace, "Cascadia Code", Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: radial-gradient(circle at 20% 0%, #18224a 0%, var(--bg) 60%);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}

code, .mono { font-family: var(--mono); font-size: 0.85em; }
code { background: #0d1328; padding: 1px 5px; border-radius: 4px; color: #9ae6f0; }

.topbar {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap;
  gap: 12px; padding: 14px 22px; border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo { font-size: 34px; color: var(--accent); animation: spin 12s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
h1 { margin: 0; font-size: 22px; letter-spacing: 0.5px; }
.tagline { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

.stats { display: flex; gap: 10px; flex-wrap: wrap; }
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 12px; display: flex; flex-direction: column; min-width: 70px;
}
.stat .k { font-size: 10px; text-transform: uppercase; color: var(--muted); letter-spacing: 1px; }
.stat .v { font-weight: 700; font-size: 15px; }

.heat { padding: 10px 22px 0; }
.heat-label { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.heat-track { height: 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; margin-top: 4px; }
.heat-bar { height: 100%; width: 0%; background: linear-gradient(90deg, var(--good), var(--warn), var(--bad)); background-size: 300% 100%; transition: width 0.25s linear; }
.heat-bar.hot { animation: throb 0.6s ease-in-out infinite alternate; }
@keyframes throb { from { filter: brightness(1); } to { filter: brightness(1.6); } }

.board { display: grid; grid-template-columns: 1.35fr 1fr; gap: 16px; padding: 16px 22px; }
@media (max-width: 900px) { .board { grid-template-columns: 1fr; } }
.left, .right { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.panel h2 { margin: 0 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--accent); }
.hint { color: var(--muted); text-transform: none; letter-spacing: 0; font-weight: 400; margin-left: 6px; }
.muted { color: var(--muted); }

.pipeline { display: flex; align-items: center; gap: 6px; overflow-x: auto; padding: 4px 2px 8px; }
.node {
  flex: 1 1 0; min-width: 96px; background: var(--panel-2); border: 2px solid var(--line);
  border-radius: 10px; padding: 10px 8px; text-align: center; cursor: pointer; user-select: none;
  transition: transform 0.12s, border-color 0.12s, box-shadow 0.12s;
}
.node:hover { transform: translateY(-2px); border-color: var(--accent); }
.node.selected { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79, 209, 197, 0.2); }
.node.inspected .node-sub::after { content: " \2713"; color: var(--good); }
.node.dash { border-color: var(--bad); animation: alarm 1s ease-in-out infinite alternate; }
@keyframes alarm { from { box-shadow: 0 0 0 0 rgba(245, 101, 101, 0.0); } to { box-shadow: 0 0 14px 2px rgba(245, 101, 101, 0.55); } }
.node-icon { font-size: 22px; }
.node-label { font-weight: 700; font-size: 13px; margin-top: 4px; }
.node-sub { font-size: 11px; color: var(--muted); margin-top: 2px; font-family: var(--mono); word-break: break-all; }
.arrow { color: var(--muted); font-size: 18px; flex: 0 0 auto; }
.arrow.flow { animation: flow 1.2s linear infinite; }
@keyframes flow { 0% { opacity: 0.3; } 50% { opacity: 1; } 100% { opacity: 0.3; } }

.inspector { min-height: 130px; font-size: 14px; line-height: 1.5; }
.inspector ul { margin: 6px 0; padding-left: 20px; }
.inspector .ev-title { font-weight: 700; margin-bottom: 4px; }
.inspector pre { background: #0d1328; padding: 8px 10px; border-radius: 6px; overflow-x: auto; font-family: var(--mono); font-size: 12px; color: #c3cdf5; margin: 6px 0; }

.changelog { font-family: var(--mono); font-size: 12px; color: var(--muted); max-height: 110px; overflow-y: auto; }
.changelog div { padding: 2px 0; }
.changelog .reveal { color: var(--warn); }

.tile { background: #0d1328; border-radius: 10px; padding: 12px 14px; border: 1px dashed var(--bad); }
.tile-metric { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.tile-values { display: flex; align-items: baseline; gap: 12px; margin-top: 4px; flex-wrap: wrap; }
.tile-bad { font-size: 30px; font-weight: 800; color: var(--bad); font-family: var(--mono); }
.tile-was { color: var(--muted); font-size: 13px; }
.symptom { margin: 10px 0 0; font-size: 14px; line-height: 1.45; }

.fixes { display: flex; flex-direction: column; gap: 8px; }
.fix {
  text-align: left; background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 10px 12px; font-size: 14px; cursor: pointer; line-height: 1.35;
  transition: border-color 0.1s, background 0.1s;
}
.fix:hover:not(:disabled) { border-color: var(--accent); background: #1f2a50; }
.fix:disabled { opacity: 0.45; cursor: not-allowed; }
.fix.wrong { border-color: var(--bad); text-decoration: line-through; }

.chat { display: flex; flex-direction: column; gap: 8px; max-height: 240px; overflow-y: auto; font-size: 13px; }
.msg { background: var(--panel-2); border-radius: 8px; padding: 7px 10px; border-left: 3px solid var(--line); animation: pop 0.25s ease-out; }
.msg .who { font-weight: 700; margin-right: 6px; }
.msg.exec { border-left-color: var(--bad); }
.msg.ops { border-left-color: var(--warn); }
.msg.sys { border-left-color: var(--good); color: var(--muted); }
@keyframes pop { from { transform: scale(0.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.leaderboard { margin: 0; padding-left: 26px; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.leaderboard li { padding: 4px 0; }
.leaderboard li:not(.muted) { display: list-item; }
.leaderboard li > .lb-who, .leaderboard li > .lb-score { display: inline-block; vertical-align: middle; }
.leaderboard li > .lb-who { width: calc(100% - 80px); }
.leaderboard li > .lb-score { width: 76px; text-align: right; font-family: var(--mono); font-weight: 700; color: var(--accent); }
.lb-name { font-weight: 700; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-title { color: var(--muted); font-size: 11px; display: block; }
.leaderboard li.mine { background: rgba(79, 209, 197, 0.12); border-radius: 6px; padding: 4px 6px; }

.score-form { display: flex; gap: 8px; flex-wrap: wrap; }
.score-form input {
  flex: 1 1 180px; background: #0d1328; color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 10px 12px; font-size: 14px;
}
.score-form input:focus { outline: none; border-color: var(--accent); }
.btn.small { padding: 10px 14px; font-size: 13px; margin-top: 0; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.score-msg { margin: 6px 0 0; font-size: 13px; color: var(--muted); min-height: 1em; }
.score-msg.ok { color: var(--good); }
.score-msg.err { color: var(--bad); }

.dedication { text-align: center; color: var(--muted); font-size: 12px; padding: 6px 0 22px; font-style: italic; }

.overlay { position: fixed; inset: 0; background: rgba(5, 8, 20, 0.82); display: none; align-items: center; justify-content: center; z-index: 10; padding: 16px; }
.overlay.show { display: flex; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; max-width: 560px; width: 100%; padding: 24px 26px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5); line-height: 1.5; }
.modal h2 { margin: 0 0 8px; font-size: 24px; }
.modal h3 { margin: 16px 0 6px; font-size: 14px; color: var(--accent); text-transform: uppercase; letter-spacing: 1px; }
.modal .memo { font-family: var(--mono); font-size: 13px; background: #0d1328; padding: 14px; border-radius: 8px; white-space: pre-wrap; }
.modal .btn { margin-top: 18px; }
.modal ul { padding-left: 20px; margin: 6px 0; }
.btn { background: var(--accent); color: #062024; border: 0; border-radius: 8px; padding: 11px 18px; font-weight: 800; font-size: 15px; cursor: pointer; }
.btn:hover { filter: brightness(1.1); }
.fired h2 { color: var(--bad); }
.win h2 { color: var(--good); }

.toast { position: fixed; top: 18px; left: 50%; transform: translateX(-50%) translateY(-120px); background: var(--good); color: #05210f; font-weight: 800; padding: 10px 18px; border-radius: 10px; transition: transform 0.3s; z-index: 20; }
.toast.show { transform: translateX(-50%) translateY(0); }

.shake { animation: shake 0.35s; }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

.duck { position: fixed; font-size: 40px; pointer-events: none; z-index: 30; animation: fly 4s ease-in forwards; }
@keyframes fly { from { transform: translate(0, 0) rotate(-10deg); opacity: 1; } to { transform: translate(40vw, -110vh) rotate(25deg); opacity: 0.9; } }
