/* Spoorkaart Stationsraadspel — NS-getinte huisstijl. */
:root {
  --ns-blue: #003082;
  --ns-blue-dark: #00226b;
  --ns-yellow: #ffc917;
  --ns-yellow-dark: #e6b400;
  --ink: #1a2230;
  --muted: #5b6470;
  --bg: #eef1f6;
  --surface: #ffffff;
  --line: #d9dee5;
  --good: #1f8a3b;
  --bad: #c5372c;
  --guess: #0b63d6;
  --shadow: 0 6px 20px rgba(0, 22, 64, 0.18);
  --radius: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

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

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

#app { height: 100dvh; }

.app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 720px;
  margin: 0 auto;
  background: var(--bg);
  overflow: hidden;
}

/* ── Topbalk ── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: calc(8px + var(--safe-top)) 12px 8px;
  background: var(--ns-blue);
  color: #fff;
  flex: 0 0 auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.ns-logo { width: 34px; height: 17px; flex: 0 0 auto; }

.brand-title {
  font-weight: 800;
  font-size: 17px;
  letter-spacing: 0.2px;
  white-space: nowrap;
}

.topbar-actions { display: flex; gap: 6px; flex: 0 0 auto; }

/* ── Statusbalk ── */
.statusbar {
  background: var(--ns-yellow);
  color: var(--ns-blue-dark);
  padding: 8px 14px 10px;
  flex: 0 0 auto;
}

.status-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-weight: 700;
  font-size: 13px;
  opacity: 0.9;
}

.status-prompt {
  margin-top: 2px;
  font-size: 21px;
  font-weight: 700;
  line-height: 1.2;
}
.status-prompt b { font-weight: 800; }

/* ── Kaart ── */
.map-wrap {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  position: relative;
}

.map-frame {
  position: relative;
  height: 100%;
  width: auto;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 1500 / 2115;
  margin: auto;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--shadow);
  background: #cfe3f2;
  touch-action: manipulation;
}

.map-frame--active { cursor: crosshair; }

.map-img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: fill;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}

.map-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.guess-line {
  stroke: var(--ns-blue-dark);
  stroke-width: 0.7;
  stroke-dasharray: 2 1.5;
  vector-effect: non-scaling-stroke;
  opacity: 0.85;
}

.marker-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.marker {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

.marker--guess { background: var(--guess); }

.marker--truth {
  background: var(--ns-yellow);
  border-color: var(--ns-blue-dark);
  width: 18px;
  height: 18px;
  animation: pop 0.25s ease-out;
}

@keyframes pop { from { transform: translate(-50%, -50%) scale(0.3); } to { transform: translate(-50%, -50%) scale(1); } }

.marker-label {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 4px);
  transform: translateX(-50%);
  background: var(--ns-blue-dark);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 6px;
  white-space: nowrap;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
  pointer-events: none;
}
.marker-label--left { left: -6px; transform: none; }
.marker-label--right { left: auto; right: -6px; transform: none; }
.marker-label--below { bottom: auto; top: calc(100% + 4px); }

/* ── Actiebalk ── */
.actionbar {
  flex: 0 0 auto;
  padding: 10px 14px calc(12px + var(--safe-bottom));
  min-height: 64px;
  display: flex;
  align-items: center;
  background: var(--surface);
  border-top: 1px solid var(--line);
}

.hint {
  color: var(--muted);
  font-size: 14.5px;
  line-height: 1.3;
}

.result-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
}

.result-info { display: flex; flex-direction: column; min-width: 0; }
.result-feedback { font-weight: 800; font-size: 16px; }
.result-detail { color: var(--muted); font-size: 13.5px; }
.result-detail b { color: var(--ns-blue); }

/* ── Knoppen ── */
.btn {
  font: inherit;
  font-weight: 700;
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  min-height: 44px;
  cursor: pointer;
  background: var(--ns-blue);
  color: #fff;
  transition: filter 0.12s ease, transform 0.05s ease;
}
.btn:active { transform: translateY(1px); }
.btn:hover { filter: brightness(1.06); }

.btn--primary { background: var(--ns-blue); white-space: nowrap; }
.btn--ghost {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  padding: 8px 12px;
  font-size: 14px;
}
.btn--ghost:hover { background: rgba(255, 255, 255, 0.28); }
.btn--block { width: 100%; margin-top: 12px; }
.btn--icon {
  background: transparent;
  color: var(--muted);
  font-size: 26px;
  line-height: 1;
  padding: 4px 10px;
  min-height: 40px;
}
.btn--icon:hover { filter: none; color: var(--ink); }

/* ── Modals ── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(8, 20, 45, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 50;
}
.modal--hidden { display: none; }

.modal-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 440px;
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  padding: 18px 18px calc(18px + var(--safe-bottom));
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-head h2 { margin: 0; font-size: 22px; color: var(--ns-blue); }
.modal-sub { color: var(--muted); font-size: 13.5px; margin: 6px 0 12px; }

.result-total {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 6px 0 4px;
}
.result-total-value { font-size: 44px; font-weight: 800; color: var(--ns-blue); line-height: 1; }
.result-total-unit { font-size: 16px; color: var(--muted); font-weight: 700; }
.result-breakdown { margin: 0 0 12px; color: var(--muted); font-size: 13.5px; }

.submit-form { display: flex; gap: 8px; }
.name-input {
  flex: 1 1 auto;
  font-size: 16px;
  padding: 11px 12px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  min-height: 44px;
  background: #fff;
  color: var(--ink);
}
.name-input:focus { outline: none; border-color: var(--ns-blue); }

.submit-msg { font-size: 13.5px; min-height: 18px; margin: 8px 0 4px; }
.submit-msg--error { color: var(--bad); }
.submit-msg--success { color: var(--good); font-weight: 700; }

/* ── Scorelijst ── */
.score-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
}
.score-item {
  display: grid;
  grid-template-columns: 30px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 9px 6px;
  border-bottom: 1px solid var(--line);
}
.score-item:nth-child(1) .score-rank { color: var(--ns-yellow-dark); }
.score-rank { font-weight: 800; color: var(--muted); text-align: center; }
.score-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score-value { font-weight: 800; color: var(--ns-blue); }
.score-empty { color: var(--muted); padding: 14px 4px; font-size: 14px; }

/* ── Laad-overlay (PWA-update) ── */
.loading-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: var(--ns-blue);
  color: #fff;
  z-index: 100;
}
.loading-overlay--hidden { display: none; }
.loading-spinner {
  width: 38px;
  height: 38px;
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-top-color: var(--ns-yellow);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Wat ruimer op grotere schermen. */
@media (min-width: 560px) {
  .status-prompt { font-size: 24px; }
  .brand-title { font-size: 19px; }
}
