:root {
  /* Dark theme - Gradient backgrounds */
  --bg-primary: linear-gradient(135deg, #1e1b4b 0%, #312e81 100%);
  --bg-overlay: rgba(17, 24, 39, 0.95);
  --bg-card: rgba(30, 41, 59, 0.8);
  --bg-glass: rgba(255, 255, 255, 0.05);
  --text-primary: #f9fafb;
  --text-secondary: #d1d5db;
  --border-color: rgba(139, 92, 246, 0.3);
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.7);
  
  /* Game colors - Vibrant */
  --color-correct: linear-gradient(135deg, #34d399 0%, #10b981 100%);
  --color-present: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
  --color-absent: linear-gradient(135deg, #94a3b8 0%, #64748b 100%);
  --color-empty: rgba(30, 41, 59, 0.5);
  --color-empty-border: rgba(139, 92, 246, 0.4);
  
  /* Accent colors - Gradient */
  --accent-primary: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
  --accent-glow: rgba(139, 92, 246, 0.5);
  
  /* Spacing */
  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 2rem;
  --spacing-2xl: 3rem;
  
  /* Border radius */
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-xl: 32px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-primary);
  z-index: -1;
}

/* Header */
.header {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-color);
  padding: var(--spacing-md);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
  animation: slideDown 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideDown {
  from {
    transform: translateY(-100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

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

.logo {
  font-size: 1.5rem;
  font-weight: 800;
  background: var(--accent-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
  text-shadow: 0 0 30px var(--accent-glow);
}

.theme-toggle {
  display: none;
}

/* Main */
.main {
  flex: 1;
  padding: var(--spacing-lg) var(--spacing-md);
  animation: fadeIn 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.container {
  max-width: 500px;
  margin: 0 auto;
}

/* Home page */
.hero {
  text-align: center;
  margin-bottom: var(--spacing-2xl);
  animation: scaleIn 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.hero-title {
  font-size: clamp(2rem, 8vw, 3rem);
  font-weight: 900;
  margin-bottom: var(--spacing-md);
  background: var(--accent-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -1px;
  line-height: 1.1;
  text-shadow: 0 0 40px var(--accent-glow);
}

.hero-subtitle {
  font-size: clamp(1rem, 4vw, 1.25rem);
  color: var(--text-secondary);
  font-weight: 500;
}

.mode-selection {
  display: grid;
  gap: var(--spacing-lg);
  margin-bottom: var(--spacing-2xl);
}

.mode-card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--spacing-2xl);
  text-align: center;
  text-decoration: none;
  color: var(--text-primary);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.mode-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--accent-primary);
  opacity: 0;
  transition: opacity 0.4s;
  z-index: 0;
}

.mode-card:hover::before {
  opacity: 0.1;
}

.mode-card:hover {
  transform: translateY(-8px) scale(1.02);
  box-shadow: var(--shadow-lg), 0 0 40px var(--accent-glow);
  border-color: transparent;
}

.mode-card:active {
  transform: translateY(-4px) scale(1.01);
}

.mode-icon {
  font-size: 4rem;
  margin-bottom: var(--spacing-md);
  display: inline-block;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  z-index: 1;
}

.mode-card:hover .mode-icon {
  transform: scale(1.2) rotate(10deg);
}

.mode-title {
  font-size: clamp(1.25rem, 5vw, 1.75rem);
  font-weight: 800;
  margin-bottom: var(--spacing-sm);
  position: relative;
  z-index: 1;
}

.mode-description {
  color: var(--text-secondary);
  font-weight: 500;
  position: relative;
  z-index: 1;
}

/* Rules */
.rules {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--spacing-xl);
  box-shadow: var(--shadow);
  animation: fadeIn 1s cubic-bezier(0.4, 0, 0.2, 1) 0.2s both;
}

.rules h3 {
  margin-bottom: var(--spacing-lg);
  font-size: clamp(1.125rem, 4vw, 1.5rem);
  font-weight: 700;
}

.rules ul {
  list-style: none;
}

.rules li {
  padding: var(--spacing-md) 0;
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  transition: transform 0.2s;
}

.rules li:hover {
  transform: translateX(5px);
}

/* Game page */
.game-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--spacing-lg);
  margin-bottom: var(--spacing-2xl);
  text-align: center;
}

.back-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 600;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: var(--radius-md);
  background: var(--bg-glass);
  align-self: flex-start;
}

.back-link:hover {
  background: var(--bg-card);
  transform: translateX(-5px);
  box-shadow: var(--shadow);
}

.game-info {
  width: 100%;
  text-align: center;
}

.game-info h2 {
  font-size: clamp(1.25rem, 5vw, 2rem);
  margin-bottom: var(--spacing-sm);
  font-weight: 800;
}

.stats {
  display: flex;
  justify-content: center;
  gap: var(--spacing-xl);
  flex-wrap: wrap;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--spacing-md);
  background: var(--bg-glass);
  backdrop-filter: blur(10px);
  border-radius: var(--radius-md);
  min-width: 80px;
  transition: all 0.3s;
}

.stat:hover {
  transform: scale(1.05);
  background: var(--bg-card);
  box-shadow: var(--shadow);
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-value {
  font-size: 2rem;
  font-weight: 900;
  background: var(--accent-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Message */
.message {
  text-align: center;
  padding: var(--spacing-md) var(--spacing-lg);
  border-radius: var(--radius-lg);
  margin-bottom: var(--spacing-lg);
  font-weight: 600;
  min-height: 3.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(10px);
  animation: slideIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message.success {
  background: linear-gradient(135deg, rgba(52, 211, 153, 0.2) 0%, rgba(16, 185, 129, 0.2) 100%);
  color: #059669;
  border: 2px solid #10b981;
  box-shadow: 0 8px 32px rgba(16, 185, 129, 0.3);
}

.message.error {
  background: linear-gradient(135deg, rgba(248, 113, 113, 0.2) 0%, rgba(239, 68, 68, 0.2) 100%);
  color: #dc2626;
  border: 2px solid #ef4444;
  box-shadow: 0 8px 32px rgba(239, 68, 68, 0.3);
}

.message.info {
  background: var(--bg-glass);
  color: var(--text-secondary);
  border: 2px solid var(--border-color);
}

/* Grid */
.grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: var(--spacing-xl);
  padding: var(--spacing-md) 0;
}

.grid-row {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.grid-cell {
  width: clamp(50px, 12vw, 70px);
  height: clamp(50px, 12vw, 70px);
  border: 3px solid var(--color-empty-border);
  background: var(--color-empty);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(1.5rem, 6vw, 2.25rem);
  font-weight: 900;
  text-transform: uppercase;
  border-radius: var(--radius-md);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
  position: relative;
  overflow: hidden;
}

.grid-cell::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, transparent 100%);
  opacity: 0;
  transition: opacity 0.3s;
}

.grid-cell:hover::before {
  opacity: 1;
}

.grid-cell.filled {
  border-color: var(--text-primary);
  transform: scale(1.05);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.grid-cell.correct {
  background: var(--color-correct);
  border-color: transparent;
  color: white;
  box-shadow: 0 8px 24px rgba(16, 185, 129, 0.4);
}

.grid-cell.present {
  background: var(--color-present);
  border-color: transparent;
  color: white;
  box-shadow: 0 8px 24px rgba(245, 158, 11, 0.4);
}

.grid-cell.absent {
  background: var(--color-absent);
  border-color: transparent;
  color: white;
  box-shadow: 0 8px 24px rgba(100, 116, 139, 0.3);
}

.grid-cell.reveal {
  animation: reveal 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes pop {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

@keyframes reveal {
  0% {
    transform: rotateX(0deg) scale(1);
  }
  50% {
    transform: rotateX(90deg) scale(1.05);
  }
  100% {
    transform: rotateX(0deg) scale(1);
  }
}

/* Keyboard */
.keyboard {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: var(--spacing-xl);
  animation: fadeIn 0.8s cubic-bezier(0.4, 0, 0.2, 1) 0.3s both;
}

.keyboard-row {
  display: flex;
  gap: 6px;
  justify-content: center;
}

.key {
  background: var(--bg-card);
  backdrop-filter: blur(10px);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: clamp(0.75rem, 3vw, 1.25rem) clamp(0.5rem, 2vw, 0.75rem);
  min-width: clamp(32px, 8vw, 44px);
  font-size: clamp(0.75rem, 3vw, 1rem);
  font-weight: 700;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  color: var(--text-primary);
  user-select: none;
  position: relative;
  overflow: hidden;
}

.key::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: var(--accent-glow);
  transition: width 0.4s, height 0.4s, top 0.4s, left 0.4s;
  transform: translate(-50%, -50%);
  z-index: -1;
}

.key:hover::before {
  width: 200px;
  height: 200px;
}

.key:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
  border-color: transparent;
}

.key:active {
  transform: scale(0.95) translateY(0);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.key.wide {
  padding: clamp(0.75rem, 3vw, 1.25rem) clamp(0.75rem, 3vw, 1.5rem);
  font-size: clamp(0.7rem, 2.5vw, 0.875rem);
}

.key.correct {
  background: var(--color-correct);
  color: white;
  border-color: transparent;
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

.key.present {
  background: var(--color-present);
  color: white;
  border-color: transparent;
  box-shadow: 0 6px 20px rgba(245, 158, 11, 0.4);
}

.key.absent {
  background: var(--color-absent);
  color: white;
  border-color: transparent;
  opacity: 0.6;
}

/* Buttons */
.btn {
  padding: var(--spacing-md) var(--spacing-xl);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-lg);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(10px);
}

.btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--accent-primary);
  opacity: 0;
  transition: opacity 0.3s;
  z-index: -1;
}

.btn:hover::before {
  opacity: 0.2;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: transparent;
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: var(--accent-primary);
  color: white;
  border-color: transparent;
  box-shadow: 0 8px 24px var(--accent-glow);
}

.btn-primary:hover {
  box-shadow: 0 12px 32px var(--accent-glow);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 2px solid var(--border-color);
}

.btn-secondary:hover {
  background: var(--bg-glass);
}

.game-actions {
  display: flex;
  gap: var(--spacing-md);
  justify-content: center;
  margin-bottom: var(--spacing-xl);
  flex-wrap: wrap;
}

/* Definitions */
.definitions {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--spacing-xl);
  margin-top: var(--spacing-xl);
  box-shadow: var(--shadow);
  animation: fadeIn 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.definitions h3 {
  margin-bottom: var(--spacing-lg);
  font-size: clamp(1.125rem, 4vw, 1.5rem);
  font-weight: 700;
}

.definitions ul {
  list-style: none;
  padding-left: 0;
}

.definitions li {
  padding: var(--spacing-md) 0;
  padding-left: var(--spacing-xl);
  position: relative;
  transition: transform 0.2s;
}

.definitions li:hover {
  transform: translateX(5px);
}

.definitions li::before {
  content: "→";
  position: absolute;
  left: 0;
  background: var(--accent-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-weight: 900;
  font-size: 1.25rem;
}

/* Loading */
#loading {
  text-align: center;
  padding: var(--spacing-2xl);
  color: var(--text-secondary);
  font-size: 1.25rem;
  font-weight: 600;
  animation: pulse 2s ease-in-out infinite;
}

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

/* Footer */
.footer {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border-top: 2px solid var(--border-color);
  padding: var(--spacing-xl);
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
}

/* Confetti */
.confetti {
  position: fixed;
  width: 12px;
  height: 12px;
  background-color: #f0f;
  pointer-events: none;
  z-index: 9999;
  border-radius: 2px;
  animation: confetti-fall 3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes confetti-fall {
  0% {
    transform: translateY(0) rotateZ(0deg) rotateX(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(100vh) rotateZ(720deg) rotateX(360deg);
    opacity: 0;
  }
}

/* Responsive - Mobile First */
@media (min-width: 480px) {
  .logo {
    font-size: 1.75rem;
  }
  
  .mode-selection {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  }
}

@media (min-width: 768px) {
  .container {
    max-width: 600px;
  }
  
  .game-header {
    flex-wrap: nowrap;
  }
}

@media (min-width: 1024px) {
  .header .container {
    padding: 0 var(--spacing-lg);
  }
  
  .main {
    padding: var(--spacing-2xl) var(--spacing-lg);
  }
}
