:root {
  --bg: #0f1115;
  --panel: #1a1d24;
  --text: #f2f4f7;
  --muted: #9aa3b2;
  --accent: #2fd27a;
  --hud: #39ff9c;
  --hud-dim: #1f8f58;
  --danger: #ff5c5c;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Noto Sans KR", sans-serif; }
button { font: inherit; color: var(--text); background: #2a2f3a; border: 0; border-radius: 12px;
  padding: 12px 16px; cursor: pointer; }
button.primary { background: var(--accent); color: #04140b; font-weight: 700; }
button:active { transform: scale(.97); }

/* ---------- 지도 화면 ---------- */
#mapView { position: fixed; inset: 0; }
#map { position: absolute; inset: 0; background: #20242c; }
#searchBar { position: absolute; top: calc(var(--safe-t) + 12px); left: 12px; right: 12px; display: flex; gap: 8px; z-index: 10; }
#searchInput { flex: 1; min-width: 0; font-size: 16px; padding: 14px 16px; border-radius: 14px; border: 0;
  background: var(--panel); color: var(--text); box-shadow: 0 4px 16px rgba(0,0,0,.35); }
.icon-btn { width: 50px; font-size: 22px; padding: 0; background: var(--panel); box-shadow: 0 4px 16px rgba(0,0,0,.35); }
#results { position: absolute; top: calc(var(--safe-t) + 72px); left: 12px; right: 12px; max-height: 55vh; overflow: auto;
  margin: 0; padding: 4px 0; list-style: none; background: var(--panel); border-radius: 14px; z-index: 10;
  box-shadow: 0 8px 24px rgba(0,0,0,.45); }
#results li { padding: 12px 16px; border-bottom: 1px solid #2a2f3a; cursor: pointer; }
#results li:last-child { border-bottom: 0; }
#results .name { font-weight: 600; }
#results .addr { color: var(--muted); font-size: 13px; margin-top: 2px; }
#results .dist { float: right; color: var(--accent); font-size: 13px; }
.fab { position: absolute; right: 16px; bottom: calc(var(--safe-b) + 24px); width: 54px; height: 54px; border-radius: 50%;
  font-size: 24px; padding: 0; background: var(--panel); box-shadow: 0 4px 16px rgba(0,0,0,.45); z-index: 5; }
#routePanel { position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 16px calc(var(--safe-b) + 16px);
  background: var(--panel); border-radius: 20px 20px 0 0; z-index: 10; box-shadow: 0 -6px 24px rgba(0,0,0,.4); }
#routePanel:not([hidden]) ~ .fab, #routePanel:not([hidden]) + .fab { display: none; }
.route-dest { font-size: 18px; font-weight: 700; }
.route-sum { color: var(--muted); margin: 4px 0 14px; }
.route-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.route-actions .primary { grid-column: 1 / -1; padding: 16px; font-size: 18px; }
#toast { position: absolute; left: 50%; top: calc(var(--safe-t) + 80px); transform: translateX(-50%); max-width: 90%;
  background: rgba(0,0,0,.85); padding: 10px 16px; border-radius: 10px; z-index: 30; font-size: 14px; }
.me-dot { width: 18px; height: 18px; border-radius: 50%; background: #3b82f6; border: 3px solid #fff;
  box-shadow: 0 0 0 6px rgba(59,130,246,.25); }

/* ---------- 설정 ---------- */
dialog { border: 0; border-radius: 18px; padding: 0; background: var(--panel); color: var(--text); width: min(92vw, 420px); }
dialog::backdrop { background: rgba(0,0,0,.6); }
#settingsForm { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
#settingsForm h2 { margin: 0; font-size: 20px; }
#settingsForm label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
#settingsForm small { color: var(--muted); }
#settingsForm input { font-size: 16px; padding: 12px; border-radius: 10px; border: 1px solid #333a47; background: #10131a; color: var(--text); }
.hint { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.45; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; background: #000; color: var(--hud); z-index: 50; overflow: hidden;
  user-select: none; -webkit-user-select: none; }
#hudInner { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center;
  align-items: center; gap: 4vmin; padding: 4vmin; transition: transform .2s; }
#hud.mirror #hudInner { transform: scaleX(-1); }
#hud.dim { filter: brightness(.45); }
#hudTurn { display: flex; align-items: center; gap: 5vmin; }
#hudArrow { width: 42vmin; height: 42vmin; flex: none; }
#hudArrow * { stroke: var(--hud); fill: none; stroke-width: 9; stroke-linecap: round; stroke-linejoin: round; }
#hudArrow .fill { fill: var(--hud); stroke: none; }
#hudDist { font-size: 19vmin; font-weight: 800; line-height: 1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
#hudRoad { font-size: 7vmin; font-weight: 600; margin-top: 2vmin; color: var(--hud); opacity: .85; max-width: 50vw;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#hudBottom { display: flex; gap: 8vmin; }
.hud-cell { display: flex; flex-direction: column; align-items: center; }
.hud-cell span { font-size: 11vmin; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.hud-cell small { font-size: 3.6vmin; color: var(--hud-dim); margin-top: 1vmin; }
#hudSpeed.over { color: var(--danger); }
#hudControls { position: absolute; left: 0; right: 0; bottom: calc(var(--safe-b) + 16px); display: flex;
  justify-content: center; gap: 10px; transition: opacity .3s; }
#hudControls button { background: #111; color: #ccc; border: 1px solid #333; }
#hud.idle #hudControls { opacity: 0; pointer-events: none; }

@media (orientation: portrait) {
  #hudTurn { flex-direction: column; text-align: center; gap: 3vmin; }
  #hudArrow { width: 55vmin; height: 55vmin; }
  #hudDist { font-size: 22vmin; }
  #hudRoad { max-width: 90vw; }
}
