:root {
  --ink: #121212; --ink-2: #5a5e64; --rule: 1px solid #dcdcdc; --card: #fff;
  --hit: #5fd06e; --now: #ffe135;
  --serif: "Zilla Slab", Georgia, serif; --text: "Libre Franklin", system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: #fff; color: var(--ink); font: 400 16px/1.4 var(--text); }
/* The masthead's contents line up with the page's: same width, same gutter. */
.masthead { position: sticky; top: 0; z-index: 5; background: #fff; border-bottom: var(--rule); padding-top: env(safe-area-inset-top); }
.masthead-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; max-width: 1040px;
  margin: 0 auto; padding: 6px 8px 6px 16px; }
.wordmark { font: 700 22px/1 var(--serif); letter-spacing: -.01em; color: inherit; text-decoration: none; white-space: nowrap; }
.masthead-nav { display: flex; margin-right: -2px; } /* the last icon, not its round button, lines up with the page */
.masthead-nav button { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%;
  background: transparent; color: var(--ink); cursor: pointer; transition: background-color .15s ease-out; }
.masthead-nav button:hover { background: #f0f0f0; }
.masthead-nav svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.masthead-nav .dot { fill: currentColor; }
@media (max-width: 400px) {
  .masthead-inner { padding-left: 12px; }
  .wordmark { font-size: 19px; }
  .masthead-nav button { width: 40px; }
}
.meta { margin: 0 2px 10px; display: flex; justify-content: space-between; gap: 12px;
  font: 800 13px var(--text); letter-spacing: .04em; text-transform: uppercase; color: var(--ink-2); }
.meta b { color: var(--ink); }

/* Pop-ups: how to play, your stats, past maps. */
dialog { width: min(100% - 32px, 400px); max-height: calc(100dvh - 32px); padding: 22px 20px 20px; border: 0; border-radius: 14px;
  background: #fff; color: var(--ink); box-shadow: 0 20px 60px rgba(14,15,16,.25); }
dialog::backdrop { background: rgba(255, 255, 255, .7); }
dialog .x { position: absolute; top: 10px; right: 10px; margin: 0; }
dialog .x button { display: grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 10px; background: transparent; color: var(--ink); cursor: pointer; }
dialog .x button:hover { background: #eef0f0; }
dialog .x svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
dialog h2 { margin: 0 0 14px; font: 700 30px/1 var(--serif); letter-spacing: -.01em; }
dialog .btn { width: 100%; }
.rules { list-style: none; margin: 0; padding: 0; border-top: var(--rule); }
.rules li { display: grid; grid-template-columns: 34px 1fr; gap: 0 12px; padding: 12px 0; border-bottom: var(--rule); }
.rules .num { font: 900 18px/1.4 var(--text); text-align: center; }
.rules p { margin: 0; font-size: 15px; line-height: 1.45; color: var(--ink-2); }
.rules p b, .rules p i { color: var(--ink); font-weight: 700; font-style: normal; }
.rules-note { margin: 14px 0 16px; font-size: 14px; color: var(--ink-2); }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 18px; text-align: center; }
.tiles b { display: block; font: 700 34px/1.1 var(--serif); }
.tiles span { font: 700 11px var(--text); text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2); }
.days { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 8px; }
.days a { display: grid; gap: 2px; padding: 8px 6px; border: var(--rule); border-radius: 8px; color: var(--ink); text-decoration: none; text-align: center; }
.days a:hover { background: #f6f6f6; }
.days a b { font: 800 15px var(--text); }
.days a span { font: 700 11px var(--text); color: var(--ink-2); }
.days a.is-found { background: #e6f8e9; border-color: var(--hit); }
.days a.is-missed { background: #f4f4f2; }
.soon { margin: 80px auto; font: 700 28px var(--serif); text-align: center; }
main { max-width: 1040px; margin: 0 auto; padding: 20px 16px 40px; display: grid; gap: 24px; }
@media (min-width: 860px) { main { grid-template-columns: 1fr 360px; align-items: start; } }

.map-card { position: relative; border-radius: 12px; overflow: hidden; box-shadow: 0 1px 0 #e6e1d6, 0 10px 30px rgba(14,15,16,.12); }
#map { display: block; width: 100%; aspect-ratio: 1; background: #f3efe6; }
#moments { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
/* Legend: each layer's key; a drawn layer is a button that hides or shows it. */
.legend { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0; }
.legend > * { display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 11px 0 9px; border: 1.5px solid var(--ink);
  border-radius: 999px; background: var(--card); color: var(--ink); font: 700 13px var(--text); }
.legend svg { width: 22px; height: 12px; flex: none; }
.legend button { cursor: pointer; transition: background-color .15s ease-out, opacity .15s ease-out; }
.legend button:hover { background: #fff6b8; }
.legend button[aria-pressed="false"] { border-style: dashed; color: var(--ink-2); text-decoration: line-through; text-decoration-thickness: 1.5px; }
.legend button[aria-pressed="false"] svg { opacity: .25; }
@media (max-width: 480px) {
  .legend { gap: 5px; }
  .legend > * { gap: 4px; min-height: 32px; padding: 0 8px 0 6px; font-size: 12px; }
  .legend svg { width: 16px; }
}
.legend .is-locked { border-color: #dcdcdc; color: #a3a6ab; }
.legend .is-locked svg { opacity: .3; filter: grayscale(1); }
.credit { margin: 8px 2px 0; font-size: 12px; color: var(--ink-2); }

.guess-box { position: relative; }
.guess-box form, .composer form { position: relative; display: flex; gap: 8px; padding: 8px; border-radius: 10px; background: var(--now); }
#guess { flex: 1; min-width: 0; height: 44px; padding: 0 12px; border: 1.5px solid var(--ink); border-radius: 8px; font: 500 16px var(--text); }
.btn { height: 44px; padding: 0 16px; border: 0; border-radius: 8px; background: var(--ink); color: #fff; cursor: pointer;
  font: 800 15px var(--text); text-transform: uppercase; letter-spacing: .02em; }
.left { position: absolute; right: 10px; top: calc(100% + 6px); font: 700 12px var(--text); color: var(--ink-2); text-transform: uppercase; }
.picks { position: absolute; left: 8px; right: 8px; top: calc(100% - 2px); z-index: 5; margin: 0; padding: 4px; list-style: none;
  background: var(--card); border: 1.5px solid var(--ink); border-radius: 10px; box-shadow: 0 10px 30px rgba(14,15,16,.2); }
.picks li { display: flex; align-items: baseline; gap: 8px; min-height: 40px; padding: 8px 10px; border-radius: 7px; cursor: pointer; font-weight: 700; }
.picks li:first-child, .picks li:hover { background: #fff6b8; }
.picks small { color: var(--ink-2); font-weight: 500; }

/* Phones: the box in the page is a button (composer.js) that opens a bar
   pinned above the keyboard, the matches stacked upward over the map. */
.guess-open { display: flex; gap: 8px; width: 100%; padding: 8px; border: 0; border-radius: 10px; background: var(--now); cursor: text; font: inherit; color: inherit; }
.guess-open span { flex: 1; min-width: 0; height: 44px; padding: 0 12px; border: 1.5px solid var(--ink); border-radius: 8px; background: var(--card);
  display: flex; align-items: center; color: #6a6e74; font: 500 16px var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.guess-open b { display: flex; align-items: center; height: 44px; padding: 0 16px; border-radius: 8px; background: var(--ink); color: #fff;
  font: 800 15px var(--text); text-transform: uppercase; letter-spacing: .02em; }
.composer { position: fixed; inset: 0; z-index: 60; }
.composer-backdrop { position: absolute; inset: 0; background: rgba(14,15,16,.5); animation: fade .15s ease-out; }
.composer-panel { position: absolute; left: 0; right: 0; bottom: 0; padding: 0 0 env(safe-area-inset-bottom); background: var(--now);
  box-shadow: 0 -6px 24px rgba(14,15,16,.25); }
.composer form { border-radius: 0; }
.composer .picks { top: auto; bottom: calc(100% + 8px); display: flex; flex-direction: column-reverse; box-shadow: 0 -10px 30px rgba(14,15,16,.3); }
@keyframes fade { from { opacity: 0; } }

.rows { list-style: none; margin: 30px 0 0; padding: 0; border-top: var(--rule); }
.row { display: grid; grid-template-columns: 22px 1fr auto 28px 104px; align-items: center; gap: 10px; min-height: 48px; border-bottom: var(--rule); }
.row b { text-align: center; }
.row .name { font-weight: 700; }
.row .km { font-variant-numeric: tabular-nums; color: var(--ink-2); text-align: right; }
.row .near { font: 800 11px var(--text); text-transform: uppercase; letter-spacing: .03em; text-align: right; }
.dir svg { display: block; width: 22px; height: 22px; fill: var(--ink); }
.row.is-hit { grid-template-columns: 22px 1fr auto; background: linear-gradient(90deg, #e6f8e9, transparent); }
.got { padding: 3px 8px; border-radius: 4px; background: var(--hit); font: 800 11px var(--text); text-transform: uppercase; }

.result { margin-bottom: 16px; }
.result h2 { margin: 0; font: 700 44px/1.05 var(--serif); }
.result p { margin: 4px 0 0; color: var(--ink-2); }
.result .how { margin-top: 10px; color: var(--ink); font-weight: 700; }

.dist { margin-top: 18px; }
.dist h3 { margin: 0 0 8px; font: 800 12px var(--text); text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2); }
.dist p { margin: 8px 0 0; font-size: 13px; color: var(--ink-2); }

.result .outcome { display: flex; align-items: baseline; gap: 12px; margin: 14px 0 0; color: var(--ink); }
.result .outcome b { font: 700 64px/1 var(--serif); font-variant-numeric: lining-nums tabular-nums; }
.result .outcome span { font: 800 15px var(--text); text-transform: uppercase; letter-spacing: .04em; }
.result .rank { margin-top: 6px; font-weight: 800; color: var(--ink); }
.bar { display: grid; grid-template-columns: 22px 1fr; align-items: center; gap: 8px; margin: 5px 0; font: 700 14px var(--text); }
.bar span { text-align: center; }
.bar i { width: var(--w); padding: 3px 8px; border-radius: 4px; background: #e2e4e6; font-style: normal; text-align: right; }
.bar.is-you i { background: var(--hit); }
