:root {
  --color-bg: #eaf6fb;
  --color-primary: #ff8a5b;
  --color-primary-dark: #f16a3d;
  --color-secondary: #4ecdc4;
  --color-accent: #ffd166;
  --color-success: #06d6a0;
  --color-error: #ef476f;
  --color-text: #22333b;
  --color-card: #ffffff;
  --radius: 20px;
  --shadow: 0 6px 0 rgba(0, 0, 0, 0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: linear-gradient(180deg, #eaf6fb 0%, #dcf2e6 100%);
  color: var(--color-text);
  font-family: "Heebo", "Arial Hebrew", Tahoma, Arial, sans-serif;
  touch-action: manipulation;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

button {
  font-family: inherit;
  cursor: pointer;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--color-card);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  position: sticky;
  top: 0;
  z-index: 10;
}

.app-title {
  font-size: 1.5rem;
  font-weight: 800;
  margin: 0;
  text-align: center;
  flex: 1;
}

.btn-stars, .btn-home {
  min-width: 100px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-help {
  background: var(--color-card);
  border: 2px solid var(--color-secondary);
  color: var(--color-secondary);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 1.1rem;
  font-weight: 800;
  box-shadow: var(--shadow);
  flex-shrink: 0;
}
.btn-help:active { transform: translateY(3px); box-shadow: none; }

.btn-home {
  background: var(--color-secondary);
  color: white;
  border: none;
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 1rem;
  font-weight: 600;
  box-shadow: var(--shadow);
}
.btn-home:active { transform: translateY(3px); box-shadow: none; }

.btn-stars {
  background: var(--color-accent);
  color: var(--color-text);
  border: none;
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 1rem;
  font-weight: 700;
  box-shadow: var(--shadow);
}
.btn-stars:active { transform: translateY(3px); box-shadow: none; }

main#app {
  flex: 1;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}

.view[hidden] { display: none; }

.view-enter { animation: view-enter 0.28s ease; }
@keyframes view-enter {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Menu ---------- */
.menu-intro {
  text-align: center;
  font-size: 1.2rem;
  margin: 8px 0 24px;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
}

@media (max-width: 560px) {
  .mode-grid { grid-template-columns: 1fr; }
}

.mode-card {
  background: var(--color-card);
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: transform 0.12s;
}
.mode-card:hover { transform: translateY(-4px); }
.mode-card:active { transform: translateY(3px); box-shadow: none; }

.mode-emoji { font-size: 3rem; }
.mode-name { font-size: 1.3rem; font-weight: 800; color: var(--color-primary-dark); }
.mode-desc { font-size: 0.95rem; color: #556; text-align: center; }

/* ---------- Setup screen ---------- */
#view-setup { text-align: center; }
#setup-title { font-size: 1.6rem; margin-bottom: 4px; }
.setup-subtitle { color: #556; margin-top: 0; margin-bottom: 20px; }
.setup-label { font-weight: 700; color: #556; margin: 0 0 10px; }

.chip-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-bottom: 28px;
}

.chip {
  background: var(--color-card);
  border: 2px solid transparent;
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 1rem;
  font-weight: 600;
  box-shadow: var(--shadow);
}
.chip.active {
  background: var(--color-accent);
  border-color: var(--color-primary-dark);
}
.chip:active { transform: translateY(2px); }

.chip-practice.active {
  background: var(--color-secondary);
  color: white;
  border-color: #329e97;
}

.btn-primary {
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: 999px;
  padding: 16px 40px;
  font-size: 1.2rem;
  font-weight: 800;
  box-shadow: 0 6px 0 var(--color-primary-dark);
}
.btn-primary:active { transform: translateY(5px); box-shadow: none; }

.btn-secondary {
  background: var(--color-secondary);
  color: white;
  border: none;
  border-radius: 999px;
  padding: 12px 26px;
  font-size: 1.05rem;
  font-weight: 700;
  box-shadow: 0 5px 0 #329e97;
}
.btn-secondary:active { transform: translateY(4px); box-shadow: none; }

/* ---------- Map ---------- */
.map-container {
  position: relative;
  width: 100%;
  max-width: 1050px;
  margin: 0 auto;
  background: #dff2fb;
  border-radius: var(--radius);
  padding: 10px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.world-map-svg {
  width: 100%;
  height: auto;
  max-height: 78vh;
  display: block;
  touch-action: none;
}

/* במסכים צרים (טלפון) יחס הרוחב-גובה הקבוע של המפה (2:1) הופך אותה לרצועה דקה מדי -
   נותנים לקונטיינר גובה קבוע ביחס למסך, וה-SVG (במצב preserveAspectRatio="slice",
   מוגדר ב-JS) ממלא את השטח ונחתך בצדדים במקום להצטמצם. */
@media (max-width: 640px) {
  main#app { padding: 14px 6px 30px; }
  .map-container { padding: 6px; }
  .world-map-svg {
    height: 58vh;
    max-height: none;
  }
}

.world-map-svg path {
  fill-rule: evenodd;
}

.country {
  fill: #b8ddb0;
  stroke: #ffffff;
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
  cursor: pointer;
  transition: fill 0.15s;
}
.country:hover { fill: #94cf88; }
.country.dimmed { fill: #e4e9e6; pointer-events: none; }
.country.selected { fill: var(--color-accent); }
.country.correct { fill: var(--color-success); }
.country.wrong { fill: var(--color-error); animation: shake 0.4s; }
.country.neighbor { fill: var(--color-secondary); }

.country-labels { pointer-events: none; }
.country-label {
  font-family: "Heebo", "Arial Hebrew", Tahoma, Arial, sans-serif;
  font-weight: 800;
  fill: #22333b;
  paint-order: stroke;
  stroke: #ffffff;
  stroke-width: 0.2em;
  stroke-linejoin: round;
  direction: rtl;
}

/* צורות במפה שאין עליהן משחק (טריטוריות קטנות) - ניטרליות וללא אינטראקציה */
.land-other {
  fill: #e4e9e6;
  stroke: #ffffff;
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}

.map-reset-btn {
  position: absolute;
  top: 18px;
  left: 18px;
  background: var(--color-card);
  border: none;
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 0.9rem;
  font-weight: 700;
  box-shadow: var(--shadow);
  z-index: 5;
}
.map-reset-btn:active { transform: translateY(2px); box-shadow: none; }
.map-reset-btn[hidden] { display: none; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-2px); }
  75% { transform: translateX(2px); }
}

/* ---------- Generic game layout ---------- */
.game-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.badge {
  background: var(--color-card);
  border-radius: 999px;
  padding: 8px 16px;
  font-weight: 700;
  box-shadow: var(--shadow);
}

.badge-streak {
  background: linear-gradient(135deg, #ffd166, #ff8a5b);
  color: white;
}
.badge-streak[hidden] { display: none; }

.btn-speak {
  background: none;
  border: none;
  font-size: 1.3rem;
  vertical-align: middle;
  margin-inline-start: 6px;
  padding: 2px 6px;
  border-radius: 999px;
  cursor: pointer;
}
.btn-speak:active { transform: scale(0.9); }

.prompt-card {
  background: var(--color-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  text-align: center;
  margin-bottom: 16px;
}

.prompt-flag {
  font-size: 4rem;
  line-height: 1;
}
.prompt-flag .fi {
  font-size: 3.2rem;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}

.prompt-name {
  font-size: 1.8rem;
  font-weight: 800;
  margin-top: 8px;
}

.shape-prompt {
  width: 100%;
  max-width: 260px;
  height: 180px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}
.silhouette-svg {
  width: 100%;
  height: 100%;
}
.silhouette-svg path {
  filter: drop-shadow(0 3px 3px rgba(0, 0, 0, 0.2));
}

.btn-hint {
  margin-top: 14px;
  background: var(--color-accent);
  color: var(--color-text);
  border: none;
  border-radius: 999px;
  padding: 8px 18px;
  font-size: 0.95rem;
  font-weight: 700;
  box-shadow: 0 4px 0 #d9a63d;
}
.btn-hint:active { transform: translateY(3px); box-shadow: none; }
.btn-hint:disabled {
  opacity: 0.5;
  box-shadow: none;
  cursor: default;
}

.hint-text {
  margin-top: 10px;
  font-weight: 700;
  color: var(--color-primary-dark);
  min-height: 1.4em;
}

.feedback-msg {
  min-height: 1.6em;
  font-weight: 700;
  font-size: 1.1rem;
  text-align: center;
  margin: 6px 0 14px;
}
.feedback-msg.good { color: var(--color-success); }
.feedback-msg.bad { color: var(--color-error); }

/* ---------- Explore info card ---------- */
.info-card {
  background: var(--color-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 24px;
  margin-top: 16px;
  max-width: 500px;
  margin-inline: auto;
}
.info-card .fi { font-size: 3rem; border-radius: 8px; box-shadow: 0 2px 6px rgba(0,0,0,0.25); }
.info-card h3 { margin: 10px 0 4px; font-size: 1.5rem; }
.info-card dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin-top: 14px; }
.info-card dt { font-weight: 700; color: var(--color-primary-dark); }
.info-card dd { margin: 0; }
.info-fact {
  margin: 16px 0 0;
  padding: 12px 14px;
  background: #fff6e5;
  border-radius: 12px;
  font-size: 1rem;
  line-height: 1.5;
}
.info-placeholder { text-align: center; color: #789; font-size: 1.1rem; padding: 30px; }

.challenge-banner {
  background: linear-gradient(135deg, #e7fbf3, #eaf6fb);
  border: 2px dashed var(--color-secondary);
  border-radius: 14px;
  padding: 12px 18px;
  text-align: center;
  font-weight: 700;
  color: #217a72;
  margin-bottom: 12px;
}
.challenge-banner[hidden] { display: none; }

.explore-actions {
  text-align: center;
  margin-bottom: 16px;
}

/* ---------- Flag match ---------- */
.match-board {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  max-width: 700px;
  margin: 0 auto;
}
.match-col { display: flex; flex-direction: column; gap: 12px; }
.match-card {
  background: var(--color-card);
  border: 3px solid transparent;
  border-radius: 16px;
  padding: 16px 18px;
  font-size: 1.25rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow);
  min-height: 68px;
  transition: transform 0.12s, border-color 0.12s;
}
.match-card .fi { font-size: 2.3rem; border-radius: 6px; box-shadow: 0 2px 4px rgba(0,0,0,0.2); }
.match-card[data-type="flag"] {
  justify-content: center;
  padding: 22px 16px;
  min-height: 110px;
}
.match-card[data-type="flag"] .fi {
  font-size: 4.6rem;
  border-radius: 8px;
  box-shadow: 0 3px 6px rgba(0,0,0,0.25);
}
.match-name { flex: 1; }
.match-mark {
  font-weight: 800;
  font-size: 1.3rem;
  min-width: 1.2em;
  text-align: center;
}
.match-card.selected { border-color: var(--color-accent); transform: translateY(-3px) scale(1.02); box-shadow: 0 8px 0 rgba(0,0,0,0.08); }
.match-card.correct {
  border-color: var(--color-success);
  background: #e7fbf3;
  pointer-events: none;
  animation: pop 0.35s ease;
}
.match-card.correct .match-mark { color: var(--color-success); }
.match-card.wrong { border-color: var(--color-error); background: #fdecef; animation: shake 0.4s; }
.match-card.wrong .match-mark { color: var(--color-error); }

/* בטלפון שומרים על שתי עמודות (דגלים מול שמות) כדי שלא יצטרכו לגלול קדימה ואחורה
   בין שתי רשימות ארוכות ונפרדות - רק מקטינים כרטיסים כדי שיתאימו. */
@media (max-width: 560px) {
  .match-board { gap: 10px; }
  .match-card {
    padding: 8px 10px;
    font-size: 0.92rem;
    gap: 6px;
    min-height: 50px;
    border-radius: 12px;
  }
  .match-card[data-type="flag"] {
    min-height: 62px;
    padding: 10px 6px;
  }
  .match-card[data-type="flag"] .fi {
    font-size: 2.6rem;
  }
  .match-mark {
    font-size: 1.05rem;
    min-width: 1em;
  }
}

@keyframes pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.06); }
  100% { transform: scale(1); }
}

/* ---------- Trivia ---------- */
.trivia-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  max-width: 640px;
  margin: 0 auto;
}
@media (max-width: 560px) {
  .trivia-options { grid-template-columns: 1fr; }
}
.trivia-option {
  background: var(--color-card);
  border: 3px solid transparent;
  border-radius: 14px;
  padding: 16px;
  font-size: 1.1rem;
  font-weight: 700;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 64px;
  text-align: center;
}
.trivia-option .fi { font-size: 2.2rem; border-radius: 6px; }
.trivia-option.correct { border-color: var(--color-success); background: #e7fbf3; }
.trivia-option.wrong { border-color: var(--color-error); background: #fdecef; }
.trivia-option:disabled { cursor: default; }

.trivia-question {
  font-size: 1.4rem;
  font-weight: 800;
  text-align: center;
  margin-bottom: 20px;
}

/* ---------- End screen ---------- */
.end-screen {
  text-align: center;
  background: var(--color-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 36px 24px;
  max-width: 500px;
  margin: 20px auto;
}
.end-emoji { font-size: 4rem; }
.end-score { font-size: 1.6rem; font-weight: 800; margin: 10px 0 20px; }

.end-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

.btn-tertiary {
  background: transparent;
  border: 2px solid var(--color-secondary);
  color: var(--color-secondary);
  border-radius: 999px;
  padding: 10px 22px;
  font-size: 1rem;
  font-weight: 700;
}
.btn-tertiary:active { transform: translateY(2px); }

.flag-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1em;
}

.app-footer {
  text-align: center;
  color: #7b8b93;
  padding: 14px;
}

/* ---------- Mascot bubble ---------- */
.mascot-bubble {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(30px) scale(0.85);
  background: linear-gradient(135deg, #fff6e5, #ffffff);
  border: 3px solid var(--color-accent);
  border-radius: 999px;
  padding: 14px 28px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.22), var(--shadow);
  display: flex;
  align-items: center;
  gap: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 70;
  max-width: 90vw;
}
.mascot-bubble.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0) scale(1);
}
.mascot-emoji {
  font-size: 2.6rem;
  line-height: 1;
  flex-shrink: 0;
  animation: mascot-bounce 0.6s ease;
}
.mascot-text { font-size: 1.1rem; font-weight: 800; color: var(--color-primary-dark); }

@keyframes mascot-bounce {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  30% { transform: translateY(-10px) rotate(-8deg); }
  60% { transform: translateY(2px) rotate(4deg); }
}

/* ---------- Confetti ---------- */
.confetti-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 60;
}
.confetti-piece {
  position: absolute;
  top: -20px;
  width: 10px;
  height: 14px;
  opacity: 0.9;
  animation-name: confetti-fall;
  animation-timing-function: ease-in;
  animation-fill-mode: forwards;
}
@keyframes confetti-fall {
  0% { transform: translateY(0) rotate(var(--start-rotate, 0deg)); opacity: 1; }
  100% { transform: translateY(100vh) rotate(calc(var(--start-rotate, 0deg) + 360deg)); opacity: 0.3; }
}

/* ---------- Passport screen ---------- */
.passport-summary {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--color-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}
.passport-summary-emoji { font-size: 3rem; }
.passport-summary-text { font-weight: 700; line-height: 1.6; }

.passport-continent { margin-bottom: 24px; }
.passport-continent h3 {
  margin: 0 0 10px;
  color: var(--color-primary-dark);
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.passport-continent-count {
  font-size: 0.85rem;
  font-weight: 700;
  color: #789;
}

/* "אלבום מדבקות": גריד קומפקטי של דגלים, במקום רשימת שורות טקסט ארוכה שקשה לסרוק. */
.passport-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 10px;
}

.sticker {
  background: var(--color-card);
  border: 3px solid transparent;
  border-radius: 14px;
  padding: 10px 6px 8px;
  text-align: center;
  box-shadow: var(--shadow);
  transition: transform 0.15s;
}
.sticker-flag .fi {
  font-size: 2.1rem;
  border-radius: 6px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}
.sticker-name {
  font-size: 0.76rem;
  font-weight: 700;
  margin-top: 6px;
  line-height: 1.2;
  min-height: 2.2em;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sticker-stars {
  font-size: 0.85rem;
  letter-spacing: 1px;
  margin-top: 4px;
  color: var(--color-accent);
}

/* לא התחילו ללמוד עליה עדיין - דהוי ואפור, כמו מדבקה ריקה שמחכה להיות מולבשת */
.sticker-locked { opacity: 0.5; }
.sticker-locked .sticker-flag .fi { filter: grayscale(1); }
.sticker-locked .sticker-stars { color: #c7cdd1; }

/* בתהליך למידה (כוכב אחד או שניים) */
.sticker-started { border-color: var(--color-secondary); }

/* נלמדה לגמרי (3 כוכבים) - מודגשת ומוזהבת, כמו מדבקה שהושלמה */
.sticker-mastered {
  border-color: var(--color-accent);
  background: linear-gradient(160deg, #fff9e8, #ffffff);
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.08), 0 0 0 3px rgba(255, 209, 102, 0.35);
}
.sticker-mastered .sticker-name { color: var(--color-primary-dark); }

.passport-reset-wrap { text-align: center; margin-top: 20px; }
.btn-secondary.armed {
  background: var(--color-error);
  box-shadow: 0 5px 0 #b8324f;
}

/* ---------- Badges (passport screen) ---------- */
.passport-badges { margin-bottom: 28px; }
.passport-badges h3 { margin: 0 0 10px; color: var(--color-primary-dark); }

.badge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
}
.badge-item {
  background: var(--color-card);
  border: 3px solid transparent;
  border-radius: 14px;
  padding: 12px 8px;
  text-align: center;
  box-shadow: var(--shadow);
}
.badge-emoji { font-size: 1.8rem; }
.badge-name { font-size: 0.78rem; font-weight: 700; margin-top: 4px; }
.badge-desc { font-size: 0.68rem; color: #789; margin-top: 3px; line-height: 1.3; }

.badge-item.badge-locked { opacity: 0.5; filter: grayscale(0.6); }
.badge-item.badge-earned {
  border-color: var(--color-accent);
  background: linear-gradient(160deg, #fff9e8, #ffffff);
}
.badge-item.badge-earned .badge-desc { display: none; }

/* ---------- Tutorial overlay ---------- */
.tutorial-overlay {
  position: fixed;
  inset: 0;
  background: rgba(34, 51, 59, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.tutorial-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.tutorial-card {
  position: relative;
  background: var(--color-card);
  border-radius: var(--radius);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.3);
  padding: 32px 28px 24px;
  max-width: 420px;
  width: 100%;
  text-align: center;
  animation: view-enter 0.25s ease;
}

.tutorial-skip {
  position: absolute;
  top: 14px;
  left: 14px;
  background: none;
  border: none;
  color: #789;
  font-size: 0.9rem;
  font-weight: 700;
  padding: 4px 8px;
}

.tutorial-emoji { font-size: 3.2rem; }
.tutorial-title { font-size: 1.3rem; font-weight: 800; margin: 10px 0 8px; }
.tutorial-text { font-size: 1rem; line-height: 1.6; color: #445; margin: 0 0 18px; }

.tutorial-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: 20px;
}
.tutorial-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #dde3e5;
}
.tutorial-dot.active { background: var(--color-primary); }

.tutorial-nav {
  display: flex;
  justify-content: center;
  gap: 12px;
}
.tutorial-nav .btn-secondary:disabled { opacity: 0.4; }
