/* CSS Custom Properties */
:root {
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-tertiary: #f7fafc;
  --text-primary: #333333;
  --text-secondary: #4a5568;
  --text-muted: #718096;
  --accent-primary: #667eea;
  --accent-secondary: #764ba2;
  --accent-tertiary: #8b5cf6;
  --border-color: #e2e8f0;
  --shadow-color: rgba(0, 0, 0, 0.1);
  --card-bg: #ffffff;
  --input-bg: #ffffff;
  --button-bg: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --button-hover: linear-gradient(135deg, #5a67d8 0%, #6b46c1 100%);
}

/* Dark Mode Variables */
[data-theme="dark"] {
  --bg-primary: #1a1a2e;
  --bg-secondary: #16213e;
  --bg-tertiary: #0f3460;
  --text-primary: #e8e8e8;
  --text-secondary: #b8b8b8;
  --text-muted: #888888;
  --accent-primary: #4f46e5;
  --accent-secondary: #6366f1;
  --accent-tertiary: #8b5cf6;
  --border-color: rgba(255, 255, 255, 0.1);
  --shadow-color: rgba(0, 0, 0, 0.3);
  --card-bg: rgba(22, 33, 62, 0.9);
  --input-bg: rgba(15, 52, 96, 0.8);
  --button-bg: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
  --button-hover: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
}

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

body {
  font-family: "Poppins", sans-serif;
  background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
  min-height: 100vh;
  color: var(--text-primary);
  overflow-x: hidden;
  transition: background 0.3s ease, color 0.3s ease;
}

/* Screen Management */
.screen {
  display: none;
  min-height: 100vh;
  position: relative;
}

.screen.active {
  display: flex;
  flex-direction: column;
}

/* Loading Screen */
#loading-screen {
  background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
  justify-content: center;
  align-items: center;
}

.loading-container {
  text-align: center;
  color: white;
}

.loading-animation {
  animation: fadeInUp 1s ease-out;
}

.tuna-logo {
  font-size: 4rem;
  margin-bottom: 1rem;
  animation: bounce 2s infinite;
}

.loading-text {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 2rem;
}

.loading-bar {
  width: 300px;
  height: 4px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
  overflow: hidden;
  margin: 0 auto;
}

.loading-progress {
  height: 100%;
  background: linear-gradient(90deg, #ffd700, #ffed4e);
  border-radius: 2px;
  animation: loading 3s ease-in-out infinite;
}

/* Login Screen */
#login-screen {
  background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
  justify-content: center;
  align-items: center;
  padding: 2rem;
}

.login-container {
  background: var(--card-bg);
  border-radius: 20px;
  padding: 3rem;
  box-shadow: 0 20px 40px var(--shadow-color);
  width: 100%;
  max-width: 500px;
  animation: slideUp 0.6s ease-out;
  border: 1px solid var(--border-color);
  transition: background 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

.game-header {
  text-align: center;
  margin-bottom: 2rem;
}

.game-header h1 {
  font-size: 1.8rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  transition: color 0.3s ease;
}

.game-subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  transition: color 0.3s ease;
}

.auth-tabs {
  display: flex;
  margin-bottom: 2rem;
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  transition: background 0.3s ease, border-color 0.3s ease;
}

.tab-button {
  flex: 1;
  padding: 1rem;
  border: none;
  background: transparent;
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: 500;
  color: var(--text-secondary);
}

.tab-button.active {
  background: var(--accent-primary);
  color: white;
}

.auth-form {
  display: none;
}

.auth-form.active {
  display: block;
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: color 0.3s ease;
}

.form-group input {
  width: 100%;
  padding: 0.75rem;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  font-size: 1rem;
  background: var(--input-bg);
  color: var(--text-primary);
  transition: border-color 0.3s ease, background 0.3s ease, color 0.3s ease;
}

.form-group input:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.player-input {
  display: flex;
  align-items: center;
  margin-bottom: 0.5rem;
}

.player-input input {
  flex: 1;
  margin-right: 0.5rem;
}

.player-role {
  font-size: 0.8rem;
  color: var(--accent-primary);
  font-weight: 500;
  transition: color 0.3s ease;
}

/* Buttons */
.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
}

.btn-primary {
  background: var(--button-bg);
  color: white;
  transition: background 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
}

.btn-primary:hover {
  background: var(--button-hover);
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(79, 70, 229, 0.3);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 2px solid var(--border-color);
  transition: background 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

.btn-secondary:hover {
  background: var(--bg-secondary);
  border-color: var(--text-muted);
}

.btn-outline {
  background: transparent;
  color: var(--accent-primary);
  border: 2px solid var(--accent-primary);
  transition: background 0.3s ease, color 0.3s ease;
}

.btn-outline:hover {
  background: var(--accent-primary);
  color: white;
}

.btn-large {
  padding: 1rem 2rem;
  font-size: 1.1rem;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
}

/* Game Screen */
#game-screen {
  background: var(--bg-secondary);
  transition: background 0.3s ease;
}

.game-container {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.game-header-bar {
  background: var(--card-bg);
  padding: 1rem 2rem;
  box-shadow: 0 2px 10px var(--shadow-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  transition: background 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

.team-info h2 {
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  transition: color 0.3s ease;
}

.team-stats {
  display: flex;
  gap: 1rem;
}

.stat {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  transition: color 0.3s ease;
}

.game-progress {
  background: var(--card-bg);
  padding: 1.5rem 2rem;
  border-bottom: 1px solid var(--border-color);
  transition: background 0.3s ease, border-color 0.3s ease;
}

.progress-track {
  height: 8px;
  background: var(--border-color);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 1rem;
  transition: background 0.3s ease;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
  border-radius: 4px;
  transition: width 0.5s ease;
  width: 0%;
}

.progress-labels {
  display: flex;
  justify-content: space-between;
}

.progress-labels .label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
  flex: 1;
  transition: color 0.3s ease;
}

.progress-labels .label.active {
  color: var(--accent-primary);
  font-weight: 600;
}

.game-content {
  flex: 1;
  padding: 2rem;
  overflow-y: auto;
}

.content-section {
  display: none;
  max-width: 800px;
  margin: 0 auto;
}

.content-section.active {
  display: block;
}

/* Welcome Screen */
.welcome-card {
  background: var(--card-bg);
  border-radius: 20px;
  padding: 3rem;
  text-align: center;
  box-shadow: 0 10px 30px var(--shadow-color);
  animation: slideUp 0.6s ease-out;
  border: 1px solid var(--border-color);
  transition: background 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

.welcome-icon {
  font-size: 4rem;
  margin-bottom: 1.5rem;
}

.welcome-card h3 {
  font-size: 1.8rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
  transition: color 0.3s ease;
}

.welcome-card p {
  color: var(--text-muted);
  margin-bottom: 2rem;
  line-height: 1.6;
  transition: color 0.3s ease;
}

.tuna-elements {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.element {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem;
  background: var(--bg-tertiary);
  border-radius: 12px;
  min-width: 120px;
  border: 1px solid var(--border-color);
  transition: background 0.3s ease, border-color 0.3s ease;
}

.element-icon {
  font-size: 1.5rem;
}

.element-name {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: color 0.3s ease;
}

/* Scenario Screen */
.scenario-card {
  background: var(--card-bg);
  border-radius: 20px;
  padding: 2rem;
  box-shadow: 0 10px 30px var(--shadow-color);
  animation: slideUp 0.6s ease-out;
  border: 1px solid var(--border-color);
  transition: background 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

.scenario-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--border-color);
  transition: border-color 0.3s ease;
}

.scenario-header h3 {
  color: var(--text-secondary);
  font-size: 1.5rem;
  transition: color 0.3s ease;
}

.scenario-position {
  background: var(--accent-primary);
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 500;
}

.scenario-text {
  font-size: 1.1rem;
  line-height: 1.8;
  color: var(--text-secondary);
  margin-bottom: 2rem;
  padding: 1.5rem;
  background: var(--bg-tertiary);
  border-radius: 12px;
  border-left: 4px solid var(--accent-primary);
  transition: color 0.3s ease, background 0.3s ease;
}

/* Decision Screen */
.decision-card {
  background: var(--card-bg);
  border-radius: 20px;
  padding: 2rem;
  box-shadow: 0 10px 30px var(--shadow-color);
  animation: slideUp 0.6s ease-out;
  border: 1px solid var(--border-color);
  transition: background 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

.decision-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--border-color);
  transition: border-color 0.3s ease;
}

.time-limit {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #e53e3e;
  font-weight: 600;
  background: rgba(229, 62, 62, 0.1);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  border: 1px solid rgba(229, 62, 62, 0.2);
}

.decision-header h3 {
  color: var(--text-secondary);
  font-size: 1.5rem;
  transition: color 0.3s ease;
}

.form-group textarea {
  width: 100%;
  padding: 1rem;
  border: 2px solid var(--border-color);
  border-radius: 12px;
  font-size: 1rem;
  font-family: inherit;
  resize: vertical;
  background: var(--input-bg);
  color: var(--text-primary);
  transition: border-color 0.3s ease, background 0.3s ease, color 0.3s ease;
}

.form-group textarea:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.char-count {
  text-align: right;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
  transition: color 0.3s ease;
}

.decision-actions {
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
  margin-top: 2rem;
}

/* Results Screen */
.results-card {
  background: var(--card-bg);
  border-radius: 20px;
  padding: 2rem;
  box-shadow: 0 10px 30px var(--shadow-color);
  animation: slideUp 0.6s ease-out;
  border: 1px solid var(--border-color);
  transition: background 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--border-color);
  transition: border-color 0.3s ease;
}

.score-display {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(79, 70, 229, 0.1);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  border: 1px solid rgba(79, 70, 229, 0.2);
}

.score-label {
  font-weight: 500;
  color: var(--text-secondary);
  transition: color 0.3s ease;
}

.score-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent-primary);
  transition: color 0.3s ease;
}

.score-max {
  color: var(--text-muted);
  transition: color 0.3s ease;
}

.results-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin-bottom: 2rem;
}

.team-answer,
.standard-answer {
  padding: 1.5rem;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  transition: background 0.3s ease, border-color 0.3s ease;
}

.team-answer {
  background: rgba(72, 187, 120, 0.1);
  border-left: 4px solid #48bb78;
}

.standard-answer {
  background: var(--bg-tertiary);
  border-left: 4px solid var(--accent-primary);
}

.team-answer h4,
.standard-answer h4 {
  color: var(--text-secondary);
  margin-bottom: 1rem;
  font-size: 1.1rem;
  transition: color 0.3s ease;
}

.answer-text {
  line-height: 1.6;
  color: var(--text-secondary);
  margin-bottom: 1rem;
  transition: color 0.3s ease;
}

.results-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  align-items: center;
}

.waiting-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
  color: white;
  border-radius: 12px;
  font-weight: 500;
  box-shadow: 0 4px 15px rgba(251, 191, 36, 0.3);
  animation: pulse 2s infinite;
}

.waiting-status i {
  font-size: 1.1rem;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

/* Game Complete Screen */
.complete-card {
  background: var(--card-bg);
  border-radius: 20px;
  padding: 3rem;
  text-align: center;
  box-shadow: 0 10px 30px var(--shadow-color);
  animation: slideUp 0.6s ease-out;
  border: 1px solid var(--border-color);
  transition: background 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

.complete-icon {
  font-size: 4rem;
  margin-bottom: 1.5rem;
}

.complete-card h3 {
  font-size: 1.8rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
  transition: color 0.3s ease;
}

.complete-card p {
  color: var(--text-muted);
  margin-bottom: 2rem;
  line-height: 1.6;
  transition: color 0.3s ease;
}

.final-stats {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-bottom: 2rem;
}

.stat-item {
  text-align: center;
}

.stat-label {
  display: block;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
  transition: color 0.3s ease;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent-primary);
  transition: color 0.3s ease;
}

.complete-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
}

/* Leaderboard Screen */
.leaderboard-card {
  background: var(--card-bg);
  border-radius: 20px;
  padding: 2rem;
  box-shadow: 0 10px 30px var(--shadow-color);
  animation: slideUp 0.6s ease-out;
  border: 1px solid var(--border-color);
  transition: background 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

.leaderboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--border-color);
  transition: border-color 0.3s ease;
}

.leaderboard-list {
  max-height: 400px;
  overflow-y: auto;
}

.leaderboard-item {
  display: flex;
  align-items: center;
  padding: 1rem;
  border-radius: 12px;
  margin-bottom: 0.5rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.leaderboard-item:hover {
  background: var(--bg-secondary);
}

.leaderboard-item.current-team {
  background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
  color: white;
  border-color: var(--accent-primary);
}

.rank {
  font-size: 1.2rem;
  font-weight: 700;
  width: 40px;
  text-align: center;
  margin-right: 1rem;
}

.team-name {
  flex: 1;
  font-weight: 500;
}

.team-stats {
  display: flex;
  gap: 1rem;
  font-size: 0.9rem;
}

/* Notification */
.notification {
  position: fixed;
  top: 2rem;
  right: 2rem;
  background: var(--card-bg);
  border-radius: 12px;
  padding: 1rem 1.5rem;
  box-shadow: 0 10px 30px var(--shadow-color);
  transform: translateX(400px);
  transition: transform 0.3s ease, background 0.3s ease, box-shadow 0.3s ease;
  z-index: 1000;
  max-width: 400px;
  border: 1px solid var(--border-color);
}

.notification.show {
  transform: translateX(0);
}

.notification-content {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.notification-icon {
  font-size: 1.2rem;
}

.notification.success .notification-icon {
  color: #48bb78;
}

.notification.error .notification-icon {
  color: #e53e3e;
}

.notification.warning .notification-icon {
  color: #ed8936;
}

.notification-info .notification-icon {
  color: #4299e1;
}

/* Animations */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

@keyframes bounce {
  0%,
  20%,
  50%,
  80%,
  100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-10px);
  }
  60% {
    transform: translateY(-5px);
  }
}

@keyframes loading {
  0% {
    width: 0%;
  }
  50% {
    width: 70%;
  }
  100% {
    width: 100%;
  }
}

/* Responsive Design */
@media (max-width: 768px) {
  .login-container {
    padding: 2rem;
    margin: 1rem;
  }

  .game-header-bar {
    padding: 1rem;
    flex-direction: column;
    gap: 1rem;
    text-align: center;
  }

  .game-progress {
    padding: 1rem;
  }

  .progress-labels {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .progress-labels .label {
    font-size: 0.7rem;
  }

  .game-content {
    padding: 1rem;
  }

  .welcome-card,
  .scenario-card,
  .decision-card,
  .results-card,
  .complete-card,
  .leaderboard-card {
    padding: 1.5rem;
  }

  .tuna-elements {
    gap: 1rem;
  }

  .element {
    min-width: 100px;
  }

  .results-content {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .final-stats {
    flex-direction: column;
    gap: 1rem;
  }

  .decision-actions,
  .results-actions,
  .complete-actions {
    flex-direction: column;
  }

  .notification {
    right: 1rem;
    left: 1rem;
    transform: translateY(-100px);
  }

  .notification.show {
    transform: translateY(0);
  }
}

@media (max-width: 480px) {
  .game-header h1 {
    font-size: 1.4rem;
  }

  .welcome-icon,
  .complete-icon {
    font-size: 3rem;
  }

  .tuna-logo {
    font-size: 3rem;
  }

  .loading-text {
    font-size: 1.2rem;
  }

  .loading-bar {
    width: 250px;
  }
}

/* Dark Mode Toggle */
.dark-mode-toggle {
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 1000;
}

.toggle-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
  color: white;
  font-size: 18px;
}

.toggle-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.3);
  transform: scale(1.1);
}

.toggle-btn:active {
  transform: scale(0.95);
}

/* Dark mode toggle in dark theme */
[data-theme="dark"] .toggle-btn {
  background: rgba(0, 0, 0, 0.2);
  border-color: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

[data-theme="dark"] .toggle-btn:hover {
  background: rgba(0, 0, 0, 0.3);
  border-color: rgba(255, 255, 255, 0.2);
}

/* Additional Dark Mode Enhancements */
[data-theme="dark"] .loading-container {
  color: var(--text-primary);
}

[data-theme="dark"] .loading-text {
  color: var(--text-primary);
}

[data-theme="dark"] .loading-bar {
  background: rgba(255, 255, 255, 0.2);
}

[data-theme="dark"] .loading-progress {
  background: linear-gradient(90deg, #ffd700, #ffed4e);
}

/* Smooth transitions for all elements */
* {
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

/* Ensure proper contrast in dark mode */
[data-theme="dark"] .notification-message {
  color: var(--text-primary);
}

[data-theme="dark"] .notification.success .notification-icon {
  color: #48bb78;
}

[data-theme="dark"] .notification.error .notification-icon {
  color: #e53e3e;
}

[data-theme="dark"] .notification.warning .notification-icon {
  color: #ed8936;
}

[data-theme="dark"] .notification.info .notification-icon {
  color: #4299e1;
}

