:root {
  --bg: #060a14;
  --panel: #0d1625;
  --panel-2: #0b1220;
  --stroke: #1f2a3d;
  --glow: #1b6bff;
  --accent: #67ffd1;
  --accent-2: #81a6ff;
  --text: #ebf1ff;
  --muted: #9bb0d4;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  --radius: 16px;
  --grid: #142035;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: radial-gradient(circle at 15% 20%, #0f1f36, #060a14 40%),
    radial-gradient(circle at 80% 0%, #0f1f36, #060a14 42%),
    linear-gradient(160deg, #071025, #060a14 65%);
  color: var(--text);
  font-family: "Avenir Next", "Futura", "Trebuchet MS", sans-serif;
  min-height: 100vh;
}

.wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
}

.hero h1 {
  margin: 4px 0 6px;
  font-size: 32px;
  letter-spacing: -0.02em;
}

.hero .lede {
  margin: 0;
  color: var(--muted);
  max-width: 640px;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 12px;
  color: var(--accent);
  margin: 0 0 6px;
}

.chips {
  display: grid;
  gap: 8px;
}

.chip {
  display: inline-flex;
  gap: 8px;
  align-items: baseline;
  padding: 10px 14px;
  background: rgba(103, 255, 209, 0.08);
  border: 1px solid rgba(103, 255, 209, 0.35);
  border-radius: 12px;
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.22);
}

.chip.secondary {
  background: rgba(129, 166, 255, 0.12);
  border-color: rgba(129, 166, 255, 0.35);
}

.chip-label {
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 18px;
}

.panel {
  background: linear-gradient(145deg, var(--panel), var(--panel-2));
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 6px;
}

.panel h2 {
  margin: 0;
}

.panel .tiny-label {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin: 0 0 4px;
  font-size: 12px;
}

.legend {
  display: inline-flex;
  gap: 12px;
  align-items: center;
  color: var(--muted);
  font-size: 14px;
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
}

.ball-dot {
  background: linear-gradient(135deg, #ffad66, #ff6c5f);
  box-shadow: 0 0 12px rgba(255, 145, 102, 0.6);
}

.peg-dot {
  background: #7aa7ff;
  box-shadow: 0 0 8px rgba(122, 167, 255, 0.65);
}

.canvas-wrap {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--stroke);
  background: radial-gradient(circle at 40% 30%, rgba(103, 255, 209, 0.08), rgba(103, 255, 209, 0) 45%),
    linear-gradient(180deg, #0b1220, #0a1326);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02);
  aspect-ratio: 3 / 2;
  min-height: 320px;
}

#board {
  width: 100%;
  height: 100%;
  display: block;
}

.control-panel {
  display: grid;
  gap: 14px;
  align-content: start;
}

.control {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--stroke);
  border-radius: 12px;
  padding: 12px;
}

.control-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--muted);
  font-size: 14px;
}

.control .value {
  color: var(--text);
  font-weight: 700;
}

input[type="range"] {
  width: 100%;
  margin-top: 10px;
  appearance: none;
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  outline: none;
  box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.4);
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #0d172a;
  border: 2px solid var(--accent);
  box-shadow: 0 0 0 6px rgba(103, 255, 209, 0.15);
}

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #0d172a;
  border: 2px solid var(--accent);
  box-shadow: 0 0 0 6px rgba(103, 255, 209, 0.15);
}

.buttons {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

button {
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease, background 140ms ease;
}

button:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.15);
}

button:active {
  transform: translateY(0);
}

button.accent {
  background: linear-gradient(135deg, rgba(103, 255, 209, 0.25), rgba(129, 166, 255, 0.25));
  border-color: rgba(103, 255, 209, 0.6);
  box-shadow: 0 12px 25px rgba(103, 255, 209, 0.25);
}

button.ghost {
  background: rgba(255, 255, 255, 0.04);
}

.histogram-block {
  border: 1px solid var(--stroke);
  border-radius: 12px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.02);
}

.hist-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}

.hist-head h3 {
  margin: 0;
}

.histogram {
  display: grid;
  gap: 4px;
  align-items: end;
  height: 190px;
  padding: 10px;
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(103, 255, 209, 0.06), rgba(255, 255, 255, 0.0));
  border: 1px solid var(--stroke);
  min-width: 0;
}

.hist-bar {
  display: flex;
  flex-direction: column;
  gap: 0;
  justify-content: flex-end;
  min-width: 0;
}

.hist-bar .bar {
  width: 100%;
  border-radius: 8px 8px 4px 4px;
  background: linear-gradient(180deg, rgba(103, 255, 209, 0.9), rgba(129, 166, 255, 0.85));
  box-shadow: 0 12px 18px rgba(103, 255, 209, 0.15);
  transition: height 180ms ease;
}


.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.stat-line {
  margin: 0;
  color: var(--text);
  font-weight: 600;
}

.footnote {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

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

  .hero {
    flex-direction: column;
  }
}

@media (max-width: 640px) {
  .wrap {
    padding: 16px;
  }

  .buttons {
    grid-template-columns: 1fr;
  }

  #board {
    aspect-ratio: 1 / 1;
  }
}
