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

:root {
  --bg: #0d1420;
  --panel: #121c2b;
  --line: #24354d;
  --text: #d7e2f0;
  --muted: #8ba0ba;
  --accent: #4da3ff;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  padding: 12px clamp(10px, 3vw, 40px) 20px;
}

header h1 { font-size: 1.35rem; letter-spacing: 0.3px; }
header .sub { color: var(--muted); font-size: 0.9rem; margin-top: 2px; }

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 22px;
  align-items: flex-end;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 14px;
  margin-top: 10px;
}

.controls label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.controls label.chk {
  flex-direction: row;
  align-items: center;
  gap: 7px;
  text-transform: none;
  font-size: 0.85rem;
  letter-spacing: 0;
  padding-bottom: 6px;
}

.controls select {
  background: #0b111c;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 0.9rem;
  max-width: 340px;
}

.controls input[type="range"] { width: 150px; accent-color: var(--accent); }
.controls .val { color: var(--text); font-size: 0.85rem; text-transform: none; letter-spacing: 0; }

.controls button {
  background: var(--accent);
  color: #06121f;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 0.9rem;
  cursor: pointer;
}
.controls button.secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}
.controls button:hover { filter: brightness(1.15); }

.info { color: var(--muted); font-size: 0.8rem; margin: 6px 2px 4px; }
.info a { color: var(--accent); }

#canvasWrap {
  background: linear-gradient(180deg, #0a1526 0%, #0c1929 100%);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
#canvas { display: block; width: 100%; }

.timebar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
}
.timebar input[type="range"] { flex: 1; accent-color: var(--accent); height: 22px; }
.playbtn {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  width: 40px;
  height: 32px;
  font-size: 1rem;
  cursor: pointer;
  line-height: 1;
}
.playbtn:hover { border-color: var(--accent); }
.clock {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1.05rem;
  min-width: 52px;
  text-align: center;
  color: var(--text);
}
.hint { color: var(--muted); font-size: 0.72rem; margin: 2px 64px; }
.summary { font-size: 0.95rem; margin: 3px 2px; color: #35c26a; font-weight: 600; min-height: 1.3em; }

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
  font-size: 0.83rem;
  color: var(--muted);
  margin-top: 3px;
}
.stats b { color: var(--text); font-weight: 600; }
.stats .phase {
  color: var(--accent);
  font-weight: 600;
  min-width: 210px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin-top: 7px;
  font-size: 0.78rem;
  color: var(--muted);
}
.legend .li { display: inline-flex; align-items: center; gap: 6px; }
.legend i {
  width: 11px; height: 11px; border-radius: 50%; display: inline-block;
}
.legend i.binbar { border-radius: 2px; height: 5px; width: 18px; background: linear-gradient(90deg, #2f9e63, #f0a53a, #e5484d); }
.legend i.heatbar { border-radius: 2px; height: 8px; width: 18px; background: rgba(229,60,60,0.55); }

#tooltip {
  position: fixed;
  display: none;
  background: #0b111ce8;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.78rem;
  line-height: 1.45;
  pointer-events: none;
  z-index: 10;
  max-width: 240px;
}

footer { margin-top: 12px; color: #5f7392; font-size: 0.7rem; max-width: 1100px; line-height: 1.45; }

@media (max-width: 700px) {
  .controls input[type="range"] { width: 110px; }
  .hint { margin: 4px 2px; }
}
