:root {
  --ink: #1d2433;
  --muted: #5b6475;
  --line: #d6dae3;
  --bg: #f4f3ee;
  --accent: #4f7942;
  --accent-soft: #e6eedf;
  --right: #0f9d58;
  --right-soft: #d9f5e5;
  --wrong: #d0312d;
  --wrong-soft: #fbe3e1;
  --header: #2f4a2a;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }

body { background: var(--bg); }

.site-header {
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding: 10px 16px;
  background: var(--header);
  color: #fff;
}

.brand {
  color: #fff;
  font-weight: 700;
  font-size: 18px;
  text-decoration: none;
  white-space: nowrap;
}

.quiz-heading {
  margin: 0;
  font-size: 18px;
  font-weight: 500;
  color: #d5e2cc;
}

/* Home */

.home-main {
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

.home-main h1 { margin: 0 0 6px; font-size: 28px; }

.lede { margin: 0 0 24px; color: var(--muted); }

.quiz-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.quiz-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  height: 100%;
  padding: 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: inherit;
  text-decoration: none;
}

.quiz-card:hover { border-color: var(--accent); box-shadow: 0 2px 10px rgba(79, 121, 66, 0.15); }

.quiz-title { font-weight: 700; font-size: 18px; color: var(--accent); }

.quiz-desc { color: var(--muted); font-size: 14px; }

.quiz-count { margin-top: auto; font-size: 13px; color: var(--muted); }

.quiz-best { font-size: 13px; font-weight: 600; color: var(--accent); }

/* Quiz page */

body.quiz {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

.toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 18px;
  padding: 8px 16px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.stat { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }

.stat-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-right: 4px;
}

.score { color: var(--wrong); }

.best { color: var(--accent); }

.note { font-size: 14px; font-weight: 600; color: var(--muted); }
.score.perfect { color: var(--right); }

.spacer { flex: 1; }

.btn {
  font: inherit;
  font-weight: 600;
  padding: 8px 18px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn:hover { filter: brightness(0.95); }

.quiz-main {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 280px;
}

.map { min-height: 0; height: 100%; background: #f1eee4; }

.bank {
  min-height: 0;
  overflow-y: auto;
  padding: 12px;
  background: #fff;
  border-left: 1px solid var(--line);
}

.bank-hint { margin: 0 0 10px; font-size: 13px; color: var(--muted); }

.submitted .bank-hint { display: none; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }

.bank-empty { margin: 0; font-size: 14px; color: var(--muted); }

.chip {
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid #b8c9ad;
  background: var(--accent-soft);
  color: var(--ink);
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.chip.selected { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip.lifted { opacity: 0.35; }

.chip.ghost {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 10000;
  pointer-events: none;
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
  white-space: nowrap;
}

body.dragging, body.dragging * { cursor: grabbing !important; }

/* Map markers. Each marker element sits exactly on its point (size 0). */

.target, .landmark { width: 0; height: 0; }

.target { touch-action: none; user-select: none; -webkit-user-select: none; }

.target .dot {
  position: absolute;
  left: -8px;
  top: -8px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--accent);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  cursor: pointer;
}

/* Bigger invisible touch area around each dot. */
.target .dot::after {
  content: "";
  position: absolute;
  left: -12px;
  top: -12px;
  right: -12px;
  bottom: -12px;
  border-radius: 50%;
}

.target.filled .dot { background: var(--accent); border-color: #fff; }

.target.armed:not(.filled) .dot { box-shadow: 0 0 0 4px rgba(79, 121, 66, 0.25); }

.target.hover .dot {
  transform: scale(1.5);
  box-shadow: 0 0 0 5px rgba(79, 121, 66, 0.35);
}

.target .tag, .target .answer {
  position: absolute;
  left: 0;
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  padding: 4px 7px;
  border-radius: 6px;
  pointer-events: none;
}

.target .tag {
  bottom: 11px;
  background: #fff;
  border: 1px solid var(--accent);
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  cursor: grab;
}

.target.filled .tag { pointer-events: auto; }
.target:not(.filled) .tag { display: none; }
.target.selected .tag { background: var(--accent); color: #fff; }
.target.selected .dot { box-shadow: 0 0 0 5px rgba(79, 121, 66, 0.4); }
.target.lifted .tag { opacity: 0.35; }

.target .answer { top: 13px; display: none; }

.target.correct .dot, .target.wrong .dot {
  left: -10px;
  top: -10px;
  width: 20px;
  height: 20px;
  border: 2px solid #fff;
  color: #fff;
  font-size: 12px;
  font-weight: 900;
  line-height: 16px;
  text-align: center;
}

.target.correct .dot::before { content: "\2713"; }
.target.wrong .dot::before { content: "\2717"; }
.target.correct .tag::before { content: "\2713  "; white-space: pre; }
.target.wrong .tag::before { content: "\2717  "; white-space: pre; display: inline-block; }

.target.correct .dot { background: var(--right); }
.target.correct .tag { border-color: var(--right); background: var(--right-soft); color: var(--right); }

.target.wrong .dot { background: var(--wrong); }
.target.wrong .tag { border-color: var(--wrong); background: var(--wrong-soft); color: var(--wrong); text-decoration: line-through; }
.target.wrong .answer { display: block; background: #fff; border: 1px solid var(--right); color: var(--right); }

.submitted .target .dot, .submitted .target .tag { cursor: default; }

.landmark { pointer-events: none; }

.landmark-star {
  position: absolute;
  left: -9px;
  top: -12px;
  width: 18px;
  font-size: 20px;
  line-height: 1;
  text-align: center;
  color: #333;
  text-shadow: 0 0 3px #fff, 0 0 3px #fff;
}

.landmark-name {
  position: absolute;
  left: 12px;
  top: -8px;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 700;
  font-style: italic;
  color: #333;
  text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 3px #fff;
}

/* Phones: map on top, word bank underneath. */
@media (max-width: 720px) {
  .site-header { padding: 8px 12px; gap: 10px; }
  .brand, .quiz-heading { font-size: 16px; }
  .toolbar { gap: 4px 12px; padding: 6px 12px; }
  .note { font-size: 13px; }
  .stat { font-size: 16px; }
  .btn { padding: 7px 14px; }
  .quiz-main { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .bank {
    max-height: 36dvh;
    border-left: 0;
    border-top: 1px solid var(--line);
    padding: 8px 10px 10px;
  }
  .bank-hint { margin-bottom: 6px; font-size: 12px; }
  .chips { gap: 6px; }
  .chip { font-size: 14px; padding: 6px 10px; }
  .target .tag, .target .answer { font-size: 11px; padding: 3px 5px; }
}
