:root {
  --bg-deep: #060412;
  --bg-panel: rgba(15, 11, 36, 0.84);
  --bg-card: rgba(21, 16, 48, 0.92);
  --border-glow: rgba(139, 92, 246, 0.28);
  --border-cyan: rgba(34, 211, 238, 0.35);
  --purple: #a855f7;
  --purple-dark: #7c3aed;
  --cyan: #22d3ee;
  --cyan-dark: #0891b2;
  --emerald: #10b981;
  --emerald-bright: #34d399;
  --rose: #f43f5e;
  --amber: #f59e0b;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  background: radial-gradient(circle at 20% 0%, #1a0f3e 0%, #09061b 45%, #05030e 100%);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  overflow-x: hidden;
}

.hidden {
  display: none !important;
}

.app-shell {
  min-height: 100dvh;
  max-width: 1320px;
  margin: 0 auto;
  padding: 8px 10px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Top Header */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-panel);
  border: 1px solid var(--border-glow);
  border-radius: var(--radius-md);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-icon {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.16), rgba(168, 85, 247, 0.26));
  border: 1px solid rgba(168, 85, 247, 0.45);
  display: grid;
  place-items: center;
  box-shadow: 0 0 16px rgba(168, 85, 247, 0.35);
}

.brand-text {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.brand-name {
  font-size: 1.15rem;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.brand-name .accent {
  background: linear-gradient(90deg, var(--cyan), var(--purple));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.brand-tag {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--cyan);
  background: rgba(34, 211, 238, 0.12);
  border: 1px solid rgba(34, 211, 238, 0.3);
  padding: 2px 6px;
  border-radius: 999px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.conn-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 8px var(--amber);
}

.conn-dot.online {
  background: var(--emerald-bright);
  box-shadow: 0 0 10px var(--emerald-bright);
}

.conn-dot.offline {
  background: var(--rose);
  box-shadow: 0 0 10px var(--rose);
}

.balance-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(10, 8, 28, 0.9);
  border: 1px solid var(--border-cyan);
  box-shadow: inset 0 0 12px rgba(34, 211, 238, 0.12);
}

.currency-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--cyan);
  letter-spacing: 0.04em;
}

.balance-value {
  font-size: 0.95rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: #fff;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--border-glow);
  background: rgba(25, 18, 56, 0.8);
  color: var(--text-main);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s;
}

.icon-btn:hover {
  border-color: var(--cyan);
}

.icon-btn:active {
  transform: scale(0.94);
}

/* History Bar */
.history-bar {
  background: var(--bg-panel);
  border: 1px solid var(--border-glow);
  border-radius: var(--radius-md);
  padding: 6px 8px;
  overflow: hidden;
}

.history-track {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}

.history-track::-webkit-scrollbar {
  display: none;
}

.hist-pill {
  flex: 0 0 auto;
  font-size: 0.75rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
  letter-spacing: 0.02em;
}

.hist-pill.low {
  color: #fda4af;
  background: rgba(244, 63, 94, 0.16);
  border-color: rgba(244, 63, 94, 0.35);
}

.hist-pill.mid {
  color: #67e8f9;
  background: rgba(34, 211, 238, 0.14);
  border-color: rgba(34, 211, 238, 0.35);
}

.hist-pill.high {
  color: #d8b4fe;
  background: rgba(168, 85, 247, 0.2);
  border-color: rgba(168, 85, 247, 0.45);
}

.hist-pill.mega {
  color: #fde68a;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.25), rgba(168, 85, 247, 0.3));
  border-color: rgba(245, 158, 11, 0.6);
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.25);
}

/* Main Grid */
.main-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  flex: 1;
}

@media (min-width: 960px) {
  .main-grid {
    grid-template-columns: minmax(0, 1fr) 330px;
    align-items: start;
  }
}

.play-column {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Flight Arena Canvas Card */
.arena-card {
  position: relative;
  width: 100%;
  height: clamp(250px, 42dvh, 420px);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #060314;
  border: 1px solid rgba(139, 92, 246, 0.4);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55), inset 0 0 40px rgba(124, 58, 237, 0.14);
}

.arena-card.crashed {
  border-color: rgba(244, 63, 94, 0.7);
  box-shadow: 0 12px 40px rgba(244, 63, 94, 0.22), inset 0 0 50px rgba(244, 63, 94, 0.2);
}

#spaceCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

.arena-hud {
  position: absolute;
  top: 10px;
  left: 12px;
  right: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
  z-index: 3;
}

.round-chip, .live-players-chip {
  font-size: 0.72rem;
  font-weight: 700;
  color: rgba(226, 232, 240, 0.85);
  background: rgba(10, 7, 28, 0.65);
  border: 1px solid rgba(148, 163, 184, 0.22);
  padding: 4px 9px;
  border-radius: 999px;
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  gap: 5px;
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 8px var(--cyan);
  animation: pulse 1.6s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.8); }
}

.center-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 4;
  padding: 16px;
  text-align: center;
}

.status-badge {
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  padding: 4px 12px;
  border-radius: 999px;
  margin-bottom: 6px;
  background: rgba(34, 211, 238, 0.15);
  border: 1px solid rgba(34, 211, 238, 0.4);
  color: var(--cyan);
}

.status-badge.flying {
  background: rgba(168, 85, 247, 0.18);
  border-color: rgba(168, 85, 247, 0.45);
  color: #e9d5ff;
}

.status-badge.crashed {
  background: rgba(244, 63, 94, 0.22);
  border-color: rgba(244, 63, 94, 0.65);
  color: #fda4af;
}

.multiplier-display {
  font-size: clamp(2.6rem, 10vw, 4.8rem);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  letter-spacing: -0.02em;
  color: #fff;
  text-shadow: 0 0 28px rgba(34, 211, 238, 0.55), 0 0 60px rgba(168, 85, 247, 0.35);
  transition: color 0.15s, text-shadow 0.15s;
}

.multiplier-display.high {
  color: #e9d5ff;
  text-shadow: 0 0 32px rgba(168, 85, 247, 0.85), 0 0 70px rgba(34, 211, 238, 0.45);
}

.multiplier-display.mega {
  color: #fde68a;
  text-shadow: 0 0 36px rgba(245, 158, 11, 0.9), 0 0 75px rgba(168, 85, 247, 0.6);
}

.multiplier-display.crashed {
  color: #fb7185;
  text-shadow: 0 0 34px rgba(244, 63, 94, 0.9);
}

.countdown-wrap {
  margin-top: 12px;
  width: min(240px, 72%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.countdown-bar {
  width: 100%;
  height: 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
  border: 1px solid rgba(34, 211, 238, 0.25);
}

.countdown-fill {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--cyan), var(--purple));
  box-shadow: 0 0 12px var(--cyan);
  transition: width 0.08s linear;
}

.countdown-text {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* Toasts */
.toast-stack {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  z-index: 6;
  pointer-events: none;
  width: 90%;
}

.toast {
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 800;
  backdrop-filter: blur(10px);
  animation: toastIn 0.22s ease-out;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toast.win {
  background: rgba(16, 185, 129, 0.25);
  border: 1px solid rgba(52, 211, 153, 0.75);
  color: #a7f3d0;
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.35);
}

.toast.error {
  background: rgba(244, 63, 94, 0.25);
  border: 1px solid rgba(251, 113, 133, 0.75);
  color: #fecdd3;
}

.toast.info {
  background: rgba(34, 211, 238, 0.2);
  border: 1px solid rgba(34, 211, 238, 0.55);
  color: #cffafe;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Dual Bet Panels */
.bet-panels {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

@media (min-width: 640px) {
  .bet-panels {
    grid-template-columns: 1fr 1fr;
  }
}

.bet-card {
  background: var(--bg-card);
  border: 1px solid var(--border-glow);
  border-radius: var(--radius-lg);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.bet-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.panel-title {
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: var(--cyan);
}

.auto-switches {
  display: flex;
  align-items: center;
  gap: 6px;
}

.toggle-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  background: rgba(9, 7, 26, 0.8);
  border: 1px solid rgba(148, 163, 184, 0.22);
  padding: 4px 8px;
  border-radius: 999px;
  cursor: pointer;
  user-select: none;
  transition: border-color 0.2s, color 0.2s;
}

.toggle-chip input {
  accent-color: var(--purple);
  width: 13px;
  height: 13px;
  cursor: pointer;
}

.toggle-chip:has(input:checked) {
  color: #e9d5ff;
  border-color: var(--purple);
  background: rgba(168, 85, 247, 0.16);
}

.bet-controls-row {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 8px;
}

.input-group {
  display: flex;
  align-items: center;
  background: rgba(7, 5, 20, 0.9);
  border: 1px solid rgba(139, 92, 246, 0.3);
  border-radius: var(--radius-sm);
  overflow: hidden;
  height: 38px;
}

.input-group:focus-within {
  border-color: var(--cyan);
  box-shadow: 0 0 0 2px rgba(34, 211, 238, 0.16);
}

.input-group input {
  width: 100%;
  min-width: 0;
  background: transparent;
  border: none;
  color: #fff;
  text-align: center;
  font-size: 0.92rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  outline: none;
}

.input-group input::-webkit-outer-spin-button,
.input-group input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.step-btn {
  height: 100%;
  padding: 0 10px;
  background: rgba(139, 92, 246, 0.14);
  border: none;
  color: #ddd6fe;
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.15s;
}

.step-btn:hover {
  background: rgba(139, 92, 246, 0.3);
}

.input-prefix, .input-suffix {
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--text-muted);
  padding: 0 7px;
  user-select: none;
}

.autocash-group.disabled {
  opacity: 0.45;
}

.preset-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.preset-btn {
  height: 30px;
  border-radius: 7px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(15, 11, 38, 0.85);
  color: #cbd5e1;
  font-size: 0.76rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: all 0.15s;
}

.preset-btn:hover {
  border-color: var(--cyan);
  color: #fff;
  background: rgba(34, 211, 238, 0.12);
}

.preset-btn:active {
  transform: scale(0.96);
}

.action-btn {
  width: 100%;
  min-height: 54px;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: #fff;
  transition: transform 0.12s, box-shadow 0.2s, filter 0.15s;
  user-select: none;
}

.action-btn:active:not(:disabled) {
  transform: scale(0.98);
}

.action-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.action-btn .btn-main {
  font-size: 1rem;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.action-btn .btn-sub {
  font-size: 0.75rem;
  font-weight: 700;
  opacity: 0.9;
  font-variant-numeric: tabular-nums;
}

.action-btn.state-bet {
  background: linear-gradient(135deg, #06b6d4 0%, #8b5cf6 100%);
  box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4);
}

.action-btn.state-bet:hover:not(:disabled) {
  filter: brightness(1.08);
}

.action-btn.state-cancel {
  background: linear-gradient(135deg, #e11d48 0%, #be123c 100%);
  box-shadow: 0 6px 20px rgba(244, 63, 94, 0.35);
}

.action-btn.state-cashout {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  box-shadow: 0 6px 24px rgba(16, 185, 129, 0.5);
  animation: cashPulse 1.1s infinite ease-in-out;
}

@keyframes cashPulse {
  0%, 100% { box-shadow: 0 6px 22px rgba(16, 185, 129, 0.45); }
  50% { box-shadow: 0 6px 32px rgba(52, 211, 153, 0.8); }
}

.action-btn.state-queued {
  background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
  box-shadow: 0 6px 18px rgba(245, 158, 11, 0.32);
}

.action-btn.state-won {
  background: rgba(16, 185, 129, 0.2);
  border: 1px solid rgba(52, 211, 153, 0.6);
  color: #a7f3d0;
}

/* Live Feed & My History Card */
.feed-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-glow);
  border-radius: var(--radius-lg);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 540px;
}

@media (min-width: 960px) {
  .feed-card {
    height: calc(clamp(250px, 42dvh, 420px) + 196px);
    max-height: 680px;
  }
}

.feed-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: rgba(8, 5, 24, 0.85);
  padding: 4px;
  border-radius: 10px;
}

.feed-tab {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 800;
  padding: 7px 8px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s;
}

.feed-tab.active {
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.2), rgba(168, 85, 247, 0.28));
  color: #fff;
  border: 1px solid rgba(168, 85, 247, 0.4);
}

.tab-count {
  font-size: 0.68rem;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(34, 211, 238, 0.2);
  color: var(--cyan);
}

.feed-header-row {
  display: grid;
  grid-template-columns: 1.3fr 0.85fr 0.75fr 0.9fr;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 0 8px;
}

.feed-header-row span:nth-child(n+2) {
  text-align: right;
}

.feed-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  overflow-y: auto;
  flex: 1;
  padding-right: 2px;
}

.feed-list::-webkit-scrollbar {
  width: 4px;
}

.feed-list::-webkit-scrollbar-thumb {
  background: rgba(139, 92, 246, 0.35);
  border-radius: 999px;
}

.feed-row {
  display: grid;
  grid-template-columns: 1.3fr 0.85fr 0.75fr 0.9fr;
  align-items: center;
  padding: 7px 8px;
  border-radius: 9px;
  background: rgba(17, 13, 40, 0.75);
  border: 1px solid rgba(148, 163, 184, 0.1);
  font-size: 0.76rem;
  font-variant-numeric: tabular-nums;
}

.feed-row.is-me {
  border-color: rgba(34, 211, 238, 0.45);
  background: rgba(34, 211, 238, 0.1);
}

.feed-row.cashed {
  border-color: rgba(16, 185, 129, 0.42);
  background: rgba(16, 185, 129, 0.12);
}

.feed-row.lost {
  border-color: rgba(244, 63, 94, 0.3);
  background: rgba(244, 63, 94, 0.08);
}

.feed-user {
  font-weight: 700;
  color: #e2e8f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.feed-bet, .feed-mult, .feed-win {
  text-align: right;
  font-weight: 700;
}

.feed-mult.won {
  color: var(--cyan);
}

.feed-win.won {
  color: var(--emerald-bright);
}

.feed-win.lost {
  color: #fda4af;
}

.empty-feed {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 28px 12px;
}
