:root {
  --bg: #090d16;
  --bg-2: #141b2d;
  --panel: rgba(17, 24, 39, 0.9);
  --panel-2: rgba(26, 35, 56, 0.92);
  --border: rgba(148, 163, 184, 0.16);
  --text: #f8fafc;
  --muted: #94a3b8;
  --red: #dc2626;
  --red-2: #ef4444;
  --green: #22c55e;
  --yellow: #f59e0b;
  --shadow: 0 24px 60px rgba(2, 6, 23, 0.45);
  --radius: 24px;
  --font-body: "Archivo", sans-serif;
  --font-mono: "JetBrains Mono", monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(220, 38, 38, 0.18), transparent 26%),
    radial-gradient(circle at bottom right, rgba(245, 158, 11, 0.12), transparent 26%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
  color: var(--text);
  font-family: var(--font-body);
}

button,
input {
  font: inherit;
}

.ambient {
  position: fixed;
  z-index: 0;
  border-radius: 999px;
  filter: blur(80px);
  pointer-events: none;
}

.ambient-a {
  top: -40px;
  left: -60px;
  width: 240px;
  height: 240px;
  background: rgba(220, 38, 38, 0.18);
}

.ambient-b {
  right: -100px;
  bottom: 120px;
  width: 280px;
  height: 280px;
  background: rgba(245, 158, 11, 0.12);
}

.screen {
  display: none;
  position: relative;
  z-index: 1;
}

.screen-active {
  display: block;
}

#entryScreen.screen-active {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card,
.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.auth-card {
  width: min(100%, 460px);
  padding: 32px;
}

.auth-card h1,
.topbar h1,
.section-head h2 {
  font-weight: 800;
  line-height: 1;
}

.auth-card h1 {
  margin: 10px 0 12px;
  font-size: clamp(2rem, 5vw, 3rem);
}

.eyebrow,
.field-label,
.support-label,
.mono-label {
  color: var(--muted);
  font-size: 0.76rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.support-copy {
  color: var(--muted);
  line-height: 1.6;
}

.field-label {
  display: block;
  margin: 16px 0 8px;
  font-weight: 700;
}

.text-input {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--panel-2);
  color: var(--text);
  outline: none;
}

.text-input:focus {
  border-color: rgba(239, 68, 68, 0.5);
}

.auth-actions,
.hero-grid,
.topbar,
.topbar-right,
.section-head,
.bet-summary {
  display: grid;
  gap: 14px;
}

.auth-actions {
  grid-template-columns: 1fr;
  margin-top: 20px;
}

.auth-actions .btn {
  width: 100%;
}

.auth-switch-copy {
  margin-top: 14px;
  text-align: center;
}

.auth-switch-btn {
  margin: 4px auto 0;
  display: block;
  border: 0;
  background: transparent;
  color: #fca5a5;
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
}

.btn {
  border: 0;
  border-radius: 16px;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.btn:hover:not(:disabled),
.icon-btn:hover:not(:disabled),
.number-btn:hover:not(:disabled),
.amount-btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

.btn:disabled,
.number-btn:disabled,
.amount-btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.btn-primary {
  padding: 14px 18px;
  background: linear-gradient(180deg, var(--red-2), var(--red));
  color: #fff;
  font-weight: 700;
}

.btn-secondary {
  padding: 14px 18px;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-small {
  padding: 10px 14px;
}

.shell {
  max-width: 1100px;
  margin: 0 auto;
  padding: 22px 16px 28px;
}

.topbar {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  margin-bottom: 18px;
}

.topbar h1 {
  margin-top: 6px;
  font-size: clamp(1.8rem, 4vw, 2.8rem);
}

.topbar-right {
  grid-auto-flow: column;
  align-items: center;
}

.icon-btn {
  width: 46px;
  height: 46px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--panel-2);
}

.user-pill {
  display: grid;
  grid-template-columns: auto auto;
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--panel-2);
}

.user-pill p {
  color: var(--green);
  font-size: 0.95rem;
  font-weight: 700;
}

.avatar {
  width: 40px;
  height: 40px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(180deg, var(--red-2), #7f1d1d);
  color: #fff;
  font-weight: 800;
}

.hero-grid {
  grid-template-columns: 1.1fr 0.9fr;
  margin-bottom: 18px;
}

.panel {
  padding: 22px;
}

.section-head {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  margin-bottom: 16px;
}

.timer-label {
  margin-bottom: 10px;
  color: var(--muted);
  font-family: var(--font-mono);
}

.timer-track {
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.timer-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--yellow), var(--red-2));
  transition: width 0.25s linear;
}

.result-box {
  margin-top: 18px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 16px;
  align-items: center;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.04);
  transition: border-color 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
}

.result-ball {
  width: 84px;
  height: 84px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(180deg, var(--red-2), #7f1d1d);
  color: #fff;
  font-size: 2rem;
  font-weight: 800;
  box-shadow: 0 8px 20px rgba(220, 38, 38, 0.35);
  transition: transform 0.22s ease, box-shadow 0.22s ease, filter 0.22s ease;
}

.result-box.phase-betting {
  border-color: rgba(34, 197, 94, 0.35);
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.1), rgba(255, 255, 255, 0.04));
}

.result-box.phase-betting .result-ball {
  animation: orbPulse 1.8s ease-in-out infinite;
}

.result-box.phase-closed {
  border-color: rgba(245, 158, 11, 0.45);
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.12), rgba(255, 255, 255, 0.04));
}

.result-box.phase-closed .result-ball {
  animation: orbPulseFast 0.95s ease-in-out infinite;
}

.result-box.phase-reveal {
  border-color: rgba(239, 68, 68, 0.55);
  box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.2), 0 18px 35px rgba(239, 68, 68, 0.15);
}

.result-box.phase-reveal .result-ball {
  filter: saturate(1.25);
}

.result-box.fx-reveal .result-ball {
  animation: revealPop 0.8s ease;
}

.result-box.fx-win {
  animation: winFlash 1.2s ease;
}

.result-box.fx-win .result-ball {
  background: linear-gradient(180deg, #22c55e, #15803d);
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.18), 0 14px 30px rgba(34, 197, 94, 0.4);
  animation: revealPop 0.8s ease;
}

.result-box.fx-loss {
  animation: lossShake 0.42s ease;
}

.result-box.fx-loss .result-ball {
  background: linear-gradient(180deg, #f97316, #c2410c);
}

.result-box h3 {
  font-size: 1.35rem;
  margin-bottom: 6px;
}

.hash-box {
  margin-top: 16px;
  display: grid;
  gap: 8px;
}

.hash-box span {
  color: var(--muted);
  font-size: 0.85rem;
}

.hash-value {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--panel-2);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
}

.numbers-grid,
.amount-row {
  display: grid;
  gap: 12px;
}

.numbers-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.amount-row {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 18px 0;
}

.number-btn,
.amount-btn {
  padding: 18px 10px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--panel-2);
  color: var(--text);
  font-weight: 700;
}

.number-btn.selected,
.amount-btn.selected {
  border-color: rgba(239, 68, 68, 0.55);
  background: rgba(239, 68, 68, 0.16);
}

.bet-summary {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 18px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
}

.history-list {
  display: grid;
  gap: 10px;
}

.history-item,
.empty-state {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
}

.history-item {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}

.history-ball {
  width: 56px;
  height: 56px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(180deg, var(--yellow), #b45309);
  color: #111827;
  font-weight: 800;
}

.history-title {
  font-weight: 700;
  margin-bottom: 4px;
}

.history-meta {
  color: var(--muted);
  font-size: 0.95rem;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  z-index: 30;
  min-width: min(92vw, 360px);
  padding: 14px 16px;
  border-radius: 14px;
  background: #020617;
  color: #fff;
  text-align: center;
  opacity: 0;
  transform: translateX(-50%) translateY(14px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@keyframes orbPulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

@keyframes orbPulseFast {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.08);
  }
}

@keyframes revealPop {
  0% {
    transform: scale(0.82) rotate(-8deg);
  }
  65% {
    transform: scale(1.14) rotate(4deg);
  }
  100% {
    transform: scale(1) rotate(0);
  }
}

@keyframes winFlash {
  0% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
  }
  35% {
    box-shadow: 0 0 0 8px rgba(34, 197, 94, 0.2), 0 20px 40px rgba(34, 197, 94, 0.28);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
  }
}

@keyframes lossShake {
  0% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-6px);
  }
  50% {
    transform: translateX(6px);
  }
  75% {
    transform: translateX(-4px);
  }
  100% {
    transform: translateX(0);
  }
}

@media (max-width: 900px) {
  .hero-grid,
  .topbar,
  .topbar-right,
  .section-head,
  .bet-summary {
    grid-template-columns: 1fr;
  }

  .topbar-right {
    grid-auto-flow: row;
    justify-items: start;
  }

  .numbers-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .amount-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
