/* ===== מגלים את הרכבים — style ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #F8FAFC;
  --surface: #FFFFFF;
  --text: #0F172A;
  --text-muted: #64748B;
  --radius: 20px;
  --shadow: 0 2px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.10);
  --quiz: #10B981;
  --quiz-light: #D1FAE5;
  --quiz-dark: #065F46;
}

html, body {
  width: 100%; height: 100%; overflow: hidden;
  font-family: "Rubik","Assistant","Segoe UI",Arial,sans-serif;
  direction: rtl; background: var(--bg); color: var(--text);
  user-select: none; -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation; overscroll-behavior: none;
}

.screen {
  display: none; position: fixed; inset: 0;
  overflow-y: auto; overflow-x: hidden;
}
.screen.active {
  display: flex; flex-direction: column;
  animation: fadeSlideIn 0.35s cubic-bezier(0.16,1,0.3,1);
}
@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateX(-24px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ===== Top Bar ===== */
.top-bar {
  display: flex; align-items: center;
  padding: 12px 16px; gap: 12px; flex-shrink: 0;
  background: var(--surface);
  position: sticky; top: 0; z-index: 10;
}
.btn-back, .btn-home {
  width: 44px; height: 44px; border-radius: 50%; border: none;
  font-size: 22px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: transform 0.15s, background 0.15s;
  background: var(--surface); color: var(--cat-color, #64748B);
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.btn-back:active, .btn-home:active { transform: scale(0.9); background: #f1f5f9; }
.btn-home { background: var(--cat-color-light, #f1f5f9); }
.screen-title {
  flex: 1; text-align: center; font-size: clamp(20px, 5vw, 24px);
  font-weight: 800; color: var(--cat-color, var(--text));
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.quiz-score {
  font-size: 20px; font-weight: 800; color: #F59E0B;
  background: #FEF3C7; padding: 6px 14px; border-radius: 30px;
  flex-shrink: 0;
}

/* ===== Home ===== */
#screen-home {
  justify-content: center; align-items: center;
  padding: 16px 20px 20px; gap: 16px;
  background: linear-gradient(180deg, #F8FAFC 0%, #F1F5F9 100%);
}
.app-title {
  font-size: clamp(30px, 7vw, 40px); font-weight: 900;
  color: var(--text); text-align: center; line-height: 1.2;
}
.app-title span { display: inline-block; }
#home-categories {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 12px; width: 100%; max-width: 440px;
}
.category-btn {
  position: relative; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 8px; padding: 16px 8px; border: none; border-radius: var(--radius);
  background: var(--cat-bg, var(--surface)); cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  min-height: 130px; box-shadow: var(--shadow); overflow: hidden;
}
.category-btn::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--cat-color) 15%, transparent),
    color-mix(in srgb, var(--cat-color) 5%, transparent));
  opacity: 0; transition: opacity 0.2s;
}
.category-btn:hover::before { opacity: 1; }
.category-btn:active { transform: scale(0.95); }
.category-icon {
  font-size: 44px; line-height: 1; position: relative; z-index: 1;
  width: 72px; height: 56px; display: flex; align-items: center; justify-content: center;
}
.category-icon img {
  width: 100%; height: 100%; object-fit: cover;
  border-radius: 12px; box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}
.category-label {
  font-size: 16px; font-weight: 700; color: var(--cat-color);
  position: relative; z-index: 1; text-align: center;
}
.btn-quiz-home {
  display: flex; align-items: center; justify-content: center;
  gap: 10px; padding: 14px 32px; border: none; border-radius: 50px;
  background: linear-gradient(135deg, #10B981, #059669);
  color: #fff; font-size: 20px; font-weight: 800;
  cursor: pointer; transition: transform 0.2s, box-shadow 0.2s;
  width: 100%; max-width: 440px; font-family: inherit;
  box-shadow: 0 4px 16px rgba(16,185,129,0.3);
}
.btn-quiz-home:active { transform: scale(0.95); }
.btn-quiz-home .quiz-icon { font-size: 26px; }
.btn-about {
  background: none; border: none; color: var(--text-muted);
  font-size: 14px; font-weight: 600; cursor: pointer;
  padding: 6px 14px; font-family: inherit; transition: color 0.15s;
}
.btn-about:hover { color: var(--text); }

/* ===== Category Grid ===== */
#screen-category { padding-bottom: 20px; }
#category-vehicles, #category-instruments {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px; padding: 16px; width: 100%; max-width: 720px; margin: 0 auto;
}
.vehicle-card {
  display: flex; flex-direction: column; align-items: center;
  gap: 8px; padding: 12px 8px; border: none; border-radius: var(--radius);
  background: var(--surface); cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: var(--shadow); font-family: inherit;
}
.vehicle-card:active { transform: scale(0.95); }
.vehicle-thumb {
  width: 100%; aspect-ratio: 4/3; border-radius: 14px; overflow: hidden;
  background: var(--cat-color-light, #f1f5f9);
}
.vehicle-thumb img {
  width: 100%; height: 100%; object-fit: cover;
  transition: transform 0.3s;
}
.vehicle-card:hover .vehicle-thumb img { transform: scale(1.06); }
.vehicle-label {
  font-size: 15px; font-weight: 700; color: var(--cat-color, var(--text));
  text-align: center; line-height: 1.3;
}

/* ===== Vehicle Screen ===== */
#screen-vehicle { align-items: center; }
.vehicle-image {
  flex: 1; display: flex; align-items: center; justify-content: center;
  width: 100%; padding: 16px; min-height: 0;
}
.img-container {
  width: 100%; max-width: 520px; aspect-ratio: 4/3;
  border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow-lg); background: var(--cat-color-light, #f1f5f9);
}
.img-container img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.vehicle-actions {
  display: flex; align-items: center; justify-content: center;
  gap: 18px; padding: 16px 16px 28px; flex-shrink: 0;
}
.btn-action {
  width: 72px; height: 72px; border-radius: 50%; border: none;
  font-size: 32px; cursor: pointer;
  background: var(--cat-color, #F59E0B); color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--cat-color, #F59E0B) 40%, transparent);
  transition: transform 0.15s, box-shadow 0.15s;
}
.btn-action:active { transform: scale(0.9); }
.btn-action.playing { animation: pulse 0.8s infinite; }
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}
.btn-nav-vehicle {
  width: 52px; height: 52px; border-radius: 50%; border: none;
  font-size: 28px; cursor: pointer;
  background: var(--cat-color-light, #f1f5f9); color: var(--cat-color, #64748B);
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.15s, opacity 0.15s;
}
.btn-nav-vehicle:active { transform: scale(0.9); }
.btn-nav-vehicle:disabled { cursor: default; }

/* ===== Quiz ===== */
#screen-quiz-menu, #screen-quiz, #screen-odd-quiz {
  align-items: center; padding-top: 0;
}
.quiz-menu-title {
  font-size: clamp(24px, 6vw, 32px); font-weight: 900;
  margin: 80px 0 24px; color: var(--text);
}
.difficulty-buttons {
  display: flex; flex-direction: column; gap: 14px;
  width: 100%; max-width: 380px; padding: 0 20px;
}
.btn-difficulty {
  padding: 18px 24px; border: none; border-radius: 50px;
  background: linear-gradient(135deg, #10B981, #059669);
  color: #fff; font-size: 19px; font-weight: 800; cursor: pointer;
  font-family: inherit; transition: transform 0.2s;
  box-shadow: 0 4px 14px rgba(16,185,129,0.3);
}
.btn-difficulty.hard {
  background: linear-gradient(135deg, #F59E0B, #D97706);
  box-shadow: 0 4px 14px rgba(245,158,11,0.3);
}
.btn-difficulty.odd {
  background: linear-gradient(135deg, #8B5CF6, #7C3AED);
  box-shadow: 0 4px 14px rgba(139,92,246,0.3);
}
.btn-difficulty:active { transform: scale(0.96); }

#screen-quiz, #screen-odd-quiz { padding-bottom: 20px; }
#quiz-options, #odd-quiz-options {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 14px; padding: 16px; width: 100%; max-width: 480px; margin: 0 auto;
}
.quiz-option {
  aspect-ratio: 1; border: 4px solid transparent; border-radius: var(--radius);
  overflow: hidden; cursor: pointer; padding: 0;
  background: var(--surface); box-shadow: var(--shadow);
  transition: transform 0.15s, border-color 0.2s, opacity 0.2s;
}
.quiz-option img { width: 100%; height: 100%; object-fit: cover; display: block; }
.quiz-option:active { transform: scale(0.96); }
.quiz-option.correct {
  border-color: #10B981; animation: pop 0.4s;
}
.quiz-option.wrong {
  border-color: #EF4444; opacity: 0.5; animation: shake 0.4s;
  pointer-events: none;
}
.quiz-option.hint {
  border-color: #F59E0B; animation: pulseHint 0.6s 2;
}
@keyframes pop {
  0% { transform: scale(1); } 50% { transform: scale(1.08); } 100% { transform: scale(1); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); } 75% { transform: translateX(8px); }
}

/* Odd category header */
.odd-category-header {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); margin: 8px 16px 0; padding: 10px 16px;
  border-radius: 50px; box-shadow: var(--shadow);
}
.odd-category-header img {
  width: 52px; height: 52px; border-radius: 50%; object-fit: cover;
}
.odd-category-header span { font-size: 18px; font-weight: 800; }

/* ===== Confetti ===== */
.confetti {
  position: fixed; width: 10px; height: 10px;
  border-radius: 2px; z-index: 999; pointer-events: none;
  animation: confetti-fall 0.9s ease-out forwards;
}
@keyframes confetti-fall {
  to { transform: translate(var(--tx), var(--ty)) rotate(360deg); opacity: 0; }
}
.confetti { animation: confetti-fall 0.9s ease-out; }

/* ===== About ===== */
#screen-about { align-items: center; }
.about-content {
  width: 100%; max-width: 440px; padding: 24px 20px 40px;
  display: flex; flex-direction: column; gap: 16px;
}
.about-content h2 { font-size: 26px; font-weight: 900; color: var(--text); }
.about-subtitle { color: var(--text-muted); font-weight: 600; }
.about-section {
  background: var(--surface); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow);
  line-height: 1.7; font-size: 15px;
}
.about-credits { font-size: 14px; color: var(--text-muted); }
.about-email { color: #3B82F6; font-weight: 600; direction: ltr; text-align: right; }
.about-year { color: var(--text-muted); font-size: 13px; }

/* ===== Responsive ===== */
@media (max-width: 380px) {
  #home-categories { gap: 10px; }
  .category-icon { width: 60px; height: 48px; }
  .btn-action { width: 64px; height: 64px; font-size: 28px; }
}
@media (min-width: 700px) {
  #quiz-options, #odd-quiz-options { grid-template-columns: repeat(4, 1fr); }
  .quiz-option { aspect-ratio: 1; }
}
