/* CSS Variables for theming */
:root {
  /* Colors */
  --primary-bg: linear-gradient(135deg, #1a0000 0%, #4a0000 100%);
  --card-bg: rgba(0, 0, 0, 0.3);
  --text-primary: white;
  --text-secondary: rgba(255, 255, 255, 0.7);
  --accent-gold: #ffc107;
  
  /* Betting Card Colors */
  --player-bg: linear-gradient(135deg, #2e5ba8, #4a7fd8);
  --tie-bg: linear-gradient(135deg, #0f7938, #15a348);
  --banker-bg: linear-gradient(135deg, #c92a2a, #ff5252);
  /* Side betting colors - 각각 다른 색상 */
  --player-pair-bg: linear-gradient(135deg, #5e35b1, #7e57c2);
  --banker-pair-bg: linear-gradient(135deg, #d32f2f, #f44336);
  --perfect-pair-bg: linear-gradient(135deg, #f57c00, #ff9800);
  --either-pair-bg: linear-gradient(135deg, #00796b, #009688);
  
  /* Chip Colors */
  --chip-5k: radial-gradient(#ff6b9d, #c44569);
  --chip-10k: radial-gradient(#ff9a56, #ff6a00);
  --chip-25k: radial-gradient(#4dabf7, #1971c2);
  --chip-50k: radial-gradient(#69db7c, #37b24d);
  --chip-100k: radial-gradient(#495057, #212529);
  --chip-500k: radial-gradient(#b197fc, #9775fa);
  
  /* Spacing */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;
  
  /* Border Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  
  /* Shadows */
  --shadow-light: 0 2px 8px rgba(0, 0, 0, 0.1);
  --shadow-medium: 0 4px 16px rgba(0, 0, 0, 0.2);
  --shadow-heavy: 0 8px 32px rgba(0, 0, 0, 0.3);
  
  /* Transitions */
  --transition-fast: all 0.15s ease;
  --transition-normal: all 0.3s ease;
  --transition-slow: all 0.5s ease;
}

/* Reset and Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--primary-bg);
  color: var(--text-primary);
  line-height: 1.6;
  height: 100%;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Loading Screen */
.loading-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--primary-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

.loading-screen.hidden {
  opacity: 0;
  visibility: hidden;
}

.loading-content {
  text-align: center;
}

.loading-spinner {
  width: 50px;
  height: 50px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top: 3px solid var(--accent-gold);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto var(--spacing-md);
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Modal Styles */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: var(--spacing-md);
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: var(--card-bg);
  backdrop-filter: blur(10px);
  border-radius: var(--radius-lg);
  padding: var(--spacing-xl);
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-heavy);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-lg);
}

.modal-header h2 {
  color: var(--accent-gold);
  font-size: 1.5rem;
}

.close-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  padding: var(--spacing-xs);
  transition: var(--transition-fast);
}

.close-btn:hover {
  color: var(--text-primary);
}

/* Form Styles */
.form-group {
  margin-bottom: var(--spacing-md);
}

.form-group label {
  display: block;
  margin-bottom: var(--spacing-xs);
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.form-group input {
  width: 100%;
  padding: var(--spacing-md);
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 1rem;
  transition: var(--transition-fast);
}

.form-group input:focus {
  outline: none;
  border-color: var(--accent-gold);
  background: rgba(255, 255, 255, 0.15);
}

.form-group input::placeholder {
  color: var(--text-secondary);
}

/* Button Styles */
.btn {
  padding: var(--spacing-md) var(--spacing-lg);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-fast);
  display: inline-block;
  text-align: center;
  text-decoration: none;
  min-width: 44px;
  min-height: 44px;
}

.btn-primary {
  background: var(--accent-gold);
  color: #000;
  margin-bottom: var(--spacing-sm);
  width: 100%;
}

.btn-primary:hover {
  background: #ffcd38;
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  width: 100%;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.2);
}

.btn-small {
  padding: var(--spacing-xs) var(--spacing-sm);
  font-size: 0.8rem;
  min-width: auto;
  min-height: auto;
}

.btn-telegram {
  background: rgba(42, 171, 238, 0.2);
  border: 1px solid rgba(42, 171, 238, 0.3);
  color: #2aabee;
}

.btn-telegram:hover {
  background: rgba(42, 171, 238, 0.3);
  border-color: #2aabee;
}

.btn-danger {
  background: rgba(244, 67, 54, 0.2);
  border: 1px solid rgba(244, 67, 54, 0.3);
  color: #f44336;
}

.btn-danger:hover {
  background: rgba(244, 67, 54, 0.3);
  border-color: #f44336;
}

/* App Layout */
.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.header {
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(10px);
  padding: var(--spacing-md);
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1200px;
  margin: 0 auto;
}

.logo {
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--accent-gold);
}

.user-info {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.user-info span {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* Main Game Container */
.game-container {
  flex: 1;
  padding: var(--spacing-sm) var(--spacing-md);
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}

.section-title {
  font-size: 1rem;
  margin-bottom: var(--spacing-sm);
  color: var(--accent-gold);
  text-align: center;
  font-weight: 600;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.7);
  position: relative;
}

.section-title::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 50%;
  transform: translateX(-50%);
  width: 30px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent-gold), transparent);
  border-radius: 1px;
}

/* Betting Section */
.betting-section {
  margin-bottom: var(--spacing-lg);
}

.betting-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-lg);
}

.betting-card {
  background: var(--card-bg);
  backdrop-filter: blur(10px);
  border-radius: var(--radius-md);
  padding: var(--spacing-md);
  cursor: pointer;
  transition: var(--transition-normal);
  position: relative;
  overflow: hidden;
  height: 120px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  border: 2px solid rgba(255, 255, 255, 0.1);
  min-width: 44px;
  box-shadow: var(--shadow-medium);
}

.betting-card:active {
  transform: scale(0.95);
}

.betting-card.player-card {
  background: var(--player-bg);
}

.betting-card.tie-card {
  background: var(--tie-bg);
}

.betting-card.banker-card {
  background: var(--banker-bg);
}

.betting-card.side-card {
  height: 70px;
  padding: var(--spacing-sm);
}

/* 각 페어별 색상 적용 */
.betting-card[data-type="플레이어 페어"] {
  background: var(--player-pair-bg);
}

.betting-card[data-type="뱅커 페어"] {
  background: var(--banker-pair-bg);
}

.betting-card[data-type="퍼펙트 페어"] {
  background: var(--perfect-pair-bg);
}

.betting-card[data-type="이더 페어"] {
  background: var(--either-pair-bg);
}

.betting-card.selected {
  border-color: var(--accent-gold);
  box-shadow: 0 0 15px rgba(255, 193, 7, 0.6), var(--shadow-medium);
  transform: translateY(-2px);
}

.betting-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.card-header {
  text-align: center;
}

.card-header h3 {
  font-size: 1.1rem;
  font-weight: bold;
  margin-bottom: 2px;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.7);
}

.card-subtitle {
  font-size: 0.7rem;
  opacity: 0.9;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: var(--spacing-xs);
}

.odds-badge {
  background: rgba(0, 0, 0, 0.6);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-weight: bold;
  text-align: center;
  font-size: 0.85rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.3);
}

.odds-badge.small {
  font-size: 0.75rem;
  padding: 2px 6px;
}

/* Side Betting */
.side-betting-section {
  margin-bottom: var(--spacing-lg);
}

.side-betting-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: var(--spacing-sm);
  max-width: 100%;
}

.side-title {
  font-size: 0.8rem;
  text-align: center;
  display: block;
  font-weight: 500;
  margin-bottom: 4px;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.7);
}

/* Chip Section */
.chip-section {
  margin-bottom: var(--spacing-lg);
}

.chip-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: var(--spacing-sm);
  justify-items: center;
  max-width: 100%;
  margin: 0 auto;
}

.chip {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-normal);
  position: relative;
  border: 2px solid rgba(255, 255, 255, 0.4);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.chip[data-value="5000"] {
  background: var(--chip-5k);
}

.chip[data-value="10000"] {
  background: var(--chip-10k);
}

.chip[data-value="25000"] {
  background: var(--chip-25k);
}

.chip[data-value="50000"] {
  background: var(--chip-50k);
}

.chip[data-value="100000"] {
  background: var(--chip-100k);
}

.chip[data-value="500000"] {
  background: var(--chip-500k);
}

.chip:active {
  transform: scale(0.9);
}

.chip:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.chip.selected {
  border-color: var(--accent-gold);
  border-width: 3px;
  animation: chipGlow 1.5s ease-in-out infinite alternate;
  transform: scale(1.1);
}

@keyframes chipGlow {
  from {
    box-shadow: 0 0 8px rgba(255, 193, 7, 0.6), 0 3px 8px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  }
  to {
    box-shadow: 0 0 16px rgba(255, 193, 7, 0.9), 0 5px 15px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  }
}

.chip-value {
  font-weight: bold;
  font-size: 0.65rem;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
  line-height: 1;
}

/* Betting Control */
.betting-control {
  margin-bottom: var(--spacing-lg);
  background: var(--card-bg);
  backdrop-filter: blur(10px);
  border-radius: var(--radius-md);
  padding: var(--spacing-md);
  box-shadow: var(--shadow-medium);
}

.betting-info {
  text-align: center;
  margin-bottom: var(--spacing-sm);
  background: rgba(0, 0, 0, 0.3);
  padding: var(--spacing-sm);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 193, 7, 0.3);
}

.current-bet {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.bet-label {
  color: var(--text-secondary);
  font-size: 0.8rem;
}

.bet-amount {
  color: var(--accent-gold);
  font-size: 1.1rem;
  font-weight: bold;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.7);
}

.control-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--spacing-sm);
}

.control-btn {
  padding: var(--spacing-sm) var(--spacing-md);
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition-fast);
  font-size: 0.8rem;
  min-height: 36px;
  font-weight: 500;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.control-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3);
}

.control-btn:active {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.control-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* History Section */
.history-section {
  margin-bottom: var(--spacing-lg);
}

.betting-history {
  background: var(--card-bg);
  backdrop-filter: blur(10px);
  border-radius: var(--radius-md);
  padding: var(--spacing-md);
  max-height: 180px;
  overflow-y: auto;
  box-shadow: var(--shadow-medium);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-xs) 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.8rem;
}

.history-item:last-child {
  border-bottom: none;
}

.history-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.history-type {
  font-weight: 500;
  color: var(--text-primary);
}

.history-time {
  font-size: 0.7rem;
  color: var(--text-secondary);
  opacity: 0.8;
}

.history-amounts {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.history-amount {
  color: var(--accent-gold);
  font-weight: bold;
  font-size: 0.8rem;
}

.history-potential {
  font-size: 0.7rem;
  color: var(--text-secondary);
  opacity: 0.9;
}

.no-bets {
  text-align: center;
  color: var(--text-secondary);
  font-style: italic;
  font-size: 0.85rem;
  padding: var(--spacing-md) 0;
}

/* Status Message */
.status-message {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--card-bg);
  backdrop-filter: blur(10px);
  color: var(--text-primary);
  padding: var(--spacing-md) var(--spacing-lg);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-heavy);
  z-index: 500;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.status-message.show {
  opacity: 1;
  visibility: visible;
  animation: slideInDown 0.3s ease;
}

.status-message.success {
  border-left: 4px solid #4caf50;
}

.status-message.error {
  border-left: 4px solid #f44336;
}

.status-message.info {
  border-left: 4px solid var(--accent-gold);
}

@keyframes slideInDown {
  from {
    transform: translateX(-50%) translateY(-20px);
    opacity: 0;
  }
  to {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
  }
}

/* Debug Panel */
.debug-panel {
  position: fixed;
  bottom: var(--spacing-md);
  right: var(--spacing-md);
  background: rgba(0, 0, 0, 0.9);
  color: var(--text-primary);
  padding: var(--spacing-md);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  max-width: 300px;
  max-height: 200px;
  overflow: auto;
  display: none;
  z-index: 200;
}

.debug-toggle {
  position: fixed;
  bottom: var(--spacing-md);
  right: var(--spacing-md);
  background: var(--accent-gold);
  color: #000;
  border: none;
  padding: var(--spacing-xs) var(--spacing-sm);
  border-radius: var(--radius-sm);
  font-size: 0.7rem;
  cursor: pointer;
  z-index: 201;
}

/* Responsive Design */
@media (max-width: 480px) {
  .game-container {
    padding: var(--spacing-xs) var(--spacing-sm);
    max-width: 100%;
  }
  
  .betting-grid {
    grid-template-columns: 1fr;
    gap: var(--spacing-xs);
  }
  
  .betting-card {
    height: 100px;
    padding: var(--spacing-sm);
  }
  
  .betting-card.side-card {
    height: 60px;
  }
  
  .side-betting-grid {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: var(--spacing-xs);
  }
  
  .chip {
    width: 45px;
    height: 45px;
  }
  
  .chip-value {
    font-size: 0.6rem;
  }
  
  .section-title {
    font-size: 0.9rem;
  }
}

@media (min-width: 481px) and (max-width: 640px) {
  .game-container {
    max-width: 500px;
    padding: var(--spacing-sm) var(--spacing-md);
  }
  
  .side-betting-grid {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: var(--spacing-xs);
  }
  
  .chip {
    width: 48px;
    height: 48px;
  }
}

@media (min-width: 641px) {
  .game-container {
    max-width: 600px;
    padding: var(--spacing-md) var(--spacing-lg);
  }
  
  .betting-card {
    height: 130px;
  }
  
  .betting-card.side-card {
    height: 75px;
  }
  
  .side-betting-grid {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: var(--spacing-sm);
  }
  
  .chip {
    width: 55px;
    height: 55px;
  }
  
  .chip-value {
    font-size: 0.7rem;
  }
  
  .section-title {
    font-size: 1.1rem;
  }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* High contrast mode */
@media (prefers-contrast: high) {
  :root {
    --card-bg: rgba(0, 0, 0, 0.8);
    --text-secondary: rgba(255, 255, 255, 0.9);
  }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
  .betting-card:hover {
    transform: none;
  }
  
  .chip:hover {
    transform: none;
  }
  
  .btn:hover {
    transform: none;
  }
}

/* Telegram Modal Styles */
.telegram-info {
  margin-bottom: var(--spacing-lg);
}

.current-telegram-info {
  background: rgba(42, 171, 238, 0.1);
  border: 1px solid rgba(42, 171, 238, 0.2);
  border-radius: var(--radius-sm);
  padding: var(--spacing-md);
  margin-bottom: var(--spacing-md);
}

.current-telegram-info h3 {
  color: var(--accent-gold);
  font-size: 1rem;
  margin-bottom: var(--spacing-sm);
}

.telegram-status {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
}

.telegram-id {
  font-family: monospace;
  background: rgba(0, 0, 0, 0.3);
  padding: var(--spacing-xs) var(--spacing-sm);
  border-radius: var(--radius-sm);
  color: var(--accent-gold);
  font-weight: bold;
}

.telegram-guide {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  padding: var(--spacing-md);
}

.telegram-guide h3 {
  color: var(--accent-gold);
  font-size: 1rem;
  margin-bottom: var(--spacing-sm);
}

.guide-steps {
  margin: 0;
  padding-left: var(--spacing-lg);
  color: var(--text-secondary);
}

.guide-steps li {
  margin-bottom: var(--spacing-xs);
  line-height: 1.4;
}

.guide-steps code {
  background: rgba(0, 0, 0, 0.3);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  color: var(--accent-gold);
}

.guide-steps strong {
  color: var(--text-primary);
}

.input-help {
  display: block;
  color: var(--text-secondary);
  font-size: 0.75rem;
  margin-top: var(--spacing-xs);
  opacity: 0.8;
}

.telegram-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-md);
}

.telegram-actions {
  text-align: center;
  padding-top: var(--spacing-md);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.telegram-actions .btn {
  font-size: 0.85rem;
}

/* Status indicators */
.status-connected {
  color: #4caf50;
}

.status-disconnected {
  color: #f44336;
}

.status-warning {
  color: #ff9800;
}

/* Print styles */
@media print {
  .modal,
  .debug-panel,
  .status-message {
    display: none !important;
  }
}