/* ── Tokens ───────────────────────────────────────────────── */
:root {
  --bg: #eef4fa; --card: #ffffff; --ink: #0f1b2d; --muted: #5c6b7f; --line: #dfe6ee;
  --primary: #2563eb; --primary-ink: #fff; --primary-soft: #e3ecff;
  --primary-text: #1d4ed8; /* blue text on --primary-soft: 5.6:1 (--primary there is 4.35:1, under the 4.5 AA asks) */
  --accent: #ff8a00; --good: #15a34a; --good-soft: #e5f7eb; --bad: #e11d48; --bad-soft: #fde8ee;
  --gold: #f5b301; --silver: #a7b1bd; --bronze: #c98a4b; --near: #d97706;
  --ocean: #cfe8f6; --space: #eef4fa; --land: #f7f1df; --land-home: #fff6cf; --land-other: #e9e5da;
  --border: #a49a86; --grid: rgba(80, 120, 160, .15); --water: #9fd1ee;
  --radius: 16px; --shadow: 0 6px 24px rgba(15, 27, 45, .10), 0 1px 3px rgba(15, 27, 45, .08);
  --topbar: 56px;
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font-family: 'Rubik', system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;
  font-size: 16px; line-height: 1.45; -webkit-tap-highlight-color: transparent;
  display: flex; flex-direction: column; min-height: 100dvh;
}
button, input, select { font: inherit; color: inherit; }
a { color: var(--primary); }
h1, h2, h3 { margin: 0 0 .4em; line-height: 1.2; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.3rem; } h3 { font-size: 1.08rem; }
.muted { color: var(--muted); } .small { font-size: .85rem; }
.spacer { flex: 1; }
code { background: #f1f4f8; padding: 2px 6px; border-radius: 6px; font-size: .85rem; direction: ltr; display: inline-block; }

/* ── Top bar ─────────────────────────────────────────────── */
#topbar {
  height: var(--topbar); flex: none; display: flex; align-items: center; gap: 6px;
  padding: 0 12px; background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 8px; background: none; border: 0; cursor: pointer; font-weight: 700; font-size: 1.1rem; padding: 4px; }
.brand .logo { font-size: 1.5rem; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--card);
  display: inline-grid; place-items: center; cursor: pointer; font-size: 1.1rem; flex: none;
}
.icon-btn:hover { background: var(--primary-soft); }
.chip { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 6px 12px; cursor: pointer; font-size: .9rem; }
.menu-wrap { position: relative; }
.menu {
  position: absolute; inset-inline-end: 0; top: 46px; min-width: 230px; background: var(--card);
  border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 6px; display: flex; flex-direction: column;
}
.menu[hidden] { display: none; }
.menu button, .menu a { text-align: start; border: 0; background: none; padding: 10px 12px; border-radius: 10px; cursor: pointer; }
.menu a { color: inherit; text-decoration: none; font-size: .92rem; }
.menu button:hover, .menu a:hover { background: var(--primary-soft); }
.menu-user { padding: 8px 12px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; font-weight: 600; }
@media (max-width: 420px) { .brand-name { display: none; } }

/* ── Layout ──────────────────────────────────────────────── */
#app { flex: 1; position: relative; min-height: 0; }
.screen { padding: 20px 16px 32px; max-width: 1120px; margin: 0 auto; }
.screen.center { display: grid; place-items: start center; padding-top: 32px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card.narrow { width: min(460px, 100%); }
.card.wide { width: min(880px, 100%); }
.stack { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; justify-content: center; margin-top: 16px; }
.hero { font-size: 3rem; text-align: center; }
.hero.spin { animation: spin 6s linear infinite; display: inline-block; width: 100%; }
@keyframes spin { to { transform: rotate(360deg); } }
.login h1, .login > p { text-align: center; }

input:not([type=radio]), select {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 1.5px solid var(--line); background: #fbfdff;
}
input:focus, select:focus { outline: 2px solid var(--primary); outline-offset: 1px; border-color: transparent; }
.code-input { text-transform: uppercase; letter-spacing: .25em; font-weight: 700; text-align: center; direction: ltr; }
label { font-weight: 600; font-size: .9rem; }

.btn {
  border: 1.5px solid var(--line); background: var(--card); padding: 10px 16px; border-radius: 12px; cursor: pointer;
  font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap;
}
.btn:hover { border-color: var(--primary); }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.primary:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.btn.big { padding: 14px 20px; font-size: 1.05rem; width: 100%; }
.btn.small { padding: 6px 10px; font-size: .85rem; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); border-color: #f3c3cf; }
.linklike { background: none; border: 0; color: var(--primary); cursor: pointer; padding: 4px; font-size: .9rem; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .85rem; margin: 18px 0 10px; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.providers { display: grid; gap: 8px; }
.provider { justify-content: flex-start; opacity: .75; }
.provider b { width: 22px; display: inline-block; text-align: center; }
.provider .g { color: #4285f4; }
.note { background: #fff8e6; border-radius: 10px; padding: 8px 12px; font-size: .88rem; color: #6b4e00; margin: 12px 0 0; }
.note.warn { background: #fff3e0; }
.err { color: var(--bad); margin: 0; }
.badge { display: inline-block; background: #fff4d6; color: #8a5a00; border-radius: 999px; padding: 6px 14px; font-weight: 700; margin-top: 8px; }

/* ── Home ────────────────────────────────────────────────── */
.home-head { margin: 4px 0 16px; }
.home-head .switch-user { margin: -2px 0 4px; padding: 2px 0; font-size: .85rem; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); margin-top: 14px; }
/* Search box, played-recently chips, topic rows in groups (levels open in a sheet) */
.home-search { position: relative; margin-bottom: 12px; }
.home-search::before {
  content: '🔍'; position: absolute; inset-inline-start: 14px; top: 50%; transform: translateY(-50%);
  font-size: 1rem; opacity: .6; pointer-events: none;
}
.home-search input {
  width: 100%; height: 48px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--card);
  padding-inline: 42px 12px; font-size: 1rem; box-shadow: 0 1px 3px rgba(15, 27, 45, .06);
}
.recent { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 2px 0 6px; }
.recent > span { margin-inline-end: 2px; }
.recent-chip { font-size: .86rem; padding: 6px 12px; color: var(--ink); }
.recent-chip:hover { background: var(--primary-soft); border-color: var(--primary); }
.group-h { font-size: .95rem; color: var(--muted); font-weight: 700; margin: 18px 4px 8px; }
.topics { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); }
.topic {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 68px; padding: 10px 14px;
  background: var(--card); border: 1.5px solid transparent; border-radius: 14px; box-shadow: 0 1px 3px rgba(15, 27, 45, .08);
  cursor: pointer; text-align: start;
}
.topic:hover, .topic:focus-visible { border-color: var(--primary); background: var(--primary-soft); }
.topic .act-icon { font-size: 1.9rem; width: 2.2rem; text-align: center; flex: none; }
.t-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.t-main b { font-size: 1.02rem; }
.t-main .small { overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.t-stars { flex: none; font-size: .82rem; font-weight: 700; color: #b07d00; background: #fff6d6; border-radius: 999px; padding: 2px 8px; }
.t-go { flex: none; font-size: 1.5rem; line-height: 1; color: var(--muted); }
.no-res { grid-column: 1 / -1; text-align: center; padding: 24px 8px; margin: 0; }
/* "Missing a topic? Suggest a new game": the last row of the list, dashed so it reads as an invitation */
#topics > .topics:last-child { margin-top: 14px; }
.topic.suggest { border: 1.5px dashed var(--primary); background: transparent; box-shadow: none; }
.topic.suggest b { color: var(--primary-text); }
.topic.suggest:hover, .topic.suggest:focus-visible { background: var(--primary-soft); border-style: solid; }
/* Level sheet */
.modal.sheet { width: min(460px, 100%); gap: 12px; max-height: calc(100dvh - 32px); overflow: auto; }
.sheet-head { display: flex; align-items: flex-start; gap: 12px; }
.sheet-head > div { flex: 1; min-width: 0; }
.sheet-head h3 { margin: 0 0 2px; } .sheet-head p { margin: 0; }
.sheet-head .lv-has { margin-top: 4px; }
.sheet-x { width: 36px; height: 36px; font-size: .95rem; }
.sheet-label { margin-bottom: -4px; font-weight: 600; }
.sheet .levels { flex-direction: column; gap: 8px; }
.sheet .level { flex-direction: row; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; text-align: start; }
.lv-text { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 0; }
.sheet .lv-sub { text-align: start; font-size: .8rem; }
.lv-has { font-size: .8rem; font-weight: 700; color: var(--good); }
.sheet .level.has { border-color: var(--good); background: var(--good-soft); }
.sheet .lv-stars { font-size: .95rem; flex: none; }
/* "No time limit" switch under the levels */
.untimed-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 4px 14px 0; cursor: pointer; }
.untimed-row strong { font-size: .92rem; }
.untimed-row .small { font-size: .78rem; }
input.switch {
  appearance: none; -webkit-appearance: none; margin: 0; flex: none; cursor: pointer;
  width: 44px; height: 26px; border-radius: 99px; background: #c9d2dc; position: relative; transition: background .15s;
}
input.switch::before {
  content: ''; position: absolute; top: 3px; inset-inline-start: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(15, 27, 45, .3); transition: transform .15s;
}
input.switch:checked { background: var(--good); }
input.switch:checked::before { transform: translateX(18px); }
[dir=rtl] input.switch:checked::before { transform: translateX(-18px); }
input.switch:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
@media (max-width: 560px) {
  .topics { grid-template-columns: 1fr; }
  .recent { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-inline: -16px; padding: 2px 16px; }
  .recent::-webkit-scrollbar { display: none; }
  .recent > * { flex: none; white-space: nowrap; }
  .modal-back.sheet-back { place-items: end stretch; padding: 0; }
  .modal.sheet {
    width: 100%; border-radius: 22px 22px 0 0; max-height: 88dvh;
    padding-bottom: calc(18px + env(safe-area-inset-bottom)); animation: sheet-up .2s ease-out;
  }
}
@keyframes sheet-up { from { transform: translateY(40px); } to { transform: none; } }
.act-top { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 12px; }
.act-icon { font-size: 2.2rem; line-height: 1; }
.act-top h3 { margin-bottom: 2px; }
.act-top p { margin: 0; }
/* Levels: one compact row of difficulty buttons — Easy · Medium · Hard */
.levels { display: flex; gap: 6px; }
.level {
  flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 3px;
  border: 1.5px solid var(--line); background: #fbfdff; border-radius: 12px; padding: 8px 4px 6px; cursor: pointer;
}
.level:hover, .level:focus-visible { border-color: var(--lv); background: var(--primary-soft); }
.d-easy { --lv: #16a34a; } .d-medium { --lv: #f59e0b; } .d-hard { --lv: #e11d48; } .d-expert { --lv: #7c3aed; } .d-x { --lv: var(--primary); }
.lv-name { font-weight: 700; font-size: .95rem; display: inline-flex; align-items: center; gap: 6px; }
.lv-name::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--lv); flex: none; }
.lv-sub { font-size: .74rem; color: var(--muted); line-height: 1.2; text-align: center; }
.lv-stars { color: #c9d2dc; letter-spacing: 1px; font-size: .8rem; line-height: 1; }
.lv-stars.on { color: var(--gold); }

/* Tip: yellow, easy to find (header pill, home card, end-of-round line) */
.tip-pill {
  height: 40px; padding: 0 14px; border-radius: 999px; border: 0; background: #ffdd00; color: #1f1a00;
  font-weight: 700; cursor: pointer; flex: none; display: inline-flex; align-items: center; gap: 6px;
  box-shadow: 0 2px 0 #e0b800;
}
.tip-pill:hover { background: #ffe94d; }
@media (max-width: 359px) { .tip-pill span { display: none; } .tip-pill { padding: 0 11px; } }
/* 💡 Suggestions: a labelled blue pill in the top bar and a card on home (user asked for it to stand out) */
.fb-pill {
  height: 40px; padding: 0 14px; border-radius: 999px; border: 1.5px solid var(--primary); background: var(--primary-soft);
  color: var(--primary-text); font-weight: 700; cursor: pointer; flex: none; display: inline-flex; align-items: center; gap: 6px;
}
.fb-pill:hover { background: #d3e1ff; }
@media (max-width: 420px) { #topbar { gap: 4px; padding: 0 10px; } .fb-pill, .tip-pill { padding: 0 10px; gap: 4px; } #topbar .chip { padding: 6px 10px; } }
@media (max-width: 359px) { .fb-pill span { display: none; } .fb-pill { padding: 0 11px; } }
.home-cards { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); margin-top: 18px; }
.home-cards:not(:has(.card)) { display: none; }
.home-cards .tip-card { margin-top: 0; }
.fb-card { display: flex; align-items: center; gap: 14px; background: linear-gradient(135deg, #eef4ff, #d9e6ff); }
.fb-card > div { flex: 1; min-width: 0; }
.fb-card h3 { margin-bottom: 2px; } .fb-card p { margin: 0; }
.btn.fb-btn { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 700; white-space: nowrap; }
.btn.fb-btn:hover { background: #1d4ed8; border-color: #1d4ed8; }
@media (max-width: 560px) { .fb-card { flex-wrap: wrap; } .fb-card .fb-btn { width: 100%; } .home-cards { grid-template-columns: 1fr; } }
.tip-card { display: flex; align-items: center; gap: 14px; margin-top: 14px; background: linear-gradient(135deg, #fffbe6, #fff2a8); }
.tip-card > div { flex: 1; min-width: 0; }
.tip-card h3 { margin-bottom: 2px; } .tip-card p { margin: 0; }
.tip-emoji { font-size: 2.2rem; line-height: 1; }
.btn.tip-btn { background: #ffdd00; border-color: #e6c400; color: #1f1a00; font-weight: 700; }
.btn.tip-btn:hover { background: #ffe94d; border-color: #d4b400; }
@media (max-width: 560px) { .tip-card { flex-wrap: wrap; } .tip-card .tip-btn { width: 100%; } }
.tip-line {
  margin-top: 16px; border: 0; background: #fff6c2; color: #5c4a00; border-radius: 999px;
  padding: 8px 16px; cursor: pointer; font-weight: 600;
}
.tip-line:hover { background: #ffec80; }
.teacher-card .btn { width: 100%; }
.links { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; align-items: center; margin-top: 22px; }
.links a { color: var(--muted); font-size: .85rem; }

/* ── Play ────────────────────────────────────────────────── */
body[data-screen=play] #app, body[data-screen=student] #app { overflow: hidden; }
.screen.play { position: absolute; inset: 0; padding: 0; max-width: none; }
.board { position: absolute; inset: 0; }
.loading { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; gap: 10px; color: var(--muted); }
.spinner { width: 36px; height: 36px; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--primary); animation: spin 0.9s linear infinite; margin: 0 auto; }
.hud {
  position: absolute; top: 10px; inset-inline: 10px; margin: 0 auto; max-width: 720px; z-index: 5;
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; padding: 10px 12px 14px;
}
.hud .prompt { font-size: 1.15rem; text-align: center; }
.hud .prompt .target { font-size: 1.35rem; color: var(--primary); }
.prompt .hint { color: var(--muted); font-size: .95rem; }
.stats { display: flex; gap: 8px; align-items: center; font-weight: 700; }
.stats .progress { color: var(--muted); font-weight: 600; font-size: .9rem; }
.stats .score { background: var(--primary-soft); color: var(--primary-text); padding: 3px 10px; border-radius: 999px; min-width: 3.5em; text-align: center; }
.stats .streak { color: var(--accent); }
.timer { position: absolute; inset-inline: 12px; bottom: 6px; height: 5px; background: var(--line); border-radius: 99px; overflow: hidden; }
.timer .bar { height: 100%; width: 100%; background: var(--good); transform-origin: right; transition: transform .1s linear, background .3s; }
[dir=ltr] .timer .bar { transform-origin: left; }
.timer.low .bar { background: var(--bad); }
.zoom-ctl { position: absolute; inset-inline-end: 12px; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; gap: 6px; z-index: 4; }
.zoom-ctl .icon-btn { box-shadow: var(--shadow); }
.panel {
  position: absolute; bottom: 12px; inset-inline: 10px; margin: 0 auto; max-width: 600px; z-index: 6;
  display: flex; flex-direction: column; gap: 8px; padding: 12px 14px;
}
.panel.asking { flex-direction: row; align-items: center; }
.panel.asking .ask-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.panel.asking .hint-text { color: var(--muted); font-size: .92rem; }
.panel.asking .clue { font-weight: 700; color: var(--ink); background: #fff7db; border-radius: 10px; padding: 6px 10px; animation: pop .25s ease-out; }
.panel.asking .hint-btn { flex: none; white-space: nowrap; }
.panel.asking .hint-btn small { color: var(--muted); font-weight: 600; }
@keyframes pop { from { transform: scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }
label.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
label.check input { margin-top: 4px; width: 18px; height: 18px; flex: none; }
.panel.feedback.good { border-top: 4px solid var(--good); }
.panel.feedback.bad { border-top: 4px solid var(--bad); }
.panel.feedback.near { border-top: 4px solid var(--near); }
.fb-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; font-size: 1.1rem; }
.fb-head .dist { color: var(--muted); font-size: .92rem; }
.fb-picked { margin-top: 4px; }
.fb-head .pts { margin-inline-start: auto; font-weight: 800; color: var(--primary); font-size: 1.3rem; }
.learn { background: #f6f9fc; border-radius: 12px; padding: 10px 12px; font-size: .95rem; }
.learn-links { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 6px; font-size: .9rem; }
.learn-links a { text-decoration: none; font-weight: 600; }
.learn-links .linklike { color: var(--muted); font-size: .82rem; }
.waiting { text-align: center; color: var(--muted); padding: 6px; }
.rank-line { text-align: center; font-size: 1rem; }
.code-chip { background: var(--ink); color: #fff; font-weight: 800; letter-spacing: .15em; border-radius: 8px; padding: 4px 10px; direction: ltr; display: inline-block; }
.code-chip.small { font-size: .75rem; padding: 2px 6px; }
@media (max-width: 560px) {
  .hud { grid-template-columns: auto 1fr; padding: 8px 10px 14px; }
  .hud .stats { grid-column: 1 / -1; justify-content: center; order: 3; }
  .hud .prompt { font-size: 1rem; } .hud .prompt .target { font-size: 1.2rem; }
  .panel.asking { gap: 10px; padding: 10px 12px; }
  .panel.asking .hint-text { font-size: .85rem; }
  .zoom-ctl { top: auto; bottom: 120px; transform: none; }
}

/* ── Map ─────────────────────────────────────────────────── */
svg.map { width: 100%; height: 100%; display: block; touch-action: none; user-select: none; direction: ltr; }
svg.map.flat { background: var(--ocean); }
svg.map.sphere { background: var(--space); }
svg.map.picking { cursor: crosshair; }
.ocean { fill: var(--ocean); }
.graticule { fill: none; stroke: var(--grid); stroke-width: .6; vector-effect: non-scaling-stroke; }
.land { fill: var(--land); stroke: #b8ae97; stroke-width: .6; vector-effect: non-scaling-stroke; }
.flat .land { fill: var(--land-other); }
.flat .home-land { fill: var(--land-home); }
.home-land { fill: var(--land-home); stroke: #9b8f73; stroke-width: 1; }
.map-credit { position: absolute; inset-inline-start: 8px; z-index: 3; font-size: 11px; color: var(--muted); background: color-mix(in srgb, var(--card) 75%, transparent); padding: 1px 6px; border-radius: 6px; text-decoration: none; direction: ltr; }
.map-credit:hover { text-decoration: underline; }
.map-line { fill: none; stroke: #3b8fd4; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; pointer-events: none; }
/* zoom detail on the Israel maps: relief tiles and main roads (no names), the km scale, the circle around the pin */
.relief { opacity: .85; pointer-events: none; }
.relief image { transition: opacity .25s; }
.road { fill: none; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; pointer-events: none; }
.road.major { stroke: #c9976a; stroke-width: 1.3; }
.road.primary { stroke: #d6c4a6; stroke-width: .8; }
.scale { pointer-events: none; }
.scale-bar { fill: none; stroke: #3b4655; stroke-width: 1.6; }
.scale-label { font-size: 11px; font-weight: 600; fill: #3b4655; paint-order: stroke; stroke: rgba(255, 255, 255, .9); stroke-width: 3px; stroke-linejoin: round; }
.tol-ring { fill: color-mix(in srgb, var(--primary) 7%, transparent); stroke: var(--primary); stroke-width: 1.6; stroke-dasharray: 6 4; pointer-events: none; }
.tol-ring.legend { stroke-dasharray: 3 2; stroke-width: 1.3; }
.tol-ring.good { fill: color-mix(in srgb, var(--good) 7%, transparent); stroke: var(--good); }
.tol-ring.bad { fill: color-mix(in srgb, var(--bad) 6%, transparent); stroke: var(--bad); }
.tol-ring.near { fill: color-mix(in srgb, var(--near) 7%, transparent); stroke: var(--near); }
.tol-label { font-size: 11px; font-weight: 600; fill: var(--primary); paint-order: stroke; stroke: rgba(255, 255, 255, .9); stroke-width: 3px; stroke-linejoin: round; pointer-events: none; }
.tol-label.good { fill: var(--good); } .tol-label.bad { fill: var(--bad); } .tol-label.near { fill: var(--near); }
.outline { fill: none; stroke: #8f8262; stroke-width: 1.3; stroke-dasharray: 5 3; vector-effect: non-scaling-stroke; pointer-events: none; }
.country { fill: var(--land); stroke: var(--border); stroke-width: .6; vector-effect: non-scaling-stroke; }
/* a home country drawn in its parts (the Iran map's provinces), the countries around it greyer, its outline on top */
.country.home { fill: var(--land-home); }
.country.other { fill: var(--land-other); }
.home-edge { fill: none; stroke: #9b8f73; stroke-width: 1.2; vector-effect: non-scaling-stroke; pointer-events: none; }
svg.picking .country:hover { fill: #fbe9b7; }
.lake { fill: var(--water); stroke: #7fb8da; stroke-width: .6; vector-effect: non-scaling-stroke; }
.target-shape { fill: rgba(21, 163, 74, .55); stroke: var(--good); stroke-width: 2; vector-effect: non-scaling-stroke; animation: pulse 1.4s ease-in-out infinite; }
.target-shape.soft { fill: rgba(21, 163, 74, .35); stroke-width: 1; }
.target-band { fill: none; stroke: rgba(21, 163, 74, .4); stroke-linecap: round; stroke-linejoin: round; }
.target-line { fill: none; stroke: var(--good); stroke-width: 2.5; stroke-dasharray: 6 4; vector-effect: non-scaling-stroke; }
@keyframes pulse { 50% { opacity: .55; } }
.lbl { fill: #3b4655; paint-order: stroke; stroke: rgba(255, 255, 255, .9); stroke-width: 3px; stroke-linejoin: round; font-weight: 500; pointer-events: none; }
.lbl.ctx { fill: #6d86a0; font-style: italic; font-weight: 400; }
.lbl.marker { fill: #1e293b; }
.lbl.ref { fill: #334155; font-weight: 600; }
.lbl.line { fill: #1d5f99; font-weight: 600; }
circle.ref { fill: #475569; stroke: #fff; stroke-width: 1.5; pointer-events: none; }
.markers path { pointer-events: none; }
.markers .dot-edge, .markers .dot1-fill { fill: #1e3a8a; }
.markers .dot-fill, .markers .dot1-edge { fill: #fff; }
.markers .city.picked { fill: var(--accent); stroke: #fff; stroke-width: 2.5; pointer-events: none; }
/* The player's pin: blue when placed, green / red once the answer is shown; a dot marks the exact spot */
.pin { --pin: var(--primary); pointer-events: none; }
.pin.good { --pin: var(--good); } .pin.bad { --pin: var(--bad); } .pin.near { --pin: var(--near); }
.pin path { fill: var(--pin); stroke: #fff; stroke-width: 1.8; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .35)); }
.pin .pin-hole { fill: #fff; }
.pin .pin-spot { fill: #fff; stroke: var(--pin); stroke-width: 2.2; }
.tap-ripple { fill: none; stroke: var(--primary); stroke-width: 3; pointer-events: none; opacity: 0;
  animation: tap-ripple .7s ease-out forwards; transform-box: fill-box; transform-origin: center; }
.tap-ripple.good { stroke: var(--good); } .tap-ripple.bad { stroke: var(--bad); }
/* Keyboard play (1.18.8): the map takes the focus, and a cross shows where Enter answers */
svg.map:focus { outline: none; }
svg.map:focus-visible { outline: 3px solid var(--primary); outline-offset: -3px; }
.kbd-halo { fill: none; stroke: #fff; stroke-width: 6; stroke-linecap: round; pointer-events: none; }
.kbd-cross { fill: none; stroke: var(--ink); stroke-width: 2.5; stroke-linecap: round; pointer-events: none; }
/* Less motion for those who asked their device for it */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
@keyframes tap-ripple { from { transform: scale(.15); opacity: .9; } to { transform: scale(1); opacity: 0; } }
.arrow { stroke: var(--bad); stroke-width: 2.5; stroke-dasharray: 7 5; }
.arrow.good { stroke: var(--good); }
.arrowhead { fill: var(--bad); } .arrowhead.good { fill: var(--good); }
.target-dot { fill: var(--good); stroke: #fff; stroke-width: 2.5; }
.target-ring { fill: none; stroke: var(--good); stroke-width: 3; animation: ring 1.2s ease-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes ring { from { transform: scale(.5); opacity: 1; } to { transform: scale(1.6); opacity: 0; } }
.answer-label { font-weight: 800; font-size: 15px; fill: #0b5d2a; paint-order: stroke; stroke: #fff; stroke-width: 4px; stroke-linejoin: round; }
circle.other { stroke: #fff; stroke-width: 1.5; }
circle.other.good { fill: var(--good); } circle.other.bad { fill: var(--bad); } circle.other.near { fill: var(--near); }
.other-name { font-size: 11px; fill: #334155; paint-order: stroke; stroke: #fff; stroke-width: 3px; }

/* ── Results ─────────────────────────────────────────────── */
.results { text-align: center; }
.big-stars { font-size: 2.6rem; letter-spacing: 6px; margin: 4px 0; }
.big-stars span { color: #d6dde5; display: inline-block; }
.big-stars span.on { color: var(--gold); animation: pop .5s backwards; }
@keyframes pop { from { transform: scale(0) rotate(-40deg); } 70% { transform: scale(1.3); } }
.big-score { font-size: 2.6rem; font-weight: 800; color: var(--primary); }
.res-stats { display: flex; justify-content: center; gap: 28px; margin: 14px 0; }
.res-stats div { display: flex; flex-direction: column; }
.res-stats b { font-size: 1.3rem; } .res-stats span { color: var(--muted); font-size: .85rem; }
.res-list { list-style: none; padding: 0; margin: 10px 0 0; text-align: start; max-height: 320px; overflow: auto; }
.res-list li { display: grid; grid-template-columns: 22px 1fr auto auto; gap: 10px; align-items: center; padding: 8px 6px; border-bottom: 1px solid var(--line); }
.res-list .mark { font-weight: 800; } .res-list .good .mark { color: var(--good); } .res-list .bad .mark { color: var(--bad); } .res-list .near .mark { color: var(--near); }
.res-list .pts { font-weight: 700; min-width: 3em; text-align: end; }
.res-list a { color: inherit; text-decoration: none; } .res-list a:hover { text-decoration: underline; }

/* ── Teacher ─────────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.form-grid label { display: flex; flex-direction: column; gap: 6px; }
.form-grid .full { grid-column: 1 / -1; }
.modes { border: 0; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.modes legend { font-weight: 600; font-size: .9rem; margin-bottom: 6px; }
.mode-card { border: 2px solid var(--line); border-radius: 14px; padding: 12px; cursor: pointer; display: flex; flex-direction: column; gap: 4px; font-weight: 400; }
.mode-card:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.mode-card input { position: absolute; opacity: 0; }
@media (max-width: 560px) { .form-grid, .modes { grid-template-columns: 1fr; } }

body[data-screen=teacherRoom] .screen { max-width: 1300px; }
.room { display: flex; flex-direction: column; gap: 12px; }
.room-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 14px; }
.room-title { font-weight: 600; }
.lobby { display: grid; grid-template-columns: 1.2fr 1fr; gap: 14px; }
@media (max-width: 760px) { .lobby { grid-template-columns: 1fr; } }
.join-info { text-align: center; }
.big-code { font-size: 3.4rem; font-weight: 800; letter-spacing: .2em; direction: ltr; color: var(--ink); }
.qr { width: 190px; height: 190px; margin: 6px auto 12px; }
.qr svg { width: 100%; height: 100%; }
.link-row { display: flex; gap: 8px; flex-wrap: wrap; }
.link-row input { flex: 1 1 220px; direction: ltr; font-size: .85rem; }
.players-card { display: flex; flex-direction: column; gap: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; min-height: 60px; align-content: flex-start; }
.pchip { background: var(--primary-soft); color: var(--primary-text); border-radius: 999px; padding: 6px 12px; font-weight: 600; animation: pop .35s; }
.pchip.off { opacity: .45; }
.live { display: grid; grid-template-columns: 1fr 340px; gap: 12px; height: calc(100dvh - var(--topbar) - 120px); min-height: 460px; }
@media (max-width: 860px) { .live { grid-template-columns: 1fr; height: auto; } .live-map { height: 60dvh; } }
.live-map { position: relative; padding: 0; overflow: hidden; }
.live-side { display: flex; flex-direction: column; gap: 10px; position: relative; overflow: auto; }
.live-side .prompt.big { font-size: 1.3rem; }
.live-side .prompt .target { color: var(--primary); font-size: 1.6rem; display: block; }
.live-side .timer { position: relative; inset: auto; height: 8px; }
.answered { font-weight: 600; }
.lb { margin: 0; padding-inline-start: 22px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.lb li { padding: 4px 0; }
.lb li { display: list-item; }
.lb li > * { vertical-align: middle; }
.lname { font-weight: 600; } .lscore { float: inline-end; font-weight: 700; }
.delta { font-size: .8rem; margin-inline-start: 6px; padding: 1px 6px; border-radius: 99px; }
.delta.good { background: var(--good-soft); color: var(--good); } .delta.bad { background: var(--bad-soft); color: var(--bad); }
.delta.near { background: color-mix(in srgb, var(--near) 14%, transparent); color: var(--near); }
.tick { color: var(--good); margin-inline-start: 6px; }
.ptable { width: 100%; border-collapse: collapse; margin: 10px 0 14px; }
.ptable td { padding: 8px 6px; border-bottom: 1px solid var(--line); }
.ptable tr.off { opacity: .5; }
.prog { width: 40%; } .pbar { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; margin-bottom: 2px; }
.pbar div { height: 100%; background: var(--primary); transition: width .4s; }
.ended { text-align: center; }

/* leaderboard (results screen and the level sheet's 🏆) */
.lb-box { border: 1.5px solid var(--line); border-radius: 14px; padding: 12px 14px; margin: 12px 0; text-align: start; }
.lb-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.lb-head h3 { margin: 0; font-size: 1.05rem; }
.seg { display: inline-flex; flex-wrap: wrap; background: var(--bg); border-radius: 999px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; border-radius: 999px; padding: 5px 12px; font: inherit; font-size: .85rem; cursor: pointer; color: var(--muted); }
.seg button.on { background: var(--card); color: var(--ink); font-weight: 700; box-shadow: 0 1px 3px rgba(15, 27, 45, .14); }
.lb-list { list-style: none; margin: 10px 0 2px; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.lb-list li { display: grid; grid-template-columns: 2.2em 1fr auto; align-items: center; gap: 6px; padding: 5px 8px; border-radius: 10px; }
.lb-list li.me { background: var(--primary-soft); }
.lb-list li.me .lname { color: var(--primary); }
.lb-list li.gap { display: block; text-align: center; color: var(--muted); padding: 0; line-height: 1; }
.lb-rank { color: var(--muted); font-weight: 700; text-align: center; }
.lb-list .lscore { float: none; }
.lb-body .spinner { width: 22px; height: 22px; border-width: 3px; margin: 14px auto; }
.lb-empty { margin: 12px 0 4px; text-align: center; }
.lb-foot { margin-top: 6px; }
.lb-standing { margin: 8px 0 0; padding: 6px 10px; border-radius: 10px; background: var(--good-soft); font-size: .92rem; }
.lb-standing b { color: var(--good); }
.lb-name { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.lb-name .row input { flex: 1; min-width: 0; }
.lb-name p { margin: 0; }
.lb-open { display: block; margin: 6px auto 0; font-weight: 600; }
.lb-modal { width: min(440px, 100%); max-height: calc(100dvh - 32px); overflow: auto; }
.lb-modal .lb-box { margin: 0; }
.lv-seg { align-self: flex-start; }

/* teams in class mode */
.team-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.team-col { border-top: 4px solid var(--team); background: color-mix(in srgb, var(--team) 8%, var(--card)); border-radius: 12px; padding: 8px; }
.team-col .chips { min-height: 36px; }
.team-col .pchip { background: color-mix(in srgb, var(--team) 18%, var(--card)); color: var(--ink); }
.team-name { font-weight: 700; margin-bottom: 6px; }
.team-bars { display: flex; flex-direction: column; gap: 6px; margin: 4px 0 8px; text-align: start; }
.team-bars p { margin: 0; }
.tbar { display: grid; grid-template-columns: minmax(96px, auto) 1fr auto; align-items: center; gap: 8px; }
.tname { font-weight: 600; white-space: nowrap; }
.ttrack { height: 12px; background: var(--line); border-radius: 99px; overflow: hidden; }
.ttrack span { display: block; height: 100%; background: var(--team); border-radius: 99px; transition: width .5s; }
.team-win { display: inline-block; font-size: 1.15rem; padding: 10px 16px; margin: 6px auto 10px; border-radius: 14px;
  background: color-mix(in srgb, var(--team) 14%, var(--card)); border: 2px solid var(--team); }
.team-pick { margin: 6px 0 10px; }
.team-pick .row.wrap { margin-top: 6px; }
.team-btn { border: 2px solid var(--team); background: var(--card); color: var(--ink); border-radius: 999px; padding: 8px 14px; font: inherit; font-weight: 600; cursor: pointer; }
.team-btn.on { background: color-mix(in srgb, var(--team) 24%, var(--card)); border-width: 3px; }
.team-btn.on::after { content: ' ✓'; }
.podium { display: grid; grid-template-columns: repeat(3, 1fr); align-items: end; gap: 8px; margin: 16px auto; max-width: 420px; }
.pod { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.pod .pname { font-weight: 700; } .pod .pscore { color: var(--muted); font-size: .9rem; }
.pod .pstep { width: 100%; border-radius: 12px 12px 0 0; color: #fff; font-weight: 800; font-size: 1.6rem; display: grid; place-items: center; }
.pod.p1 .pstep { height: 110px; background: var(--gold); } .pod.p2 .pstep { height: 80px; background: var(--silver); } .pod.p3 .pstep { height: 60px; background: var(--bronze); }
.pod.me .pname { color: var(--primary); }
.wait { text-align: center; }
.wait .code-chip { margin: 8px 0; }

/* ── Modal & toast ───────────────────────────────────────── */
.modal-back { position: fixed; inset: 0; background: rgba(15, 27, 45, .35); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { width: min(420px, 100%); display: flex; flex-direction: column; gap: 10px; }
/* In-app feedback box: type chips, text + 🎤 dictation */
.fb-box h3, .fb-box p { margin: 0; }
.fb-types { display: flex; flex-wrap: wrap; gap: 6px; }
.fb-types .chip { font-size: .85rem; padding: 5px 10px; color: var(--ink); }
.fb-types .chip[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: #fff; }
.fb-text { position: relative; }
.fb-text textarea {
  width: 100%; min-height: 110px; resize: vertical; padding: 12px 14px; padding-inline-end: 52px;
  border-radius: 12px; border: 1.5px solid var(--line); background: #fbfdff; font: inherit;
}
.fb-text textarea:focus { outline: 2px solid var(--primary); outline-offset: 1px; border-color: transparent; }
.fb-text .mic {
  position: absolute; inset-inline-end: 8px; bottom: 10px; width: 40px; height: 40px; border-radius: 50%;
  border: 1.5px solid var(--line); background: #fff; font-size: 1.15rem; cursor: pointer; display: grid; place-items: center;
}
.fb-text .mic.on { background: #ffe4e6; border-color: #e11d48; animation: mic-pulse 1.2s ease-in-out infinite; }
@keyframes mic-pulse { 50% { box-shadow: 0 0 0 6px rgba(225, 29, 72, .18); } }
.fb-note:empty { display: none; }
.fb-email { display: flex; flex-direction: column; gap: 4px; }
.fb-email span { color: var(--muted); }
.fb-email input { width: 100%; text-align: start; }
.fb-email input::placeholder { text-align: right; }
[dir="ltr"] .fb-email input::placeholder, html[dir="ltr"] .fb-email input::placeholder { text-align: left; }
.fb-box .fb-form { align-self: center; color: var(--muted); font-size: .82rem; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; z-index: 60; transition: opacity .4s; box-shadow: var(--shadow); }
.toast.out { opacity: 0; }
