:root {
  --primary-bg: #343a40;
  --game-bg: #000;
  --accent-red: #e60040;
  --accent-green: #22c55e;
  --text-white: #f8fafc;
  --text-gray: #94a3b8;
  --border-color: rgba(255, 255, 255, 0.07);
  --font-family: 'Inter', system-ui, sans-serif;
  --panel-bg: #343a40;
}

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

body {
  background: var(--primary-bg);
  color: var(--text-white);
  font-family: var(--font-family);
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Header ────────────────────────────────── */
header {
  height: 54px;
  background: #0d1a24;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 2px solid rgba(0, 0, 0, 0.4);
  flex-shrink: 0;
}

.back-btn {
  color: white;
  text-decoration: none;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.1);
  font-size: 14px;
  transition: all 0.2s;
}

.back-btn:active {
  transform: scale(0.9);
}

.logo-main {
  color: #fff;
  font-weight: 900;
  font-style: italic;
  font-size: 24px;
  letter-spacing: -1.5px;
  text-transform: uppercase;
}

.logo-main span {
  color: var(--accent-red);
}

.hdr-r {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  height: 100%;
}

.balance-badge {
  display: flex;
  align-items: center;
  background: rgba(20, 45, 62, 0.8);
  border: 1px solid rgba(34, 197, 94, 0.3);
  border-radius: 100px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  padding: 3px 3px 3px 14px;
  height: 38px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
  animation: balanceFloat 3s ease-in-out infinite;
  position: relative;
  transform: none;
  left: auto;
  top: auto;
}

.balance-badge:hover {
  background: rgba(34, 197, 94, 0.08);
  border-color: rgba(34, 197, 94, 0.6);
  transform: scale(1.04);
}

.wallet-pill-left {
  display: flex;
  align-items: center;
  padding-right: 10px;
}

.balance-badge .balance-amount {
  font-size: 16px;
  font-weight: 800;
  color: #22c55e;
}

.wallet-pill-right {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid rgba(34, 197, 94, 0.2);
  border-radius: 50%;
  width: 32px;
  height: 32px;
}

.wallet-rupee-coin {
  height: 18px;
  width: auto;
  animation: floatingCoin 3s ease-in-out infinite;
}

@keyframes floatingCoin {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-2px);
  }
}

/* ── History Bar ───────────────────────────── */
.history-bar {
  height: 30px;
  background: #000;
  display: flex;
  align-items: center;
  padding: 0 6px;
  gap: 5px;
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

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

.history-item {
  flex-shrink: 0;
  padding: 2px 9px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 900;
  color: #fff;
}

/* ≥2.00x = green, <2.00x = red — no other colours */
.history-item.low {
  background: #e60040;
}

.history-item.medium {
  background: #22c55e;
}

.history-item.high {
  background: #22c55e;
}

.history-item.mega {
  background: #22c55e;
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.5);
}

/* ── Main ──────────────────────────────────── */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 4px;
  gap: 4px;
}

/* ── Game Canvas ───────────────────────────── */
.game-container {
  flex-shrink: 0;
  width: 100%;
  aspect-ratio: 375 / 230;
  min-height: 180px;
  background: #000;
  border-radius: 12px;
  position: relative;
  overflow: hidden;
  border: 1px solid #1a1a1a;
  transform: translateZ(0);
  will-change: transform;
}

.bg-rotate-layer {
  display: none;
}

#game-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transform: translateZ(0);
  will-change: transform;
  z-index: 2;
}

/* ── Multiplier ────────────────────────────── */
.multiplier-display {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: clamp(28px, 8vw, 72px);
  font-weight: 950;
  color: #fff;
  z-index: 10;
  pointer-events: none;
  filter: drop-shadow(0 0 20px rgba(0, 0, 0, 1));
  white-space: nowrap;
  letter-spacing: -1px;
  transition: color 0.3s;
}

.multiplier-display.high-tension {
  animation: tension-pulse 0.4s infinite alternate;
  text-shadow: 0 0 20px rgba(255, 100, 0, 0.8);
}

@keyframes tension-pulse {
  from {
    transform: translate(-50%, -50%) scale(1);
  }

  to {
    transform: translate(-50%, -50%) scale(1.04);
  }
}

/* ── Crash Message ─────────────────────────── */
.crashed-message {
  position: absolute;
  top: 22%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--accent-red);
  font-size: clamp(14px, 4vw, 28px);
  font-weight: 950;
  line-height: 1.2;
  text-align: center;
  text-transform: uppercase;
  z-index: 11;
  display: none;
  background: rgba(0, 0, 0, 0.9);
  padding: 8px 22px;
  border-radius: 30px;
  box-shadow: 0 0 30px rgba(230, 0, 64, 0.6);
  border: 2px solid #e60040;
  animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  white-space: nowrap;
}

/* ── Cashout Center Popup ──────────────────── */
.cashout-popup {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 15;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #1c2127;
  /* Dark slate background matching reference */
  padding: 24px 48px;
  border-radius: 24px;
  /* Rounded square look */
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
  border: 6px solid #e60040;
  /* Thick red border */
  animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  white-space: nowrap;
}

.cashout-popup .c-multi {
  color: #e60040;
  /* Red multiplier */
  font-size: clamp(36px, 9vw, 68px);
  font-weight: 800;
  line-height: 1;
  text-shadow: none;
  margin-bottom: 12px;
  letter-spacing: -0.5px;
}

.cashout-popup .divider {
  width: 70%;
  height: 4px;
  background-color: #313742;
  margin-bottom: 12px;
  border-radius: 2px;
}

.cashout-popup .c-return-container {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cashout-popup .c-return {
  color: #e60040;
  /* Red return amount */
  font-size: clamp(20px, 5vw, 32px);
  font-weight: 800;
  letter-spacing: 0;
}

@keyframes popIn {
  0% {
    transform: translate(-50%, -50%) scale(0.5);
    opacity: 0;
  }

  60% {
    transform: translate(-50%, -50%) scale(1.1);
    opacity: 1;
  }

  100% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
}

/* ── Red Flash on Crash ────────────────────── */
.crash-flash {
  animation: crashFlash 0.5s ease-out forwards;
}

@keyframes crashFlash {
  0% {
    box-shadow: inset 0 0 0 0 rgba(230, 0, 64, 0);
  }

  20% {
    box-shadow: inset 0 0 0 40px rgba(230, 0, 64, 0.5);
  }

  100% {
    box-shadow: inset 0 0 0 0 rgba(230, 0, 64, 0);
  }
}

/* ── Canvas Shake on Crash ─────────────────── */
@keyframes canvasShake {

  0%,
  100% {
    transform: translate(0, 0);
  }

  15% {
    transform: translate(-5px, -4px);
  }

  30% {
    transform: translate(5px, 4px);
  }

  45% {
    transform: translate(-5px, 2px);
  }

  60% {
    transform: translate(4px, -4px);
  }

  75% {
    transform: translate(-3px, 3px);
  }
}

.shake-canvas {
  animation: canvasShake 0.4s ease-out both;
}

/* ── Live Activity Feed ────────────────────── */
.live-feed {
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  padding: 5px 8px;
  overflow: hidden;
  flex-shrink: 0;
  max-height: 34px;
  display: none;
}

.feed-header {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 9px;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 2px;
}

.feed-dot {
  width: 5px;
  height: 5px;
  background: #22c55e;
  border-radius: 50%;
  animation: blink 1.2s infinite;
}

@keyframes blink {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.2;
  }
}

.feed-scroll {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  scrollbar-width: none;
  white-space: nowrap;
  font-size: 10px;
  font-weight: 600;
  color: #94a3b8;
}

.feed-scroll::-webkit-scrollbar {
  display: none;
}

.feed-item {
  flex-shrink: 0;
}

.feed-item.win {
  color: #22c55e;
}

.feed-item.loss {
  color: #e60040;
}

/* ── Panels ────────────────────────────────── */
.panels-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
  padding: 8px;
}

/* ── Redesigned Bet Panel (v3 — Reference Match) ── */
.bet-panel-v2 {
  background: #1c1d1f;
  border-radius: 16px;
  padding: 10px 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

/* Bet Tab Pill */
.bet-tabs-v3 {
  display: flex;
  justify-content: center;
  display: none;
}

.bet-tab-v3 {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  padding: 4px 32px;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.3px;
}

.bet-controls-v2 {
  display: flex;
  gap: 12px;
}

.left-controls {
  flex: 0 0 auto;
  width: 200px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Numeric Input: [ - ] amount [ + ] */
.numeric-input-v3 {
  background: #000;
  border-radius: 30px;
  display: flex;
  align-items: center;
  height: 42px;
  border: 1.5px solid rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.num-btn-v3 {
  width: 48px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #2a2d30;
  border: none;
  color: #fff;
  font-size: 12px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s;
}

.num-btn-v3:active {
  background: #3d4145;
}

.num-btn-v3.sub {
  border-radius: 30px 0 0 30px;
}

.num-btn-v3.add {
  border-radius: 0 30px 30px 0;
}

.numeric-input-v3 input {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  width: 100%;
  text-align: center;
  outline: none;
  -moz-appearance: textfield;
}

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

/* Quick Chips — 2x2 compact grid */
.quick-chips-v3 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}

.quick-chips-v3 button {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #94a3b8;
  border-radius: 8px;
  padding: 5px 0;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}

.quick-chips-v3 button:active {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

/* Right controls — main action button */
.right-controls {
  flex: 1;
  display: flex;
}

.aviator-main-btn {
  width: 100%;
  border: none;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  min-height: 76px;
}

/* BET state — green */
.aviator-main-btn.bet {
  background: #28a745;
  border: 2px solid #34c759;
  color: #fff;
}

.aviator-main-btn.bet:active {
  background: #218838;
}

/* CANCEL state — red */
.aviator-main-btn.cancel {
  background: #d62d2d;
  border: 2px solid #e04444;
  color: #fff;
}

.aviator-main-btn.cancel:active {
  background: #b82323;
}

/* CASHOUT state — orange */
.aviator-main-btn.cashout {
  background: #e8960c;
  border: 2px solid #f0a622;
  color: #fff;
}

.aviator-main-btn.cashout:active {
  background: #cc8400;
}

.btn-primary-text {
  font-size: 22px;
  font-weight: 800;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  pointer-events: none;
}

.btn-sub-text {
  font-size: 15px;
  font-weight: 700;
  opacity: 0.95;
  pointer-events: none;
}

/* State texts inside the button */
.aviator-main-btn.bet #btn-text {
  font-size: 22px;
}

.aviator-main-btn.cancel #btn-text {
  font-size: 20px;
}

.aviator-main-btn.cashout #btn-text {
  font-size: 17px;
  text-transform: capitalize;
}

.aviator-main-btn.cashout #btn-subtext {
  font-size: 18px;
  font-weight: 800;
}

/* Grayscale disabled state */
.aviator-main-btn.grayscale {
  filter: grayscale(1) opacity(0.5);
  cursor: not-allowed;
}

/* ── Panel Footer ──────────────────────────── */
.panel-footer {
  display: flex;
  justify-content: space-between;
}

.footer-item {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.35);
  padding: 5px 12px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 700;
  color: #f1f5f9;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.footer-item img {
  width: 16px;
}

/* ── Stats Panel ───────────────────────────── */
.stats-panel {
  background: var(--panel-bg);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(255, 255, 255, 0.06);
  overflow: hidden;
  min-height: 200px;
}

.stats-header {
  padding: 9px;
  display: flex;
  justify-content: space-around;
  background: rgba(0, 0, 0, 0.3);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.stats-tab {
  color: #888;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.stats-tab.active {
  color: #fff;
  border-bottom: 2px solid var(--accent-red);
  padding-bottom: 3px;
}

.stats-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  background: #000;
}

.stat-row {
  display: grid;
  grid-template-columns: 2fr 1.2fr 1fr 1.5fr;
  padding: 8px 12px;
  font-size: 11px;
  background: rgba(40, 40, 45, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  align-items: center;
  margin-bottom: 5px;
  transition: all 0.2s;
}

.stat-row.my-bet {
  background: rgba(34, 197, 94, 0.1);
  border-color: rgba(34, 197, 94, 0.4);
  box-shadow: 0 0 10px rgba(34, 197, 94, 0.1);
}

.stat-row.my-bet .user-avatar {
  background: rgba(34, 197, 94, 0.2);
  color: #22c55e;
}

.user-identity {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: #fff;
}

.user-avatar {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: #ccc;
}

.mult-pill {
  background: rgba(0, 0, 0, 0.5);
  border-radius: 12px;
  padding: 2px 8px;
  display: inline-block;
  min-width: 40px;
}

/* ── Toast Notifications ───────────────────── */
.toast-container {
  position: absolute;
  top: 10px;
  left: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 20;
  pointer-events: none;
}

.fomo-toast {
  background: rgba(0, 0, 0, 0.88);
  border-left: 3px solid var(--accent-green);
  border-radius: 5px;
  padding: 6px 10px;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 6px;
  animation: slideInLeft 0.3s ease-out, fadeOut 0.5s ease-in 2.5s forwards;
}

.fomo-toast .toast-amt {
  color: var(--accent-green);
}

@keyframes slideInLeft {
  from {
    transform: translateX(-100%);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes fadeOut {
  to {
    opacity: 0;
    transform: translateY(-8px);
  }
}

/* ── Countdown ─────────────────────────────── */
.progress-bar-bg {
  width: 130px;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  margin: 0 auto;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: #e60040;
  width: 100%;
  transform-origin: left;
  box-shadow: 0 0 6px #e60040;
}

.loading-spin {
  width: 26px;
  height: 26px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-top: 2px solid #e60040;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 8px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── Shake ─────────────────────────────────── */
@keyframes shake {

  0%,
  100% {
    transform: translate(0, 0);
  }

  10%,
  30%,
  50%,
  70%,
  90% {
    transform: translate(-3px, -2px) rotate(-0.5deg);
  }

  20%,
  40%,
  60%,
  80% {
    transform: translate(3px, 2px) rotate(0.5deg);
  }
}

.shake-it {
  animation: shake 0.4s cubic-bezier(.36, .07, .19, .97) both;
}

/* ── Desktop ───────────────────────────────── */
@media (min-width: 1024px) {
  .game-container {
    aspect-ratio: 375/248;
    max-height: 350px;
  }

  main {
    flex-direction: row;
    padding: 16px;
    gap: 16px;
    overflow: hidden;
  }

  .game-container {
    flex: 3;
    height: 100%;
    min-height: unset;
    max-height: unset;
    aspect-ratio: unset;
  }

  .panels-container {
    flex: 1;
    height: 100%;
    overflow-y: auto;
  }

  .live-feed {
    display: none;
  }

  main>.game-container {
    border-radius: 16px;
  }

  .multiplier-display {
    font-size: clamp(36px, 7vw, 80px);
  }

  .main-bet-btn {
    height: 56px;
    font-size: 22px;
  }
}

@keyframes balanceFloat {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-3px);
  }
}


/* ── Global Loader ─────────────────────────── */
.global-loader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: #000;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  transition: opacity 0.5s ease;
}

.loader-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  width: 100%;
  max-width: 300px;
}

.loader-logo {
  width: 120px;
  height: 120px;
  animation: spin 3s linear infinite;
  filter: drop-shadow(0 0 15px rgba(230, 0, 64, 0.5));
}

.loader-text {
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 4px;
  opacity: 0.8;
  animation: pulse 1.5s ease-in-out infinite;
}

.loader-progress-container {
  width: 200px;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  overflow: hidden;
}

.loader-progress-bar {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #e60040, #ff4d79);
  box-shadow: 0 0 10px rgba(230, 0, 64, 0.8);
  transition: width 0.1s linear;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

@keyframes pulse {

  0%,
  100% {
    opacity: 0.4;
  }

  50% {
    opacity: 1;
  }
}