:root {
  --night: #060c16;
  --night-2: #0a1524;
  --card: rgba(13, 27, 45, 0.82);
  --card-line: rgba(148, 178, 214, 0.16);
  --field: rgba(4, 10, 19, 0.72);
  --ink: #eef3f8;
  --muted: #8fa3bd;
  --gold: #f2c14e;
  --mint: #5ce0a0;
  --coral: #ff6f61;
  --gutter: 12px;
  --radius: 16px;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--night);
  color: var(--ink);
  font-family: "Familjen Grotesk", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

.hud,
.foot {
  transition: opacity .45s var(--ease);
}
body.is-pre .hud,
body.is-pre .foot {
  opacity: 0;
  pointer-events: none;
}

body.is-map .foot {
  opacity: 0;
  pointer-events: none;
}

#map {
  position: absolute;
  inset: 0;
  background: #071120;
  z-index: 0;
}

/* Map chrome ------------------------------------------------------------- */
.leaflet-container {
  background: #071120;
  font-family: inherit;
  outline: none;
}
.leaflet-control-attribution {
  background: rgba(6, 12, 22, 0.6) !important;
  color: rgba(180, 200, 225, 0.5) !important;
  font-size: 9px !important;
  padding: 1px 6px !important;
  border-radius: 4px 0 0 0;
}
.leaflet-control-attribution a { color: rgba(190, 212, 240, 0.7) !important; }

.scrim {
  position: absolute;
  left: 0;
  right: 0;
  height: 190px;
  pointer-events: none;
  z-index: 2;
}
.scrim--top { top: 0; background: linear-gradient(180deg, rgba(4, 9, 17, .82), rgba(4, 9, 17, 0)); }
.scrim--bottom {
  bottom: 0;
  height: 150px;
  background: linear-gradient(0deg, rgba(4, 9, 17, .88), rgba(4, 9, 17, 0));
}

/* Ring geometry ---------------------------------------------------------- */
.ring {
  stroke-linecap: round;
}
.ring--outer { stroke: rgba(255, 255, 255, .62); }
.ring--inner { stroke: rgba(242, 193, 78, .38); }

.target-pulse { background: none; border: 0; }
.target-pulse::before,
.target-pulse::after {
  content: "";
  position: absolute;
  left: -13px;
  top: -13px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid rgba(242, 193, 78, .55);
  animation: pulse 2.6s var(--ease) infinite;
}
.target-pulse::after { animation-delay: 1.3s; }

@keyframes pulse {
  0%   { transform: scale(.4); opacity: 0; }
  25%  { opacity: .9; }
  100% { transform: scale(1.9); opacity: 0; }
}

.pin-dot { filter: drop-shadow(0 1px 3px rgba(0, 0, 0, .55)); }

.pin-label {
  background: rgba(8, 18, 32, .88) !important;
  border: 1px solid rgba(148, 190, 240, .18) !important;
  border-radius: 7px !important;
  color: var(--ink) !important;
  font-family: "Familjen Grotesk", sans-serif !important;
  font-size: 11px !important;
  font-weight: 500 !important;
  letter-spacing: .01em;
  padding: 1px 6px !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .35) !important;
  white-space: nowrap;
}
.pin-label::before { display: none !important; }

.pin-label--missed {
  border-color: rgba(242, 193, 78, .45) !important;
  color: #ffe6b6 !important;
  background: rgba(28, 22, 8, .9) !important;
}

/* HUD -------------------------------------------------------------------- */
.hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5;
  padding: calc(var(--gutter) + env(safe-area-inset-top)) var(--gutter) 0;
  pointer-events: none;
}

.card {
  pointer-events: auto;
  background: var(--card);
  border: 1px solid var(--card-line);
  border-radius: var(--radius);
  padding: 13px 14px 11px;
  backdrop-filter: blur(16px) saturate(1.15);
  -webkit-backdrop-filter: blur(16px) saturate(1.15);
  box-shadow: 0 14px 34px -18px rgba(0, 0, 0, .9), inset 0 1px 0 rgba(255, 255, 255, .04);
}

.card-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.count {
  flex: none;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  letter-spacing: .02em;
  padding-top: 2px;
}
.count.is-done { color: var(--mint); }

.target {
  margin: 0;
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 7px;
  flex-wrap: wrap;
}
.target-city {
  font-family: "Newsreader", Georgia, serif;
  font-size: 25px;
  line-height: 1.05;
  font-weight: 500;
  letter-spacing: -.01em;
}
.target-country {
  font-size: 13px;
  color: var(--muted);
  font-weight: 400;
  letter-spacing: .01em;
}

.guess { margin-top: 11px; }

.guess input {
  width: 100%;
  height: 46px;
  padding: 0 13px;
  border-radius: 11px;
  border: 1px solid rgba(150, 182, 219, .14);
  background: var(--field);
  color: var(--ink);
  font-family: inherit;
  font-size: 16px; /* stays ≥16px so iOS does not zoom on focus */
  font-weight: 400;
  outline: none;
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease), background .18s var(--ease);
}
.guess input::placeholder { color: rgba(143, 163, 189, .72); }
.guess input:focus {
  border-color: rgba(242, 193, 78, .5);
  box-shadow: 0 0 0 3px rgba(242, 193, 78, .12);
  background: rgba(4, 10, 19, .9);
}
.guess input:disabled { opacity: .5; }

.guess input.shake { animation: shake .34s var(--ease); border-color: rgba(255, 111, 97, .65); }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  45% { transform: translateX(5px); }
  70% { transform: translateX(-3px); }
}

.hint {
  margin: 9px 0 0;
  font-size: 12.5px;
  line-height: 1.35;
  color: var(--muted);
  letter-spacing: .005em;
}
.hint b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }

/* Footer / timer --------------------------------------------------------- */
.foot {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  padding: 0 calc(var(--gutter) + 2px) calc(var(--gutter) + env(safe-area-inset-bottom));
  pointer-events: none;
}

.timer {
  display: flex;
  align-items: baseline;
  gap: 7px;
}

.foot-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.timer-left {
  font-size: 34px;
  line-height: 1;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
}
.timer-left.is-low { color: var(--coral); }
.timer-total {
  font-size: 13px;
  color: rgba(180, 200, 225, .55);
  font-variant-numeric: tabular-nums;
}

.bar {
  height: 3px;
  border-radius: 99px;
  background: rgba(255, 255, 255, .18);
  overflow: hidden;
}
.bar i {
  display: block;
  height: 100%;
  width: 100%;
  border-radius: 99px;
  background: var(--ink);
  transform-origin: left center;
}

/* Toast ------------------------------------------------------------------ */
.toast {
  position: absolute;
  left: 50%;
  bottom: 96px;
  z-index: 8;
  transform: translate(-50%, 8px);
  max-width: calc(100% - 32px);
  padding: 8px 13px;
  border-radius: 10px;
  background: rgba(8, 18, 32, .94);
  border: 1px solid rgba(148, 182, 219, .18);
  font-size: 13px;
  line-height: 1.3;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s var(--ease), transform .2s var(--ease);
  box-shadow: 0 12px 26px -14px #000;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.ok { border-color: rgba(92, 224, 160, .45); color: #d7fff0; }
.toast.bad { border-color: rgba(255, 111, 97, .5); color: #ffe2de; }

/* Sheets ----------------------------------------------------------------- */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: end center;
  padding: var(--gutter);
  padding-bottom: calc(var(--gutter) + env(safe-area-inset-bottom));
  background: rgba(3, 8, 15, .42);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: fade .22s var(--ease);
}
.sheet[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.panel {
  width: 100%;
  max-width: 430px;
  background: linear-gradient(180deg, rgba(16, 32, 53, .97), rgba(9, 18, 31, .98));
  border: 1px solid var(--card-line);
  border-radius: 20px;
  padding: 22px 20px 18px;
  box-shadow: 0 30px 60px -30px #000;
  animation: rise .26s var(--ease);
}
@keyframes rise {
  from { transform: translateY(14px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.panel .eyebrow {
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 6px;
  font-variant-numeric: tabular-nums;
}
.panel h2 {
  margin: 0 0 4px;
  font-family: "Newsreader", Georgia, serif;
  font-size: 30px;
  font-weight: 500;
  letter-spacing: -.015em;
  line-height: 1.1;
}
.panel p { margin: 0; font-size: 14px; line-height: 1.5; color: var(--muted); }
.panel strong { color: var(--ink); font-weight: 600; }

.panel .stats {
  display: flex;
  gap: 22px;
  margin: 18px 0 4px;
}
.panel .stat { display: flex; flex-direction: column; gap: 2px; }
.panel .stat span:first-child {
  font-size: 24px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
}
.panel .stat span:last-child { font-size: 11.5px; color: var(--muted); }

.panel .found {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}
.panel .found li {
  font-size: 12.5px;
  padding: 3px 9px;
  border-radius: 99px;
  border: 1px solid rgba(92, 224, 160, .35);
  color: #ccf7e4;
  background: rgba(92, 224, 160, .08);
}

.panel .examples { margin-top: 14px; font-size: 13px; color: var(--muted); line-height: 1.5; }
.panel .examples b { color: var(--ink); font-weight: 500; }

.panel .btn {
  display: block;
  width: 100%;
  margin-top: 18px;
  height: 50px;
  border: 0;
  border-radius: 13px;
  background: var(--gold);
  color: #1a1204;
  font-family: inherit;
  font-size: 15.5px;
  font-weight: 600;
  letter-spacing: .005em;
  cursor: pointer;
  transition: transform .12s var(--ease), filter .12s var(--ease);
}
.panel .btn:hover { filter: brightness(1.06); }
.panel .btn:active { transform: scale(.99); }
.panel .btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

.panel .btn.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid rgba(150, 182, 219, .24);
  margin-top: 9px;
  height: 44px;
  font-weight: 500;
}

.panel .rules {
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}
.panel .rules li {
  font-size: 13.5px;
  line-height: 1.45;
  color: #c6d5e6;
  padding-left: 17px;
  position: relative;
}
.panel .rules li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 8px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--gold);
  opacity: .8;
}

.panel .note {
  margin-top: 16px;
  font-size: 11px;
  line-height: 1.45;
  color: rgba(143, 163, 189, .65);
}

@media (min-width: 720px) {
  :root { --gutter: 22px; }
  .card { max-width: 430px; }
  .target-city { font-size: 28px; }
  .sheet { place-items: center; }
  .toast { bottom: 120px; }
}

/* Round indicator and city index entry point ----------------------------- */
.round-count {
  margin-left: auto;
  flex: none;
  align-self: center;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  letter-spacing: .02em;
  padding: 2px 7px;
  border: 1px solid rgba(148, 182, 219, .18);
  border-radius: 99px;
  white-space: nowrap;
}

.index-btn {
  pointer-events: auto;
  flex: none;
  height: 30px;
  padding: 0 11px;
  border-radius: 99px;
  border: 1px solid rgba(148, 182, 219, .22);
  background: rgba(9, 20, 34, .78);
  color: #cfe0f2;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .01em;
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.index-btn:hover { border-color: rgba(242, 193, 78, .45); color: var(--ink); }
.index-btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* City index ------------------------------------------------------------- */
.index {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #0a1524 0%, #060d17 100%);
  padding-top: env(safe-area-inset-top);
  animation: indexIn .24s var(--ease);
}
.index[hidden] { display: none; }
@keyframes indexIn {
  from { transform: translateY(18px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.index-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px var(--gutter) 10px;
}
.index-head h2 {
  margin: 0;
  font-family: "Newsreader", Georgia, serif;
  font-size: 26px;
  font-weight: 500;
  letter-spacing: -.015em;
}
.index-head p {
  margin: 3px 0 0;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.4;
}

.index-close {
  flex: none;
  height: 34px;
  padding: 0 13px;
  border-radius: 99px;
  border: 1px solid rgba(148, 182, 219, .24);
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
}
.index-close:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.index-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 0 var(--gutter) 10px;
}
.index-tools input[type="search"] {
  flex: 1 1 100%;
  min-width: 0;
  height: 38px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid rgba(150, 182, 219, .16);
  background: rgba(4, 10, 19, .8);
  color: var(--ink);
  font-family: inherit;
  font-size: 15px;
  outline: none;
}
.index-tools input[type="search"]:focus { border-color: rgba(242, 193, 78, .5); }

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid rgba(150, 182, 219, .16);
  font-size: 12.5px;
  color: #c6d5e6;
  cursor: pointer;
  user-select: none;
}
.toggle input { accent-color: var(--gold); margin: 0; }
.toggle:has(input:checked) {
  border-color: rgba(242, 193, 78, .5);
  background: rgba(242, 193, 78, .12);
  color: #ffe6b6;
}

.index-tools select {
  height: 38px;
  padding: 0 8px;
  border-radius: 10px;
  border: 1px solid rgba(150, 182, 219, .16);
  background: rgba(4, 10, 19, .8);
  color: var(--ink);
  font-family: inherit;
  font-size: 12.5px;
  outline: none;
}

.index-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 0 var(--gutter) calc(24px + env(safe-area-inset-bottom));
}

.city-group {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin: 0;
  padding: 9px 0 7px;
  background: linear-gradient(180deg, rgba(8, 16, 28, .98) 70%, rgba(8, 16, 28, .86));
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-bottom: 1px solid rgba(140, 178, 220, .12);
  font-size: 12.5px;
  font-weight: 600;
  color: #d6e5f5;
  letter-spacing: .01em;
}
.city-group span:last-child {
  font-weight: 400;
  font-size: 11.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.city-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 1px 10px;
  padding: 9px 0;
  border-bottom: 1px solid rgba(140, 178, 220, .07);
}
.city-row .name {
  color: var(--ink);
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.city-row .meta {
  font-size: 11.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.city-row .dist {
  grid-column: 2;
  grid-row: 1 / span 2;
  font-size: 11.5px;
  color: rgba(160, 180, 205, .75);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  padding: 3px 8px;
  border-radius: 99px;
  border: 1px solid rgba(150, 182, 219, .12);
}
.city-row .dist.in {
  color: #c9f8e2;
  border-color: rgba(92, 224, 160, .45);
  background: rgba(92, 224, 160, .1);
}
.city-row .dist.near {
  color: #ffe3ae;
  border-color: rgba(242, 193, 78, .4);
}

.index-empty {
  padding: 26px 0;
  font-size: 13.5px;
  color: var(--muted);
}

@media (min-width: 760px) {
  .index-head,
  .index-tools,
  .index-scroll {
    width: 100%;
    max-width: 720px;
    margin-left: auto;
    margin-right: auto;
  }
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 14px 0 0;
  padding: 10px 12px;
  border: 1px solid rgba(150, 182, 219, .18);
  border-radius: 11px;
  background: rgba(4, 10, 19, .5);
  font-size: 13px;
  color: #cfe0f2;
  cursor: pointer;
  user-select: none;
}
.toggle-row input { width: 16px; height: 16px; margin: 0; accent-color: var(--gold); }
.toggle-row:has(input:checked) {
  border-color: rgba(242, 193, 78, .45);
  background: rgba(242, 193, 78, .08);
}

.map-hint {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 22;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: calc(100% - 24px);
  padding: 7px 7px 7px 14px;
  border-radius: 99px;
  border: 1px solid rgba(148, 182, 219, .22);
  background: rgba(9, 20, 34, .93);
  box-shadow: 0 16px 32px -18px #000;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-size: 12.5px;
  color: #d6e5f5;
}
.map-hint[hidden] { display: none; }
.map-hint button {
  flex: none;
  height: 30px;
  padding: 0 12px;
  border: 0;
  border-radius: 99px;
  background: var(--gold);
  color: #1a1204;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
