/* ==========================================================================
   CAT AVIATOR (MÈO CƯỠI TRÁI DƯA LEO) - 100% SINGLE SCREEN CASINO LAYOUT
   Designed to fit 100% in 1 screen with ZERO vertical or horizontal page scroll.
   ========================================================================== */

:root {
  --bg-main: #0b0e14;
  --bg-surface: #141822;
  --bg-surface-elevated: #1a202c;
  --bg-input: #0f131a;
  --border-color: #242c3c;
  --border-light: rgba(255, 255, 255, 0.08);

  --color-primary: #e51c44;      /* Aviator signature neon red */
  --color-green: #00e676;        /* Cashout green */
  --color-green-dark: #00b05b;
  --color-yellow: #ffc107;
  --color-gold: #ffd700;
  --color-purple: #b388ff;
  --color-blue: #29b6f6;
  --color-orange: #ff7043;
  --color-text: #ffffff;
  --color-text-muted: #8c9ba5;

  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
}

html, body {
  width: 100%;
  height: 100%;
  height: 100vh;
  height: 100dvh;
  margin: 0;
  padding: 0;
  overflow: hidden; /* ABSOLUTE: Zero page scroll! */
  background-color: var(--bg-main);
  color: var(--color-text);
  font-family: var(--font-family);
  user-select: none;
}

body {
  display: flex;
  flex-direction: column;
}

/* --- HEADER BAR (COMPACT 44px) --- */
.game-header {
  height: 44px;
  min-height: 44px;
  max-height: 44px;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  flex-shrink: 0;
  z-index: 100;
}

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

.logo-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
}

.logo-icon {
  width: 28px;
  height: 28px;
  background: linear-gradient(135deg, #4caf50, #2e7d32);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  box-shadow: 0 2px 6px rgba(76, 175, 80, 0.4);
}

.logo-title {
  font-weight: 900;
  font-size: 15px;
  letter-spacing: 0.5px;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 4px;
}

.logo-title span {
  color: var(--color-primary);
}

.logo-subtitle {
  font-size: 10px;
  background: rgba(229, 28, 68, 0.15);
  color: var(--color-primary);
  border: 1px solid rgba(229, 28, 68, 0.3);
  padding: 1px 5px;
  border-radius: 4px;
  font-weight: 700;
}

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

.balance-card {
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  display: flex;
  align-items: center;
  padding: 2px 4px 2px 10px;
  gap: 8px;
}

.balance-label {
  font-size: 10px;
  color: var(--color-text-muted);
  text-transform: uppercase;
}

.balance-amount {
  font-weight: 800;
  font-size: 13px;
  color: var(--color-green);
  letter-spacing: 0.3px;
}

.btn-deposit {
  background: linear-gradient(135deg, #00e676, #00b05b);
  border: none;
  color: #0b0e14;
  font-size: 11px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.15s, filter 0.15s;
}

.btn-deposit:hover {
  filter: brightness(1.1);
  transform: scale(1.03);
}

.header-icon-btn {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  color: var(--color-text);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  transition: background 0.15s;
}

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

.header-icon-btn.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
}

/* --- HISTORY PILLS BAR (COMPACT 30px) --- */
.history-bar-container {
  height: 30px;
  min-height: 30px;
  max-height: 30px;
  background-color: #0e121a;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  padding: 0 10px;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
}

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

.history-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--color-text-muted);
  text-transform: uppercase;
  white-space: nowrap;
}

.history-pills-list {
  display: flex;
  align-items: center;
  gap: 5px;
  flex: 1;
}

.history-pill {
  font-size: 11px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 10px;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.12s;
}

.history-pill:hover {
  transform: scale(1.08);
}

.pill-blue {
  background: rgba(41, 182, 246, 0.15);
  color: var(--color-blue);
  border: 1px solid rgba(41, 182, 246, 0.35);
}

.pill-purple {
  background: rgba(179, 136, 255, 0.2);
  color: var(--color-purple);
  border: 1px solid rgba(179, 136, 255, 0.4);
}

.pill-gold {
  background: rgba(255, 215, 0, 0.25);
  color: var(--color-gold);
  border: 1px solid rgba(255, 215, 0, 0.6);
  box-shadow: 0 0 6px rgba(255, 215, 0, 0.25);
}

/* --- MAIN CONTAINER LAYOUT (FLEX 1, NO OVERFLOW) --- */
.game-main-layout {
  flex: 1;
  display: flex;
  min-height: 0; /* CRITICAL: Enables children to shrink without expanding page */
  overflow: hidden;
}

/* --- SIDEBAR (LIVE BETS) --- */
.game-sidebar {
  width: 270px;
  min-width: 250px;
  max-width: 300px;
  background-color: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  flex-shrink: 0;
  transition: width 0.2s ease, transform 0.2s ease;
}

.game-sidebar.sidebar-collapsed {
  display: none;
}

.sidebar-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--bg-input);
  flex-shrink: 0;
}

.sidebar-tab {
  flex: 1;
  padding: 8px 4px;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  color: var(--color-text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}

.sidebar-tab.active {
  color: #ffffff;
  border-color: var(--color-primary);
  background-color: var(--bg-surface);
}

.sidebar-summary-header {
  padding: 6px 10px;
  font-size: 10px;
  color: var(--color-text-muted);
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  flex-shrink: 0;
}

.sidebar-tab-content {
  display: none;
  flex: 1;
  min-height: 0;
  overflow-y: auto; /* Internal scrolling only */
  scrollbar-width: thin;
  scrollbar-color: var(--border-color) transparent;
}

.sidebar-tab-content::-webkit-scrollbar {
  width: 4px;
}

.sidebar-tab-content::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

.sidebar-tab-content.active {
  display: block;
}

/* Sidebar Bets Table */
.bets-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

.bets-table th {
  padding: 5px 8px;
  color: var(--color-text-muted);
  font-weight: 600;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
  font-size: 10px;
}

.bets-table td {
  padding: 5px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  vertical-align: middle;
}

.row-user-bet {
  background: rgba(255, 193, 7, 0.1) !important;
  border-left: 3px solid var(--color-yellow);
}

.col-user {
  display: flex;
  align-items: center;
  gap: 6px;
}

.user-avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  color: #ffffff;
  font-size: 10px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-name {
  font-weight: 600;
  color: #d1d5db;
  max-width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.col-bet {
  font-weight: 700;
  color: #ffffff;
}

.col-result {
  text-align: right;
}

.badge-win-mult {
  background: rgba(0, 230, 118, 0.15);
  color: var(--color-green);
  border: 1px solid rgba(0, 230, 118, 0.4);
  padding: 1px 5px;
  border-radius: 6px;
  font-weight: 800;
  font-size: 10px;
  margin-right: 3px;
}

.text-win-val {
  color: var(--color-green);
  font-weight: 700;
}

.badge-waiting {
  color: var(--color-text-muted);
  font-style: italic;
  font-size: 10px;
}

.badge-lost {
  color: #ef5350;
  font-size: 10px;
  font-weight: 600;
}

.badge-mult-history {
  background: rgba(179, 136, 255, 0.2);
  color: var(--color-purple);
  padding: 1px 5px;
  border-radius: 6px;
  font-weight: 800;
  font-size: 10px;
}

.text-win {
  color: var(--color-green);
  font-weight: 700;
}

.text-danger {
  color: #ef5350;
  font-weight: 700;
}

/* --- MAIN PLAY AREA (STAGE & CONTROLS) --- */
.game-play-area {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-main);
  position: relative;
  overflow: hidden;
}

/* Canvas Area - Stretches dynamically to fill 100% remaining space */
.canvas-wrapper {
  flex: 1;
  min-height: 0;
  position: relative;
  background-color: #0b0f17;
  overflow: hidden;
}

#gameCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* --- DUAL BETTING PANELS CONSOLE (COMPACT & RESPONSIVE) --- */
.betting-console {
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  padding: 8px 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  flex-shrink: 0; /* Stays securely pinned to bottom */
  z-index: 10;
}

.bet-panel {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
}

.panel-header-tabs {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.tabs-toggle {
  display: flex;
  background: var(--bg-input);
  border-radius: 14px;
  padding: 2px;
  border: 1px solid var(--border-color);
}

.tab-btn {
  border: none;
  background: none;
  color: var(--color-text-muted);
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.tab-btn.active {
  background: var(--color-primary);
  color: #ffffff;
}

.panel-badge {
  font-size: 10px;
  font-weight: 800;
  color: var(--color-text-muted);
  text-transform: uppercase;
}

/* Panel Body Layout */
.panel-body {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 8px;
  align-items: stretch;
}

/* Left controls of Panel */
.bet-amount-section {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.bet-input-wrapper {
  display: flex;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 1px;
}

.btn-stepper {
  width: 28px;
  height: 28px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  color: #ffffff;
  font-size: 15px;
  font-weight: 800;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.btn-stepper:hover {
  background: var(--border-color);
}

.bet-input {
  flex: 1;
  background: none;
  border: none;
  color: #ffffff;
  font-weight: 800;
  font-size: 13px;
  text-align: center;
  outline: none;
  width: 50px;
}

/* Quick chips */
.quick-chips-row {
  display: flex;
  gap: 3px;
}

.chip-btn {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--color-text-muted);
  font-size: 10px;
  font-weight: 700;
  padding: 3px 0;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}

.chip-btn:hover {
  background: var(--border-color);
  color: #ffffff;
}

/* Right button of Panel (BIG ACTION BUTTON) */
.bet-action-section {
  display: flex;
  flex-direction: column;
}

.btn-action-main {
  flex: 1;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4px 6px;
  transition: transform 0.12s, filter 0.15s, box-shadow 0.15s;
  min-height: 54px;
}

.btn-action-main:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.btn-action-main:active {
  transform: translateY(1px);
}

.btn-subtext {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.btn-payout {
  font-size: 15px;
  font-weight: 900;
  margin-top: 1px;
}

.btn-mult {
  font-size: 11px;
  font-weight: 700;
  opacity: 0.9;
}

/* Button States */
.btn-bet {
  background: linear-gradient(135deg, #00e676, #00b05b);
  color: #0b0e14;
  box-shadow: 0 2px 10px rgba(0, 230, 118, 0.35);
}

.btn-cancel {
  background: linear-gradient(135deg, #e51c44, #b71c1c);
  color: #ffffff;
  box-shadow: 0 2px 10px rgba(229, 28, 68, 0.35);
}

.btn-cashout {
  background: linear-gradient(135deg, #ffc107, #ff9800);
  color: #0b0e14;
  box-shadow: 0 0 16px rgba(255, 193, 7, 0.6);
  animation: pulse-cashout 0.8s infinite alternate ease-in-out;
}

@keyframes pulse-cashout {
  0% { transform: scale(1); box-shadow: 0 0 12px rgba(255, 193, 7, 0.5); }
  100% { transform: scale(1.02); box-shadow: 0 0 20px rgba(255, 193, 7, 0.85); }
}

.btn-won {
  background: linear-gradient(135deg, #ab47bc, #7b1fa2);
  color: #ffffff;
}

.btn-bet-next {
  background: linear-gradient(135deg, #ff9800, #f57f17);
  color: #0b0e14;
}

/* Auto Controls Section */
.auto-controls-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  gap: 8px;
}

.auto-controls-section.hidden {
  display: none;
}

.auto-toggle-group {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

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

.auto-cashout-val {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: #ffffff;
  font-weight: 800;
  width: 48px;
  padding: 2px 4px;
  border-radius: 4px;
  text-align: center;
  font-size: 11px;
  outline: none;
}

/* Win notification badge */
.cashout-win-badge {
  background: rgba(0, 230, 118, 0.2);
  border: 1px solid var(--color-green);
  color: var(--color-green);
  font-size: 11px;
  font-weight: 800;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  text-align: center;
  animation: fadeIn 0.2s ease-out;
}

.cashout-win-badge.hidden {
  display: none;
}

/* --- MODALS & OVERLAYS --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s;
}

.modal-overlay.hidden {
  display: none;
}

.modal-dialog {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 460px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
  overflow: hidden;
}

.modal-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 15px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 6px;
}

.modal-close-btn {
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 18px;
  cursor: pointer;
}

.modal-body {
  padding: 16px;
  font-size: 12.5px;
  line-height: 1.5;
  color: #cfd8dc;
  max-height: 65vh;
  overflow-y: auto;
}

.fair-card {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px;
  margin-bottom: 10px;
}

.fair-field {
  margin-bottom: 6px;
}

.fair-field-title {
  font-size: 10px;
  color: var(--color-text-muted);
  text-transform: uppercase;
  font-weight: 700;
}

.fair-field-value {
  font-family: monospace;
  font-size: 11px;
  color: #ffffff;
  word-break: break-all;
  background: rgba(0, 0, 0, 0.3);
  padding: 3px 5px;
  border-radius: 4px;
  margin-top: 2px;
}

/* BIG WIN OVERLAY */
.big-win-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  animation: zoomIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.big-win-overlay.hidden {
  display: none;
}

.big-win-box {
  background: linear-gradient(135deg, #1f1435, #2c0e22);
  border: 2px solid var(--color-gold);
  border-radius: 16px;
  padding: 24px 36px;
  text-align: center;
  box-shadow: 0 0 40px rgba(255, 215, 0, 0.5);
}

.big-win-title {
  font-size: 26px;
  font-weight: 900;
  color: var(--color-gold);
  text-shadow: 0 0 16px rgba(255, 215, 0, 0.8);
  letter-spacing: 1.5px;
}

.big-win-mult-text {
  font-size: 36px;
  font-weight: 900;
  color: #ffffff;
  margin: 4px 0;
}

.big-win-payout-text {
  font-size: 22px;
  font-weight: 800;
  color: var(--color-green);
}

/* Toast Container */
.toast-container {
  position: fixed;
  bottom: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 2000;
  pointer-events: none;
}

.toast-msg {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 700;
  color: #ffffff;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  animation: slideIn 0.25s ease-out;
  pointer-events: auto;
}

.toast-success {
  border-left: 3px solid var(--color-green);
}

.toast-warning {
  border-left: 3px solid var(--color-yellow);
}

.toast-info {
  border-left: 3px solid var(--color-blue);
}

.toast-msg.fade-out {
  opacity: 0;
  transform: translateY(-8px);
  transition: all 0.3s;
}

/* ANIMATIONS */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes zoomIn {
  from { opacity: 0; transform: scale(0.7); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(50px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ULTRA COMPACT & MOBILE BREAKPOINTS (STILL ZERO SCROLL!) */
@media (max-width: 820px) {
  .game-sidebar {
    width: 220px;
    min-width: 200px;
  }
}

@media (max-width: 680px) {
  .betting-console {
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 6px 8px;
  }
  .game-sidebar {
    position: absolute;
    left: 0;
    top: 74px;
    bottom: 0;
    z-index: 99;
    box-shadow: 4px 0 16px rgba(0, 0, 0, 0.7);
  }
}
