/* Halfway */
:root {
  --ocean: #13202f;
  --ocean-edge: #0f1924;
  --land: #343f52;
  --coast: #5d6b84;
  --border-line: #445066;
  --grat: rgba(170, 200, 255, .09);
  --line: #ffffff;
  --truth: var(--good);
  --halo: #0f1115;
}
@media (prefers-color-scheme: light) {
  :root {
    --ocean: #cfe2f2;
    --ocean-edge: #c3d9ec;
    --land: #f7f4ec;
    --coast: #95a3b6;
    --border-line: #c2cad6;
    --grat: rgba(30, 70, 120, .1);
    --line: #1c2230;
    --truth: #16a36b;
    --halo: #ffffff;
  }
}

.pd-main {
  max-width: 760px; padding-top: 10px;
  padding-left: calc(16px + env(safe-area-inset-left)); padding-right: calc(16px + env(safe-area-inset-right));
  padding-bottom: calc(48px + env(safe-area-inset-bottom));
}
.dg-header { padding-left: calc(12px + env(safe-area-inset-left)); padding-right: calc(12px + env(safe-area-inset-right)); padding-top: calc(10px + env(safe-area-inset-top)); }

/* top bar: round dots + running total */
.pd-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.pd-dots { display: flex; gap: 6px; }
.pd-dot {
  width: 30px; height: 30px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-2); color: var(--muted); font-size: 13px; font-weight: 700; border: 1px solid var(--border);
}
.pd-dot.cur { border-color: var(--accent); color: var(--text); box-shadow: 0 0 0 1px var(--accent) inset; }
.pd-dot.filled { background: var(--surface); font-size: 16px; }
.pd-total { font-variant-numeric: tabular-nums; white-space: nowrap; }
.pd-total-n { font-size: 22px; font-weight: 800; }
.pd-total-of { color: var(--muted); font-size: 14px; }

/* prompt */
.pd-prompt { text-align: center; padding: 6px 0 10px; min-height: 84px; }
.pd-round { font-size: 12px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--muted); font-weight: 700; }
.pd-place { margin: 2px 0 0; font-size: 28px; line-height: 1.15; font-weight: 800; letter-spacing: .2px; }
.pd-hint { color: var(--muted); font-size: 15px; }

/* map */
.pd-map {
  position: relative; width: 100%; aspect-ratio: 2 / 1; max-height: 62vh; min-height: 220px;
  border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); background: var(--ocean-edge);
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.pd-svg { display: block; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.pd-map.grabbing .pd-svg { cursor: grabbing; }
.pd-ocean { fill: var(--ocean-edge); }
.pd-ocean-map { fill: var(--ocean); }
.pd-grat { fill: none; stroke: var(--grat); stroke-width: 1; }
.pd-land { fill: var(--land); stroke: var(--coast); stroke-width: .7; stroke-linejoin: round; }
.pd-borders { fill: none; stroke: var(--border-line); stroke-width: .6; stroke-linejoin: round; }

.pd-ctrls { position: absolute; right: 8px; top: 8px; display: flex; flex-direction: column; gap: 6px; }
.pd-ctrl {
  width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font-size: 22px; font-weight: 700; line-height: 1; cursor: pointer; box-shadow: var(--shadow);
  display: inline-flex; align-items: center; justify-content: center; padding: 0;
}
.pd-ctrl:active { transform: scale(.94); }
.pd-ctrl-reset { font-size: 19px; }
.pd-chip {
  position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); pointer-events: none;
  background: color-mix(in srgb, var(--surface) 88%, transparent); border: 1px solid var(--border);
  color: var(--text); font-size: 13px; font-weight: 600; padding: 5px 12px; border-radius: 999px; white-space: nowrap;
}

/* overlay marks (screen space, so they keep their size at any zoom) */
.pd-overlay { pointer-events: none; }
.pd-line { stroke: var(--line); stroke-width: 2; stroke-dasharray: 5 4; stroke-linecap: round; opacity: .85; }
.pd-pin-body { fill: var(--accent); stroke: #3a0c0c; stroke-width: 1.2; }
.pd-pin-dot { fill: #fff; }
.pd-pin-shadow { fill: rgba(0, 0, 0, .35); }
.pd-pin-sm .pd-drop, .pd-pin-sm > g { transform: scale(.75); }
.pd-truth-dot { fill: var(--truth); stroke: #fff; stroke-width: 2.5; }
.pd-truth-num { fill: #fff; font-size: 11px; font-weight: 800; text-anchor: middle; dominant-baseline: central; }
.pd-label {
  fill: var(--text); font-size: 13px; font-weight: 800; text-anchor: middle;
  paint-order: stroke; stroke: var(--halo); stroke-width: 4px; stroke-linejoin: round;
}
.pd-pulse { fill: none; stroke: var(--truth); stroke-width: 2; transform-box: fill-box; transform-origin: center; animation: pd-pulse 1s ease-out 2; opacity: 0; }
.pd-drop { animation: pd-drop .28s cubic-bezier(.3, 1.6, .6, 1); }
.pd-pop { transform-box: fill-box; transform-origin: center; animation: pd-pop .35s cubic-bezier(.3, 1.8, .5, 1); }
@keyframes pd-drop { 0% { transform: translateY(-18px); opacity: 0; } 100% { transform: translateY(0); opacity: 1; } }
@keyframes pd-pop { 0% { transform: scale(0); } 100% { transform: scale(1); } }
@keyframes pd-pulse { 0% { transform: scale(1); opacity: .9; } 100% { transform: scale(3.2); opacity: 0; } }

/* panel */
.pd-panel { margin-top: 12px; min-height: 120px; }
.pd-panel.pd-wait > * { visibility: hidden; }
.pd-panel.pd-panel-done { min-height: 0; }
.pd-main-btn { width: 100%; font-size: 17px; padding: 14px 18px; }
.pd-main-btn:disabled { background: var(--surface-2); border-color: var(--border); color: var(--muted); opacity: 1; }
.pd-tip { text-align: center; margin: 8px 0 0; font-size: 13px; }
.pd-result { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; }
.pd-result-row { display: flex; align-items: center; gap: 10px; }
.pd-emoji { font-size: 26px; line-height: 1; }
.pd-dist { flex: 1; font-size: 20px; font-variant-numeric: tabular-nums; }
.pd-dist small { color: var(--muted); font-size: 14px; font-weight: 600; }
.pd-pts { font-size: 22px; font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; }
.pd-fact { margin: 8px 0 0; color: var(--muted); font-size: 15px; }

/* finished view */
.pd-actions { display: grid; grid-template-columns: 2fr 1fr; gap: 10px; }
.pd-review-h { margin: 20px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.pd-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.pd-item { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; }
.pd-item-head { display: flex; align-items: baseline; gap: 8px; }
.pd-item-num {
  flex: none; width: 22px; height: 22px; border-radius: 50%; background: var(--truth); color: #fff; font-size: 12px; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center; align-self: center;
}
.pd-item-name { flex: 1; min-width: 0; }
.pd-item-name small { color: var(--muted); }
.pd-item-score { font-weight: 800; white-space: nowrap; font-variant-numeric: tabular-nums; }
.pd-item-dist { margin: 2px 0 0 30px; font-size: 13px; }
.pd-item-fact { margin: 4px 0 0 30px; font-size: 14px; }
.pd-next { margin-top: 18px; }
.pd-of { color: var(--muted); font-size: 18px; font-weight: 700; }

@media (max-width: 520px) {
  .pd-main { padding-left: calc(12px + env(safe-area-inset-left)); padding-right: calc(12px + env(safe-area-inset-right)); }
  /* Full-bleed and taller on phones: zoom 1 fills the box (full latitude range, ~170 deg of longitude). */
  .pd-map {
    margin: 0 calc(-12px - env(safe-area-inset-left)) 0 calc(-12px - env(safe-area-inset-right));
    width: calc(100% + 24px + env(safe-area-inset-left) + env(safe-area-inset-right));
    border-radius: 0; border-left: 0; border-right: 0; aspect-ratio: 1.2 / 1; max-height: 58vh;
  }
  .pd-place { font-size: 25px; }
  .pd-prompt { min-height: 76px; padding-bottom: 8px; }
}

/* ---------- Halfway additions ---------- */
:root {
  --route: #3ecf8e;
  --flat: rgba(238, 240, 244, .75);
  --city: #eef0f4;
  --city-ink: #0f1115;
  --conn: #f5c451;
}
@media (prefers-color-scheme: light) {
  :root { --route: #0e9a62; --flat: rgba(21, 24, 33, .6); --city: #151821; --city-ink: #ffffff; --conn: #b7791f; }
}
.hw-pair { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 4px 10px; font-size: 25px; }
.hw-end { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.hw-arrow { color: var(--muted); font-weight: 700; }
.hw-badge {
  display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 50%;
  background: var(--city); color: var(--city-ink); font-size: 13px; font-weight: 800; flex: none;
}
.hw-city-dot { fill: var(--city); stroke: var(--city-ink); stroke-width: 2; }
.hw-city-sm .hw-city-dot { stroke-width: 1.5; }
.hw-city-letter { fill: var(--city-ink); font-size: 11px; font-weight: 800; text-anchor: middle; dominant-baseline: central; }
.hw-city-label { font-size: 12.5px; }
.hw-route { fill: none; stroke: var(--route); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.hw-route-thin { stroke-width: 2; opacity: .75; }
.hw-flatline { stroke: var(--flat); stroke-width: 1.6; stroke-dasharray: 7 6; stroke-linecap: round; }
.hw-flat-dot { fill: var(--surface); stroke: var(--flat); stroke-width: 2; }
.hw-flat-label {
  fill: var(--muted); font-size: 11.5px; font-weight: 700; font-style: italic; text-anchor: middle;
  paint-order: stroke; stroke: var(--halo); stroke-width: 3.5px; stroke-linejoin: round;
}
.hw-fade { animation: hw-fade .5s ease-out; }
@keyframes hw-fade { from { opacity: 0; } to { opacity: 1; } }
.hw-slider circle { fill: var(--truth); stroke: #fff; stroke-width: 2.5; }
.hw-trap { margin: 6px 0 0; font-size: 13.5px; color: var(--muted); border-top: 1px dashed var(--border); padding-top: 6px; }
@media (max-width: 520px) { .hw-pair { font-size: 21px; } }
.hw-city-name { display: inline-flex; flex-direction: column; align-items: flex-start; line-height: 1.05; text-align: left; }
.hw-city-name small { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: .2px; }

/* ---------- Round 2 polish ---------- */
html { -webkit-text-size-adjust: 100%; }
body { overflow-x: hidden; }
.hw-noscript { max-width: 520px; margin: 40px auto; padding: 0 16px; text-align: center; }
.hw-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
.pd-map:focus { outline: none; }
.pd-map:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.hw-crosshair { display: none; position: absolute; left: 50%; top: 50%; width: 26px; height: 26px; margin: -13px 0 0 -13px; pointer-events: none; }
.hw-crosshair::before, .hw-crosshair::after { content: ''; position: absolute; background: var(--accent); }
.hw-crosshair::before { left: 12px; top: 0; width: 2px; height: 26px; }
.hw-crosshair::after { top: 12px; left: 0; height: 2px; width: 26px; }
.pd-map:focus-visible .hw-crosshair { display: block; }
.pd-ctrl { touch-action: manipulation; }
.pd-ctrl:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; }

/* reveal: straight ruler line vs the real route, and the arrow between their middles */
.hw-flatline { stroke-width: 2; }
.hw-conn-line { fill: none; stroke: var(--conn); stroke-width: 2.4; stroke-linecap: round; }
.hw-conn-head { fill: var(--conn); }
.hw-conn-anim { animation: hw-fade .35s ease-out .12s both; }
.hw-truth-label { fill: var(--truth); }
.pd-pulse { animation-iteration-count: 1; animation-duration: .8s; }

.hw-trap { display: flex; gap: 8px; align-items: flex-start; margin: 8px 0 0; padding: 8px 0 0; font-size: 14.5px; color: var(--text); border-top: 1px dashed var(--border); }
.hw-trap-icon { font-size: 18px; line-height: 1.2; flex: none; }
.pd-fact { font-size: 14.5px; }

/* finished view: score first */
.hw-prompt-done { padding-bottom: 12px; }
.hw-final { font-size: 40px; font-variant-numeric: tabular-nums; }
.hw-final .pd-of { font-size: 20px; }
.hw-final-emoji { font-size: 22px; letter-spacing: 2px; margin: 2px 0 4px; }
.hw-modal-emoji { font-size: 22px; letter-spacing: 2px; margin-bottom: 4px; }
.pd-actions .dg-btn { min-height: 48px; }
.pd-next { margin: 14px 0 0; }
.hw-more-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.hw-more-chip {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 6px; border-radius: 12px; min-height: 64px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text); text-decoration: none; font-weight: 700; font-size: 14px;
}
.hw-more-chip:hover { background: var(--surface-2); }
.hw-more-icon { font-size: 22px; line-height: 1.1; }

/* how-to diagram */
.hw-howto-svg { display: block; width: 100%; max-width: 320px; margin: 4px auto 6px; overflow: visible; }
.hw-howto-flat { stroke: var(--flat); stroke-width: 2; stroke-dasharray: 6 5; }
.hw-howto-route { fill: none; stroke: var(--route); stroke-width: 3.5; stroke-linecap: round; }
.hw-howto-arrow { stroke: var(--conn); stroke-width: 2.4; }
.hw-howto-head { fill: var(--conn); }
.hw-howto-fdot { fill: var(--surface); stroke: var(--flat); stroke-width: 2; }
.hw-howto-tdot { fill: var(--truth); stroke: #fff; stroke-width: 2.5; }
.hw-howto-city { fill: var(--city); }
.hw-howto-letter { fill: var(--city-ink); font-size: 11px; font-weight: 800; text-anchor: middle; dominant-baseline: central; }
.hw-howto-ftext { fill: var(--muted); font-size: 12px; font-style: italic; font-weight: 700; text-anchor: middle; }
.hw-howto-ttext { fill: var(--truth); font-size: 12.5px; font-weight: 800; text-anchor: start; }
.hw-conn-km {
  fill: var(--conn); font-size: 12px; font-weight: 800; font-variant-numeric: tabular-nums;
  paint-order: stroke; stroke: var(--halo); stroke-width: 3.5px; stroke-linejoin: round;
}
.hw-trap-small { border-top: 0; padding-top: 0; color: var(--muted); font-size: 13.5px; }
.pd-map.hw-done { aspect-ratio: 2.25 / 1; min-height: 150px; }
.hw-done .pd-ctrl { width: 34px; height: 34px; font-size: 19px; border-radius: 9px; }
.hw-done .pd-ctrls { gap: 4px; top: 6px; right: 6px; }
/* the header lines up with the (wider) game column */
.dg-header, .dg-banner { max-width: 760px; }
