@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Serif:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
  --ink: #101722;
  --paper: #f3f7fb;
  --white: #fff;
  --muted: #657386;
  --line: #d6e0eb;
  --blue: #1685f8;
  --blue-dark: #0759af;
  --cyan: #12b8c4;
  --lime: #b9eb45;
  --orange: #f0713a;
  --dark: #101722;
  --dark-soft: #192637;
  --mono: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --serif: "IBM Plex Serif", Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 14% -10%, rgba(22, 133, 248, .13), transparent 31%),
    var(--paper);
  font-family: var(--sans);
}

button, a { font: inherit; }
::selection { color: var(--white); background: var(--blue); }

.funding-ribbon {
  position: fixed;
  top: 28px;
  right: -62px;
  z-index: 100;
  width: 230px;
  padding: 9px 12px 7px;
  transform: rotate(45deg);
  color: var(--ink);
  border: 1px solid var(--ink);
  background: var(--lime);
  box-shadow: 0 2px 0 var(--ink);
  font: 600 10px/1.35 var(--mono);
  letter-spacing: .035em;
  text-align: center;
  text-decoration: none;
  text-transform: uppercase;
}
.funding-ribbon:hover { color: var(--white); background: var(--orange); }

.app-shell {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 8px;
  width: min(1440px, calc(100% - 28px));
  height: 100dvh;
  margin: 0 auto;
  padding: 12px 0 8px;
}

.masthead, .panel-heading, .metrics, .footer, .stream-heading,
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.masthead {
  position: relative;
  min-height: 90px;
  overflow: hidden;
  border-bottom: 1px solid var(--ink);
}

.mascot {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 92px;
  height: 84px;
  object-fit: contain;
  object-position: center;
  filter: contrast(1.04);
  pointer-events: none;
}

.brand {
  position: relative;
  z-index: 2;
  margin-left: 112px;
  color: var(--ink);
}
.brand-home { color: inherit; text-decoration: none; }
.brand:hover .eyebrow { color: var(--blue); }

.eyebrow, .kicker, .metric-label, .panel-note, .leader-rank,
.leader-score, .leader-detail, .post-language, .post-detail, .bubble-rate,
.footer, .math-button, .modal-label, .math-parameters, .math-footnote {
  font-family: var(--mono);
}

.eyebrow, .kicker {
  display: block;
  color: var(--blue-dark);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .025em;
  text-transform: uppercase;
}
.eyebrow::before, .kicker::before { content: "// "; color: var(--orange); }

.site-title {
  display: block;
  margin: -1px 0 -2px;
  font-size: clamp(32px, 4.1vw, 53px);
  font-weight: 900;
  letter-spacing: -.065em;
  line-height: .88;
}
.dek { color: var(--muted); font: 13px/1.3 var(--serif); }
.dek-link {
  color: var(--blue-dark);
  font-weight: 700;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--blue) 50%, transparent);
  text-underline-offset: 2px;
}
.dek-link:hover { color: var(--blue); }

.connection-card {
  position: relative;
  z-index: 2;
  min-width: 118px;
  margin-right: 108px;
  padding: 9px 12px;
  color: var(--white);
  border: 1px solid var(--ink);
  background: var(--ink);
  text-align: center;
}
.connection-status {
  color: #ff9a6d;
  font: 600 11px/1 var(--mono);
  letter-spacing: .08em;
  text-transform: uppercase;
}
.connection-status.is-live { color: var(--lime); }
.connection-status.is-resting { color: #ffd37a; }
.connection-status.is-offline { color: #ff9a6d; }
.winding-status, .viewer-link {
  display: block;
  margin-top: 5px;
  font: 500 7px/1.25 var(--mono);
  white-space: nowrap;
}
.winding-status { color: #c5cfdb; text-transform: uppercase; }
.viewer-link {
  color: #61d8e0;
  text-decoration-color: rgba(97, 216, 224, .45);
  text-underline-offset: 2px;
}
.viewer-link:hover { color: var(--lime); }
.rewind-button {
  margin-top: 5px;
  padding: 3px 6px;
  color: var(--ink);
  border: 1px solid var(--lime);
  border-radius: 0;
  background: var(--lime);
  font: 700 7px/1 var(--mono);
  letter-spacing: .025em;
  text-transform: uppercase;
  cursor: pointer;
}

.metrics {
  min-height: 52px;
  color: var(--white);
  border: 1px solid var(--dark);
  background: var(--dark);
}
.metric {
  display: flex;
  min-width: 0;
  height: 100%;
  flex: 1;
  align-items: baseline;
  gap: 10px;
  padding: 10px 18px;
  border-right: 1px solid #344457;
}
.metric:last-child { border-right: 0; }
.metric-value { color: var(--lime); font: 600 22px/1 var(--mono); }
.metric:nth-child(2) .metric-value { color: #60b0ff; }
.metric:nth-child(3) .metric-value { color: #62dce4; }
.metric:nth-child(4) .metric-value { color: #ff9a6d; }
.metric-label {
  overflow: hidden;
  color: #c5cfdb;
  font-size: 9px;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.dashboard {
  display: grid;
  min-height: 0;
  grid-template-columns: minmax(370px, .82fr) minmax(500px, 1.18fr);
  gap: 8px;
}
.panel {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--ink);
  background: rgba(255,255,255,.94);
}
.panel-heading {
  min-height: 62px;
  padding: 10px 15px;
  border-bottom: 1px solid var(--ink);
}
.panel-title {
  display: block;
  margin-top: 1px;
  font-size: 20px;
  font-weight: 830;
  letter-spacing: -.035em;
}
.panel-note { color: var(--muted); font-size: 8px; }
.math-button, .modal-close, .wake-button {
  padding: 7px 10px;
  color: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 0;
  background: var(--lime);
  box-shadow: 2px 2px 0 var(--ink);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .015em;
  text-transform: uppercase;
  cursor: pointer;
}
.math-button:hover, .modal-close:hover, .wake-button:hover {
  color: var(--white);
  background: var(--blue);
}

.leaderboard-panel { display: flex; flex-direction: column; }
.leader-list {
  min-height: 0;
  flex: 1;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0 14px;
  scrollbar-color: var(--blue-dark) var(--paper);
  scrollbar-width: thin;
}
.leader-list::-webkit-scrollbar { width: 8px; }
.leader-list::-webkit-scrollbar-track {
  border-left: 1px solid var(--line);
  background: var(--paper);
}
.leader-list::-webkit-scrollbar-thumb {
  border: 2px solid var(--paper);
  background: var(--blue-dark);
}
.leader-row {
  display: grid;
  min-height: 49px;
  grid-template-columns: 24px minmax(0, 1fr) 76px;
  gap: 9px;
  align-items: center;
  border-bottom: 1px solid var(--line);
}
.leader-row:last-child { border-bottom: 0; }
.leader-rank, .leader-score { color: var(--muted); font-size: 9px; }
.leader-score { color: var(--blue-dark); font-weight: 600; text-align: right; }
.leader-name {
  display: block;
  overflow: hidden;
  font-size: 12px;
  font-weight: 780;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.leader-detail {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  color: var(--muted);
  font-size: 7px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.leader-track { height: 3px; margin-top: 4px; overflow: hidden; background: #e1e9f1; }
.leader-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--blue-dark), var(--cyan));
  transition: width .28s ease;
}

.activity-panel {
  display: grid;
  grid-template-rows: 62px minmax(0, .72fr) 40px minmax(0, 1.28fr);
}
.constellation {
  position: relative;
  display: grid;
  min-height: 0;
  overflow: hidden;
  padding: 8px 14px;
  grid-template-columns: repeat(10, minmax(48px, 1fr));
  gap: 5px;
  align-items: center;
  background:
    linear-gradient(90deg, transparent 49.9%, rgba(16,23,34,.06) 50%, transparent 50.1%),
    linear-gradient(0deg, transparent 49.9%, rgba(16,23,34,.06) 50%, transparent 50.1%),
    var(--paper);
}
.language-bubble {
  --level: .5;
  --tilt: 0deg;
  display: flex;
  width: clamp(40px, 4.8vw, 70px);
  max-width: 100%;
  aspect-ratio: .85;
  min-width: 0;
  z-index: 1;
  transform: rotate(var(--tilt)) scale(calc(.64 + var(--level) * .36));
  flex-direction: column;
  align-items: center;
  justify-self: center;
  justify-content: center;
  border: 1px solid var(--ink);
  border-radius: 61% 39% 54% 46% / 44% 61% 39% 56%;
  background: rgba(22,133,248,calc(.12 + var(--level) * .54));
  cursor: pointer;
  transition: transform .3s ease, background .3s ease;
}
.language-bubble:hover { box-shadow: 0 0 0 3px rgba(22,133,248,.22); filter: brightness(.98); }
.language-bubble:focus-visible { outline: 3px solid var(--orange); outline-offset: 3px; }
.language-bubble:nth-child(3n+2) { background-color: rgba(18,184,196,calc(.1 + var(--level) * .42)); }
.language-bubble:nth-child(4n) { background-color: rgba(185,235,69,calc(.11 + var(--level) * .48)); }
.language-bubble:nth-child(5n) { background-color: rgba(240,113,58,calc(.08 + var(--level) * .34)); }
.language-bubble:nth-child(1) { --tilt: -2deg; }
.language-bubble:nth-child(2) { --tilt: 1.5deg; border-radius: 45% 55% 63% 37% / 59% 44% 56% 41%; }
.language-bubble:nth-child(3) { --tilt: -1deg; border-radius: 55% 45% 43% 57% / 39% 60% 40% 61%; }
.language-bubble:nth-child(4) { --tilt: 2deg; }
.language-bubble:nth-child(5) { --tilt: -2.5deg; border-radius: 41% 59% 53% 47% / 63% 38% 62% 37%; }
.bubble-name {
  max-width: 82%;
  overflow: hidden;
  color: var(--ink);
  font-size: 10px;
  font-weight: 850;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}
.bubble-rate { margin-top: 2px; color: #253448; font-size: 7px; }

.stream-heading {
  position: relative;
  z-index: 2;
  min-height: 40px;
  padding: 7px 15px;
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--line);
  background: var(--white);
}
.stream-heading .kicker { font-size: 12px; }
.stream-caption { color: var(--muted); font: 11px var(--serif); }
.post-list {
  display: grid;
  min-height: 0;
  padding: 0 14px;
  grid-template-rows: repeat(5, minmax(0, 1fr));
}
.post-row {
  display: grid;
  min-height: 0;
  grid-template-columns: 62px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  animation: wire-flash .34s ease-out;
}
.post-row:last-child { border-bottom: 0; }
.post-row.is-reply .post-language { color: var(--cyan); }
.post-language {
  overflow: hidden;
  color: var(--blue-dark);
  font-size: 9px;
  font-weight: 600;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}
.post-copy { min-width: 0; }
.post-body {
  display: block;
  overflow: hidden;
  font: 500 11px/1.32 var(--serif);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.post-detail {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  color: var(--muted);
  font-size: 7px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
@keyframes wire-flash {
  from { background: rgba(185,235,69,.45); transform: translateX(6px); }
  to { background: transparent; transform: translateX(0); }
}

.footer {
  min-height: 20px;
  gap: 18px;
  justify-content: space-between;
  color: var(--muted);
  font-size: 7px;
  letter-spacing: .035em;
  text-align: center;
  text-transform: uppercase;
}
.footer-disclaimer { color: #4d5968; font-weight: 600; }
.footer-tech { flex: 0 0 auto; color: var(--blue-dark); }

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  padding: 24px;
  overflow: auto;
  place-items: center;
  background: rgba(8,16,27,.76);
  backdrop-filter: blur(3px);
}
.modal-window {
  width: min(620px, calc(100vw - 32px));
  max-height: calc(100dvh - 44px);
  padding: 20px;
  overflow-y: auto;
  border: 1px solid var(--ink);
  background: var(--white);
  box-shadow: 8px 8px 0 var(--blue), 9px 9px 0 var(--ink);
}
.math-window { width: min(760px, calc(100vw - 32px)); }
.modal-header { gap: 24px; padding-bottom: 12px; border-bottom: 1px solid var(--ink); }
.modal-title {
  display: block;
  margin-top: 2px;
  font-size: 25px;
  font-weight: 850;
  letter-spacing: -.04em;
}
.modal-facts {
  display: grid;
  margin: 18px 0;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--line);
}
.modal-fact { padding: 14px; border-right: 1px solid var(--line); }
.modal-fact:last-child { border-right: 0; }
.modal-value { display: block; color: var(--blue-dark); font: 700 21px/1 var(--mono); }
.modal-label {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 7px;
  text-transform: uppercase;
}
.modal-explanation, .math-copy {
  display: block;
  color: #344357;
  font: 13px/1.55 var(--serif);
}
.math-parameters {
  display: block;
  margin: 15px 0;
  padding: 9px 11px;
  color: var(--white);
  background: var(--dark);
  font-size: 10px;
}
.math-copy { margin: 12px 0; }
.math-source {
  display: inline-block;
  margin-right: 16px;
  color: var(--blue-dark);
  font: 600 9px/1.4 var(--mono);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  text-transform: uppercase;
}
.math-source:hover { color: var(--orange); }
.math-formula {
  display: block;
  margin: 12px 0;
  padding: 13px 15px;
  overflow-x: auto;
  color: #d9f3ff;
  border-left: 4px solid var(--lime);
  background: var(--dark-soft);
  font: 500 13px/1.75 var(--mono);
  white-space: pre;
}
.math-pruning {
  display: block;
  margin-top: 12px;
  padding: 12px;
  color: #334155;
  border: 1px solid var(--line);
  background: var(--paper);
  font: 11px/1.5 var(--mono);
}
.math-footnote {
  display: block;
  margin-top: 13px;
  color: var(--blue-dark);
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
}
.tired-window {
  display: grid;
  width: min(670px, calc(100vw - 32px));
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 24px;
  align-items: center;
}
.tired-chicken {
  width: 100%;
  max-height: 330px;
  object-fit: contain;
}
.tired-window .wake-button { margin-top: 18px; }

@media (max-width: 900px) {
  html, body { overflow: auto; }
  .app-shell { width: min(100% - 20px, 760px); height: auto; min-height: 100dvh; }
  .dashboard { grid-template-columns: 1fr; }
  .leaderboard-panel { min-height: 560px; }
  .activity-panel { min-height: 650px; }
  .constellation { grid-template-columns: repeat(5, 1fr); }
  .connection-card { margin-right: 82px; }
}

@media (max-width: 580px) {
  .funding-ribbon { display: none; }
  .masthead { min-height: 82px; }
  .mascot { width: 62px; height: 58px; }
  .brand { margin-left: 74px; }
  .site-title { font-size: 31px; }
  .dek { font-size: 10px; }
  .connection-card { min-width: 92px; margin-right: 0; padding: 7px; }
  .viewer-link, .winding-status { font-size: 6px; }
  .metrics { display: grid; grid-template-columns: 1fr 1fr; }
  .metric { border-bottom: 1px solid #344457; }
  .metric:nth-child(2n) { border-right: 0; }
  .metric:nth-child(3), .metric:nth-child(4) { border-bottom: 0; }
  .metric-value { font-size: 17px; }
  .metric-label { font-size: 7px; }
  .panel-heading { padding: 9px 11px; }
  .panel-title { font-size: 17px; }
  .leader-row { grid-template-columns: 21px minmax(0,1fr) 65px; }
  .constellation { padding: 7px; gap: 2px; }
  .stream-caption, .panel-note { display: none; }
  .modal-backdrop { padding: 12px; }
  .modal-window { padding: 15px; }
  .modal-facts { grid-template-columns: 1fr; }
  .modal-fact { border-right: 0; border-bottom: 1px solid var(--line); }
  .modal-fact:last-child { border-bottom: 0; }
  .math-formula { font-size: 10px; }
  .tired-window { grid-template-columns: 1fr; gap: 8px; }
  .tired-chicken { max-height: 190px; }
  .footer { display: block; line-height: 1.45; }
  .footer-tech { display: block; margin-top: 3px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
