/* =============================================
   DRAZE Aviator — Responsive Mobile-First CSS
   ============================================= */

/* ── CSS Custom Properties ─────────────────── */
: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;

  /* Safe-area insets for iPhone notch / home bar */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);

  /* Fluid spacing tokens */
  --gap-xs: clamp(3px, 0.8vw, 6px);
  --gap-sm: clamp(5px, 1.2vw, 10px);
  --gap-md: clamp(8px, 1.8vw, 16px);
  --gap-lg: clamp(12px, 2.5vw, 24px);

  /* Fluid typography */
  --text-xs:   clamp(9px,  2vw, 11px);
  --text-sm:   clamp(11px, 2.5vw, 13px);
  --text-base: clamp(13px, 3vw,  15px);
  --text-lg:   clamp(15px, 3.5vw, 18px);
  --text-xl:   clamp(17px, 4vw,  22px);
  --text-2xl:  clamp(20px, 5vw,  28px);
}

/* ── Global Reset ──────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

html {
  /* Prevent font inflation on Android */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* Prevent horizontal overflow globally */
  overflow-x: hidden;
}

body {
  background: var(--primary-bg);
  color: var(--text-white);
  font-family: var(--font-family);
  /* Use dynamic viewport height so address bar doesn't cut content */
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* Apply safe-area padding for iPhone */
  padding-top: var(--safe-top);
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
  /* Hardware-accelerate composited layers */
  -webkit-overflow-scrolling: touch;
}

/* ── Header ────────────────────────────────── */
header {
  /* Fluid height: 48px on phones, 56px on desktop */
  height: clamp(48px, 6vh, 56px);
  background: #0d1a24;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(10px, 3vw, 20px);
  border-bottom: 2px solid rgba(0, 0, 0, 0.4);
  flex-shrink: 0;
  /* Prevent children from overflowing */
  min-width: 0;
  width: 100%;
}

.back-btn {
  color: white;
  text-decoration: none;
  /* Bigger tap target (44×44 minimum) */
  width: clamp(36px, 9vw, 44px);
  height: clamp(36px, 9vw, 44px);
  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: clamp(12px, 3vw, 14px);
  transition: background 0.2s;
  flex-shrink: 0;
}

.back-btn:active {
  background: rgba(255, 255, 255, 0.12);
  transform: scale(0.9);
}

.logo-main {
  color: #fff;
  font-weight: 900;
  font-style: italic;
  font-size: clamp(18px, 5vw, 24px);
  letter-spacing: -1px;
  text-transform: uppercase;
  white-space: nowrap;
}

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

.hdr-r {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  height: 100%;
  flex-shrink: 0;
  min-width: 0;
}

/* ── Balance Badge ─────────────────────────── */
.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);
  /* Fluid padding so it never overflows */
  padding: 3px 3px 3px clamp(8px, 2.5vw, 14px);
  height: clamp(34px, 5.5vh, 40px);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
  animation: balanceFloat 3s ease-in-out infinite;
  /* Remove old absolute positioning remnants */
  position: relative;
  transform: none;
  left: auto;
  top: auto;
  /* Prevent badge from overflowing header */
  max-width: clamp(100px, 40vw, 180px);
  min-width: 0;
  overflow: hidden;
}

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

.balance-badge:active {
  transform: scale(0.97);
}

.wallet-pill-left {
  display: flex;
  align-items: center;
  padding-right: 8px;
  min-width: 0;
  overflow: hidden;
}

.balance-badge .balance-amount {
  font-size: clamp(12px, 3.5vw, 16px);
  font-weight: 800;
  color: #22c55e;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.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%;
  /* Fluid coin circle size */
  width: clamp(26px, 6vw, 34px);
  height: clamp(26px, 6vw, 34px);
  flex-shrink: 0;
}

.wallet-rupee-coin {
  height: clamp(14px, 3.5vw, 20px);
  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;
  overflow-y: hidden;
  scrollbar-width: none;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  /* Smooth momentum scrolling on iOS */
  -webkit-overflow-scrolling: touch;
  /* Prevent layout-breaking horizontal scroll on page */
  max-width: 100%;
}

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

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

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

/* ── Main layout ───────────────────────────── */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  padding: clamp(3px, 1vw, 6px);
  gap: clamp(3px, 1vw, 6px);
  /* Smooth iOS scrolling */
  -webkit-overflow-scrolling: touch;
  /* Keep content inside safe area on bottom */
  padding-bottom: calc(var(--safe-bottom) + clamp(3px, 1vw, 6px));
  /* Prevent any child from causing horizontal scroll */
  width: 100%;
  max-width: 100%;
}

/* ── Game Canvas Container ─────────────────── */
.game-container {
  flex-shrink: 0;
  width: 100%;
  /* Fluid aspect ratio — taller on tiny phones */
  aspect-ratio: 375 / 230;
  /* Minimum so it's always visible */
  min-height: clamp(160px, 35vw, 220px);
  background: #000;
  border-radius: 12px;
  position: relative;
  overflow: hidden;
  border: 1px solid #1a1a1a;
  /*
   * ANDROID FIX: Do NOT put will-change or transform on the container.
   * Doing so creates a separate compositor layer that COMPETES with the
   * canvas's own layer, causing tearing and repaint glitches on Android Chrome.
   * Instead we let the canvas promote its own layer via isolation below.
   *
   * contain:strict tells the browser this element has fixed paint bounds —
   * preventing the parent scroll container from triggering full-page repaints.
   */
  contain: strict;
  isolation: isolate;
}

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

/* Canvas fills its container exactly */
#game-canvas {
  position: absolute;
  top: 0;
  left: 0;
  /*
   * CSS size = container size.
   * Physical pixel size is set by JS (canvas.width/height = cssSize * dpr).
   * ANDROID FIX: Do NOT set both transform:translateZ(0) AND will-change:transform
   * on the canvas — this creates a redundant layer that causes double-buffering
   * flicker on Android Chrome. One promotion hint is enough.
   */
  width: 100%;
  height: 100%;
  display: block;
  /* Single GPU layer promotion — translateZ is the most compatible hint */
  transform: translateZ(0);
  z-index: 2;
  /* Prevent canvas from being affected by parent border-radius repaints */
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

/* ── Multiplier Display ────────────────────── */
.multiplier-display {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: clamp(28px, 10vw, 72px);
  font-weight: 950;
  color: #fff;
  z-index: 10;
  pointer-events: none;
  /*
   * ANDROID FIX: filter:drop-shadow() triggers a software rasterisation pass
   * on Android Chrome. This runs on the CPU, not GPU, causing frame drops
   * that appear as the multiplier number flickering. Use text-shadow instead —
   * it is GPU-accelerated on Android.
   */
  text-shadow: 0 0 20px rgba(0, 0, 0, 0.9), 0 2px 4px rgba(0, 0, 0, 0.8);
  white-space: nowrap;
  letter-spacing: -1px;
  transition: color 0.3s;
  /* Own compositor layer so text updates don't repaint the canvas */
  will-change: contents;
}

.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(13px, 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: clamp(6px, 1.5vw, 10px) clamp(14px, 4vw, 24px);
  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;
  padding: clamp(14px, 4vw, 24px) clamp(24px, 7vw, 48px);
  border-radius: 24px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
  border: 6px solid #e60040;
  animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  white-space: nowrap;
  max-width: 90%;
}

.cashout-popup .c-multi {
  color: #e60040;
  font-size: clamp(28px, 9vw, 68px);
  font-weight: 800;
  line-height: 1;
  margin-bottom: 10px;
  letter-spacing: -0.5px;
}

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

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

.cashout-popup .c-return {
  color: #e60040;
  font-size: clamp(16px, 5vw, 32px);
  font-weight: 800;
}

@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; }
}

/* ── Crash Flash ───────────────────────────── */
.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 ──────────────────────────── */
@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;
}

/* ── Countdown Overlay ─────────────────────── */
#countdown-overlay {
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: rgba(255, 255, 255, 0.8);
  font-size: clamp(18px, 5vw, 24px);
  font-weight: 900;
  z-index: 12;
  display: none;
  text-align: center;
  width: 100%;
  padding: 0 16px;
}

#countdown-overlay .cd-wait-label {
  font-size: clamp(9px, 2.2vw, 11px);
  opacity: 0.8;
  margin-bottom: 4px;
  letter-spacing: 2px;
  color: #e60040;
  white-space: nowrap;
}

#countdown-overlay .cd-players {
  font-size: clamp(9px, 2vw, 10px);
  color: #22c55e;
  font-weight: 800;
  margin-bottom: 6px;
  letter-spacing: 1px;
}

/* ── 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: var(--text-xs);
  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: var(--text-xs);
  font-weight: 600;
  color: #94a3b8;
  -webkit-overflow-scrolling: touch;
}

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

.feed-item         { flex-shrink: 0; }
.feed-item.win     { color: #22c55e; }
.feed-item.loss    { color: #e60040; }

/* ── Panels Container ──────────────────────── */
.panels-container {
  display: flex;
  flex-direction: column;
  gap: var(--gap-sm);
  flex-shrink: 0;
  /* Use padding instead of margins to keep content inside viewport */
  padding: clamp(4px, 1.5vw, 10px);
  width: 100%;
  max-width: 100%;
}

/* ── Bet Panel ─────────────────────────────── */
.bet-panel-v2 {
  background: #1c1d1f;
  border-radius: 16px;
  padding: clamp(8px, 2vw, 12px) clamp(10px, 2.5vw, 14px) clamp(10px, 2.5vw, 14px);
  display: flex;
  flex-direction: column;
  gap: var(--gap-sm);
  border: 1px solid rgba(255, 255, 255, 0.06);
  transition: all 0.2s ease;
  width: 100%;
  /* Prevent panel from exceeding screen width */
  max-width: 100%;
  min-width: 0;
}

.bet-panel-v2.state-cashout {
  border: 1px solid #f0a622;
  box-shadow: 0 0 12px rgba(240, 166, 34, 0.25);
}

.bet-panel-v2.state-cancel {
  border: 1px solid #e04444;
  box-shadow: 0 0 12px rgba(224, 68, 68, 0.25);
}

/* ── Bet Controls Row ──────────────────────── */
.bet-controls-v2 {
  display: flex;
  gap: var(--gap-sm);
  align-items: stretch;
  width: 100%;
  min-width: 0;
}

/* Left side: input + quick chips — fills remaining space */
.left-controls {
  /* Let it grow/shrink naturally, remove fixed width */
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--gap-xs);
}

/* ── Numeric Input ─────────────────────────── */
.numeric-input-v3 {
  background: #000;
  border-radius: 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  /* Fluid height */
  height: clamp(38px, 7vw, 46px);
  border: 1.5px solid rgba(255, 255, 255, 0.1);
  padding: 0 6px;
  width: 100%;
}

.numeric-input-v3 input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  color: #fff;
  font-size: clamp(15px, 4vw, 20px);
  font-weight: 800;
  text-align: center;
  outline: none;
  -moz-appearance: textfield;
  /* Prevent iOS zoom on input focus */
  font-size: max(16px, clamp(15px, 4vw, 20px));
}

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

/* +/- buttons — bigger tap targets */
.num-btn-v3 {
  width: clamp(28px, 7vw, 34px);
  height: clamp(28px, 7vw, 34px);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #666;
  border: none;
  color: #000;
  font-size: clamp(16px, 4.5vw, 22px);
  font-weight: 900;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s;
  /* Ensure minimum tap target */
  min-width: 28px;
  min-height: 28px;
}

.num-btn-v3:active {
  background: #888;
  transform: scale(0.92);
}

/* ── Quick Chips — 2×2 grid ────────────────── */
.quick-chips-v3 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(3px, 1vw, 6px);
  width: 100%;
}

.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: clamp(5px, 1.5vw, 8px) 0;
  font-size: clamp(10px, 2.8vw, 13px);
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  /* Minimum tap target */
  min-height: 32px;
  width: 100%;
}

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

/* ── Action Button (Bet / Cancel / Cashout) ── */
.right-controls {
  /* Fixed width on mobile, grows on larger screens */
  flex: 0 0 clamp(80px, 26vw, 120px);
  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);
  /* Fluid height to match controls */
  min-height: clamp(70px, 18vw, 92px);
  /* Hardware accelerate for smooth press animation */
  transform: translateZ(0);
  will-change: transform;
}

.aviator-main-btn.bet {
  background: #28a745;
  border: 2px solid #34c759;
  color: #fff;
}

.aviator-main-btn.bet:active    { background: #218838; transform: scale(0.97); }

.aviator-main-btn.cancel {
  background: #d62d2d;
  border: 2px solid #e04444;
  color: #fff;
}

.aviator-main-btn.cancel:active { background: #b82323; transform: scale(0.97); }

.aviator-main-btn.cashout {
  background: #e8960c;
  border: 2px solid #f0a622;
  color: #fff;
}

.aviator-main-btn.cashout:active { background: #cc8400; transform: scale(0.97); }

.aviator-main-btn.grayscale {
  filter: grayscale(1) opacity(0.5);
  cursor: not-allowed;
}

/* ── Button Text Labels ────────────────────── */
.btn-primary-text {
  font-size: clamp(16px, 5vw, 22px);
  font-weight: 800;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  pointer-events: none;
  line-height: 1;
}

.btn-sub-text {
  font-size: clamp(11px, 3.5vw, 15px);
  font-weight: 700;
  opacity: 0.95;
  pointer-events: none;
  line-height: 1;
}

/* Bet state text sizes */
.aviator-main-btn.bet .btn-primary-text     { font-size: clamp(16px, 5vw, 22px); }
.aviator-main-btn.cancel .btn-primary-text  { font-size: clamp(14px, 4.5vw, 20px); }
.aviator-main-btn.cashout .btn-primary-text { font-size: clamp(12px, 3.5vw, 17px); text-transform: capitalize; }
.aviator-main-btn.cashout .btn-sub-text     { font-size: clamp(13px, 4vw, 18px); font-weight: 800; }

/* ── Bet Tab Pills ─────────────────────────── */
.bet-tabs-v3 {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.toggle-panel-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  border-radius: 50%;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}
.toggle-panel-btn.add { border-color: rgba(34,197,94,0.4); color: #22c55e; }
.toggle-panel-btn.sub { border-color: rgba(230,0,64,0.4); color: #e60040; }

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

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

.footer-item {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.35);
  padding: 5px 12px;
  border-radius: 7px;
  font-size: var(--text-xs);
  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: 180px;
}

.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: clamp(10px, 2.8vw, 12px);
  font-weight: 800;
  cursor: pointer;
  padding: 4px 12px;
  /* Bigger tap target */
  min-height: 32px;
  display: flex;
  align-items: center;
}

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

.stats-list {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 6px;
  background: #000;
  -webkit-overflow-scrolling: touch;
}

/* ── Stat Row — responsive grid ────────────── */
.stat-row {
  display: grid;
  /* Responsive column sizing: shrink on small screens */
  grid-template-columns: 2fr 1.2fr 1fr 1.5fr;
  padding: clamp(6px, 1.5vw, 8px) clamp(8px, 2vw, 12px);
  font-size: clamp(9px, 2.5vw, 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: 4px;
  transition: all 0.2s;
  /* Prevent overflow */
  min-width: 0;
  word-break: break-all;
}

.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: 6px;
  font-weight: 700;
  color: #fff;
  min-width: 0;
  overflow: hidden;
}

.user-identity > div:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.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;
  flex-shrink: 0;
}

.mult-pill {
  background: rgba(0, 0, 0, 0.5);
  border-radius: 12px;
  padding: 2px 6px;
  display: inline-block;
  min-width: 36px;
  text-align: center;
}

/* ── Toast Notifications ───────────────────── */
.toast-container {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 20;
  pointer-events: none;
  /* Limit width on wide screens */
  max-width: 280px;
}

.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: clamp(10px, 2.5vw, 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;
  /* GPU accelerate toast animation */
  will-change: transform, opacity;
}

.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: clamp(100px, 35vw, 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); }
}

/* ── Animations ────────────────────────────── */
@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; }

@keyframes balanceFloat {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-3px); }
}

/* ── Global Loader ─────────────────────────── */
.global-loader {
  position: fixed;
  inset: 0;
  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;
  padding: 0 20px;
}

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

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

.loader-progress-container {
  width: clamp(150px, 55vw, 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 pulse {
  0%, 100% { opacity: 0.4; }
  50%       { opacity: 1; }
}

/* ── Two-Panel Layout ──────────────────────── */
.bet-panel-v2 .bet-tabs-v3,
.bet-panel-2  .bet-tabs-v3 {
  display: flex;
}

.bet-panel-v2:not(.bet-panel-2) .bet-tab-v3 {
  background: rgba(230, 0, 64, 0.12);
  color: #e60040;
  border-color: rgba(230, 0, 64, 0.3);
}

.bet-panel-2 {
  border-color: rgba(34, 197, 94, 0.25);
  box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.08) inset;
  margin-top: 2px;
  position: relative;
}

.bet-panel-2::before {
  content: '';
  display: block;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.07), transparent);
  margin-bottom: 4px;
  margin-top: -4px;
}

.bet-panel-2 .numeric-input-v3:focus-within {
  border-color: rgba(34, 197, 94, 0.4);
}

.bet-panel-2 .quick-chips-v3 button:active {
  background: rgba(34, 197, 94, 0.14);
  color: #22c55e;
}

/* ═══════════════════════════════════════════
   RESPONSIVE BREAKPOINTS
   ═══════════════════════════════════════════ */

/* ── Very small phones (< 360px) ─────────── */
@media (max-width: 359px) {
  .stat-row {
    grid-template-columns: 1.8fr 1fr 0.9fr 1.2fr;
    font-size: 9px;
    padding: 5px 7px;
  }

  .right-controls {
    flex: 0 0 72px;
  }

  .quick-chips-v3 button {
    font-size: 9px;
    min-height: 28px;
  }

  .aviator-main-btn {
    min-height: 64px;
  }

  .bet-panel-v2 {
    padding: 8px 8px 10px;
  }
}

/* ── Phones (360px – 479px) ──────────────── */
@media (min-width: 360px) and (max-width: 479px) {
  .right-controls {
    flex: 0 0 clamp(82px, 24vw, 100px);
  }
}

/* ── Mid-size phones (480px – 767px) ─────── */
@media (min-width: 480px) and (max-width: 767px) {
  .right-controls {
    flex: 0 0 clamp(100px, 22vw, 130px);
  }

  .game-container {
    aspect-ratio: 480 / 260;
  }
}

/* ── Tablets (768px – 1023px) ────────────── */
@media (min-width: 768px) and (max-width: 1023px) {
  main {
    padding: 10px;
    gap: 10px;
  }

  .game-container {
    aspect-ratio: 16 / 7;
    min-height: 260px;
  }

  .panels-container {
    flex-direction: row;
    align-items: flex-start;
  }

  .bet-panel-v2 {
    flex: 1;
  }

  .stats-panel {
    flex: 1.2;
  }

  .right-controls {
    flex: 0 0 clamp(110px, 18vw, 150px);
  }

  .aviator-main-btn {
    min-height: 88px;
  }
}

/* ── Desktop (≥ 1024px) ──────────────────── */
@media (min-width: 1024px) {
  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;
    border-radius: 16px;
  }

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

  .live-feed {
    display: none;
  }

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

  .right-controls {
    flex: 0 0 clamp(120px, 14vw, 160px);
  }

  .aviator-main-btn {
    min-height: 96px;
  }

  .stat-row {
    font-size: 12px;
  }
}

/* ── Landscape phones ────────────────────── */
@media (max-height: 500px) and (orientation: landscape) {
  body {
    /* Allow scroll when screen is very short */
    overflow-y: auto;
    height: auto;
    min-height: 100dvh;
  }

  header {
    height: 44px;
  }

  .history-bar {
    height: 26px;
  }

  .game-container {
    aspect-ratio: 16 / 6;
    min-height: 130px;
  }

  main {
    flex-direction: row;
    overflow: hidden;
    height: calc(100dvh - 44px - 26px);
  }

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

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

  .aviator-main-btn {
    min-height: 58px;
  }

  .stats-panel {
    min-height: 120px;
  }
}

/* ── High-DPI / Retina screens ───────────── */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  /* Canvas already handles DPR in JS; just ensure crisp borders */
  .game-container {
    border-width: 0.5px;
  }
}