/**
 * CoinRush Plinko - Premium Casino Style
 * Stake.com inspired design with Matter.js physics
 */

/* ============================================
   FONT IMPORT
   ============================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&family=JetBrains+Mono:wght@500;600;700&family=Outfit:wght@400;500;600;700;800;900&display=swap');

/* Global page background */
html, body {
  background: #0d1117 !important;
  margin: 0;
  padding: 0;
}

/* ============================================
   CSS VARIABLES - PLINKO THEME
   ============================================ */
:root {
  /* Typography */
  --pk-font-primary: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --pk-font-mono: 'JetBrains Mono', 'SF Mono', monospace;
  
  /* Core colors - Dark theme */
  --pk-bg-dark: #0d1117;
  --pk-bg-darker: #080b0f;
  --pk-bg-card: #161b22;
  --pk-bg-card-hover: #1c2128;
  --pk-bg-elevated: #21262d;
  --pk-bg-input: #0d1117;
  
  /* Accent colors */
  --pk-gold: #f7931a;
  --pk-gold-light: #ffb84d;
  --pk-gold-dark: #cc7a15;
  --pk-gold-glow: rgba(247, 147, 26, 0.4);
  
  --pk-green: #00d26a;
  --pk-green-light: #00ff88;
  --pk-green-glow: rgba(0, 210, 106, 0.4);
  
  --pk-red: #ff4757;
  --pk-red-light: #ff6b7a;
  --pk-red-glow: rgba(255, 71, 87, 0.4);
  
  --pk-orange: #ff9500;
  --pk-yellow: #ffcc00;
  --pk-purple: #a855f7;
  
  /* Text hierarchy */
  --pk-text-primary: #ffffff;
  --pk-text-secondary: rgba(255, 255, 255, 0.7);
  --pk-text-muted: rgba(255, 255, 255, 0.5);
  --pk-text-disabled: rgba(255, 255, 255, 0.3);
  
  /* Borders */
  --pk-border: rgba(255, 255, 255, 0.08);
  --pk-border-hover: rgba(255, 255, 255, 0.15);
  
  /* Radius */
  --pk-radius-sm: 8px;
  --pk-radius-md: 12px;
  --pk-radius-lg: 16px;
  --pk-radius-xl: 20px;
  
  /* Shadows */
  --pk-shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --pk-shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
  --pk-shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5);
  
  /* Transitions */
  --pk-transition-fast: 0.15s ease;
  --pk-transition-base: 0.25s ease;
  --pk-transition-slow: 0.4s ease;
}

/* ============================================
   APP LAYOUT
   ============================================ */
.plinko-app {
  height: 100vh;
  overflow: hidden;
  background: var(--pk-bg-dark);
  color: var(--pk-text-primary);
  font-family: var(--pk-font-primary);
  -webkit-font-smoothing: antialiased;
  padding-top: 72px;
  position: relative;
  box-sizing: border-box;
}

.plinko-app * {
  font-family: var(--pk-font-primary);
  box-sizing: border-box;
}

/* Subtle gradient background */
.plinko-app::before {
  content: '';
  position: fixed;
  inset: 0;
  background: 
    radial-gradient(ellipse 80% 50% at 50% 0%, rgba(247, 147, 26, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(0, 210, 106, 0.05) 0%, transparent 40%);
  pointer-events: none;
  z-index: 0;
}

/* ============================================
   MAIN LAYOUT - STAKE STYLE
   ============================================ */
.plinko-container {
  display: flex;
  gap: 16px;
  max-width: 1400px;
  height: calc(100vh - 92px); /* Account for navbar + padding */
  margin: 0 auto;
  padding: 10px 20px;
  position: relative;
  z-index: 1;
  overflow: hidden;
}

/* Left Panel - Controls */
.plinko-controls {
  width: 320px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 100%;
  overflow-y: auto;
}

/* Main Game Area */
.plinko-game-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  max-height: 100%;
  overflow: hidden;
}

/* Right Panel - Chat */
.plinko-chat {
  width: 320px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

/* Chat container styling to match coinflip */
.plinko-chat .cr-chat-container {
  height: calc(100vh - 120px);
  max-height: none;
  min-height: 500px;
  position: sticky;
  top: 100px;
}

@media (max-width: 1200px) {
  .plinko-container {
    flex-direction: column;
  }
  .plinko-controls {
    width: 100%;
    order: 2;
  }
  .plinko-game-area {
    order: 1;
  }
  .plinko-chat {
    width: 100%;
    order: 3;
  }
}

/* ============================================
   CONTROL PANEL CARD
   ============================================ */
.pk-card {
  background: var(--pk-bg-card);
  border: 1px solid var(--pk-border);
  border-radius: var(--pk-radius-lg);
  padding: 20px;
}

.pk-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.pk-card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--pk-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ============================================
   MODE TABS (Manual / Auto)
   ============================================ */
.pk-mode-tabs {
  display: flex;
  background: var(--pk-bg-input);
  border-radius: var(--pk-radius-sm);
  padding: 4px;
  gap: 4px;
  margin-bottom: 16px;
}

.pk-mode-tab {
  flex: 1;
  padding: 10px 16px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--pk-text-muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--pk-transition-fast);
}

.pk-mode-tab:hover {
  color: var(--pk-text-secondary);
}

.pk-mode-tab.active {
  background: var(--pk-bg-elevated);
  color: var(--pk-text-primary);
}

/* ============================================
   INPUT FIELDS
   ============================================ */
.pk-input-group {
  margin-bottom: 16px;
}

.pk-input-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--pk-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.pk-input-wrapper {
  display: flex;
  align-items: center;
  background: var(--pk-bg-input);
  border: 1px solid var(--pk-border);
  border-radius: var(--pk-radius-sm);
  overflow: hidden;
  transition: var(--pk-transition-fast);
}

.pk-input-wrapper:focus-within {
  border-color: var(--pk-gold);
  box-shadow: 0 0 0 3px rgba(247, 147, 26, 0.15);
}

.pk-input-icon {
  padding: 0 12px;
  color: var(--pk-gold);
  font-size: 16px;
}

.pk-input {
  flex: 1;
  background: transparent;
  border: none;
  padding: 12px;
  padding-left: 0;
  color: var(--pk-text-primary);
  font-size: 16px;
  font-weight: 600;
  font-family: var(--pk-font-mono);
  outline: none;
}

.pk-input::placeholder {
  color: var(--pk-text-disabled);
}

.pk-input-btn {
  padding: 8px 12px;
  margin: 4px;
  background: var(--pk-bg-elevated);
  border: none;
  border-radius: 6px;
  color: var(--pk-text-secondary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--pk-transition-fast);
}

.pk-input-btn:hover {
  background: var(--pk-border-hover);
  color: var(--pk-text-primary);
}

/* ============================================
   RISK SELECTOR
   ============================================ */
.pk-risk-selector {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.pk-risk-btn {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid var(--pk-border);
  border-radius: var(--pk-radius-sm);
  background: var(--pk-bg-input);
  color: var(--pk-text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--pk-transition-fast);
  text-transform: capitalize;
}

.pk-risk-btn:hover {
  border-color: var(--pk-border-hover);
  color: var(--pk-text-secondary);
}

.pk-risk-btn.active.low {
  background: rgba(0, 210, 106, 0.15);
  border-color: var(--pk-green);
  color: var(--pk-green);
}

.pk-risk-btn.active.medium {
  background: rgba(247, 147, 26, 0.15);
  border-color: var(--pk-gold);
  color: var(--pk-gold);
}

.pk-risk-btn.active.high {
  background: rgba(255, 71, 87, 0.15);
  border-color: var(--pk-red);
  color: var(--pk-red);
}

/* ============================================
   ROWS SELECTOR
   ============================================ */
.pk-rows-selector {
  margin-bottom: 16px;
}

.pk-rows-slider {
  width: 100%;
  height: 6px;
  background: var(--pk-bg-input);
  border-radius: 3px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  margin-top: 8px;
}

.pk-rows-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  background: var(--pk-gold);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(247, 147, 26, 0.4);
}

.pk-rows-value {
  text-align: center;
  font-size: 24px;
  font-weight: 700;
  color: var(--pk-text-primary);
  margin-top: 8px;
}

/* ============================================
   BET BUTTON
   ============================================ */
.pk-bet-btn {
  width: 100%;
  padding: 16px 24px;
  border: none;
  border-radius: var(--pk-radius-md);
  background: linear-gradient(135deg, var(--pk-green), #00b85d);
  color: #000;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--pk-transition-base);
  box-shadow: 0 4px 20px var(--pk-green-glow);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.pk-bet-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 30px var(--pk-green-glow);
}

.pk-bet-btn:active:not(:disabled) {
  transform: translateY(0);
}

.pk-bet-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.pk-bet-btn.dropping {
  background: linear-gradient(135deg, #ff9500, #ff6b00);
  box-shadow: 0 4px 20px rgba(255, 149, 0, 0.3);
}

/* ============================================
   AUTO MODE CONTROLS
   ============================================ */
.pk-auto-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
  background: var(--pk-bg-darker);
  border-radius: var(--pk-radius-md);
  border: 1px solid var(--pk-border);
}

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

.pk-preset-btn {
  padding: 8px 4px;
  background: var(--pk-bg-main);
  border: 1px solid var(--pk-border);
  border-radius: var(--pk-radius-sm);
  color: var(--pk-text-secondary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--pk-transition-base);
}

.pk-preset-btn:hover:not(:disabled) {
  background: var(--pk-bg-card);
  border-color: var(--pk-green);
  color: var(--pk-text-primary);
}

.pk-preset-btn.active {
  background: rgba(0, 210, 106, 0.15);
  border-color: var(--pk-green);
  color: var(--pk-green);
}

.pk-preset-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.pk-auto-status {
  padding: 8px 12px;
  background: rgba(0, 210, 106, 0.1);
  border-radius: var(--pk-radius-sm);
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--pk-green);
}

/* ============================================
   GAME BOARD CONTAINER
   ============================================ */
.pk-board-container {
  background: var(--pk-bg-card);
  border: 1px solid var(--pk-border);
  border-radius: var(--pk-radius-lg);
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.pk-board-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--pk-border);
  flex-shrink: 0;
}

.pk-board-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--pk-text-primary);
}

.pk-fairness-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: rgba(0, 210, 106, 0.1);
  border: 1px solid rgba(0, 210, 106, 0.2);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  color: var(--pk-green);
}

/* Canvas Container */
.pk-canvas-container {
  position: relative;
  width: 100%;
  max-width: 760px;
  background: var(--pk-bg-darker);
  border-radius: var(--pk-radius-md);
  overflow: hidden;
  margin: 0 auto;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

#plinko-canvas {
  width: 100%;
  height: 100%;
  max-height: 100%;
  display: block;
  object-fit: contain;
}

/* ============================================
   MULTIPLIER BUCKETS
   ============================================ */
.pk-buckets {
  display: flex;
  gap: 0;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 0;
  box-sizing: border-box;
  flex-shrink: 0;
}

.pk-bucket {
  flex: 1;
  padding: 8px 0;
  text-align: center;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  font-family: var(--pk-font-mono);
  transition: var(--pk-transition-fast);
  min-width: 0;
  margin: 0;
}

.pk-bucket.highlight {
  transform: scale(1.15);
  box-shadow: 0 0 20px currentColor;
  z-index: 10;
}

/* Bucket colors based on multiplier - Stake style gradient */
.pk-bucket.tier-1 { 
  background: linear-gradient(180deg, #ff0055 0%, #cc0044 100%); 
  color: #fff; 
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}
.pk-bucket.tier-2 { 
  background: linear-gradient(180deg, #ff4466 0%, #dd3355 100%); 
  color: #fff; 
}
.pk-bucket.tier-3 { 
  background: linear-gradient(180deg, #ff8833 0%, #ee7722 100%); 
  color: #000; 
}
.pk-bucket.tier-4 { 
  background: linear-gradient(180deg, #ffaa22 0%, #ee9911 100%); 
  color: #000; 
}
.pk-bucket.tier-5 { 
  background: linear-gradient(180deg, #dddd00 0%, #bbbb00 100%); 
  color: #000; 
}
.pk-bucket.tier-6 { 
  background: linear-gradient(180deg, #88cc55 0%, #77aa44 100%); 
  color: #000; 
}
.pk-bucket.tier-7 { 
  background: linear-gradient(180deg, #44aa44 0%, #339933 100%); 
  color: #fff; 
}

/* ============================================
   RESULT POPUP
   ============================================ */
.pk-result-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  background: var(--pk-bg-card);
  border: 1px solid var(--pk-border);
  border-radius: var(--pk-radius-xl);
  padding: 40px 60px;
  text-align: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s ease;
}

.pk-result-popup.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  pointer-events: auto;
}

.pk-result-popup.win {
  border-color: var(--pk-green);
  box-shadow: 0 0 60px var(--pk-green-glow);
}

.pk-result-popup.loss {
  border-color: var(--pk-red);
  box-shadow: 0 0 60px var(--pk-red-glow);
}

.pk-result-multiplier {
  font-size: 48px;
  font-weight: 800;
  margin-bottom: 12px;
}

.pk-result-popup.win .pk-result-multiplier {
  color: var(--pk-green);
}

.pk-result-popup.loss .pk-result-multiplier {
  color: var(--pk-red);
}

.pk-result-payout {
  font-size: 24px;
  font-weight: 600;
  color: var(--pk-text-secondary);
}

/* ============================================
   HISTORY PANEL
   ============================================ */
.pk-history {
  margin-top: 16px;
}

.pk-history-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pk-history-item {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--pk-font-mono);
}

.pk-history-item.win {
  background: rgba(0, 210, 106, 0.15);
  color: var(--pk-green);
}

.pk-history-item.loss {
  background: rgba(255, 71, 87, 0.15);
  color: var(--pk-red);
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes ball-drop {
  0% { transform: translateY(-50px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}

@keyframes bucket-glow {
  0%, 100% { box-shadow: 0 0 0 currentColor; }
  50% { box-shadow: 0 0 30px currentColor; }
}

@keyframes win-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.pk-bucket.winning {
  animation: bucket-glow 0.5s ease-in-out 3;
}

/* ============================================
   SOUND TOGGLE
   ============================================ */
.pk-sound-toggle {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--pk-bg-elevated);
  border: 1px solid var(--pk-border);
  color: var(--pk-text-muted);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--pk-transition-fast);
}

.pk-sound-toggle:hover {
  color: var(--pk-text-primary);
  border-color: var(--pk-border-hover);
}

/* ============================================
   RESPONSIVE ADJUSTMENTS
   ============================================ */
/* ============================================
   ROWS MARKERS
   ============================================ */
.pk-rows-markers {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  padding: 0 4px;
}

.pk-rows-markers span {
  font-size: 11px;
  font-weight: 500;
  color: var(--pk-text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: var(--pk-transition-fast);
}

.pk-rows-markers span:hover {
  color: var(--pk-text-secondary);
  background: var(--pk-bg-elevated);
}

.pk-rows-markers span.active {
  color: var(--pk-gold);
  font-weight: 700;
}

/* ============================================
   CONNECTION STATUS
   ============================================ */
.pk-connection-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
  padding: 8px;
  font-size: 12px;
  color: var(--pk-text-muted);
}

.pk-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--pk-red);
  transition: var(--pk-transition-base);
}

.pk-status-dot.connected {
  background: var(--pk-green);
  box-shadow: 0 0 8px var(--pk-green-glow);
}

/* ============================================
   NO HISTORY STATE
   ============================================ */
.pk-no-history {
  color: var(--pk-text-muted);
  font-size: 13px;
  font-style: italic;
}

/* ============================================
   TITLE ICON
   ============================================ */
.pk-title-icon {
  margin-right: 8px;
}

/* ============================================
   BET BUTTON STATES
   ============================================ */
.pk-bet-btn.dropping {
  background: linear-gradient(135deg, var(--pk-gold), var(--pk-orange));
  animation: pulse-glow 1s ease-in-out infinite;
}

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 4px 20px var(--pk-gold-glow); }
  50% { box-shadow: 0 4px 30px var(--pk-gold-glow); }
}

/* ============================================
   RESPONSIVE ADJUSTMENTS
   ============================================ */
@media (max-width: 768px) {
  .plinko-container {
    padding: 12px;
  }
  
  .pk-card {
    padding: 16px;
  }
  
  .pk-bucket {
    font-size: 9px;
    padding: 6px 2px;
  }
  
  .pk-result-popup {
    padding: 24px 32px;
  }
  
  .pk-result-multiplier {
    font-size: 36px;
  }
  
  .pk-rows-markers {
    display: none;
  }
}
