:root {
  --bg: #070b07;
  --surface: #0d140d;
  --surface-2: #111c11;
  --border: #1d3a1c;
  --green: #3fab3c;
  --green-dark: #254f24;
  --green-glow: rgba(63, 171, 60, 0.35);
  --gold: #ffd54a;
  --silver: #d6dde3;
  --bronze: #d38b4c;
  --text: #d9ead8;
  --muted: #7d977c;
  --alert: #ff3b3b;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; overflow: hidden; }

body {
  font-family: var(--sans);
  color: var(--text);
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--green-dark) 1px, transparent 1px),
    linear-gradient(90deg, var(--green-dark) 1px, transparent 1px);
  background-size: 48px 48px;
  background-position: -1px -1px;
  background-attachment: fixed;
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
}
body::before {
  background: radial-gradient(ellipse at top, transparent 0%, var(--bg) 75%);
  opacity: 0.85;
}
body::after {
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0,
    rgba(0, 0, 0, 0) 2px,
    rgba(0, 0, 0, 0.18) 3px
  );
}

.view { position: relative; z-index: 1; height: 100vh; display: flex; flex-direction: column; }
.view[hidden] { display: none; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 3rem;
  border-bottom: 1px solid var(--border);
  background: rgba(7, 11, 7, 0.85);
}
.topbar img { display: block; height: 40px; width: auto; }

.sys-status {
  font-family: var(--mono);
  font-size: 1rem;
  letter-spacing: 0.2em;
  color: var(--green);
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
}
.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  animation: blink 1.6s ease-in-out infinite;
}

.page {
  width: min(1200px, 100% - 4rem);
  margin: 0 auto;
  padding: clamp(1rem, 3vh, 2.5rem) 0 1rem;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.board-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 2rem;
  margin: 0 0 clamp(0.75rem, 2vh, 2rem);
}
h1 { font-size: clamp(2.5rem, 9vh, 7rem); line-height: 1.05; margin: 0; letter-spacing: -0.02em; }
.accent { color: var(--green); text-shadow: 0 0 18px var(--green-glow); }

.player-count {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-family: var(--mono);
  line-height: 1;
}
#players {
  font-size: clamp(2rem, 7vh, 5rem);
  font-weight: 700;
  color: var(--green);
  text-shadow: 0 0 18px var(--green-glow);
}
.player-label {
  margin-top: 0.5rem;
  font-size: clamp(0.9rem, 2vh, 1.3rem);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted);
}

.board-window {
  flex: 1;
  min-height: 0;
  padding: 1rem;
  overflow: hidden;
  container-type: size;
  mask-image: linear-gradient(transparent, #000 1rem, #000 calc(100% - 1rem), transparent);
}

.entries {
  --row-gap: clamp(0.4rem, 1.2vh, 0.9rem);
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--row-gap);
  grid-auto-rows: calc((100cqh - 4 * var(--row-gap)) / 5);
  will-change: transform;
}
.entries.scrolled { transform: translateY(min(0px, calc(100cqh - 100%))); }

.entry {
  position: relative;
  display: grid;
  grid-template-columns: 3.5ch 1fr 6.5ch;
  align-items: center;
  gap: 1.5rem;
  min-height: 0;
  padding: 0 2rem;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border);
  border-left: 4px solid var(--green);
  border-radius: 6px;
  font-family: var(--mono);
  font-size: clamp(1.2rem, 7.5cqh, 3.5rem);
  opacity: 0;
  animation: drop-in 0.5s ease-out forwards;
}
.entry:nth-child(1) { --podium: var(--gold); }
.entry:nth-child(2) { --podium: var(--silver); }
.entry:nth-child(3) { --podium: var(--bronze); }
.entry:nth-child(-n + 3) { border-left-color: var(--podium); }
.entry:nth-child(-n + 3) .rank,
.entry:nth-child(-n + 3) .points { color: var(--podium); }
.entry { --row-color: var(--green); transition: border-color 0.6s, box-shadow 0.6s; }
.entry:nth-child(-n + 3) { --row-color: var(--podium); }
.entry.lit {
  border-color: var(--row-color);
  box-shadow: 0 0 28px var(--row-color), inset 0 0 14px color-mix(in srgb, var(--row-color) 25%, transparent);
}
.entry.fresh { border-color: var(--green); box-shadow: 0 0 24px var(--green-glow); }

.rank { color: var(--green); font-weight: 700; }
.nickname { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.points { text-align: right; font-weight: 700; color: var(--green); }

.empty { font-family: var(--mono); font-size: 1.6rem; color: var(--muted); }
.status { font-family: var(--mono); color: var(--alert); min-height: 1.5em; margin: 0.5rem 0 0; }

.footer {
  display: flex;
  justify-content: space-between;
  padding: 1rem 3rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
}
.mono { font-family: var(--mono); }

.video-view { background: #000; align-items: center; justify-content: center; }
.video-view video { width: 100%; height: 100%; object-fit: contain; }

@keyframes blink { 50% { opacity: 0.25; } }
@keyframes drop-in {
  from { opacity: 0; transform: translateY(-16px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .entry { opacity: 1; }
}
