/* ===========================================================
   NUMBERHUNT — "Signal Intercept" console
   Palette:  bg #0A0D12 · panel #12161D · hairline #232833
             amber #FFB020 (signal/primary) · blue #4C8DFF (band)
             green #3ED598 (lock) · coral #FF6B5B (deflect) · text-dim #8A93A3
   Type: JetBrains Mono (display/data) + IBM Plex Sans (body)
   =========================================================== */

:root {
  --bg: #0a0d12;
  --panel: #12161d;
  --panel-raised: #161b23;
  --hairline: #232833;
  --amber: #ffb020;
  --amber-dim: #8a6423;
  --blue: #4c8dff;
  --green: #3ed598;
  --coral: #ff6b5b;
  --text: #e8ebf0;
  --text-dim: #8a93a3;
  --text-faint: #4d5563;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --sans: "IBM Plex Sans", -apple-system, "Segoe UI", sans-serif;
  --radius: 3px;
}

* { box-sizing: border-box; }

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

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
}

body {
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(76, 141, 255, 0.08), transparent),
    radial-gradient(ellipse 60% 40% at 90% 100%, rgba(255, 176, 32, 0.06), transparent);
  background-attachment: fixed;
}

/* subtle CRT scanline + vignette overlay, purely decorative */
.crt-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.012) 0px,
    rgba(255, 255, 255, 0.012) 1px,
    transparent 1px,
    transparent 3px
  );
  mix-blend-mode: overlay;
}

.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 20px 40px;
}

/* ---------- topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 20px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--hairline);
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  color: var(--amber);
  font-size: 20px;
  text-shadow: 0 0 12px rgba(255, 176, 32, 0.6);
}
.brand-text {
  font-family: var(--mono);
  font-weight: 700;
  letter-spacing: 0.12em;
  font-size: 15px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  padding: 6px 12px;
  background: var(--panel);
}
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-faint);
}
.status-pill[data-state="scanning"] .status-dot { background: var(--blue); box-shadow: 0 0 8px var(--blue); animation: pulse 1.4s ease-in-out infinite; }
.status-pill[data-state="locked"] .status-dot { background: var(--green); box-shadow: 0 0 8px var(--green); }
.status-pill[data-state="scanning"] #statusLabel { color: var(--blue); }
.status-pill[data-state="locked"] #statusLabel { color: var(--green); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* ---------- layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 20px;
  align-items: start;
}

@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 28px;
  position: relative;
}

.panel::before {
  /* terminal window chrome — three dots */
  content: "";
  position: absolute;
  top: 14px;
  left: 16px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-faint);
  box-shadow: 12px 0 0 var(--text-faint), 24px 0 0 var(--text-faint);
  opacity: 0.5;
}

.console { padding-top: 42px; min-height: 420px; }
.leaderboard { padding-top: 42px; }

/* ---------- typography ---------- */
.eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--amber);
  margin: 0 0 10px;
}

.title {
  font-family: var(--mono);
  font-size: clamp(22px, 3vw, 30px);
  font-weight: 600;
  line-height: 1.25;
  margin: 0 0 12px;
  letter-spacing: -0.01em;
}

.title-win { color: var(--green); }
#winNumber { text-shadow: 0 0 16px rgba(62, 213, 152, 0.6); }

.lede {
  color: var(--text-dim);
  font-size: 15px;
  line-height: 1.6;
  margin: 0 0 24px;
  max-width: 56ch;
}
.lede strong { color: var(--text); font-family: var(--mono); }

/* ---------- form controls ---------- */
.screen.hidden { display: none; }

.row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-width: 160px;
}

.field-label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--text-faint);
}

input[type="text"],
input[type="number"] {
  background: var(--bg);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--mono);
  font-size: 16px;
  padding: 12px 14px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus-visible {
  border-color: var(--amber);
  box-shadow: 0 0 0 3px rgba(255, 176, 32, 0.15);
}
input::placeholder { color: var(--text-faint); }

.btn {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 12px 20px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.1s ease, filter 0.15s ease;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--amber);
  color: #16110a;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.hint {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-faint);
  margin: 10px 2px 0;
  min-height: 16px;
}
.hint[data-tone="error"] { color: var(--coral); }
.hint[data-tone="good"] { color: var(--green); }

/* ---------- spectrum / signature element ---------- */
.readout { margin: 8px 0 28px; }

.readout-labels {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 8px;
}
.readout-bound {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 600;
  color: var(--blue);
}
.readout-caption {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--text-faint);
}

.spectrum {
  position: relative;
  height: 46px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  background-color: var(--panel-raised);
  background-image: repeating-linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.03) 0px,
    rgba(255, 255, 255, 0.03) 1px,
    transparent 1px,
    transparent 20px
  ); /* faint vertical grid texture */
  overflow: hidden;
}
.spectrum-track {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent, rgba(0,0,0,0.25));
}
.spectrum-band {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0%;
  width: 100%;
  background: linear-gradient(90deg, rgba(76,141,255,0.28), rgba(76,141,255,0.12));
  border-right: 2px solid var(--blue);
  border-left: 2px solid var(--blue);
  transition: left 0.5s cubic-bezier(0.22, 1, 0.36, 1), width 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}
.spectrum-band.locked {
  background: linear-gradient(90deg, rgba(62,213,152,0.35), rgba(62,213,152,0.15));
  border-color: var(--green);
}
.spectrum-sweep {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 40px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.12), transparent);
  left: -40px;
  animation: sweep 2.6s linear infinite;
  pointer-events: none;
}
@keyframes sweep {
  0% { left: -40px; }
  100% { left: 100%; }
}
.spectrum-marker {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 2px;
  background: var(--amber);
  left: 50%;
  opacity: 0;
  box-shadow: 0 0 10px var(--amber);
  transition: left 0.4s ease, opacity 0.4s ease;
}
.spectrum-marker.show { opacity: 1; }

.spectrum-ticks {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-faint);
  margin-top: 6px;
}

/* ---------- transmission log ---------- */
.log-wrap { margin-top: 8px; }
.log {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column-reverse;
  gap: 6px;
  max-height: 220px;
  overflow-y: auto;
}
.log-entry {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--mono);
  font-size: 13px;
  padding: 8px 10px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  background: var(--panel-raised);
}
.log-index { color: var(--text-faint); width: 22px; }
.log-value { color: var(--text); width: 36px; font-weight: 600; }
.log-result { flex: 1; letter-spacing: 0.02em; }
.log-result[data-r="higher"] { color: var(--coral); }
.log-result[data-r="lower"] { color: var(--coral); }
.log-result[data-r="correct"] { color: var(--green); }
.log-empty { color: var(--text-faint); font-family: var(--mono); font-size: 13px; padding: 8px 2px; }

/* ---------- leaderboard ---------- */
.board-title {
  font-family: var(--mono);
  font-size: 18px;
  margin: 0 0 16px;
}
.board {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 13px;
}
.board thead th {
  text-align: left;
  color: var(--text-faint);
  font-weight: 500;
  font-size: 10px;
  letter-spacing: 0.1em;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--hairline);
}
.board td {
  padding: 9px 4px;
  border-bottom: 1px solid var(--hairline);
  color: var(--text-dim);
}
.board tr:last-child td { border-bottom: none; }
.board td:first-child { color: var(--text-faint); width: 34px; }
.board tr.you td { color: var(--amber); }
.board tr.rank-1 td:first-child { color: var(--amber); }
.board-empty td { color: var(--text-faint); padding: 16px 4px; }

/* ---------- footer ---------- */
.footer {
  margin-top: 28px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-faint);
}
.blink-cursor {
  color: var(--amber);
  animation: blink 1.1s steps(1) infinite;
}
@keyframes blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}
