/* ============ tokens ============ */
:root {
  --bg: #f7f5f0;
  --surface: #ffffff;
  --ink: #22303c;
  --muted: #71808c;
  --line: #e7e2d8;
  --accent: #2f7e6d;
  --accent-soft: #e3efeb;
  --gold: #c98f2c;
  --danger: #b4552f;
  --radius: 18px;
  --shadow: 0 8px 30px rgba(34, 48, 60, 0.1);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --serif: "Iowan Old Style", "Palatino", Georgia, serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* ============ screens ============ */
.screen { position: fixed; inset: 0; display: none; }
.screen.active { display: block; }

/* ============ home ============ */
#screen-home { overflow-y: auto; }
.home-inner {
  max-width: 520px;
  margin: 0 auto;
  padding: clamp(24px, 7vh, 72px) 24px 40px;
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.brand {
  font-family: var(--serif);
  font-size: clamp(2.4rem, 6vw, 3.4rem);
  font-weight: 500;
  letter-spacing: -0.01em;
}
.brand::after { content: " 📍"; font-size: 0.6em; }

.tagline { color: var(--muted); font-size: 1.05rem; margin-top: -14px; }

/* daily hero card */
.daily-card {
  font-family: var(--font);
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 20px 22px;
  border-radius: var(--radius);
  border: 1.5px solid var(--accent);
  background: linear-gradient(135deg, var(--accent-soft), var(--surface));
  cursor: pointer;
  transition: transform 0.18s, box-shadow 0.18s;
}
.daily-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(47, 126, 109, 0.25); }
.daily-card:active { transform: translateY(0) scale(0.99); }
.daily-kicker {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
}
.daily-city {
  font-family: var(--serif);
  font-size: 1.9rem;
  font-weight: 550;
  color: var(--ink);
  line-height: 1.1;
}
.daily-city::after { content: " ▸"; color: var(--accent); font-size: 0.7em; }
.daily-sub { font-size: 0.85rem; color: var(--muted); line-height: 1.45; }

.mode-cards.mode-cards-3 { grid-template-columns: 1fr 1fr 1fr; }
.mode-cards-3 .mode-desc { font-size: 0.78rem; }

.summary-practice {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
  background: var(--accent-soft);
  border-radius: 10px;
  padding: 8px 12px;
  width: fit-content;
}

.field label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 8px;
}
.field .hint { font-weight: 400; text-transform: none; letter-spacing: 0; }

#city-input {
  width: 100%;
  font-size: 1.1rem;
  font-family: var(--font);
  padding: 14px 16px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
#city-input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }

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

.chip {
  font-family: var(--font);
  font-size: 0.9rem;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  transition: all 0.18s;
}
.chip:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-1px); }
.chip.selected { background: var(--accent); border-color: var(--accent); color: #fff; }

.mode-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mode-card {
  font-family: var(--font);
  text-align: left;
  padding: 16px;
  border-radius: var(--radius);
  border: 1.5px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: all 0.18s;
}
.mode-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.mode-card.selected { border-color: var(--accent); background: var(--accent-soft); }
.mode-title { font-weight: 650; font-size: 1rem; color: var(--ink); }
.mode-desc { font-size: 0.82rem; color: var(--muted); line-height: 1.45; }

.btn-primary {
  font-family: var(--font);
  font-size: 1.02rem;
  font-weight: 600;
  padding: 14px 24px;
  border: none;
  border-radius: 14px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s, opacity 0.15s;
}
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(47, 126, 109, 0.35); }
.btn-primary:active:not(:disabled) { transform: translateY(0) scale(0.98); }
.btn-primary:disabled { background: #c6cec9; cursor: default; }

.btn-secondary {
  font-family: var(--font);
  font-size: 1.02rem;
  font-weight: 600;
  padding: 14px 24px;
  border-radius: 14px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  transition: all 0.15s;
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }

.link-btn {
  font-family: var(--font);
  background: none;
  border: none;
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  padding: 6px 0;
}
.link-btn:hover { text-decoration: underline; }

.error { color: var(--danger); font-size: 0.92rem; }

/* "did you mean" confirmation */
.dym {
  border: 1.5px solid var(--gold);
  background: #faf3e3;
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: card-in 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.1);
}
.dym p { font-size: 0.95rem; color: var(--ink); }
.dym-actions { display: flex; gap: 14px; align-items: center; }
.hidden { display: none !important; }

.credits { font-size: 0.75rem; color: var(--muted); line-height: 1.6; margin-top: 12px; }
.credits a { color: var(--muted); }

/* ============ loading ============ */
#screen-loading { display: none; place-items: center; }
#screen-loading.active { display: grid; }
.loading-inner { text-align: center; padding: 24px; max-width: 420px; }
.loading-pin { font-size: 2.6rem; animation: bob 1.4s ease-in-out infinite; }
@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}
.loading-inner h2 { font-family: var(--serif); font-weight: 500; margin: 14px 0 6px; }
.loading-step { color: var(--muted); font-size: 0.95rem; min-height: 1.4em; }
.progress-track {
  margin: 22px auto 0;
  width: 260px;
  height: 6px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: var(--accent);
  transition: width 0.35s ease;
}

/* ============ game ============ */
#map { position: absolute; inset: 0; }

.topbar {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 16px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 20px;
  box-shadow: var(--shadow);
  z-index: 5;
  white-space: nowrap;
}
.topbar-city { font-weight: 650; font-size: 0.95rem; }
.topbar-rounds { color: var(--muted); font-size: 0.88rem; }
.topbar-score { font-weight: 700; font-size: 0.95rem; color: var(--accent); font-variant-numeric: tabular-nums; }
.topbar-score::after { content: " pts"; font-weight: 500; color: var(--muted); font-size: 0.8em; }

/* cards */
.card {
  position: absolute;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  overflow: hidden;
  z-index: 6;
}
.card-in { animation: card-in 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.1); }
@keyframes card-in {
  from { opacity: 0; transform: translateY(24px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.prompt-card, .reveal-card {
  left: 18px;
  bottom: 18px;
  width: min(370px, calc(100vw - 36px));
  max-height: calc(100vh - 120px);
  overflow-y: auto;
}

.prompt-img, .reveal-img {
  width: 100%;
  height: 150px;
  object-fit: cover;
  display: block;
}

.prompt-body, .reveal-body { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 10px; }

.prompt-kicker {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
}
.prompt-card h3, .reveal-card h3 {
  font-family: var(--serif);
  font-size: 1.35rem;
  font-weight: 550;
  line-height: 1.2;
}
.prompt-desc { color: var(--muted); font-size: 0.92rem; line-height: 1.5; }
.prompt-desc:empty { display: none; }

.btn-confirm { width: 100%; margin-top: 4px; }

.feedback-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.feedback-chips:empty { display: none; }
.chip-feedback {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--accent-soft);
  border-color: transparent;
  color: var(--ink);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: default;
  animation: chip-pop 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.4);
}
@keyframes chip-pop {
  from { opacity: 0; transform: scale(0.6); }
  to { opacity: 1; transform: scale(1); }
}
.chip-n {
  background: var(--accent);
  color: #fff;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  font-size: 0.68rem;
}
.chip-arrow { color: var(--accent); transition: transform 0.3s; }

/* reveal */
.reveal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.reveal-score {
  text-align: right;
  font-weight: 750;
  font-size: 1.7rem;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  flex-shrink: 0;
}
.pts-label { display: block; font-size: 0.66rem; font-weight: 600; color: var(--muted); letter-spacing: 0.08em; text-transform: uppercase; margin-top: 3px; }
.reveal-dist { font-size: 0.92rem; color: var(--ink); font-weight: 550; }
.reveal-blurb { font-size: 0.9rem; color: var(--muted); line-height: 1.55; }
.reveal-blurb.clamped {
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.reveal-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; }

/* ============ pins ============ */
.pin-guess { position: relative; width: 22px; height: 22px; animation: pin-drop 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.3); }
@keyframes pin-drop {
  from { opacity: 0; transform: translateY(-22px) scale(0.6); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.pin-dot {
  position: absolute; inset: 3px;
  border-radius: 50%;
  background: var(--ink);
  border: 3px solid #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}
.pin-ripple {
  position: absolute; inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  opacity: 0;
  animation: ripple 1.6s ease-out infinite;
}
@keyframes ripple {
  0% { transform: scale(0.5); opacity: 0.5; }
  70% { transform: scale(1.5); opacity: 0; }
  100% { opacity: 0; }
}

.pin-ghost {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: rgba(34, 48, 60, 0.35);
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

.pin-target { position: relative; width: 34px; height: 34px; animation: target-pop 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.4); }
@keyframes target-pop {
  from { opacity: 0; transform: scale(0.2) rotate(-40deg); }
  to { opacity: 1; transform: scale(1) rotate(0deg); }
}
.pin-star {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  background: var(--accent);
  color: #fff;
  font-size: 1.05rem;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 3px 12px rgba(47, 126, 109, 0.5);
}
.pin-pulse {
  position: absolute; inset: -6px;
  border-radius: 50%;
  border: 2.5px solid var(--accent);
  animation: ripple 1.8s ease-out infinite;
}

/* ============ confetti ============ */
.confetti {
  position: fixed;
  width: 8px; height: 8px;
  border-radius: 2px;
  z-index: 99;
  pointer-events: none;
  animation: confetti-fly 1s cubic-bezier(0.2, 0.7, 0.4, 1) forwards;
}
@keyframes confetti-fly {
  from { opacity: 1; transform: translate(0, 0) rotate(0deg); }
  to { opacity: 0; transform: translate(var(--dx), var(--dy)) rotate(var(--rot)); }
}

/* ============ summary ============ */
#screen-summary {
  display: none;
  place-items: center;
  background: rgba(34, 48, 60, 0.25);
  backdrop-filter: blur(3px);
}
#screen-summary.active { display: grid; }
.summary-inner {
  position: relative;
  width: min(440px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: card-in 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.1);
}
.summary-inner h2 { font-family: var(--serif); font-weight: 550; font-size: 1.8rem; }
.summary-total {
  font-size: 2.6rem;
  font-weight: 750;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.summary-rounds { list-style: none; display: flex; flex-direction: column; gap: 4px; }
.summary-rounds li {
  display: grid;
  grid-template-columns: 28px 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 9px 10px;
  border-radius: 10px;
  background: var(--bg);
  font-size: 0.9rem;
}
.sr-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.sr-dist { color: var(--muted); font-size: 0.82rem; }
.sr-score { font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
.summary-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 6px; }

/* ============ mobile ============ */
@media (max-width: 560px) {
  .prompt-card, .reveal-card {
    left: 10px; right: 10px; bottom: 10px;
    width: auto;
    max-height: 46vh;
  }
  .prompt-img, .reveal-img { height: 110px; }
  .topbar { gap: 10px; padding: 8px 14px; top: 10px; max-width: calc(100vw - 20px); }
  .mode-cards, .mode-cards-3 { grid-template-columns: 1fr; }
  .daily-city { font-size: 1.5rem; }
}

/* maplibre attribution: keep it subtle but present */
.maplibregl-ctrl-attrib { font-size: 10px; opacity: 0.75; }
