:root {
  --primary: #00e6ac;
  --primary-dark: #00b386;
  --secondary: #6c5ce7;
  --bg-dark: #0f2027;
  --bg-medium: #203a43;
  --bg-light: #2c5364;
  --card-bg: rgba(255, 255, 255, 0.05);
  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.7);
  --success: #00e6ac;
  --warning: #fdcb6e;
  --danger: #e17055;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.4);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Poppins', sans-serif;
  background: linear-gradient(135deg, var(--bg-dark) 0%, var(--bg-medium) 50%, var(--bg-light) 100%);
  background-attachment: fixed;
  color: var(--text-primary);
  min-height: 100vh;
  padding: 20px;
  line-height: 1.6;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
}

/* Header */
.header {
  text-align: center;
  margin-bottom: 30px;
  padding: 20px;
}

.header h1 {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 10px;
  text-shadow: 0 2px 10px rgba(0, 230, 172, 0.3);
}

.subtitle {
  font-size: 1.1rem;
  color: var(--text-secondary);
  font-weight: 300;
}

/* Login Section */
.login-section {
  display: flex;
  justify-content: center;
  margin-bottom: 30px;
}

.login-card {
  background: var(--card-bg);
  backdrop-filter: blur(10px);
  padding: 40px;
  border-radius: 20px;
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 400px;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.login-card h2 {
  margin-bottom: 25px;
  color: var(--primary);
  font-weight: 600;
}

.login-card input {
  width: 100%;
  padding: 15px;
  margin-bottom: 20px;
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  color: var(--text-primary);
  font-size: 1rem;
  font-family: 'Poppins', sans-serif;
  transition: all 0.3s ease;
}

.login-card input:focus {
  outline: none;
  border-color: var(--primary);
  background: rgba(255, 255, 255, 0.15);
}

.login-card input::placeholder {
  color: var(--text-secondary);
}

/* Buttons */
button {
  font-family: 'Poppins', sans-serif;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  border: none;
  border-radius: 12px;
  padding: 12px 24px;
  font-size: 1rem;
}

.btn-primary {
  background: var(--primary);
  color: #000;
  box-shadow: 0 4px 15px rgba(0, 230, 172, 0.3);
}

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 230, 172, 0.4);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.2);
}

.btn-large {
  padding: 15px 40px;
  font-size: 1.1rem;
}

/* App Section */
.hidden {
  display: none;
}

.welcome-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  padding: 20px;
  background: var(--card-bg);
  border-radius: 15px;
  backdrop-filter: blur(10px);
}

.welcome-header h2 {
  color: var(--primary);
  font-size: 1.8rem;
  font-weight: 600;
}

/* Treino Form */
.treino-form {
  background: var(--card-bg);
  backdrop-filter: blur(10px);
  padding: 30px;
  border-radius: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 30px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.form-header {
  text-align: center;
  margin-bottom: 30px;
}

.form-header h3 {
  font-size: 1.8rem;
  color: var(--primary);
  margin-bottom: 10px;
  font-weight: 600;
}

.goal-info {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.racks-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.rack-card {
  background: rgba(0, 0, 0, 0.3);
  padding: 20px;
  border-radius: 15px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  transition: all 0.3s ease;
}

.rack-card:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 15px rgba(0, 230, 172, 0.2);
}

.rack-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.rack-title {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--primary);
}

.rack-score {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--primary);
  background: rgba(0, 230, 172, 0.2);
  padding: 5px 15px;
  border-radius: 20px;
}

/* Ball Selection */
.balls-section {
  margin-bottom: 15px;
}

.balls-label {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 10px;
  display: block;
  font-weight: 500;
}

.balls-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 15px;
}

.ball-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.3s ease;
  border: 3px solid transparent;
  user-select: none;
}

.ball-item .ball-number {
  position: relative;
  z-index: 1;
  color: white;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

/* Ball colors (9-ball pool) */
.ball-1 { background: linear-gradient(135deg, #FFD700, #FFA500); }
.ball-2 { background: linear-gradient(135deg, #0066FF, #0044CC); }
.ball-3 { background: linear-gradient(135deg, #FF0000, #CC0000); }
.ball-4 { background: linear-gradient(135deg, #800080, #5A005A); }
.ball-5 { background: linear-gradient(135deg, #FF8C00, #CC7000); }
.ball-6 { background: linear-gradient(135deg, #008000, #006600); }
.ball-7 { background: linear-gradient(135deg, #8B0000, #660000); }
.ball-8 { background: linear-gradient(135deg, #000000, #1a1a1a); }
.ball-9 { background: linear-gradient(135deg, #FFFF00, #CCCC00); }

.ball-item:hover {
  transform: scale(1.1);
  border-color: rgba(255, 255, 255, 0.5);
}

.ball-item.pocketed {
  opacity: 0.6;
  border-color: var(--success);
  box-shadow: 0 0 10px rgba(0, 230, 172, 0.5);
}

.ball-item.pocketed::after {
  content: '✓';
  position: absolute;
  top: -5px;
  right: -5px;
  background: var(--success);
  color: #000;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: bold;
  z-index: 2;
}

.ball-item.removed {
  opacity: 0.4;
  border-color: var(--danger);
  box-shadow: 0 0 10px rgba(225, 112, 85, 0.5);
}

.ball-item.removed::after {
  content: '✕';
  position: absolute;
  top: -5px;
  right: -5px;
  background: var(--danger);
  color: white;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: bold;
  z-index: 2;
}

/* White ball option */
.white-ball-section {
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.white-ball-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  padding: 10px;
  border-radius: 10px;
  transition: background 0.3s ease;
}

.white-ball-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
}

.white-ball-toggle label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-weight: 500;
}

.white-ball-icon {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ffffff, #e0e0e0);
  border: 2px solid rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  color: #000;
  font-weight: bold;
}

.white-ball-toggle input[type="checkbox"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
  accent-color: var(--primary);
}

.white-ball-toggle.active {
  background: rgba(225, 112, 85, 0.2);
  border: 1px solid var(--danger);
}

/* Form Footer */
.form-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.score-preview {
  display: flex;
  align-items: center;
  gap: 10px;
}

.score-preview .label {
  font-size: 1.1rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.score-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--primary);
  background: rgba(0, 230, 172, 0.2);
  padding: 10px 20px;
  border-radius: 12px;
}

/* Stats Section */
.stats-section {
  background: var(--card-bg);
  backdrop-filter: blur(10px);
  padding: 30px;
  border-radius: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 30px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.stats-section h3 {
  text-align: center;
  font-size: 1.8rem;
  color: var(--primary);
  margin-bottom: 25px;
  font-weight: 600;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
}

.stat-card {
  background: rgba(0, 0, 0, 0.3);
  padding: 25px;
  border-radius: 15px;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: all 0.3s ease;
}

.stat-card:hover {
  transform: translateY(-5px);
  border-color: var(--primary);
  box-shadow: 0 6px 20px rgba(0, 230, 172, 0.2);
}

.stat-value {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 10px;
}

.stat-label {
  font-size: 0.95rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Chart Section */
.chart-section {
  background: var(--card-bg);
  backdrop-filter: blur(10px);
  padding: 30px;
  border-radius: 20px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.chart-section h3 {
  text-align: center;
  font-size: 1.8rem;
  color: var(--primary);
  margin-bottom: 25px;
  font-weight: 600;
}

#graficoEvolucao {
  max-height: 400px;
}

/* Responsive Design */
@media (max-width: 768px) {
  .header h1 {
    font-size: 2rem;
  }

  .welcome-header {
    flex-direction: column;
    gap: 15px;
    text-align: center;
  }

  .racks-container {
    grid-template-columns: 1fr;
  }

  .balls-grid {
    grid-template-columns: repeat(5, 1fr);
  }

  .form-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .score-preview {
    justify-content: center;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .treino-form {
    padding: 20px;
  }

  .login-card {
    padding: 30px 20px;
  }
}

@media (max-width: 480px) {
  body {
    padding: 10px;
  }

  .header h1 {
    font-size: 1.5rem;
  }

  .balls-grid {
    gap: 6px;
  }

  .ball-item {
    font-size: 0.8rem;
  }

  .rack-title {
    font-size: 1.1rem;
  }

  .score-value {
    font-size: 1.5rem;
  }
}