/* ==================== CSS VARIABLES ==================== */
:root {
  --primary: #6C63FF;
  --primary-dark: #5A52D5;
  --secondary: #FF6B9D;
  --accent: #00D9A5;
  --warning: #FFB84D;
  --gaming: #FF4757;
  --study: #5352ED;
  --creative: #A55EEA;
  
  --bg-dark: #1a1a2e;
  --bg-card: #16213e;
  --bg-light: #0f3460;
  
  --text: #ffffff;
  --text-muted: #a0a0b0;
  
  --radius: 20px;
  --radius-sm: 12px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  
  /* FPS Colors */
  --fps-excellent: #00D9A5;
  --fps-good: #7ED321;
  --fps-ok: #FFB84D;
  --fps-bad: #FF4757;
}

/* ==================== RESET & BASE ==================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Fredoka', 'Comic Neue', sans-serif;
  background: var(--bg-dark);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

.screen {
  display: none;
  min-height: 100vh;
  animation: fadeIn 0.5s ease;
}

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

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

/* ==================== ANIMATED BACKGROUND ==================== */
.bg-particles {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.particle {
  position: absolute;
  font-size: 2rem;
  opacity: 0.15;
  animation: float 20s infinite ease-in-out;
}

.particle:nth-child(1) { left: 10%; top: 20%; animation-delay: 0s; }
.particle:nth-child(2) { left: 80%; top: 10%; animation-delay: -3s; }
.particle:nth-child(3) { left: 30%; top: 70%; animation-delay: -6s; }
.particle:nth-child(4) { left: 70%; top: 60%; animation-delay: -9s; }
.particle:nth-child(5) { left: 50%; top: 30%; animation-delay: -12s; }
.particle:nth-child(6) { left: 20%; top: 50%; animation-delay: -15s; }
.particle:nth-child(7) { left: 90%; top: 80%; animation-delay: -18s; }
.particle:nth-child(8) { left: 5%; top: 90%; animation-delay: -2s; }

@keyframes float {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  25% { transform: translate(30px, -50px) rotate(90deg); }
  50% { transform: translate(-20px, 20px) rotate(180deg); }
  75% { transform: translate(40px, 40px) rotate(270deg); }
}

/* ==================== WELCOME SCREEN ==================== */
#welcome {
  justify-content: center;
  align-items: center;
  padding: 2rem;
}

.welcome-content {
  text-align: center;
  position: relative;
  z-index: 1;
}

.logo-animation {
  margin-bottom: 1rem;
}

.logo-icon {
  font-size: 6rem;
  display: inline-block;
  animation: bounce 2s infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-20px); }
}

.title-main {
  font-size: clamp(2rem, 8vw, 4rem);
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 1rem;
}

.title-word {
  display: inline-block;
  margin-right: 0.3em;
  animation: slideIn 0.6s ease backwards;
}

.title-word:nth-child(1) { animation-delay: 0.1s; }
.title-word:nth-child(2) { animation-delay: 0.2s; }
.title-word:nth-child(3) { animation-delay: 0.3s; }
.title-word:nth-child(4) { animation-delay: 0.4s; }

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

.gradient-text {
  background: linear-gradient(135deg, var(--secondary), var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  font-size: 1.5rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
  animation: fadeIn 1s ease 0.6s backwards;
}

.welcome-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 2rem;
  animation: fadeIn 1s ease 0.8s backwards;
}

/* ==================== BUTTONS ==================== */
.btn-primary, .btn-secondary {
  padding: 1rem 2rem;
  font-size: 1.1rem;
  font-family: inherit;
  font-weight: 600;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.3s ease;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  box-shadow: 0 5px 20px rgba(108, 99, 255, 0.4);
}

.btn-primary:hover {
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 8px 30px rgba(108, 99, 255, 0.6);
}

.btn-primary.pulse {
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 5px 20px rgba(108, 99, 255, 0.4); }
  50% { box-shadow: 0 5px 40px rgba(108, 99, 255, 0.8); }
}

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

.btn-secondary:hover {
  background: var(--primary);
  transform: translateY(-3px);
}

/* ==================== FEATURES PREVIEW ==================== */
.features-preview {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 1rem;
  animation: fadeIn 1s ease 1s backwards;
}

.feature-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  min-width: 100px;
}

.feature-icon {
  font-size: 2rem;
}

.feature-name {
  font-weight: 600;
}

.feature-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ==================== LESSON SCREEN ==================== */
#lesson {
  padding: 1rem;
}

.lesson-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: var(--bg-card);
  border-radius: var(--radius);
  margin-bottom: 1rem;
}

.progress-bar {
  flex: 1;
  height: 12px;
  background: var(--bg-dark);
  border-radius: 6px;
  overflow: hidden;
}

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

.step-counter {
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
}

.btn-back {
  padding: 0.5rem 1rem;
  background: var(--bg-light);
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-back:hover {
  background: var(--primary);
}

.lesson-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.lesson-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 2rem;
  max-width: 800px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow);
  animation: cardIn 0.5s ease;
}

@keyframes cardIn {
  from { opacity: 0; transform: scale(0.9) rotateX(10deg); }
  to { opacity: 1; transform: scale(1) rotateX(0); }
}

.lesson-icon {
  font-size: 5rem;
  margin-bottom: 1rem;
  animation: wiggle 1s ease infinite;
}

@keyframes wiggle {
  0%, 100% { transform: rotate(-5deg); }
  50% { transform: rotate(5deg); }
}

.lesson-title {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
  color: var(--accent);
}

.lesson-word {
  font-size: 1.5rem;
  color: var(--warning);
  margin-bottom: 1rem;
  font-weight: 600;
}

.lesson-description {
  font-size: 1.2rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

.pronunciation {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.8rem 1.5rem;
  background: var(--bg-dark);
  border-radius: var(--radius-sm);
  margin-bottom: 1.5rem;
}

.pronunciation-text {
  font-size: 1.1rem;
  color: var(--primary);
  font-style: italic;
}

.speak-btn {
  padding: 0.8rem 1.5rem;
  background: var(--primary);
  border: none;
  border-radius: 50%;
  color: white;
  font-size: 1.2rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

.speak-btn:hover {
  transform: scale(1.1);
  background: var(--secondary);
}

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

.visual-box {
  padding: 1.5rem;
  background: var(--bg-dark);
  border-radius: var(--radius-sm);
  text-align: center;
  min-width: 150px;
  transition: all 0.3s ease;
  cursor: pointer;
}

.visual-box:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 30px rgba(108, 99, 255, 0.3);
}

.visual-icon {
  font-size: 3rem;
  margin-bottom: 0.5rem;
}

.visual-label {
  font-weight: 600;
}

.example-sentence {
  padding: 1rem;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: var(--radius-sm);
  font-size: 1.1rem;
  line-height: 1.6;
}

.example-sentence .highlight {
  background: rgba(255,255,255,0.2);
  padding: 0.2rem 0.5rem;
  border-radius: 5px;
}

.lesson-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem;
}

.btn-nav {
  padding: 1rem 2rem;
  font-size: 1.1rem;
  font-family: inherit;
  font-weight: 600;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.3s ease;
}

.btn-nav.prev {
  background: var(--bg-card);
  color: var(--text);
}

.btn-nav.next {
  background: linear-gradient(135deg, var(--accent), var(--primary));
  color: white;
}

.btn-nav:hover {
  transform: translateY(-3px);
}

.btn-nav:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ==================== BUILDER SCREEN ==================== */
#builder {
  padding: 1rem;
  height: 100vh;
  overflow: hidden;
}

.builder-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1rem;
}

.builder-header h2 {
  font-size: 1.3rem;
  color: var(--accent);
}

.builder-layout {
  display: grid;
  grid-template-columns: 300px 1fr 260px;
  gap: 1rem;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* Parts Panel */
.parts-panel {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1rem;
  overflow-y: auto;
}

.part-section {
  margin-bottom: 1.5rem;
}

.part-section h4 {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  color: var(--primary);
  font-size: 1rem;
}

.selected-name {
  font-size: 0.8rem;
  color: var(--accent);
  font-weight: normal;
}

.part-options {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.part-option {
  padding: 0.6rem;
  background: var(--bg-dark);
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.part-option:hover {
  border-color: var(--primary);
  transform: translateX(5px);
}

.part-option.selected {
  border-color: var(--accent);
  background: rgba(0, 217, 165, 0.15);
}

.part-option-icon {
  font-size: 1.3rem;
}

.part-option-info {
  flex: 1;
}

.part-option-name {
  font-weight: 600;
  font-size: 0.9rem;
  display: block;
}

.part-option-specs {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.part-option-price {
  font-weight: 600;
  color: var(--warning);
  font-size: 0.9rem;
}

/* Build Center */
.build-center {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.pc-showcase {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.5rem;
  flex: 1;
}

.pc-frame {
  text-align: center;
  padding: 1.5rem;
  background: linear-gradient(135deg, var(--bg-dark), var(--bg-light));
  border-radius: var(--radius);
  margin-bottom: 1rem;
}

.pc-icon-large {
  font-size: 4rem;
  animation: float 3s ease-in-out infinite;
}

.pc-status {
  margin-top: 0.5rem;
  font-size: 1rem;
  color: var(--text-muted);
}

/* FPS Display */
.fps-display {
  background: var(--bg-dark);
  border-radius: var(--radius);
  padding: 1rem;
}

.fps-display h3 {
  text-align: center;
  margin-bottom: 1rem;
  color: var(--accent);
}

.fps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.fps-game {
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  text-align: center;
  border: 2px solid transparent;
  transition: all 0.3s ease;
}

.fps-game:hover {
  transform: scale(1.05);
  border-color: var(--primary);
}

.fps-game-icon {
  font-size: 1.5rem;
  margin-bottom: 0.3rem;
}

.fps-game-name {
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
}

.fps-value {
  font-size: 1.5rem;
  font-weight: 700;
}

.fps-value.excellent { color: var(--fps-excellent); }
.fps-value.good { color: var(--fps-good); }
.fps-value.ok { color: var(--fps-ok); }
.fps-value.bad { color: var(--fps-bad); }

.fps-quality {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.fps-summary {
  text-align: center;
  padding: 1rem;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: var(--radius-sm);
}

.fps-summary-text {
  font-size: 1.1rem;
  font-weight: 600;
}

/* Summary Panel */
.summary-panel {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  flex-direction: column;
}

.summary-panel h3 {
  margin-bottom: 0.75rem;
  color: var(--accent);
}

.budget-breakdown {
  flex: 1;
  overflow-y: auto;
  margin-bottom: 0.75rem;
}

.budget-item {
  display: flex;
  justify-content: space-between;
  padding: 0.4rem 0.5rem;
  background: var(--bg-dark);
  border-radius: var(--radius-sm);
  margin-bottom: 0.3rem;
  font-size: 0.85rem;
}

.budget-item.empty {
  color: var(--text-muted);
  justify-content: center;
  font-style: italic;
}

.budget-item-name {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.budget-item-price {
  color: var(--warning);
}

.total-price {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: var(--radius-sm);
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
}

.build-rating {
  text-align: center;
  padding: 0.75rem;
  background: var(--bg-dark);
  border-radius: var(--radius-sm);
  margin-bottom: 0.75rem;
}

.rating-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: block;
  margin-bottom: 0.3rem;
}

.rating-stars {
  font-size: 1.5rem;
  margin-bottom: 0.3rem;
}

.rating-text {
  font-size: 0.9rem;
  font-weight: 600;
}

.btn-present {
  padding: 0.8rem;
  background: linear-gradient(135deg, var(--accent), var(--primary));
  border: none;
  border-radius: var(--radius);
  color: white;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-present:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 30px rgba(0, 217, 165, 0.4);
}

/* Benchmark Overlay */
.benchmark-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.benchmark-overlay.active {
  display: flex;
}

.benchmark-content {
  text-align: center;
  padding: 2rem;
}

.benchmark-icon {
  font-size: 5rem;
  animation: spin 1s linear infinite;
  margin-bottom: 1rem;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.benchmark-content h2 {
  margin-bottom: 1rem;
  color: var(--accent);
}

.benchmark-progress {
  width: 300px;
  height: 20px;
  background: var(--bg-dark);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 1rem;
}

.benchmark-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--primary), var(--secondary));
  border-radius: 10px;
  transition: width 0.3s ease;
}

#benchmarkStatus {
  color: var(--text-muted);
}

/* ==================== GAMES SCREEN ==================== */
#games {
  padding: 1rem;
  height: 100vh;
  overflow-y: auto;
}

.games-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.games-header h2 {
  color: var(--accent);
}

.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.game-container {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.game-container h3 {
  margin-bottom: 0.5rem;
  color: var(--accent);
}

.game-container p {
  color: var(--text-muted);
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.game-stats {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.game-stats span {
  background: var(--bg-dark);
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}

/* Memory Game */
.memory-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  max-width: 300px;
  margin: 0 auto;
}

.memory-card {
  aspect-ratio: 1;
  background: var(--bg-light);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

.memory-card:hover {
  transform: scale(1.05);
}

.memory-card.flipped {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
}

.memory-card.matched {
  background: var(--accent);
  cursor: default;
}

/* Quiz Game */
.quiz-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

.quiz-option {
  padding: 0.8rem;
  background: var(--bg-dark);
  border: 3px solid transparent;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text);
  cursor: pointer;
  transition: all 0.3s ease;
}

.quiz-option:hover:not(:disabled) {
  border-color: var(--primary);
}

.quiz-option.correct {
  background: var(--accent);
  border-color: var(--accent);
}

.quiz-option.wrong {
  background: var(--secondary);
  border-color: var(--secondary);
}

.quiz-result {
  text-align: center;
  padding: 1rem;
  margin-top: 1rem;
  border-radius: var(--radius-sm);
}

/* What's This Game */
.whatsthis-display {
  font-size: 5rem;
  text-align: center;
  padding: 1.5rem;
  animation: zoomIn 0.5s ease;
}

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

.whatsthis-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
}

.wt-option {
  padding: 0.7rem;
  background: var(--bg-dark);
  border: 3px solid transparent;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s ease;
}

.wt-option.correct { background: var(--accent); border-color: var(--accent); }
.wt-option.wrong { background: var(--secondary); border-color: var(--secondary); }

/* Sort Game */
.sort-board {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.sort-categories {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

.sort-category {
  background: var(--bg-dark);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  min-height: 100px;
  border: 2px dashed var(--text-muted);
  transition: all 0.3s ease;
}

.sort-category.drag-over {
  border-color: var(--accent);
  background: rgba(0, 217, 165, 0.1);
}

.sort-pool {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  padding: 0.75rem;
  background: var(--bg-dark);
  border-radius: var(--radius-sm);
  min-height: 60px;
}

.sort-item {
  padding: 0.4rem 0.8rem;
  background: var(--bg-light);
  border-radius: var(--radius-sm);
  cursor: grab;
  font-size: 0.85rem;
  border: 2px solid transparent;
}

.sort-item:hover { border-color: var(--primary); }
.sort-item.correct { background: var(--accent); }
.sort-item.wrong { background: var(--secondary); }

/* Speed Game */
.speed-board {
  display: flex;
  gap: 2rem;
  justify-content: center;
  flex-wrap: wrap;
}

.speed-words, .speed-pics {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  max-width: 250px;
}

.speed-word {
  padding: 0.5rem 1rem;
  background: var(--bg-dark);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--text);
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.2s ease;
}

.speed-word:hover { border-color: var(--primary); }
.speed-word.selected { border-color: var(--accent); background: rgba(0, 217, 165, 0.2); }
.speed-word.matched { background: var(--accent); cursor: default; }

.speed-pic {
  width: 60px;
  height: 60px;
  background: var(--bg-dark);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.2s ease;
}

.speed-pic:hover { border-color: var(--primary); transform: scale(1.1); }
.speed-pic.matched { background: var(--accent); cursor: default; }

.timer-bar {
  height: 6px;
  background: var(--bg-dark);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 0.5rem;
}

.timer-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--primary));
  width: 100%;
  transition: width 0.1s linear;
}

/* ==================== MODALS ==================== */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 2rem;
  max-width: 500px;
  width: 100%;
  position: relative;
  animation: modalIn 0.3s ease;
}

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

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: var(--bg-dark);
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

.modal-close:hover {
  background: var(--secondary);
  transform: rotate(90deg);
}

/* Celebration Modal */
.celebration {
  text-align: center;
  padding: 2.5rem;
}

.celebration-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
  animation: celebrateBounce 0.5s ease;
}

@keyframes celebrateBounce {
  0% { transform: scale(0) rotate(-180deg); }
  60% { transform: scale(1.2) rotate(10deg); }
  100% { transform: scale(1) rotate(0deg); }
}

.celebration-stars {
  font-size: 2rem;
  margin: 1rem 0;
}

/* Presentation Modal */
.presentation h2 {
  text-align: center;
  color: var(--accent);
  margin-bottom: 1rem;
}

.pres-build-name {
  font-size: 1.3rem;
  text-align: center;
  margin-bottom: 1rem;
  padding: 0.75rem;
  background: var(--bg-dark);
  border-radius: var(--radius-sm);
}

.pres-parts {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.pres-part {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  background: var(--bg-dark);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}

.pres-total {
  text-align: center;
  font-size: 1.2rem;
  color: var(--warning);
  padding: 0.75rem;
  background: var(--bg-dark);
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
}

.pres-speech {
  text-align: center;
  padding: 1rem;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: var(--radius-sm);
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 900px) {
  .builder-layout {
    grid-template-columns: 1fr;
    overflow-y: auto;
  }
  
  .parts-panel {
    max-height: 300px;
  }
  
  .sort-categories {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .memory-board {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .quiz-options {
    grid-template-columns: 1fr;
  }
  
  .fps-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .welcome-buttons {
    flex-direction: column;
  }
  
  .features-preview {
    flex-direction: column;
    align-items: center;
  }
}

/* ==================== QUIZ SCREEN ==================== */
#quiz {
  padding: 1rem;
  height: 100vh;
  overflow-y: auto;
}

.quiz-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1rem;
  background: var(--bg-card);
  padding: 1rem;
  border-radius: var(--radius);
}

.quiz-header h2 {
  color: var(--accent);
}

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

.stat-badge {
  background: var(--bg-dark);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}

.stat-badge b {
  color: var(--accent);
}

.quiz-categories {
  max-width: 900px;
  margin: 0 auto;
}

.quiz-categories h3 {
  text-align: center;
  margin-bottom: 1.5rem;
  color: var(--text-muted);
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
}

.category-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  border: 3px solid transparent;
}

.category-card:hover {
  transform: translateY(-5px);
  border-color: var(--primary);
  box-shadow: 0 10px 30px rgba(108, 99, 255, 0.3);
}

.category-card.rainbow {
  background: linear-gradient(135deg, var(--primary), var(--secondary), var(--accent));
  animation: rainbowPulse 2s infinite;
}

@keyframes rainbowPulse {
  0%, 100% { filter: hue-rotate(0deg); }
  50% { filter: hue-rotate(30deg); }
}

.cat-icon {
  font-size: 3rem;
  display: block;
  margin-bottom: 0.5rem;
}

.cat-name {
  font-weight: 600;
  font-size: 1rem;
  display: block;
  margin-bottom: 0.3rem;
}

.cat-count {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.quiz-game {
  max-width: 700px;
  margin: 0 auto;
}

.quiz-progress {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.quiz-progress-bar {
  flex: 1;
  height: 10px;
  background: var(--bg-dark);
  border-radius: 5px;
  overflow: hidden;
}

.quiz-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--primary));
  transition: width 0.5s ease;
}

.quiz-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
}

.quiz-question-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.quiz-question-num {
  background: var(--primary);
  padding: 0.3rem 0.8rem;
  border-radius: 20px;
  font-size: 0.9rem;
}

.quiz-difficulty {
  font-size: 0.85rem;
  padding: 0.3rem 0.8rem;
  border-radius: 20px;
}

.quiz-difficulty.easy { background: var(--accent); }
.quiz-difficulty.medium { background: var(--warning); color: #000; }
.quiz-difficulty.hard { background: var(--secondary); }

.quiz-question-area {
  margin-bottom: 1.5rem;
}

.quiz-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
  animation: wiggle 2s ease infinite;
}

.quiz-question {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.quiz-hint {
  color: var(--warning);
  font-style: italic;
  min-height: 1.5rem;
}

.btn-speak {
  padding: 0.6rem 1.2rem;
  background: var(--bg-dark);
  border: 2px solid var(--primary);
  border-radius: 50px;
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-speak:hover {
  background: var(--primary);
}

.quiz-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-bottom: 1rem;
}

.quiz-option {
  padding: 1rem;
  background: var(--bg-dark);
  border: 3px solid transparent;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 1rem;
  color: var(--text);
  cursor: pointer;
  transition: all 0.3s ease;
}

.quiz-option:hover:not(:disabled) {
  border-color: var(--primary);
  transform: translateY(-3px);
}

.quiz-option.correct {
  background: var(--accent);
  border-color: var(--accent);
}

.quiz-option.wrong {
  background: var(--secondary);
  border-color: var(--secondary);
}

.quiz-feedback {
  padding: 1rem;
  border-radius: var(--radius-sm);
  margin-top: 1rem;
  display: none;
}

.quiz-feedback.show {
  display: block;
}

.quiz-feedback.correct {
  background: rgba(0, 217, 165, 0.2);
  border: 2px solid var(--accent);
}

.quiz-feedback.wrong {
  background: rgba(255, 107, 157, 0.2);
  border: 2px solid var(--secondary);
}

.quiz-navigation {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-top: 1rem;
}

.btn-skip, .btn-hint {
  padding: 0.8rem 1.5rem;
  background: var(--bg-card);
  border: none;
  border-radius: var(--radius);
  font-family: inherit;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-hint {
  color: var(--warning);
}

.btn-skip:hover, .btn-hint:hover {
  transform: translateY(-2px);
  background: var(--bg-light);
}

.quiz-results {
  max-width: 600px;
  margin: 0 auto;
}

.results-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
}

.results-icon {
  font-size: 5rem;
  margin-bottom: 1rem;
}

.results-stats {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin: 1.5rem 0;
}

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

.result-num {
  display: block;
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
}

.result-label {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.results-message {
  padding: 1rem;
  background: var(--bg-dark);
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  font-size: 1.1rem;
}

.results-achievements {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.achievement {
  padding: 0.4rem 0.8rem;
  background: var(--bg-dark);
  border-radius: 20px;
  font-size: 0.85rem;
}

.achievement.earned {
  background: linear-gradient(135deg, var(--warning), var(--accent));
}

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

.spelling-input {
  width: 100%;
  max-width: 280px;
  padding: 1rem;
  font-size: 1.3rem;
  font-family: inherit;
  text-align: center;
  background: var(--bg-dark);
  border: 3px solid var(--primary);
  border-radius: var(--radius);
  color: var(--text);
  margin-bottom: 1rem;
}

.spelling-input:focus {
  outline: none;
  border-color: var(--accent);
}

@media (max-width: 600px) {
  .quiz-options {
    grid-template-columns: 1fr;
  }
  
  .category-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .results-stats {
    flex-direction: column;
    gap: 1rem;
  }
}
