/* "Vind het Station" — schematische NS-spoorkaart-stijl. */

:root {
  --ns-blue: #003082;
  --ns-blue-dark: #00205a;
  --ns-yellow: #ffc917;
  --land: #e9edcf;
  --water: #b7d4dc;
  --ijssel: #a9cad5;
  --rail: #1d262f;
  --dot: #2a2f36;
  --ink: #14202c;
  --muted: #5c6b78;
  --paper: #f6f4e9;
  --panel: #ffffff;
  --correct: #1f9d55;
  --guess: #003082;
  --line-soft: #d7d3c2;
  --radius: 14px;
  --shadow: 0 6px 22px rgba(0, 24, 64, 0.14);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--water);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#app { height: 100%; }

.game-root {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  padding:
    calc(env(safe-area-inset-top) + 8px)
    calc(env(safe-area-inset-right) + 10px)
    calc(env(safe-area-inset-bottom) + 8px)
    calc(env(safe-area-inset-left) + 10px);
  gap: 8px;
  max-width: 760px;
  margin: 0 auto;
}

/* Kopbalk */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.topbar-info { display: flex; gap: 6px; flex-wrap: wrap; }
.round-pill, .score-pill {
  font-size: 13px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.round-pill { background: var(--ns-blue); color: #fff; }
.score-pill { background: var(--ns-yellow); color: var(--ns-blue-dark); }
.board-btn {
  border: none;
  background: var(--panel);
  color: var(--ns-blue);
  font-weight: 700;
  font-size: 14px;
  border-radius: 999px;
  padding: 9px 14px;
  min-height: 44px;
  box-shadow: var(--shadow);
  cursor: pointer;
}
.board-btn:active { transform: translateY(1px); }

/* Opdracht */
.prompt {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 2px 0;
}
.prompt-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 700;
}
.prompt-station {
  font-size: clamp(22px, 6vw, 30px);
  font-weight: 800;
  color: var(--ink);
  line-height: 1.1;
}

/* Kaart */
.map-wrap {
  flex: 1;
  min-height: 0;
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  background: var(--water);
  touch-action: manipulation;
}
.spoorkaart {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}
.map-locked .spoorkaart { cursor: default; }

.map-water { fill: var(--water); }
.map-land { fill: var(--land); stroke: none; }
.map-ijsselmeer { fill: var(--ijssel); stroke: none; }
.map-rail { stroke: var(--rail); stroke-width: 2.1; stroke-linecap: round; opacity: 0.85; }
.map-dot { fill: var(--dot); opacity: 0.55; }

/* Markeringen na een gok */
.marker-line { stroke: var(--ns-blue); stroke-width: 2; stroke-dasharray: 5 5; opacity: 0.8; }
.marker-guess { fill: none; stroke: var(--ns-blue); stroke-width: 3; }
.marker-actual-halo { fill: rgba(31, 157, 85, 0.25); }
.marker-actual { fill: var(--correct); stroke: #fff; stroke-width: 2; }
.marker-label {
  font-size: 16px;
  font-weight: 800;
  fill: var(--ink);
  paint-order: stroke;
  stroke: #fff;
  stroke-width: 3.5;
  stroke-linejoin: round;
}

/* Actiebalk */
.action-bar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
  min-height: 56px;
  justify-content: center;
}
.action-hint {
  margin: 0;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}
.result-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}
.result-dist { font-size: 16px; font-weight: 700; color: var(--muted); }
.result-points { font-size: 18px; font-weight: 800; color: var(--correct); }

.primary-btn {
  border: none;
  background: var(--ns-blue);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  border-radius: 12px;
  padding: 13px 16px;
  min-height: 48px;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.primary-btn:active { transform: translateY(1px); }
.primary-btn:disabled { opacity: 0.6; cursor: default; }

.secondary-btn {
  border: 2px solid var(--ns-blue);
  background: transparent;
  color: var(--ns-blue);
  font-size: 15px;
  font-weight: 700;
  border-radius: 12px;
  padding: 11px 16px;
  min-height: 46px;
  cursor: pointer;
}
.secondary-btn:active { transform: translateY(1px); }

.finish-summary { text-align: center; font-size: 15px; color: var(--ink); }
.submit-row { display: flex; gap: 8px; }
.name-input {
  flex: 1;
  min-width: 0;
  font-size: 16px;
  padding: 12px 14px;
  border: 2px solid var(--line-soft);
  border-radius: 12px;
  min-height: 48px;
  background: #fff;
  color: var(--ink);
}
.name-input:focus { outline: none; border-color: var(--ns-blue); }
.submit-row .primary-btn { flex: 0 0 auto; }
.status-msg { margin: 0; text-align: center; font-size: 13px; color: #c0392b; min-height: 1em; }
.submitted-msg { margin: 0; text-align: center; font-size: 15px; font-weight: 700; color: var(--correct); }

/* Scorebord-modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 22, 44, 0.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
}
.modal-hidden { display: none; }
.sheet {
  background: var(--panel);
  width: 100%;
  max-width: 560px;
  border-radius: 18px 18px 0 0;
  padding: 16px calc(env(safe-area-inset-right) + 16px) calc(env(safe-area-inset-bottom) + 18px) calc(env(safe-area-inset-left) + 16px);
  max-height: 80dvh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 -8px 30px rgba(0, 24, 64, 0.25);
}
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.sheet-head h2 { margin: 0; font-size: 20px; color: var(--ns-blue); }
.sheet-close {
  border: none;
  background: #eef1f6;
  color: var(--ink);
  font-size: 18px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
}
.sheet-status { margin: 0 0 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
.sheet-status[data-status="connected"] { color: var(--correct); }
.sheet-status[data-status="fallback"] { color: var(--ns-blue); }
.sheet-status[data-status="offline"] { color: #c0392b; }

.board-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; }
.board-item, .board-empty {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 8px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 15px;
}
.board-empty { color: var(--muted); justify-content: center; }
.board-rank { width: 26px; font-weight: 800; color: var(--ns-blue); text-align: center; }
.board-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.board-score { font-weight: 800; color: var(--ink); }
.board-mine { background: #fff7d6; border-radius: 8px; }
.board-mine .board-rank { color: var(--ns-blue-dark); }

@media (min-width: 720px) {
  .prompt-station { font-size: 32px; }
}

/* Laad-overlay (SW-updates) */
.loading-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: var(--paper);
  color: var(--ns-blue);
  z-index: 100;
  font-weight: 700;
}
.loading-overlay--hidden { display: none; }
.loading-spinner {
  width: 38px;
  height: 38px;
  border: 4px solid #d7d3c2;
  border-top-color: var(--ns-blue);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
