:root {
  color-scheme: dark;
  --bg: #07131a;
  --surface: rgba(9, 23, 31, 0.88);
  --surface-strong: #102734;
  --surface-soft: #143443;
  --border: rgba(125, 177, 199, 0.24);
  --text: #f4fbff;
  --muted: #9db4c0;
  --accent: #5eead4;
  --accent-2: #38bdf8;
  --warm: #fbbf24;
  --danger: #fb7185;
  --success: #4ade80;
  --shadow: rgba(1, 9, 13, 0.42);
}

* {
  box-sizing: border-box;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(56, 189, 248, 0.16), transparent 34%),
    radial-gradient(circle at 84% 18%, rgba(94, 234, 212, 0.15), transparent 26%),
    linear-gradient(180deg, #07131a, #081821 42%, #061118);
  color: var(--text);
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

#pickerApp {
  min-height: 100vh;
}

.picker-app {
  display: grid;
  gap: 1rem;
  min-height: 100vh;
  padding: clamp(0.9rem, 2vw, 1.5rem);
}

.picker-header,
.picker-panel,
.picker-stage,
.history-panel,
.metric-card {
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 0 22px 50px var(--shadow);
}

.picker-header {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
  align-items: flex-end;
  padding: 1rem 1.1rem;
  border-radius: 1rem;
  backdrop-filter: blur(18px);
}

.picker-title {
  margin: 0;
  font-size: clamp(2.1rem, 5vw, 4.2rem);
  line-height: 0.95;
  letter-spacing: -0.03em;
}

.picker-subtitle {
  margin: 0.6rem 0 0;
  max-width: 48rem;
  color: var(--muted);
  line-height: 1.55;
}

.picker-actions,
.inline-actions,
.panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
}

.picker-layout,
.live-layout {
  display: grid;
  gap: 1rem;
  align-items: start;
}

.picker-panel,
.picker-stage,
.history-panel {
  border-radius: 1rem;
  overflow: hidden;
}

.picker-panel {
  padding: 1rem;
}

.panel-title {
  margin: 0;
  font-size: 1.1rem;
}

.panel-copy {
  margin: 0.5rem 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.field-grid,
.metrics-grid {
  display: grid;
  gap: 0.9rem;
}

.field {
  display: grid;
  gap: 0.45rem;
}

.field span {
  font-size: 0.95rem;
  color: var(--muted);
}

.field input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 0.85rem;
  padding: 0.9rem 1rem;
  background: rgba(7, 19, 26, 0.86);
  color: var(--text);
}

.field-note,
.muted {
  color: var(--muted);
}

.field-error {
  color: #ffc4cf;
  font-size: 0.9rem;
}

.button,
.mini-button {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(9, 23, 31, 0.9);
  color: var(--text);
  padding: 0.8rem 1.1rem;
  text-decoration: none;
}

.button.primary,
.mini-button.primary {
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #071118;
  font-weight: 800;
}

.button.danger,
.mini-button.danger {
  border-color: rgba(251, 113, 133, 0.32);
  color: #ffd7de;
}

.status {
  min-height: 1.5rem;
  margin-bottom: 0.9rem;
  color: var(--muted);
}

.status.success {
  color: var(--success);
}

.status.error {
  color: #ffc4cf;
}

.metrics-grid {
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  margin-top: 1rem;
}

.metric-card {
  padding: 1rem;
  border-radius: 1rem;
  background: linear-gradient(180deg, rgba(19, 52, 67, 0.9), rgba(10, 28, 37, 0.9));
}

.metric-card strong {
  display: block;
  margin-top: 0.35rem;
  font-size: 1.8rem;
}

.picker-stage {
  position: relative;
  display: grid;
  gap: 1rem;
  justify-items: center;
  padding: clamp(1rem, 2.3vw, 1.5rem);
}

.live-stage {
  min-height: calc(100vh - 3rem);
  align-content: start;
}

.picker-stage-top {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
  align-items: center;
}

.stage-kicker {
  margin: 0;
  color: var(--accent);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.stage-title {
  margin: 0.35rem 0 0;
  font-size: clamp(1.6rem, 3vw, 2.4rem);
}

.number-machine {
  position: relative;
  display: grid;
  place-items: center;
  width: min(92vw, 31rem);
  aspect-ratio: 1;
  margin-top: 0.4rem;
  border-radius: 2rem;
  background:
    radial-gradient(circle at 50% 35%, rgba(255, 255, 255, 0.12), transparent 36%),
    linear-gradient(180deg, rgba(20, 52, 67, 0.92), rgba(8, 19, 25, 0.96));
  border: 1px solid rgba(94, 234, 212, 0.18);
  overflow: hidden;
}

.number-machine::before,
.number-machine::after {
  content: "";
  position: absolute;
  inset: 6%;
  border-radius: 1.6rem;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.number-machine::after {
  inset: 13%;
}

.number-stage-ball {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: min(58vw, 15.5rem);
  aspect-ratio: 1;
  border-radius: 999px;
  background:
    radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.44), transparent 22%),
    radial-gradient(circle at 68% 70%, rgba(56, 189, 248, 0.24), transparent 28%),
    linear-gradient(180deg, #15394a, #0b1f29);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    0 26px 44px rgba(0, 0, 0, 0.32);
  font-size: clamp(3.8rem, 11vw, 7rem);
  font-weight: 800;
  letter-spacing: -0.05em;
  transition: transform 650ms cubic-bezier(0.21, 0.82, 0.25, 1), opacity 650ms ease;
}

.number-stage-ball.is-rolling {
  animation: pickerPulse 280ms linear infinite;
}

.number-stage-ball.is-settled {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    0 0 0 12px rgba(94, 234, 212, 0.08),
    0 26px 44px rgba(0, 0, 0, 0.36);
}

.number-stage-ball.is-dropping {
  transform: translateY(155%) scale(0.72);
  opacity: 0;
}

.machine-rails {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), transparent 18%, transparent 82%, rgba(255, 255, 255, 0.05)),
    linear-gradient(90deg, transparent 26%, rgba(255, 255, 255, 0.04) 50%, transparent 74%);
}

.history-panel {
  padding: 1rem;
}

.history-grid {
  display: grid;
  gap: 0.65rem;
  grid-template-columns: repeat(auto-fill, minmax(4.25rem, 1fr));
  margin-top: 1rem;
}

.history-ball {
  display: grid;
  place-items: center;
  min-height: 4.25rem;
  border-radius: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, rgba(25, 58, 73, 0.92), rgba(10, 26, 34, 0.96));
  font-size: 1.45rem;
  font-weight: 800;
}

.history-ball.latest {
  animation: historyArrive 700ms cubic-bezier(0.19, 0.89, 0.24, 1);
  border-color: rgba(94, 234, 212, 0.45);
}

.empty-state {
  padding: 1rem;
  border: 1px dashed rgba(157, 180, 192, 0.24);
  border-radius: 1rem;
  color: var(--muted);
}

.range-strip {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: space-between;
  align-items: center;
  padding: 0.9rem 1rem;
  border-radius: 1rem;
  background: rgba(8, 19, 25, 0.72);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border-radius: 999px;
  padding: 0.45rem 0.75rem;
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
}

@keyframes pickerPulse {
  0% { transform: scale(0.985) rotate(-1.1deg); }
  50% { transform: scale(1.015) rotate(1.1deg); }
  100% { transform: scale(0.985) rotate(-1.1deg); }
}

@keyframes historyArrive {
  0% {
    transform: translateY(-2rem) scale(0.72);
    opacity: 0;
  }
  100% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

@media (min-width: 900px) {
  .picker-layout {
    grid-template-columns: minmax(19rem, 28rem) minmax(0, 1fr);
  }

  .live-layout {
    grid-template-columns: minmax(0, 1.4fr) minmax(18rem, 26rem);
  }
}

@media (max-width: 640px) {
  .button,
  .mini-button {
    width: 100%;
    justify-content: center;
    text-align: center;
  }

  .picker-actions,
  .inline-actions,
  .panel-actions {
    width: 100%;
  }
}
