:root {
  --bg: #eff1f4;
  --fg: #2b323b;
  --muted: #78838f;
  --line: #d3dae1;
  --sheet-bg: #ffffff;
  --btn-bg: #4d5a68;
  --btn-fg: #f3f6f9;
  --warn: #c8452f;
  --good: #2f7a45;
  /* 차로 고르개가 판과 같은 색을 쓴다(main.js의 SKIN과 짝이다). */
  --road-top: #7d8794;
  --road-mark: #e8ecf1;
  --road-mid: #e7c94f;
  --road-dash: #e8ecf1;
  --pick: #3b6ea5;
  /* 고른 차로. 아스팔트 위에 --pick을 26%로 섞은 값을 미리 적어 둔다 — 계산식에
     기대면 받아 주지 않는 판이 있고, 여기서 아낄 것은 없다. */
  --pick-fill: #6c8098;

  /* 판 위에 얹는 겹의 바탕. 판이 비치도록 반투명이다. */
  --veil: rgba(239, 241, 244, 0.86);
  --veil-line: rgba(120, 131, 143, 0.22);

  --pad-x: clamp(10px, 4vmin, 26px);
  --app-max: 520px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131619;
    --fg: #dde3ea;
    --muted: #8b95a1;
    --line: #2f373f;
    --sheet-bg: #1e2329;
    --btn-bg: #47535f;
    --btn-fg: #eef2f6;
    --warn: #e0705a;
    --good: #5aa876;
    --road-top: #3b434c;
    --road-mark: #8994a1;
    --road-mid: #a98f31;
    --road-dash: #7c8794;
    --pick: #79a7d8;
    --pick-fill: #4b5d70;
    --veil: rgba(19, 22, 25, 0.84);
    --veil-line: rgba(139, 149, 161, 0.22);
  }
}

* { box-sizing: border-box; }

/* **판이 화면 전체다.** 계기와 조작은 그 위에 겹으로 얹는다. 판을 글상자 폭에
   맞춰 두던 때는 큰 화면에서 도시가 가운데 좁은 띠에만 보였고, 폰에서는 머리글과
   조작줄이 세로를 먼저 가져가 정작 도시가 들어갈 자리가 남지 않았다.
   **몸통은 스크롤하지 않는다** — 스크롤할 것이 없고, 판을 끌다 손가락이 새면
   페이지가 따라 움직인다. */
html, body { margin: 0; height: 100%; overflow: hidden; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: "Pretendard", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
}

.app { position: fixed; inset: 0; }

/* 판 위에 얹는 겹. 위쪽에는 머리글과 미션, 아래쪽에는 패널과 조작줄이다.
   **빈 자리는 손가락을 판으로 흘려보낸다**(`pointer-events`) — 겹이 차지한 띠가
   통째로 판을 가리면 그 높이만큼 도시를 끌 수 없다. */
.hud {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 var(--pad-x);
  pointer-events: none;
}

.hud > * {
  pointer-events: auto;
  width: min(100%, var(--app-max));
  margin: 0 auto;
}

.hud-top { top: 0; padding-top: calc(env(safe-area-inset-top, 0px) + 8px); }
.hud-bottom { bottom: 0; padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 10px); }

/* 머리글과 조작줄은 판 위에 뜬 카드다. */
.head, .pad {
  background: var(--veil);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border: 1px solid var(--veil-line);
  border-radius: 14px;
  padding: 8px 12px 9px;
}

.head { display: flex; flex-direction: column; gap: 6px; }

/* 헤더 배치는 모든 게임이 같다 — 왼쪽 위에 목록과 도움말, 가운데에 이름, 오른쪽에 소리. */
.title-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
}

.title-row h1 { text-align: center; }
.title-row .head-nav { justify-self: start; }
.title-row .head-actions { justify-self: end; }
.head-nav { display: flex; align-items: center; gap: 14px; }
.head-actions { display: flex; align-items: baseline; gap: 14px; }

h1 {
  margin: 0;
  font-size: clamp(22px, 5.6vmin, 32px);
  font-weight: 800;
  letter-spacing: -0.02em;
}

.toggle {
  border: 0; background: none; padding: 0;
  color: inherit; font-family: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer; opacity: 0.6;
}
.toggle:hover { opacity: 1; }
.toggle.sound { font-size: 12px; }
.toggle.sound[aria-pressed="false"] { opacity: 0.38; text-decoration: line-through; }

.back {
  color: inherit; opacity: 0.6; text-decoration: none;
  font-size: 14px; font-weight: 600;
}
.back:hover { opacity: 1; }

/* --- 계기 --- */

.gauges { display: flex; justify-content: center; gap: 14px; flex-wrap: wrap; }
.gauge { display: flex; align-items: baseline; gap: 4px; }
.gauge b { font-size: 17px; font-weight: 800; font-variant-numeric: tabular-nums; }
.gauge i { font-style: normal; font-size: 12px; color: var(--muted); }

/* --- 미션 --- */

.mission {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--sheet-bg);
  margin: 0 auto;
}

.hud .mission { width: auto; max-width: 100%; }
.mission[hidden] { display: none; }
.mission b { font-size: 16px; font-weight: 800; font-variant-numeric: tabular-nums; }
.mission i { font-style: normal; font-size: 12.5px; color: var(--muted); }
.mission .pick { padding: 4px 10px; }

/* 남은 시간이 얼마 없을 때. **숫자만으로는 눈에 안 들어온다.** */
.mission.hurry { border-color: var(--warn); }
.mission.hurry b { color: var(--warn); }
.mission.good b { color: var(--good); }

/* --- 판 --- */

.board-wrap {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

/* **판은 `none`이다.** 손가락을 끌어 길을 놓는 자리라 페이지가 따라 스크롤되면
   선을 그을 수 없다. 그래서 판 안의 조작은 click이 아니라 포인터 이벤트로 돈다
   (`shared/base.js`가 이 자리의 touchend를 취소한다). */
.board { display: block; width: 100%; height: 100%; touch-action: none; }

/* --- 고른 것을 손보는 패널 --- */

.panel {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 10px 12px 11px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--sheet-bg);
  /* **판을 다 덮지 않는다.** 여덟 차로짜리 고르개는 세로로 길어, 그대로 두면
     고르는 동안 정작 고른 차로가 화면 밖으로 밀린다. */
  max-height: 46vh;
  overflow-y: auto;
}

.panel[hidden] { display: none; }

.panel-body { display: flex; flex-direction: column; gap: 7px; }
.panel-title { margin: 0; font-size: 12px; font-weight: 700; color: var(--muted); }
.panel-note { margin: 0; font-size: 12.5px; line-height: 1.5; }
.panel-note.dim { color: var(--muted); font-size: 12px; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }

.chip {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: none;
  color: inherit;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 700;
  padding: 7px 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
}

.chip[disabled] { opacity: 0.4; cursor: default; }
.chip .cost {
  font-variant-numeric: tabular-nums;
  opacity: 0.7;
  font-size: 11.5px;
}

.chip.go {
  background: var(--btn-bg);
  border-color: var(--btn-bg);
  color: var(--btn-fg);
}

.chip[aria-pressed="true"] {
  background: var(--btn-bg);
  border-color: var(--btn-bg);
  color: var(--btn-fg);
}

.chip .ico { width: 18px; height: 18px; display: block; }
.chip.icon { flex: 0 1 auto; padding: 6px 10px; }

/* 차로 고르개. **도로의 단면이다** — 붙여서 한 덩어리로 두고 사이에 중앙선과 차선을
   긋는다. 줄의 방향과 차례는 화면 속 도로에 맞춰 `main.js`가 정한다. */
.strip {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: var(--road-top);
}

.strip.across { flex-direction: row; }
.strip.down { flex-direction: column; }

.lane-cell {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  color: var(--road-mark);
  padding: 8px 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.strip.across .lane-cell { min-height: 46px; }
.strip.down .lane-cell { min-height: 0; padding: 5px 6px; }

/* 고른 차로. 판 위에서도 같은 색으로 덮인다. */
.lane-cell[aria-pressed="true"] {
  background: var(--pick-fill);
  box-shadow: inset 0 0 0 2px var(--pick);
}

.lane-arrows { display: flex; gap: 1px; }
.lane-arrows > span { display: block; width: 18px; height: 18px; }
.lane-cell .ico { width: 18px; height: 18px; display: block; }

/* 차로 사이의 선. 어느 쪽이 중앙선인지는 `Net.boundaries`가 정한다. */
.lane-line { display: block; flex: 0 0 auto; align-self: stretch; }
.strip.across .lane-line { width: 2px; }
.strip.down .lane-line { height: 2px; }

.lane-line.middle { background: var(--road-mid); }

.strip.across .lane-line.dash {
  background: repeating-linear-gradient(to bottom,
    var(--road-dash) 0 6px, transparent 6px 12px);
}

.strip.down .lane-line.dash {
  background: repeating-linear-gradient(to right,
    var(--road-dash) 0 6px, transparent 6px 12px);
}

.panel-close {
  align-self: flex-end;
  border: 0;
  background: none;
  color: var(--muted);
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  padding: 2px 4px;
  cursor: pointer;
}

/* --- 조작 --- */

.pad { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; align-items: center; gap: 8px; }

.btn {
  border: 0;
  border-radius: 11px;
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  padding: 10px 16px;
  cursor: pointer;
}

.btn.ghost {
  background: none;
  border: 1px solid var(--line);
  color: inherit;
}

.picker { display: flex; gap: 4px; margin: 0 auto; }

.pick {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: none;
  color: inherit;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  padding: 5px 11px;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}

.pick[aria-pressed="true"] {
  background: var(--btn-bg);
  border-color: var(--btn-bg);
  color: var(--btn-fg);
}

/* --- 시트 --- */

.sheet-title { margin: 0; font-size: 16px; font-weight: 800; }
.sheet-note { margin: 0; font-size: 13px; color: var(--muted); }
.sheet-actions { display: flex; gap: 8px; justify-content: flex-end; }

.help-list {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13.5px;
  line-height: 1.55;
}
