:root{
  --bg: #0f1115;
  --card: #171a22;
  --ink: #e9ecf1;
  --muted: #aab1bd;
  --brand: #9ad1ff;
  --ok: #7ef5a6;
  --bad: #ff8484;

  --radius: 1.2em;
  --gap: 1.2em;
  --shadow: 0 .6em 1.6em rgba(0,0,0,.25);

  /* סקייל טיפוגרפי (em) */
  --fs-xs: clamp(.9em, .85em + .2vw, 1.0em);
  --fs-sm: clamp(1.0em, .95em + .3vw, 1.15em);
  --fs-md: clamp(1.1em, 1.0em + .6vw, 1.5em);
  --fs-lg: clamp(1.6em, 1.25em + 1.2vw, 2.2em);
  --fs-xl: clamp(2.2em, 1.6em + 2vw, 3.2em);
}

*,
*::before,
*::after{ box-sizing: border-box; }

html{ scroll-behavior: smooth; }
body{
  margin: 0;
  background: radial-gradient(120% 140% at 100% 0%, #121318 0%, #0b0c0f 60%, #07080a 100%);
  color: var(--ink);
  font-family: "Heebo", system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  line-height: 1.6;
  font-size: 16px;
}

.container{ width: min(92%, 90em); margin-inline: auto; }

/* ===== נגישות ===== */
.skip{
  position: absolute;
  inset-inline-start: 0;
  inset-block-start: -10em;
  background: var(--brand);
  color: #000;
  padding: .8em 1.2em;
  border-radius: .6em;
  text-decoration: none;
  z-index: 1000;
}
.skip:focus{ inset-block-start: .8em; }

/* ===== כותרת אתר ===== */
.site-header{ padding: 2.2em 0 1.2em; }
.brand{
  margin: 0 0 .2em 0;
  font-size: var(--fs-xl);
  font-weight: 800;
  background: linear-gradient(90deg, var(--brand), #c7f9cc);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.tagline{ margin: 0; color: var(--muted); font-size: var(--fs-sm); }

/* ===== שליטה/כפתורים ===== */
.controls{
  display: flex; gap: var(--gap); align-items: center; justify-content: space-between;
  margin-block: 1.6em .8em; flex-wrap: wrap;
}

.modes{ display: flex; gap: .6em; flex-wrap: wrap; }
.tab{
  border: .1em solid #2a2e38; background: #141821; color: var(--ink);
  padding: .8em 1.2em; border-radius: .8em; cursor: pointer; font-weight: 600;
}
.tab.is-active{ background: #1b2030; border-color: var(--brand); box-shadow: 0 0 0 .2em rgba(154,209,255,.15); }
.tab:focus-visible{ outline: .2em solid var(--brand); outline-offset: .1em; }

.tools{ display: flex; gap: .6em; align-items: center; flex-wrap: wrap; }
.btn{
  display: inline-flex; gap: .6em; align-items: center; justify-content: center;
  padding: .8em 1.2em; border-radius: .8em; cursor: pointer; font-weight: 600;
  border: .1em solid #2a2e38; background: #141821; color: var(--ink); text-decoration: none;
}
.btn-ghost{ background: transparent; }
.btn[aria-pressed="true"]{
  box-shadow: 0 0 0 .2em rgba(154,209,255,.2);
  border-color: var(--brand);
}
.select{
  background: #141821; color: var(--ink); border: .1em solid #2a2e38; border-radius: .6em; padding: .6em 1em;
  font-size: var(--fs-sm);
}

/* ===== סטטיסטיקה ===== */
.stats{
  display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: var(--gap);
  margin-block: .8em 1.2em;
}
.stat{
  background: var(--card); border: .1em solid #2a2e38; border-radius: var(--radius); padding: 1.0em 1.2em;
  text-align: center; box-shadow: var(--shadow);
}
.stat span{ display: block; font-size: var(--fs-lg); font-weight: 800; }
.stat small{ color: var(--muted); font-size: var(--fs-xs); }

.stage{ display: grid; gap: var(--gap); }

/* ===== לימוד ===== */
.grid{
  display: grid; gap: var(--gap);
  grid-template-columns: repeat(1, minmax(0,1fr));
}
@media (min-width: 40em){ .grid{ grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (min-width: 64em){ .grid{ grid-template-columns: repeat(3, minmax(0,1fr)); } }
@media (min-width: 80em){ .grid{ grid-template-columns: repeat(4, minmax(0,1fr)); } }

.card{
  position: relative; padding: 1.2em 1.4em; border-radius: var(--radius);
  border: .1em solid #2a2e38; background: var(--card); box-shadow: var(--shadow);
}
.card-head{ display: flex; align-items: baseline; gap: .6em; margin-bottom: .4em; }
.card-letter{ font-size: var(--fs-xl); font-weight: 800; }
.card-name{ font-size: var(--fs-sm); color: var(--muted); }
.card-word{ font-size: var(--fs-md); font-weight: 700; margin-top: .4em; }
.card-actions{ margin-top: .6em; display: flex; gap: .6em; flex-wrap: wrap; }

.colorful{ color: #000; border: none; }

/* ===== חידון ===== */
.quiz-head{ display: flex; align-items: center; justify-content: space-between; gap: var(--gap); }
.quiz-q{ font-size: var(--fs-lg); font-weight: 800; margin: 0; }
.quiz-q .target-letter{ font-size: var(--fs-xl); line-height: 1; display: inline-block; margin-inline-start: .3em; }
.quiz-actions{ display: flex; gap: .6em; flex-wrap: wrap; }

.answers{
  display: grid;
  gap: var(--gap);
  grid-template-columns: repeat(2, minmax(0,1fr));
}
@media (min-width: 40em){ .answers{ grid-template-columns: repeat(3, minmax(0,1fr)); } }
@media (min-width: 64em){ .answers{ grid-template-columns: repeat(4, minmax(0,1fr)); } }

.answer{
  aspect-ratio: 1 / 1;
  border: none;
  border-radius: var(--radius);
  background: #141821;
  color: #000;
  font-weight: 800;
  font-size: clamp(1.4em, 1.1em + 1.4vw, 2.2em);
  display: grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.answer:focus-visible{ outline: .2em solid var(--brand); outline-offset: .1em; }
.answer.ok{ box-shadow: 0 0 0 .2em rgba(126,245,166,.35); }
.answer.bad{ box-shadow: 0 0 0 .2em rgba(255,132,132,.35); }

.ans-letter{
  display: block;
  font-size: clamp(2.4em, 2em + 3vw, 4em);
  font-weight: 900;
  line-height: 1;
}
.ans-name{
  display: block;
  margin-top: .2em;
  font-size: clamp(.9em, .8em + .3vw, 1.1em);
  font-weight: 600;
}

/* ===== משחק זיכרון רספונסיבי ===== */
.memory{
  display: grid;
  gap: .8em;
  /* מספר עמודות משתנה לפי הרוחב, עם גודל מינימלי לכל קלף */
  grid-template-columns: repeat(auto-fit, minmax(6em, 1fr));
}

.tile{
  aspect-ratio: 1 / 1;             /* ריבוע תמידי */
  border: none;
  border-radius: var(--radius);
  background: #141821;
  color: #000;
  font-weight: 800;
  display: grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
  box-shadow: var(--shadow);
  user-select: none;
}

/* גודל טקסט בתוך הקלף רספונסיבי */
.tile .ans-letter{
  font-size: clamp(1.6em, 1.2em + 2vw, 3em);
  font-weight: 900;
  line-height: 1;
}
.tile .ans-name{
  font-size: clamp(.8em, .6em + 1vw, 1.2em);
  font-weight: 600;
  margin-top: .2em;
}

/* מצב של קלף תואם */
.tile.matched{
  background: #173222;
  border-color: #27593e;
  color: #c8fbdc;
  cursor: default;
}
