:root {
  --ice: #c9daea;
  --cyan: #03f7eb;
  --teal: #00b295;
  --ink: #191516;
  --crimson: #ab2346;

  --bg: var(--ink);
  --surface: #221d1f;
  --surface-2: #2b2528;
  --line: #3a3236;
  --text: var(--ice);
  --muted: #8f9eab;
  --radius: 4px;
  --font: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.site-header {
  padding: 32px 16px 8px;
  max-width: 1120px;
  width: 100%;
  margin: 0 auto;
  border-bottom: 2px solid var(--line);
}

h1 {
  margin: 0;
  font-size: clamp(1.5rem, 4vw, 2.25rem);
  font-weight: 700;
  letter-spacing: -0.02em;
}
.accent { color: var(--cyan); }

.tagline {
  margin: 6px 0 20px;
  color: var(--muted);
  font-size: 0.9rem;
}

.layout {
  flex: 1;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px 16px;
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  gap: 24px;
  align-items: start;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 3px solid var(--teal);
  border-radius: var(--radius);
  padding: 20px;
  min-width: 0;
}
.stats-panel { border-top-color: var(--crimson); }

.panel-title {
  margin: 0 0 16px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.sub-title {
  margin: 24px 0 10px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

/* ---------- Wheel ---------- */
.wheel-wrap {
  position: relative;
  width: min(100%, 360px);
  aspect-ratio: 1;
  margin: 8px auto 0;
}

.wheel {
  width: 100%;
  height: 100%;
  display: block;
  transform: rotate(0deg);
  transition: transform 4s cubic-bezier(0.12, 0.7, 0.12, 1);
  will-change: transform;
}

.wheel text {
  font-family: var(--font);
  font-weight: 700;
  pointer-events: none;
}

.pointer {
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 14px solid transparent;
  border-right: 14px solid transparent;
  border-top: 26px solid var(--cyan);
  filter: drop-shadow(0 2px 0 var(--ink));
  z-index: 2;
}

.hub {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 14%;
  height: 14%;
  transform: translate(-50%, -50%);
  background: var(--ink);
  border: 3px solid var(--cyan);
  border-radius: 50%;
  z-index: 2;
}

/* ---------- Result ---------- */
.result {
  margin: 20px 0 16px;
  padding: 12px 16px;
  background: var(--surface-2);
  border-left: 4px solid var(--cyan);
  border-radius: var(--radius);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.result-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}
.result-value {
  font-size: 2.25rem;
  font-weight: 700;
  color: var(--cyan);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.result-value.pop { animation: pop 0.35s ease-out; }
@keyframes pop {
  0% { transform: scale(1.35); color: var(--ice); }
  100% { transform: scale(1); }
}

/* ---------- Buttons ---------- */
.controls {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 10px;
}

.btn {
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 600;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 2px solid transparent;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s, transform 0.05s;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:focus-visible, .step-btn:focus-visible, input:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--teal);
  color: var(--ink);
  text-transform: uppercase;
  letter-spacing: 0.15em;
}
.btn-primary:hover:not(:disabled) { background: var(--cyan); }

.btn-ghost {
  background: transparent;
  color: var(--ice);
  border-color: var(--line);
  font-size: 0.85rem;
}
.btn-ghost:hover:not(:disabled) { border-color: var(--crimson); color: #fff; background: rgba(171, 35, 70, 0.15); }

/* ---------- Batch spins ---------- */
.batch {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 8px;
}
.batch label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}
.batch-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}
.batch-row input {
  font-family: var(--font);
  min-width: 0;
  height: 48px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--ice);
  font-size: 1rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
  appearance: textfield;
}
.batch-row input::-webkit-outer-spin-button,
.batch-row input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.batch-row input[aria-invalid="true"] { border-color: var(--crimson); }
.batch-row input:disabled { opacity: 0.5; }
.batch .hint { font-size: 0.75rem; color: var(--muted); }
.batch .hint.error { color: #e0577a; }

.btn-secondary {
  background: transparent;
  color: var(--cyan);
  border-color: var(--cyan);
  white-space: nowrap;
}
.btn-secondary:hover:not(:disabled) { background: var(--cyan); color: var(--ink); }

/* ---------- Segment stepper ---------- */
.segments-control {
  margin-top: 18px;
  display: grid;
  grid-template-columns: auto auto;
  justify-content: start;
  align-items: center;
  gap: 8px 14px;
}
.segments-control label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}
.segments-control .hint {
  grid-column: 1 / -1;
  font-size: 0.75rem;
  color: var(--muted);
}

.stepper {
  display: flex;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.step-btn {
  font-family: var(--font);
  width: 40px;
  height: 40px;
  border: 0;
  background: var(--surface-2);
  color: var(--ice);
  font-size: 1.1rem;
  cursor: pointer;
}
.step-btn:hover:not(:disabled) { background: var(--line); color: var(--cyan); }
.step-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.stepper input {
  font-family: var(--font);
  width: 52px;
  height: 40px;
  border: 0;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  background: var(--ink);
  color: var(--ice);
  text-align: center;
  font-size: 1rem;
  font-weight: 600;
  -moz-appearance: textfield;
  appearance: textfield;
}
.stepper input::-webkit-outer-spin-button,
.stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* ---------- Stats ---------- */
.stats {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.stat {
  background: var(--surface-2);
  padding: 12px 14px;
  min-width: 0;
}
.stat dt {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.stat dd {
  margin: 4px 0 0;
  font-size: 1.4rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.stat-highlight dd { color: var(--cyan); }

/* ---------- Chart ---------- */
.chart-wrap {
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 12px 10px;
}
.chart {
  --plot-h: 200px;
  position: relative;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 6px;
  align-items: end;
}
.bar-col {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  min-width: 0;
}
.bar-track {
  position: relative;
  height: var(--plot-h);
  display: flex;
  align-items: flex-end;
  border-bottom: 2px solid var(--line);
}
.bar {
  width: 100%;
  background: var(--teal);
  border-radius: 2px 2px 0 0;
  transition: height 0.35s ease-out, background-color 0.2s;
  min-height: 0;
}
.bar.latest { background: var(--cyan); }
.bar-count {
  position: absolute;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--ice);
  transition: bottom 0.35s ease-out;
  font-variant-numeric: tabular-nums;
}
.bar-label {
  margin-top: 6px;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}
.expected-line {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 2px dashed var(--crimson);
  pointer-events: none;
  transition: bottom 0.35s ease-out;
  z-index: 1;
}
.chart-legend {
  margin: 10px 0 0;
  font-size: 0.72rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}
.legend-line {
  display: inline-block;
  width: 22px;
  border-top: 2px dashed var(--crimson);
}

/* ---------- Probability table ---------- */
.prob-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.prob-table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
.prob-table th,
.prob-table td {
  padding: 8px 14px;
  text-align: right;
  border-bottom: 1px solid var(--line);
}
.prob-table tbody tr:last-child th,
.prob-table tbody tr:last-child td { border-bottom: 0; }
.prob-table th:first-child { text-align: left; }
.prob-table thead th {
  background: var(--surface-2);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.prob-table tbody th { font-weight: 700; }
.prob-table tbody td { color: var(--muted); }
.prob-table tbody td.exp { color: var(--ice); font-weight: 600; }
.prob-table tbody tr.latest { background: rgba(3, 247, 235, 0.08); }
.prob-table tbody tr.latest th,
.prob-table tbody tr.latest td.exp { color: var(--cyan); }

.muted { color: var(--muted); font-weight: 400; text-transform: none; letter-spacing: 0; }
.empty { margin: 0; font-size: 0.85rem; }

.site-footer {
  max-width: 1120px;
  width: 100%;
  margin: 0 auto;
  padding: 16px 16px 28px;
  font-size: 0.75rem;
  color: var(--muted);
  border-top: 2px solid var(--line);
}
.site-footer code { color: var(--teal); }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 16px; padding-top: 16px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 420px) {
  .panel { padding: 16px; }
  .chart { --plot-h: 160px; gap: 3px; }
  .bar-count { font-size: 0.62rem; }
  .result-value { font-size: 1.9rem; }
}

@media (prefers-reduced-motion: reduce) {
  .wheel { transition-duration: 0.6s; }
  .bar, .bar-count, .expected-line { transition: none; }
  .result-value.pop { animation: none; }
}
