:root {
  --bg-primary: #0a0e1a;
  --bg-secondary: #1a1f2e;
  --bg-card: #242938;
  --bg-graph: #1e2332;
  --text-primary: #ffffff;
  --text-secondary: #a0a6b8;
  --text-muted: #6b7280;
  --accent-green: #00ff88;
  --accent-purple: #8b5cf6;
  --accent-blue: #3b82f6;
  --danger: #ef4444;
  --warning: #f59e0b;
  --border: #374151;
  --border-light: #4b5563;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.4;
  overflow-x: hidden;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: linear-gradient(180deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
}

/* Header */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.5px;
}

.logo {
  font-size: 20px;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-blue));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.balance-container {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--accent-purple);
  padding: 8px 16px;
  border-radius: 20px;
  font-weight: 600;
}

.balance-amount {
  color: white;
  font-size: 14px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0; /* Prevent shrinking */
}

.user-avatar img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}

.user-avatar span {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

/* History */
.history {
  display: flex;
  gap: 6px;
  padding: 12px 20px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.history::-webkit-scrollbar {
  display: none;
}

.history .pill {
  padding: 6px 12px;
  border-radius: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  font-weight: 600;
  font-size: 12px;
  white-space: nowrap;
  min-width: fit-content;
}

.history .pill.green {
  color: var(--accent-green);
  background: rgba(0, 255, 136, 0.1);
  border-color: var(--accent-green);
}

.history .pill.orange {
  color: var(--warning);
  background: rgba(245, 158, 11, 0.1);
  border-color: var(--warning);
}

/* Main Game Container */
.game-container {
  padding: 0 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Graph Section */
.graph-section {
  position: relative;
}

.graph-card {
  background: var(--bg-graph);
  border-radius: 16px;
  padding: 20px;
  position: relative;
  height: 280px;
  border: 1px solid var(--border);
  overflow: hidden;
}

#graph {
  width: 100% !important;
  height: 100% !important;
  position: absolute;
  top: 0;
  left: 0;
}

.multiplier-overlay {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
}

.multiplier-display {
  font-size: 48px;
  font-weight: 800;
  color: var(--accent-green);
  text-shadow: 0 0 20px rgba(0, 255, 136, 0.3);
  text-align: center;
  letter-spacing: -1px;
}

.game-info {
  position: absolute;
  bottom: 16px;
  left: 20px;
  right: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
}

.round-info {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 12px;
}

.round-label {
  color: var(--text-muted);
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-green);
  box-shadow: 0 0 8px var(--accent-green);
}

/* Controls Section */
.controls-section {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 20px;
  border: 1px solid var(--border);
}

.bet-input-container {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.bet-amount-wrapper {
  flex: 1;
  background: var(--bg-secondary);
  border-radius: 12px;
  padding: 12px;
  border: 1px solid var(--border);
}

.bet-amount-wrapper input {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
  outline: none;
}

.bet-amount-wrapper input::placeholder {
  color: var(--text-muted);
}

.bet-controls {
  display: flex;
  gap: 6px;
}

.bet-control-btn {
  flex: 1;
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.bet-control-btn:hover {
  background: var(--border);
  color: var(--text-primary);
}

.cashout-wrapper {
  flex: 1;
  background: var(--bg-secondary);
  border-radius: 12px;
  padding: 12px;
  border: 1px solid var(--border);
}

.cashout-label {
  display: block;
  color: var(--text-muted);
  font-size: 11px;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.cashout-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cashout-btn {
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 10px;
  transition: all 0.2s ease;
}

.cashout-btn:hover {
  background: var(--border);
  color: var(--text-primary);
}

.cashout-controls input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  outline: none;
}

/* Action Buttons */
.action-buttons {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.bet-button {
  flex: 1;
  background: linear-gradient(135deg, var(--accent-green), #00cc6a);
  color: var(--bg-primary);
  border: none;
  padding: 16px 24px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  text-transform: capitalize;
}

.bet-button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 255, 136, 0.3);
}

.bet-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.cashout-button {
  flex: 1;
  background: linear-gradient(135deg, var(--danger), #dc2626);
  color: white;
  border: none;
  padding: 16px 24px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  text-transform: capitalize;
}

.cashout-button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.cashout-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

/* Game Stats */
.game-stats {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 12px;
}

.stat-icon {
  font-size: 14px;
}

.stat-value {
  font-weight: 600;
  color: var(--text-primary);
}

.stat-label {
  font-weight: 600;
  color: var(--text-primary);
}

/* Round Details */
.round-details {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 12px 16px;
  border: 1px solid var(--border);
}

.seed-info {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.seed-hash {
  color: var(--text-secondary);
  font-family: 'Monaco', 'Menlo', monospace;
  word-break: break-all;
}

/* Responsive Design */
@media (max-width: 480px) {
  #app {
    max-width: 100%;
  }
  
  .game-container {
    padding: 0 16px 16px;
  }
  
  .topbar {
    padding: 12px 16px;
  }
  
  .history {
    padding: 8px 16px;
  }
  
  .multiplier-display {
    font-size: 36px;
  }
  
  .bet-input-container {
    flex-direction: column;
    gap: 8px;
  }
  
  .action-buttons {
    flex-direction: column;
    gap: 8px;
  }
}

/* Animation Classes */
.pulse {
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

.glow {
  animation: glow 2s ease-in-out infinite alternate;
}

@keyframes glow {
  from {
    text-shadow: 0 0 20px rgba(0, 255, 136, 0.3);
  }
  to {
    text-shadow: 0 0 30px rgba(0, 255, 136, 0.6), 0 0 40px rgba(0, 255, 136, 0.3);
  }
}

/* Rocket Animation */
.rocket {
  position: absolute;
  font-size: 28px;
  z-index: 15;
  transition: all 0.05s linear;
  filter: drop-shadow(0 0 12px rgba(0, 255, 136, 0.8)) drop-shadow(0 0 4px rgba(255, 255, 255, 0.6));
  display: none;
  pointer-events: none;
  transform-origin: center center;
}

.rocket::after {
  content: '';
  position: absolute;
  top: 50%;
  left: -8px;
  width: 20px;
  height: 3px;
  background: linear-gradient(90deg, transparent, rgba(0, 255, 136, 0.8), transparent);
  border-radius: 2px;
  transform: translateY(-50%);
  animation: rocketTrail 0.2s ease-out infinite alternate;
}

@keyframes rocketTrail {
  0% {
    width: 15px;
    opacity: 0.8;
  }
  100% {
    width: 25px;
    opacity: 0.4;
  }
}

/* Explosion Animation */
.explosion {
  position: absolute;
  width: 60px;
  height: 60px;
  z-index: 20;
  pointer-events: none;
  animation: explode 1s ease-out forwards;
}

.explosion::before {
  content: '💥';
  position: absolute;
  font-size: 48px;
  animation: explodeScale 1s ease-out forwards;
}

@keyframes explode {
  0% {
    transform: scale(0);
    opacity: 1;
  }
  50% {
    transform: scale(1.2);
    opacity: 1;
  }
  100% {
    transform: scale(2);
    opacity: 0;
  }
}

@keyframes explodeScale {
  0% {
    transform: scale(0) rotate(0deg);
  }
  50% {
    transform: scale(1.3) rotate(180deg);
  }
  100% {
    transform: scale(2) rotate(360deg);
  }
}

/* Player List on Chart */
.player-list {
  position: absolute;
  right: 20px;
  top: 60px;
  bottom: 60px;
  width: 150px;
  z-index: 10;
  pointer-events: none;
  overflow-y: auto;
  scrollbar-width: none;
  display: none; /* Hide player names from graph since All Bets shows this */
}

.player-list::-webkit-scrollbar {
  display: none;
}

.player-item {
  background: rgba(0, 0, 0, 0.3);
  color: var(--text-secondary);
  padding: 4px 8px;
  margin-bottom: 2px;
  border-radius: 4px;
  font-size: 11px;
  display: flex;
  justify-content: space-between;
  backdrop-filter: blur(4px);
  transform: translateY(-20px);
  opacity: 0;
  transition: all 0.4s ease-out;
}

.player-item.cashed-out {
  color: var(--accent-green);
  background: rgba(0, 255, 136, 0.2);
  border: 1px solid rgba(0, 255, 136, 0.4);
  box-shadow: 0 0 8px rgba(0, 255, 136, 0.3);
}

.player-item.visible {
  transform: translateY(0);
  opacity: 1;
  animation: cashoutGlow 0.8s ease-out;
}

.player-item.fade-out {
  transform: translateY(20px);
  opacity: 0;
  transition: all 0.5s ease-in;
}

@keyframes cashoutGlow {
  0% {
    box-shadow: 0 0 8px rgba(0, 255, 136, 0.3);
    transform: translateY(0) scale(1);
  }
  50% {
    box-shadow: 0 0 16px rgba(0, 255, 136, 0.6);
    transform: translateY(0) scale(1.05);
  }
  100% {
    box-shadow: 0 0 8px rgba(0, 255, 136, 0.3);
    transform: translateY(0) scale(1);
  }
}

/* Chart specific styles */
.chart-container {
  position: relative;
  height: 100%;
  width: 100%;
}

/* Hide default chart.js elements we don't want */
.chartjs-tooltip {
  display: none !important;
}

/* Enhanced multiplier display */
.multiplier-display {
  animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {
  0%, 100% {
    text-shadow: 0 0 20px rgba(0, 255, 136, 0.3);
    transform: scale(1);
  }
  50% {
    text-shadow: 0 0 30px rgba(0, 255, 136, 0.6), 0 0 40px rgba(0, 255, 136, 0.3);
    transform: scale(1.05);
  }
}

/* Bets section styles */
.bets-section {
  margin-top: 20px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 12px;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.bets-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.bets-header h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: #ffffff;
}

.bet-tabs {
  display: flex;
  gap: 8px;
}

.bet-tab {
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  color: #9ca3af;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.bet-tab.active {
  background: rgba(0, 255, 136, 0.1);
  border-color: #00ff88;
  color: #00ff88;
}

.bet-tab:hover:not(.active) {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.bets-content {
  position: relative;
}

.bet-list {
  max-height: 150px;
  overflow-y: auto;
}

.bet-list.hidden {
  display: none;
}

.bet-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 6px;
  margin-bottom: 6px;
  border-left: 3px solid #374151;
}

.bet-item.my-bet {
  border-left-color: #3b82f6;
  background: rgba(59, 130, 246, 0.05);
}

.bet-item.cashed-out {
  border-left-color: #00ff88;
  background: rgba(0, 255, 136, 0.05);
}

.bet-item.active-bet {
  border-left-color: #3b82f6;
  background: rgba(59, 130, 246, 0.1);
}

.bet-item.history-bet {
  opacity: 0.8;
  background: rgba(255, 255, 255, 0.02);
}

.bet-item.history-bet.cashed-out {
  border-left-color: #00ff88;
  background: rgba(0, 255, 136, 0.03);
}

.bet-status.won {
  color: #00ff88;
}

.bet-status.lost {
  color: #ef4444;
}

.bet-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.bet-player {
  font-size: 11px;
  color: #9ca3af;
}

.bet-amount {
  font-size: 12px;
  font-weight: 600;
  color: #ffffff;
}

.bet-status {
  font-size: 11px;
  font-weight: 500;
}

.bet-status.waiting {
  color: #fbbf24;
}

.bet-status.active {
  color: #3b82f6;
}

.bet-status.cashed-out {
  color: #00ff88;
}

.no-bets {
  text-align: center;
  padding: 20px;
  color: #6b7280;
  font-size: 12px;
}

/* Modal Styles */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
}

.modal-content {
  background: linear-gradient(135deg, #1a1a2e, #2a2a4e);
  margin: 5% auto;
  padding: 0;
  border: 2px solid #4f46e5;
  border-radius: 16px;
  width: 90%;
  max-width: 500px;
  box-shadow: 0 25px 50px rgba(79, 70, 229, 0.3);
  animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-50px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 2px solid #4f46e5;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  border-radius: 14px 14px 0 0;
}

.modal-header h3 {
  margin: 0;
  color: white;
  font-size: 1.2em;
  font-weight: 600;
}

.close {
  color: white;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
  line-height: 1;
  transition: all 0.2s;
}

.close:hover {
  color: #fbbf24;
  transform: scale(1.1);
}

.modal-body {
  padding: 24px;
  color: white;
}

.round-info, .seed-details {
  margin-bottom: 20px;
}

.seed-details h4 {
  color: #4f46e5;
  margin: 0 0 12px 0;
  font-size: 1.1em;
  border-bottom: 1px solid #4f46e5;
  padding-bottom: 4px;
}

.info-item {
  margin-bottom: 16px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.info-item:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.info-label {
  display: block;
  font-weight: 500;
  color: #a3a3a3;
  margin-bottom: 6px;
  font-size: 0.9em;
}

.seed-value {
  font-family: 'Courier New', monospace;
  font-size: 0.85em;
  color: #e5e7eb;
  word-break: break-all;
  line-height: 1.4;
  background: rgba(255, 255, 255, 0.05);
  padding: 8px;
  border-radius: 4px;
  margin-top: 4px;
}

.result.win {
  color: #10b981;
  font-weight: 600;
  font-size: 1.1em;
}

.result.loss {
  color: #ef4444;
  font-weight: 600;
  font-size: 1.1em;
}

/* Clickable Round IDs */
.clickable-round {
  color: #4f46e5;
  cursor: pointer;
  text-decoration: underline;
  transition: color 0.2s;
}

.clickable-round:hover {
  color: #7c3aed;
}