* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: #1a1a1a;
}

/* ---- game page layout: HUD (top) / map (fill) / question bar (bottom) ---- */
body.game { display: flex; flex-direction: column; }

#map {
  flex: 1 1 auto;
  min-height: 0;   /* let the map shrink inside the flex column */
  cursor: crosshair;
}

/* Mild color/contrast boost for the base tiles so buildings, parks and water
   read clearly. Streets are drawn on top as a separate layer, so unaffected. */
.leaflet-tile-pane {
  filter: saturate(2) contrast(1.05);
}

/* ---- HUD ---- */
#hud {
  flex: 0 0 auto;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding: 8px 14px;
  background: #1f2937;
  color: #fff;
  z-index: 1000;
}
#hud strong { font-size: 18px; letter-spacing: 0.3px; }
.hud-left { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.hud-area-tools { display: flex; align-items: center; gap: 10px; }
.hud-right { display: flex; align-items: center; gap: 14px; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---- question bar (current street), pinned at the bottom ---- */
#prompt-bar {
  flex: 0 0 auto;
  background: #111827;
  color: #fff;
  padding: 12px 16px;
  text-align: center;
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.25);
  z-index: 1000;
}
#prompt { font-size: 18px; line-height: 1.35; }
#prompt b { color: #fde047; font-weight: 700; }

#city-select, #area-select {
  background: #374151;
  color: #fff;
  border: 1px solid #4b5563;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 14px;
}

/* ---- HUD area buttons ---- */
.hud-left button {
  padding: 5px 10px;
  font-size: 13px;
  border-radius: 6px;
}
#draw-area-btn, #cancel-area-btn, #delete-area-btn {
  background: #374151;
  border: 1px solid #4b5563;
}
#draw-area-btn:hover, #cancel-area-btn:hover, #delete-area-btn:hover { background: #4b5563; }
#done-area-btn, #save-area-btn { background: #16a34a; }
#done-area-btn:hover, #save-area-btn:hover { background: #15803d; }

/* ---- drawing hint ---- */
#draw-hint {
  position: absolute;
  top: 66px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  background: rgba(37, 99, 235, 0.95);
  color: #fff;
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 14px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}
#draw-hint b { color: #fde047; }

/* ---- feedback bar ---- */
#feedback {
  position: fixed;
  left: 50%;
  bottom: 84px;   /* sits above the bottom question bar */
  transform: translateX(-50%);
  z-index: 1500;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.25);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: 92vw;
}
#feedback-text { font-size: 15px; }
#feedback-text .ok { color: #15803d; font-weight: 700; }
#feedback-text .bad { color: #b91c1c; font-weight: 700; }
#feedback-text .show-link { color: #2563eb; font-weight: 600; text-decoration: underline; white-space: nowrap; }
#feedback-text .show-link:hover { color: #1d4ed8; }

button {
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 15px;
  cursor: pointer;
}
button:hover { background: #1d4ed8; }

/* ---- overlays ---- */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(17, 24, 39, 0.55);
}
.card {
  background: #fff;
  border-radius: 14px;
  padding: 28px 32px;
  text-align: center;
  max-width: 90vw;
  box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}
.card h2 { margin: 0 0 12px; }
#summary-text { font-size: 17px; margin-bottom: 20px; }

.hidden { display: none !important; }

/* ---- HUD link ---- */
.hud-link {
  color: #93c5fd;
  text-decoration: none;
  font-size: 14px;
  white-space: nowrap;
}
.hud-link:hover { color: #fff; text-decoration: underline; }

/* ---- summary hardest-streets list ---- */
ul.hardest {
  text-align: left;
  margin: 8px 0 0;
  padding-left: 20px;
  font-size: 15px;
}

/* ---- stats page ---- */
body.page { height: auto; min-height: 100%; background: #f3f4f6; }
.content {
  max-width: 760px;
  margin: 0 auto;
  padding: 76px 16px 40px;
}
.content h1 { margin: 0 0 12px; font-size: 22px; }
.totals { margin: 0 0 18px; color: #374151; font-size: 15px; }
.empty { color: #6b7280; }

.table-wrap { overflow-x: auto; }
#stats-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  font-size: 15px;
}
#stats-table th, #stats-table td {
  padding: 9px 12px;
  border-bottom: 1px solid #eef0f2;
  text-align: left;
}
#stats-table thead th {
  background: #1f2937;
  color: #fff;
  font-weight: 600;
  position: sticky;
  top: 0;
}
#stats-table tbody tr:last-child td { border-bottom: none; }
#stats-table tbody tr:hover { background: #f9fafb; }
#stats-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
#stats-table td.ok { color: #15803d; font-weight: 600; }
#stats-table td.bad { color: #b91c1c; font-weight: 600; }

@media (max-width: 640px) {
  #hud { padding: 8px 10px; gap: 6px 10px; }
  #hud strong { font-size: 16px; }
  /* Area drawing and the stats link are hidden on small screens (game page). */
  body.game .hud-area-tools,
  body.game .stats-link { display: none; }
  #city-select, #area-select { max-width: 44vw; }
  .hud-right { gap: 10px; }
  #prompt { font-size: 16px; }
  #feedback { width: 92vw; }
}
