/* ========================================
   Vocabulary Duck Race - Style System
   Mobile-first responsive design
   ======================================== */

:root {
  /* Color Palette */
  --primary: #ff9f1c;
  --primary-dark: #e88a00;
  --secondary: #2ec4b6;
  --secondary-dark: #1a9e92;
  --accent: #e71d36;
  --accent-soft: #ff6b6b;
  
  /* Backgrounds */
  --bg-dark: #0f1419;
  --bg-card: #1a2332;
  --bg-card-hover: #243447;
  --bg-input: #2d3748;
  
  /* Text */
  --text-primary: #ffffff;
  --text-secondary: #a0aec0;
  --text-muted: #718096;
  
  /* Status */
  --success: #48bb78;
  --error: #fc8181;
  --warning: #f6e05e;
  
  /* Race track */
  --track-bg: #1e3a5f;
  --track-lane: #2d5a87;
  --water: #0077b6;
  --water-light: #00b4d8;
  
  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  
  /* Border radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-full: 9999px;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px rgba(255, 159, 28, 0.3);
  
  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow: 400ms ease;
}

/* ========================================
   Base Reset & Typography
   ======================================== */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Wave background animation */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: 
    radial-gradient(ellipse at 20% 80%, rgba(0, 119, 182, 0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(46, 196, 182, 0.1) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 50%, rgba(255, 159, 28, 0.05) 0%, transparent 60%);
  pointer-events: none;
  z-index: -1;
}

h1, h2, h3, h4 {
  font-weight: 700;
  line-height: 1.2;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }

a {
  color: var(--primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--primary-dark);
}

/* ========================================
   Layout Components
   ======================================== */

.container {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  padding: var(--space-md);
}

.container--wide {
  max-width: 900px;
}

.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.page__header {
  text-align: center;
  padding: var(--space-xl) var(--space-md);
}

.page__content {
  flex: 1;
  padding: var(--space-md);
}

/* ========================================
   Card Component
   ======================================== */

.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-md);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.card + .card {
  margin-top: var(--space-md);
}

.card__title {
  font-size: 1.125rem;
  margin-bottom: var(--space-md);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.card__title::before {
  content: '';
  width: 4px;
  height: 1.2em;
  background: var(--primary);
  border-radius: var(--radius-full);
}

/* ========================================
   Form Elements
   ======================================== */

.form-group {
  margin-bottom: var(--space-md);
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--space-xs);
}

.input {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  font-size: 1rem;
  color: var(--text-primary);
  background: var(--bg-input);
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(255, 159, 28, 0.2);
}

.input::placeholder {
  color: var(--text-muted);
}

.input--code {
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

select.input {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23a0aec0' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

/* ========================================
   Buttons
   ======================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-lg);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  background: var(--primary);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  min-height: 44px;
}

.btn:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn:active {
  transform: translateY(0);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn--secondary {
  background: var(--secondary);
}

.btn--secondary:hover {
  background: var(--secondary-dark);
}

.btn--outline {
  background: transparent;
  border: 2px solid var(--primary);
  color: var(--primary);
}

.btn--outline:hover {
  background: var(--primary);
  color: var(--text-primary);
}

.btn--danger {
  background: var(--accent);
}

.btn--danger:hover {
  background: var(--accent-soft);
}

.btn--large {
  padding: var(--space-md) var(--space-xl);
  font-size: 1.125rem;
  min-height: 56px;
}

.btn--full {
  width: 100%;
}

.btn--icon {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: var(--radius-full);
}

/* ========================================
   Duck Race Logo & Branding
   ======================================== */

.logo {
  font-size: 2.5rem;
  font-weight: 800;
  text-align: center;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: 0 2px 10px rgba(255, 159, 28, 0.3);
}

.logo__icon {
  font-size: 3rem;
  display: block;
  margin-bottom: var(--space-sm);
  animation: duck-bob 2s ease-in-out infinite;
}

@keyframes duck-bob {
  0%, 100% { transform: translateY(0) rotate(-5deg); }
  50% { transform: translateY(-8px) rotate(5deg); }
}

.subtitle {
  color: var(--text-secondary);
  font-size: 1rem;
  margin-top: var(--space-sm);
}

/* ========================================
   Room Code Display
   ======================================== */

.room-code {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-lg);
  text-align: center;
  box-shadow: var(--shadow-glow);
}

.room-code__label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  opacity: 0.9;
}

.room-code__value {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  font-family: 'Courier New', monospace;
}

/* ========================================
   Player List
   ======================================== */

.player-list {
  list-style: none;
}

.player-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-input);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-sm);
  animation: slide-in 0.3s ease;
}

@keyframes slide-in {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
}

.player-item__avatar {
  width: 40px;
  height: 40px;
  background: var(--secondary);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

.player-item__name {
  flex: 1;
  font-weight: 600;
}

.player-item__status {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.player-count {
  text-align: center;
  padding: var(--space-md);
  color: var(--text-secondary);
}

.player-count__number {
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary);
}

/* ========================================
   Race Track
   ======================================== */

.race-track {
  background: var(--track-bg);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  overflow: hidden;
  position: relative;
}

.race-track::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: repeating-linear-gradient(
    90deg,
    transparent 0px,
    transparent 48px,
    rgba(255, 255, 255, 0.03) 48px,
    rgba(255, 255, 255, 0.03) 50px
  );
  pointer-events: none;
}

.race-lane {
  display: flex;
  align-items: center;
  background: var(--track-lane);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md);
  margin-bottom: var(--space-sm);
  position: relative;
  min-height: 50px;
  overflow: hidden;
}

.race-lane:last-child {
  margin-bottom: 0;
}

.race-lane__name {
  width: 80px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  z-index: 2;
}

.race-lane__track {
  flex: 1;
  height: 100%;
  position: relative;
  margin: 0 var(--space-sm);
}

.race-lane__duck {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.5rem;
  transition: left 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
  z-index: 2;
}

.race-lane__finish {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 30px;
  background: repeating-linear-gradient(
    0deg,
    #fff 0px,
    #fff 5px,
    #000 5px,
    #000 10px
  );
  border-radius: var(--radius-sm);
  opacity: 0.8;
}

.race-lane__progress {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  background: linear-gradient(90deg, var(--water) 0%, var(--water-light) 100%);
  border-radius: var(--radius-sm);
  opacity: 0.3;
  transition: width 0.5s ease;
}

/* ========================================
   Question Card
   ======================================== */

.question-card {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  text-align: center;
  box-shadow: var(--shadow-lg);
  border: 2px solid rgba(255, 159, 28, 0.2);
}

.question-card__number {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: var(--space-sm);
}

.question-card__prompt {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: var(--space-lg);
  color: var(--text-primary);
}

.question-card__word {
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary);
  margin: var(--space-md) 0;
}

.options-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-sm);
}

@media (min-width: 480px) {
  .options-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.option-btn {
  padding: var(--space-md);
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-primary);
  background: var(--bg-input);
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: center;
}

.option-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--primary);
  transform: scale(1.02);
}

.option-btn:active {
  transform: scale(0.98);
}

.option-btn.selected {
  background: var(--primary);
  border-color: var(--primary);
}

.option-btn.correct {
  background: var(--success);
  border-color: var(--success);
}

.option-btn.wrong {
  background: var(--error);
  border-color: var(--error);
}

.option-btn:disabled {
  cursor: not-allowed;
  opacity: 0.7;
}

/* ========================================
   Progress Bar
   ======================================== */

.progress-bar {
  background: var(--bg-input);
  border-radius: var(--radius-full);
  height: 12px;
  overflow: hidden;
  position: relative;
}

.progress-bar__fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary) 0%, var(--secondary) 100%);
  border-radius: var(--radius-full);
  transition: width var(--transition-normal);
  position: relative;
}

.progress-bar__fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.3) 50%,
    transparent 100%
  );
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* ========================================
   Timer
   ======================================== */

.timer {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-card);
  border-radius: var(--radius-full);
  font-size: 1.25rem;
  font-weight: 700;
  font-family: 'Courier New', monospace;
}

.timer__icon {
  font-size: 1.5rem;
}

.timer--warning {
  color: var(--warning);
  animation: pulse 1s infinite;
}

.timer--danger {
  color: var(--error);
  animation: pulse 0.5s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ========================================
   Status Badge
   ======================================== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-radius: var(--radius-full);
  background: var(--bg-input);
  color: var(--text-secondary);
}

.badge--lobby {
  background: rgba(255, 159, 28, 0.2);
  color: var(--primary);
}

.badge--playing {
  background: rgba(72, 187, 120, 0.2);
  color: var(--success);
}

.badge--closed {
  background: rgba(160, 174, 192, 0.2);
  color: var(--text-muted);
}

/* ========================================
   Toast Notifications
   ======================================== */

.toast-container {
  position: fixed;
  top: var(--space-md);
  right: var(--space-md);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.toast {
  padding: var(--space-md) var(--space-lg);
  background: var(--bg-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  border-left: 4px solid var(--primary);
  animation: toast-in 0.3s ease;
  max-width: 320px;
}

.toast--success {
  border-color: var(--success);
}

.toast--error {
  border-color: var(--error);
}

.toast--warning {
  border-color: var(--warning);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
}

.toast-exit {
  animation: toast-out 0.3s ease forwards;
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateX(100%);
  }
}

/* ========================================
   Winner Celebration
   ======================================== */

.winner-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 20, 25, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fade-in 0.5s ease;
}

@keyframes fade-in {
  from { opacity: 0; }
}

.winner-card {
  text-align: center;
  padding: var(--space-2xl);
  animation: winner-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes winner-pop {
  from {
    opacity: 0;
    transform: scale(0.5);
  }
}

.winner-card__trophy {
  font-size: 5rem;
  animation: trophy-bounce 1s ease infinite;
}

@keyframes trophy-bounce {
  0%, 100% { transform: translateY(0) rotate(-5deg); }
  50% { transform: translateY(-20px) rotate(5deg); }
}

.winner-card__title {
  font-size: 1.5rem;
  color: var(--text-secondary);
  margin-top: var(--space-lg);
}

.winner-card__name {
  font-size: 2.5rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-top: var(--space-sm);
}

.confetti {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
  z-index: 999;
}

.confetti-piece {
  position: absolute;
  width: 10px;
  height: 10px;
  background: var(--primary);
  animation: confetti-fall 3s linear forwards;
}

@keyframes confetti-fall {
  0% {
    transform: translateY(-100vh) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(100vh) rotate(720deg);
    opacity: 0;
  }
}

/* ========================================
   Loading States
   ======================================== */

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--bg-input);
  border-top-color: var(--primary);
  border-radius: var(--radius-full);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  margin-left: var(--space-md);
  color: var(--text-secondary);
}

/* ========================================
   Section Visibility
   ======================================== */

.hidden {
  display: none !important;
}

.fade-in {
  animation: fade-in 0.3s ease;
}

/* ========================================
   Waiting Animation
   ======================================== */

.waiting-animation {
  text-align: center;
  padding: var(--space-xl);
}

.waiting-animation__duck {
  font-size: 4rem;
  animation: duck-swim 3s ease-in-out infinite;
}

@keyframes duck-swim {
  0%, 100% { 
    transform: translateX(-30px) rotate(-5deg); 
  }
  50% { 
    transform: translateX(30px) rotate(5deg); 
  }
}

.waiting-animation__text {
  margin-top: var(--space-md);
  color: var(--text-secondary);
}

.waiting-animation__dots::after {
  content: '';
  animation: dots 1.5s infinite;
}

@keyframes dots {
  0% { content: ''; }
  25% { content: '.'; }
  50% { content: '..'; }
  75% { content: '...'; }
}

/* ========================================
   Responsive Adjustments
   ======================================== */

@media (max-width: 480px) {
  :root {
    font-size: 14px;
  }
  
  .logo {
    font-size: 2rem;
  }
  
  .room-code__value {
    font-size: 2rem;
  }
  
  .question-card__word {
    font-size: 1.5rem;
  }
  
  .race-lane__name {
    width: 60px;
    font-size: 0.675rem;
  }
}

@media (min-width: 768px) {
  .container {
    padding: var(--space-xl);
  }
  
  h1 {
    font-size: 2.5rem;
  }
}

/* ========================================
   Utility Classes
   ======================================== */

.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-error { color: var(--error); }
.text-warning { color: var(--warning); }

.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mt-xl { margin-top: var(--space-xl); }

.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }

.flex { display: flex; }
.flex-center { 
  display: flex; 
  align-items: center; 
  justify-content: center; 
}
.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
