@import url("common.css");

:root {
  --rl-felt: #0d4a2f;
  --rl-felt-deep: #083322;
  --rl-gold: #f5d76e;
  --rl-gold-dim: #c9a227;
  --rl-red: #c41e3a;
  --rl-black: #121212;
  --rl-panel: #0b1220;
}

.roulette-page {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  color: #f8fafc;
  background:
    radial-gradient(ellipse at 50% -10%, rgba(245, 215, 110, 0.12), transparent 45%),
    radial-gradient(ellipse at 80% 80%, rgba(13, 74, 47, 0.45), transparent 40%),
    linear-gradient(180deg, #050a08 0%, #0a1520 50%, #07140f 100%);
  overflow-x: hidden;
}

.rl-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.55);
  border-bottom: 1px solid rgba(245, 215, 110, 0.2);
  flex-shrink: 0;
}
.rl-brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.rl-brand a {
  color: #93c5fd;
  font-size: 0.78rem;
  font-weight: 700;
  text-decoration: none;
}
.rl-brand strong {
  letter-spacing: 0.08em;
  font-size: 0.92rem;
  color: var(--rl-gold);
}
.rl-top-right {
  display: flex;
  gap: 8px;
  align-items: center;
}
.rl-pill {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 0.82rem;
  font-weight: 700;
}
.rl-pill.gold {
  color: #111;
  background: linear-gradient(135deg, #f5d76e, #c9a227);
  border-color: transparent;
}
.rl-icon {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.rl-history {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  overflow-x: auto;
  flex-shrink: 0;
  background: rgba(0, 0, 0, 0.35);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  -webkit-overflow-scrolling: touch;
}
.rl-hist {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 0.78rem;
  border: 2px solid rgba(255, 255, 255, 0.15);
}
.rl-hist.red { background: var(--rl-red); }
.rl-hist.black { background: #1a1a1a; }
.rl-hist.green { background: #15803d; box-shadow: 0 0 10px rgba(34, 197, 94, 0.5); }

.rl-main {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(320px, 1.15fr);
  gap: 12px;
  padding: 12px;
}

.rl-wheel-panel {
  position: relative;
  border-radius: 20px;
  background:
    radial-gradient(circle at 50% 40%, #145c3a 0%, var(--rl-felt-deep) 55%, #031910 100%);
  border: 2px solid rgba(245, 215, 110, 0.28);
  box-shadow:
    inset 0 0 60px rgba(0, 0, 0, 0.45),
    0 20px 50px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 12px 16px;
  overflow: hidden;
}
.rl-phase {
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.78rem;
  color: var(--rl-gold);
  margin-bottom: 6px;
}
.rl-phase.spin { color: #fda4af; animation: rlPulse 0.9s ease infinite; }
.rl-phase.result { color: #86efac; }
@keyframes rlPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

.rl-timer-wrap { margin-bottom: 4px; }
.rl-timer-ring {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 1.15rem;
  background: conic-gradient(#f5d76e var(--p, 100%), rgba(255, 255, 255, 0.12) 0);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.35);
}
.rl-timer-ring span {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #0b1220;
  display: grid;
  place-items: center;
}

.rl-wheel-stage {
  position: relative;
  width: min(100%, 420px);
  aspect-ratio: 1;
  perspective: 900px;
}
.rl-wheel-glow {
  position: absolute;
  inset: 8%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(245, 215, 110, 0.2), transparent 65%);
  filter: blur(8px);
  pointer-events: none;
}
#wheelCanvas {
  width: 100%;
  height: 100%;
  display: block;
  transform: rotateX(28deg);
  transform-style: preserve-3d;
  filter: drop-shadow(0 28px 24px rgba(0, 0, 0, 0.55));
}
.rl-result-burst {
  position: absolute;
  left: 50%;
  top: 48%;
  transform: translate(-50%, -50%);
  text-align: center;
  z-index: 5;
  pointer-events: none;
  animation: rlPop 0.45s cubic-bezier(0.2, 0.9, 0.2, 1);
}
.rl-result-burst.hidden { display: none !important; }
.rl-result-num {
  display: block;
  font-size: clamp(2.4rem, 8vw, 3.6rem);
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
}
.rl-result-label {
  display: block;
  margin-top: 4px;
  font-weight: 800;
  letter-spacing: 0.14em;
  font-size: 0.75rem;
}
@keyframes rlPop {
  from { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
  to { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

.rl-stats {
  display: flex;
  gap: 16px;
  margin-top: 10px;
  width: 100%;
  max-width: 420px;
  justify-content: space-around;
}
.rl-stats div {
  text-align: center;
}
.rl-stats span {
  display: block;
  font-size: 0.68rem;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.rl-stats strong {
  font-size: 1rem;
  color: #fff;
}
.rl-stats strong.win { color: #86efac; }

.rl-table-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  background: linear-gradient(180deg, rgba(13, 74, 47, 0.55), rgba(8, 51, 34, 0.85));
  border: 2px solid rgba(245, 215, 110, 0.22);
  border-radius: 18px;
  padding: 12px;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.35);
}

.rl-chip-bar {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  padding: 4px 0 8px;
}
.rl-chip {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 3px dashed rgba(255, 255, 255, 0.55);
  font-weight: 900;
  font-size: 0.78rem;
  color: #111;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
  transition: transform 0.12s, box-shadow 0.12s;
}
.rl-chip:hover { transform: translateY(-3px); }
.rl-chip.active {
  transform: translateY(-4px) scale(1.08);
  box-shadow: 0 0 0 3px #f5d76e, 0 8px 16px rgba(0, 0, 0, 0.4);
}
.rl-chip.c1 { background: radial-gradient(circle at 35% 30%, #fff, #cbd5e1); }
.rl-chip.c5 { background: radial-gradient(circle at 35% 30%, #fecaca, #dc2626); color: #fff; }
.rl-chip.c10 { background: radial-gradient(circle at 35% 30%, #bfdbfe, #2563eb); color: #fff; }
.rl-chip.c25 { background: radial-gradient(circle at 35% 30%, #bbf7d0, #16a34a); color: #fff; }
.rl-chip.c100 { background: radial-gradient(circle at 35% 30%, #fde68a, #ca8a04); }
.rl-chip.c500 { background: radial-gradient(circle at 35% 30%, #e9d5ff, #7c3aed); color: #fff; }

.rl-board-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.rl-board {
  display: grid;
  grid-template-columns: 42px repeat(12, minmax(28px, 1fr)) 42px;
  grid-template-rows: repeat(5, minmax(36px, 48px));
  gap: 3px;
  max-width: 720px;
  margin: 0 auto;
  user-select: none;
}
.rl-cell {
  position: relative;
  border-radius: 6px;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 0.85rem;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.12);
  transition: filter 0.12s, transform 0.08s;
  -webkit-tap-highlight-color: transparent;
}
.rl-cell:active { transform: scale(0.96); }
.rl-cell.red { background: linear-gradient(160deg, #e11d48, #9f1239); }
.rl-cell.black { background: linear-gradient(160deg, #334155, #0f172a); }
.rl-cell.green { background: linear-gradient(160deg, #22c55e, #15803d); }
.rl-cell.out {
  background: rgba(0, 0, 0, 0.35);
  font-size: 0.68rem;
  letter-spacing: 0.02em;
  text-align: center;
  padding: 2px;
  line-height: 1.15;
}
.rl-cell.hot {
  outline: 2px solid #f5d76e;
  filter: brightness(1.15);
}
.rl-chip-on {
  position: absolute;
  right: 2px;
  bottom: 2px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 999px;
  background: #f5d76e;
  color: #111;
  font-size: 0.62rem;
  font-weight: 900;
  display: grid;
  place-items: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  pointer-events: none;
}

.rl-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}
.rl-btn {
  border: none;
  border-radius: 12px;
  padding: 11px 16px;
  font-weight: 800;
  cursor: pointer;
  min-height: 42px;
}
.rl-btn.ghost {
  background: rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.rl-btn.primary {
  background: linear-gradient(135deg, #f5d76e, #c9a227);
  color: #111;
}
.rl-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.rl-hint {
  text-align: center;
  margin: 0;
  font-size: 0.78rem;
  color: #94a3b8;
}

.rl-toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%) translateY(12px);
  background: rgba(0, 0, 0, 0.9);
  color: #fff;
  padding: 10px 16px;
  border-radius: 12px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: 0.25s;
  z-index: 50;
  max-width: 90vw;
  text-align: center;
}
.rl-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 960px) {
  .rl-main {
    grid-template-columns: 1fr;
    padding: 8px;
    gap: 8px;
  }
  .rl-wheel-panel {
    padding: 10px 8px 12px;
  }
  .rl-wheel-stage {
    width: min(72vw, 300px);
  }
  #wheelCanvas { transform: rotateX(18deg); }
  .rl-board {
    grid-template-columns: 36px repeat(12, minmax(22px, 1fr)) 36px;
    grid-template-rows: repeat(5, minmax(32px, 40px));
    gap: 2px;
  }
  .rl-cell { font-size: 0.72rem; border-radius: 4px; }
  .rl-cell.out { font-size: 0.58rem; }
  .rl-chip { width: 42px; height: 42px; font-size: 0.7rem; }
  .rl-brand strong { font-size: 0.78rem; }
  .rl-stats { gap: 8px; }
  .rl-stats strong { font-size: 0.88rem; }
}

@media (max-width: 420px) {
  .rl-board {
    grid-template-columns: 30px repeat(12, minmax(18px, 1fr)) 30px;
    grid-template-rows: repeat(5, 30px);
  }
  .rl-pill { font-size: 0.72rem; padding: 6px 8px; }
}
