/* Reactbits-style tokens and components (rb-*) */
:root {
  --rb-bg: hsl(230 15% 6%);
  --rb-bg-elev: hsl(230 18% 9%);
  --rb-surface: hsl(230 18% 12%);
  --rb-border: hsl(230 15% 22%);
  --rb-ring: hsl(220 90% 56%);
  --rb-text: hsl(220 20% 95%);
  --rb-muted: hsl(220 15% 70%);
  --rb-primary: hsl(220 90% 56%);
  --rb-success: hsl(150 70% 45%);
  --rb-warning: hsl(45 95% 60%);
  --rb-radius: 12px;
  --rb-radius-sm: 8px;
  --rb-control-h: 40px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
/* Ensure overscroll reveals a dark backdrop instead of white */
html { background: var(--rb-bg); }
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, PingFang SC, Microsoft YaHei, Noto Sans, Arial;
  color: var(--rb-text);
  background: radial-gradient(1200px 600px at 10% -10%, hsl(230 30% 16%) 0%, var(--rb-bg) 35%, var(--rb-bg) 100%);
}

/* Container, Stack, Grid */
.rb-container { max-width: 1120px; margin: 0 auto; padding: 0 20px; }
.rb-stack-md > * + * { margin-top: 14px; }
.rb-stack-lg > * + * { margin-top: 18px; }
.rb-row { display: flex; align-items: center; }
.rb-row-gap-sm { gap: 10px; }
.rb-center { display: flex; flex-direction: column; align-items: center; }
.rb-grid { display: grid; }
.rb-grid-gap { gap: 16px; }
.rb-grid-col-2 { grid-template-columns: 1fr 480px; }
.rb-grid-col-3 { grid-template-columns: repeat(3, 1fr); }

@media (max-width: 1100px) { .rb-grid-col-2 { grid-template-columns: 1fr; } }
@media (max-width: 780px) { .rb-grid-col-3 { grid-template-columns: 1fr; } }

/* Header & Footer */
.rb-header { position: sticky; top: 0; backdrop-filter: saturate(1.2) blur(6px); background: linear-gradient(180deg, rgba(20,22,30,0.7), rgba(20,22,30,0.35)); border-bottom: 1px solid var(--rb-border); z-index: 20; }
.rb-header-inner { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; }
.rb-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: 0.2px; }
.rb-logo { font-size: 20px; }
.rb-brand-text { font-size: 18px; }
.rb-brand-sub { color: var(--rb-muted); font-size: 12px; }
.rb-footer { border-top: 1px solid var(--rb-border); margin-top: 24px; }
.rb-footer-inner { padding: 16px 0 28px; display: flex; gap: 16px; flex-wrap: wrap; }
.rb-muted { color: var(--rb-muted); font-size: 12px; }

/* Card */
.rb-card { background: linear-gradient(180deg, var(--rb-bg-elev), var(--rb-surface)); border: 1px solid var(--rb-border); border-radius: var(--rb-radius); padding: 14px; box-shadow: 0 8px 28px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.04); }
.rb-card-fill { padding: 0; overflow: hidden; position: relative; }
/* Glass effect for cards */
.rb-card, .rb-card-fill {
  background: hsla(230 18% 14% / 0.38);
  border: 1px solid hsla(230 15% 85% / 0.08);
  box-shadow: 0 8px 28px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.04);
  backdrop-filter: blur(12px) saturate(1.1);
  -webkit-backdrop-filter: blur(12px) saturate(1.1);
}

/* Optional stronger glass utility */
.rb-glass {
  background: linear-gradient(180deg, hsla(230 18% 16% / 0.45), hsla(230 18% 12% / 0.35));
  border: 1px solid hsla(230 15% 85% / 0.12);
  box-shadow: 0 10px 32px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.05);
  backdrop-filter: blur(14px) saturate(1.15);
  -webkit-backdrop-filter: blur(14px) saturate(1.15);
}
/* subtle border highlight on hover */
.rb-glass:hover {
  border-color: hsla(230 15% 85% / 0.18);
}

/* Form */
.rb-field .rb-label { color: var(--rb-muted); display: block; margin: 0 0 6px; font-size: 12px; }
.rb-input { width: 100%; appearance: none; background: hsla(230 18% 14% / 0.35); border: 1px solid hsla(230 15% 85% / 0.08); color: var(--rb-text); padding: 10px 12px; border-radius: var(--rb-radius-sm); outline: none; height: var(--rb-control-h); backdrop-filter: blur(6px) saturate(1.05); -webkit-backdrop-filter: blur(6px) saturate(1.05); }
.rb-input:focus { border-color: var(--rb-ring); box-shadow: 0 0 0 3px color-mix(in srgb, var(--rb-ring) 35%, transparent); }
.rb-btn { border: 1px solid hsla(230 15% 85% / 0.08); background: hsla(230 18% 14% / 0.35); color: var(--rb-text); padding: 0 12px; border-radius: var(--rb-radius-sm); cursor: pointer; transition: 120ms ease; height: var(--rb-control-h); display: inline-flex; align-items: center; justify-content: center; backdrop-filter: blur(6px) saturate(1.05); -webkit-backdrop-filter: blur(6px) saturate(1.05); }
.rb-btn:hover { filter: brightness(1.05); }
.rb-btn[disabled] { opacity: 0.6; cursor: not-allowed; }
.rb-btn-primary { background: var(--rb-primary); border-color: var(--rb-primary); color: #fff; }
.rb-btn-success { background: var(--rb-success); border-color: var(--rb-success); color: #07130d; }
.rb-btn-outline { background: transparent; color: var(--rb-text); }
.rb-btn-ghost { background: transparent; color: var(--rb-muted); }
.rb-help { color: var(--rb-muted); font-size: 12px; }
.hidden { display: none !important; }
.rb-presets { margin-top: 8px; }
.rb-presets { flex-direction: column; align-items: flex-start; }
.rb-presets .rb-input { margin-top: 6px; max-width: 260px; }
.rb-btn-chip { padding: 6px 10px; font-size: 12px; border-radius: 999px; }

/* Map and Wheel */
.map { height: 520px; width: 100%; background: #0b0e17; }
.wheel-wrap { position: relative; width: 100%; max-width: 420px; margin: 6px auto 0; }
#wheel { width: 100%; background: radial-gradient(circle at 50% 50%, #0e1320 65%, #0e1320 65%), transparent; border-radius: 50%; display: block; border: 1px solid var(--rb-border); }
.wheel-wrap canvas { width: 100%; height: auto; display: block; border-radius: 50%; border: 1px solid var(--rb-border); background: radial-gradient(circle at 50% 50%, rgba(0,0,0,0.2) 60%, transparent 60%); box-shadow: 0 10px 30px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.04); }
.pointer { position: absolute; top: -2px; left: 50%; transform: translateX(-50%); font-size: 20px; color: var(--rb-warning); text-shadow: 0 2px 6px rgba(0,0,0,0.6); }
.wheel-actions { display: flex; justify-content: center; margin-top: 10px; }
.wheel-actions { flex-wrap: wrap; gap: 8px; }

/* Custom wheel result emphasis */
#cw-result {
  font-size: 18px;
  line-height: 1.2;
}
#cw-result .cw-value {
  display: inline-block;
  margin-left: 6px;
  font-size: 24px;
  font-weight: 800;
  color: color-mix(in srgb, var(--rb-primary) 85%, #fff);
  text-shadow: 0 2px 10px rgba(0, 102, 255, 0.45);
}
.cw-pop {
  animation: cw-pop-kf 600ms cubic-bezier(.2,.8,.2,1);
}
@keyframes cw-pop-kf {
  0% { transform: scale(0.96); opacity: 0.6; }
  40% { transform: scale(1.12); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* Custom wheel table */
.cw-table-wrap { max-height: 320px; overflow: auto; }
.cw-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.cw-table thead th { position: sticky; top: 0; background: hsla(230 18% 14% / 0.6); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); border-bottom: 1px solid hsla(230 15% 85% / 0.08); padding: 8px; text-align: left; }
.cw-table tbody td { border-bottom: 1px solid hsla(230 15% 85% / 0.06); padding: 8px; }
.cw-table input[type="color"] { width: 100%; height: 32px; border: none; background: transparent; padding: 0; cursor: pointer; }
.cw-table input[type="text"] { width: 100%; height: 36px; border-radius: 8px; border: 1px solid hsla(230 15% 85% / 0.08); background: hsla(230 18% 14% / 0.35); color: var(--rb-text); padding: 6px 10px; }
.cw-table .actions { display: flex; gap: 6px; }

/* Selection card */
.selection { background: hsla(230 18% 14% / 0.38); border: 1px solid hsla(230 15% 85% / 0.08); border-radius: var(--rb-radius); padding: 12px; box-shadow: 0 8px 28px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.04); backdrop-filter: blur(12px) saturate(1.1); -webkit-backdrop-filter: blur(12px) saturate(1.1); }
.selection.hidden { display: none; }
.selection h3 { margin: 0 0 6px; }
.selection .muted { color: var(--rb-muted); }
.selection .row { display: flex; gap: 14px; align-items: center; margin: 6px 0; }
.selection a { color: var(--rb-primary); text-decoration: none; }

/* Results panel replacing the wheel */
.results-panel { display: flex; flex-direction: column; gap: 10px; position: relative; }
.results-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
/* Infinite Menu look */
.results-grid.inf-menu {
  position: relative;
  padding: 4px 2px;
  max-height: 360px;
  overflow: hidden;
  overscroll-behavior: contain;
  transform: translateZ(0);
  will-change: scroll-position;
  /* fade top/bottom edges */
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 18px, #000 calc(100% - 18px), transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0, #000 18px, #000 calc(100% - 18px), transparent 100%);
}
/* Track wrapper for GPU-accelerated translations */
.results-track {
  will-change: transform;
  transform: translate3d(0,0,0);
}
.results-cell {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  height: 64px; /* fixed row height to keep slot steps equal */
  border-radius: 12px;
  border: 1px solid hsla(230 15% 85% / 0.08);
  background: hsla(230 18% 14% / 0.38);
  box-shadow: 0 8px 28px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.04);
  backdrop-filter: blur(10px) saturate(1.1);
  -webkit-backdrop-filter: blur(10px) saturate(1.1);
  padding: 10px 12px;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 180ms ease, background 180ms ease, border-color 180ms ease;
}
.results-cell .cell-inner { display: flex; flex-direction: column; gap: 4px; width: 100%; }
.results-cell .name, .results-cell .addr { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.results-cell::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; border-radius: 12px 0 0 12px;
  background: linear-gradient(180deg, transparent, transparent);
  transition: background 180ms ease, width 180ms ease;
}
.results-cell:hover { transform: translateX(2px); box-shadow: 0 10px 20px rgba(0,0,0,0.38); }
.results-cell:hover::before { background: linear-gradient(180deg, var(--rb-primary), color-mix(in srgb, var(--rb-primary) 50%, transparent)); }
.results-cell .name { font-weight: 600; }
.results-cell .addr { color: var(--rb-muted); font-size: 12px; }
.results-cell .dist { color: var(--rb-muted); font-size: 12px; margin-left: 6px; }
.results-cell .rate { color: color-mix(in srgb, var(--rb-primary) 85%, #fff); font-weight: 600; margin-left: 6px; }
.results-cell .sched { color: var(--rb-muted); margin-right: 6px; }

/* Fixed center highlighter for slot-machine selection */
.results-center {
  position: absolute;
  left: 8px;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  height: 56px; /* overridden by JS */
  border-radius: 12px;
  pointer-events: none;
  /* Hollow frame */
  background: transparent;
  border: 2px solid hsla(220 90% 56% / 0.5); /* Use primary color for visibility */
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  box-shadow: 0 0 12px hsla(220 90% 56% / 0.3); /* Add a subtle glow to the frame */
  z-index: 2;
}

/* Flash animation for selected cell */
@keyframes rb-flash {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 215, 0, 0.0); }
  50% { box-shadow: 0 0 0 4px rgba(255, 215, 0, 0.55); }
}
@keyframes rb-glow {
  0%, 100% { filter: drop-shadow(0 0 0 rgba(255,215,0,0)); }
  50% { filter: drop-shadow(0 0 14px rgba(255,215,0,0.5)); }
}
@keyframes rb-pulse {
  0%, 100% { opacity: 0; }
  50% { opacity: 0.9; }
}
.results-cell.flash {
  animation: rb-flash 1200ms ease-in-out 5, rb-glow 1200ms ease-in-out 5;
}
.results-cell.flash::after {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  pointer-events: none;
  background: radial-gradient(circle at 50% 50%, rgba(255,215,0,0.35) 0%, rgba(255,215,0,0.18) 25%, transparent 60%);
  opacity: 0;
  animation: rb-pulse 1200ms ease-in-out 5;
}
.results-cell.active {
  border-color: color-mix(in srgb, var(--rb-primary) 60%, var(--rb-border));
  background: linear-gradient(180deg, color-mix(in srgb, var(--rb-primary) 12%, hsl(230 18% 13%)), hsl(230 18% 12%));
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--rb-primary) 35%, transparent), 0 12px 28px rgba(0,0,0,0.45);
}
.results-cell.active::before { width: 6px; background: linear-gradient(180deg, var(--rb-primary), color-mix(in srgb, var(--rb-primary) 60%, transparent)); }

/* Spinning animation for list items during shuffle */
.cell-inner.spinning { animation: rb-spin-y 700ms linear infinite; transform-style: preserve-3d; backface-visibility: hidden; }
@keyframes rb-spin-y { from { transform: rotateY(0deg); } to { transform: rotateY(360deg); } }

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

@media (max-width: 768px) {
  .map { height: 50vh; min-height: 340px; }
  .pointer { font-size: 18px; }
}
@media (max-width: 480px) {
  body { background: radial-gradient(900px 450px at 10% -10%, hsl(230 30% 16%) 0%, var(--rb-bg) 40%, var(--rb-bg) 100%); }
  .map { height: 45vh; min-height: 300px; }
  .wheel-actions .rb-btn { padding: 12px 18px; }
}

/* Custom wheel responsive layout */
.cw-layout { grid-template-columns: 420px 1fr; align-items: start; }
@media (max-width: 980px) {
  .cw-layout { grid-template-columns: 1fr; }
}

/* Results list height adapt on small screens */
@media (max-width: 980px) {
  .results-grid.inf-menu { max-height: min(56vh, 380px); }
}
@media (max-width: 560px) {
  .results-grid.inf-menu { max-height: min(52vh, 340px); }
  .cw-table { font-size: 13px; }
  .cw-table input[type="text"] { height: 34px; font-size: 14px; }
}

/* Map overlay for results */
.map-overlay { position: absolute; top: 10px; left: 10px; right: 10px; pointer-events: none; }
.overlay-stats { display: inline-block; background: hsla(230 18% 14% / 0.45); backdrop-filter: blur(8px) saturate(1.05); -webkit-backdrop-filter: blur(8px) saturate(1.05); border: 1px solid hsla(230 15% 85% / 0.08); border-radius: 10px; padding: 6px 10px; font-size: 12px; pointer-events: auto; box-shadow: 0 8px 28px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.04); }
.overlay-list { margin-top: 8px; max-height: 180px; overflow: auto; display: grid; gap: 6px; pointer-events: auto; }
.overlay-item { background: hsla(230 18% 14% / 0.45); border: 1px solid hsla(230 15% 85% / 0.08); border-radius: 10px; padding: 8px 10px; font-size: 12px; cursor: pointer; backdrop-filter: blur(8px) saturate(1.05); -webkit-backdrop-filter: blur(8px) saturate(1.05); box-shadow: 0 8px 28px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.04); }
.overlay-item:hover { background: rgba(14,19,32,0.92); }
.overlay-item .name { font-weight: 600; }
.overlay-item .addr { color: var(--rb-muted); }
.overlay-item .dist { color: var(--rb-muted); margin-left: 6px; }

/* Blue outline glow on hover/focus */
.rb-btn { position: relative; z-index: 0; }
.rb-btn::before {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  padding: 2px; /* border thickness */
  background: linear-gradient(180deg, var(--rb-primary), color-mix(in srgb, var(--rb-primary) 60%, transparent));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
  opacity: 0; /* off by default */
  box-shadow: 0 0 12px color-mix(in srgb, var(--rb-primary) 55%, transparent), 0 0 24px color-mix(in srgb, var(--rb-primary) 35%, transparent);
  transition: opacity 140ms ease;
}
.rb-btn:hover::before,
.rb-btn:focus-visible::before {
  opacity: 1;
  animation: rb-blue-pulse 1200ms ease-in-out infinite;
}

@keyframes rb-blue-pulse {
  0%, 100% {
    box-shadow: 0 0 10px color-mix(in srgb, var(--rb-primary) 45%, transparent), 0 0 20px color-mix(in srgb, var(--rb-primary) 25%, transparent);
  }
  50% {
    box-shadow: 0 0 20px color-mix(in srgb, var(--rb-primary) 85%, transparent), 0 0 36px color-mix(in srgb, var(--rb-primary) 55%, transparent);
  }
}

@media (prefers-reduced-motion: reduce) {
  .rb-btn::before { animation: none; }
}

/* Scroll Stack effect for results list */
.rb-ss { position: relative; overflow: auto; overscroll-behavior: contain; background: rgba(14,19,32,0.5); }
.rb-ss .rb-ss-item {
  position: sticky;
  top: 6px;
  z-index: calc(200 - var(--i, 0));
  transform: translateY(calc(var(--i, 0) * var(--ss-gap, 8px)));
  will-change: transform;
  transition: transform 220ms ease;
}
.rb-ss::-webkit-scrollbar { width: 8px; height: 8px; }
.rb-ss::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 8px; }
.rb-ss::-webkit-scrollbar-track { background: transparent; }

/* Gradual Blur (Reactbits style) */
.rb-gb {
  --gb-blur-from: 8px;
  --gb-blur-to: 0px;
  --gb-shift: 6px;
  filter: blur(var(--gb-blur-from));
  opacity: 0.2;
  transform: translateY(var(--gb-shift));
  transition: filter 600ms ease, opacity 600ms ease, transform 600ms ease;
  will-change: filter, opacity, transform;
}
.rb-gb.is-visible {
  filter: blur(var(--gb-blur-to));
  opacity: 1;
  transform: translateY(0);
}

/* Shape Blur (Reactbits style) for final selection */
.rb-shape-blur { position: relative; overflow: hidden; }
.rb-shape-blur .sb-inner {
  filter: blur(10px);
  clip-path: circle(0% at 50% 50%);
}
.rb-shape-blur.is-visible .sb-inner {
  animation: rb-sb-reveal 700ms cubic-bezier(.2,.7,.2,1) forwards;
}
@keyframes rb-sb-reveal {
  0%   { filter: blur(10px); clip-path: circle(0% at 50% 50%); transform: scale(1.01); }
  60%  { filter: blur(4px);  clip-path: circle(80% at 50% 50%); }
  100% { filter: blur(0);    clip-path: circle(150% at 50% 50%); transform: scale(1); }
}
