:root {
  --blue: #1f6feb;
  --green: #2e9e5b;
  --yellow: #f5c518;
  --orange: #f08c1e;
  --ink: #1b1b1b;
  --paper: #fffdf5;
  --card: #ffffff;
  --road: #cfd6dd;
  --grass: #dff3d8;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--paper); color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 18px; }
body { display: flex; flex-direction: column; height: 100dvh; overflow: hidden; overscroll-behavior: none; }

.top { display: flex; align-items: center; justify-content: space-between; padding: 6px 14px;
  padding-top: calc(10px + env(safe-area-inset-top)); background: var(--blue); color: #fff; }
.brand { font-weight: 800; font-size: 18px; }
.dots { display: flex; gap: 8px; }
.dots span { width: 14px; height: 14px; border-radius: 50%; background: rgba(255,255,255,.35); display: block; }
.dots span.done { background: var(--yellow); }
.dots span.now { background: #fff; }
.dad { background: transparent; border: 0; font-size: 22px; opacity: .55; padding: 4px 6px; }

main { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.mapWrap { background: var(--grass); padding: 4px; flex: 1 1 auto; min-height: 0; display: flex; justify-content: center; }
#map { width: 100%; height: 100%; display: block; touch-action: none; }

.panel { flex: 0 0 auto; display: flex; flex-direction: column; padding: 4px 12px 8px;
  padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
.qbar { display: flex; gap: 8px; align-items: flex-start; }
.qtext { flex: 1; font-size: 17px; line-height: 1.28; font-weight: 600; min-height: 40px; }
.speak { border: 0; background: #eef2f7; border-radius: 12px; font-size: 20px; padding: 4px 8px; }
.answerBox { margin: 4px 0 0; min-height: 40px; font-size: 26px; font-weight: 800; letter-spacing: 2px;
  text-align: center; background: var(--card); border: 3px solid #e3e8ee; border-radius: 14px; padding: 4px 10px; }
.answerBox .unit { font-size: 18px; font-weight: 600; color: #667; margin-left: 8px; letter-spacing: 0; }
.answerBox.empty { color: #aab; }
.feedback { min-height: 24px; font-size: 16px; font-weight: 700; text-align: center; margin: 2px 0; color: var(--green); }
.feedback.hint { color: var(--orange); }

.pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; margin-top: auto; }
.pad button { font-size: 21px; font-weight: 700; padding: 5px 0; border-radius: 12px; border: 0;
  background: #fff; box-shadow: 0 3px 0 #d5dbe3; color: var(--ink); }
.pad button:active { transform: translateY(2px); box-shadow: 0 1px 0 #d5dbe3; }
.pad button.go { background: var(--green); color: #fff; box-shadow: 0 3px 0 #1d6f3e; }
.pad button.del { background: #f2f4f7; }

.actions { display: flex; gap: 10px; margin-top: 6px; }
.btn { flex: 1; font-size: 19px; font-weight: 700; padding: 11px; border-radius: 14px; border: 0;
  background: var(--blue); color: #fff; box-shadow: 0 3px 0 #144ea8; }
.btn.small { flex: 0 0 auto; font-size: 15px; padding: 8px 12px; }
.btn.alt { background: #fff; color: var(--ink); box-shadow: 0 3px 0 #d5dbe3; }
.btn:active { transform: translateY(2px); }

.big { font-size: 24px; font-weight: 800; text-align: center; margin: 10px 0 6px; line-height: 1.3; }
.sub { text-align: center; font-size: 17px; color: #556; margin: 0 0 6px; }

/* map bits */
.road { stroke: var(--road); stroke-width: 22; stroke-linecap: round; }
.roadLine { stroke: #fff; stroke-width: 2; stroke-dasharray: 10 12; }
.route { stroke: var(--blue); stroke-width: 12; fill: none; stroke-linecap: round; stroke-linejoin: round; opacity: .85; }
.drawn { stroke: var(--orange); stroke-width: 10; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.place { font-size: 34px; text-anchor: middle; }
.placeLabel { font-size: 20px; font-weight: 700; text-anchor: middle; fill: #223; paint-order: stroke; stroke: #fff; stroke-width: 5; }
.segLabel { font-size: 24px; font-weight: 800; text-anchor: middle; fill: var(--blue); paint-order: stroke; stroke: #fff; stroke-width: 6; }
.plate { font-family: ui-monospace, Menlo, monospace; text-anchor: middle; }
.plateL { font-size: 20px; font-weight: 600; fill: #fff; }
.plateN { font-size: 28px; font-weight: 900; fill: #f5c518; }
.plateBox { fill: #111; stroke: #fff; stroke-width: 3; rx: 6; }
.scaleText { font-size: 20px; font-weight: 700; fill: #223; paint-order: stroke; stroke: #fff; stroke-width: 5; }
.car { font-size: 34px; }

/* dad page */
.hidden { display: none !important; }
.dadPage { position: fixed; inset: 0; background: var(--paper); overflow: auto; padding: 14px;
  padding-top: calc(14px + env(safe-area-inset-top)); }
.dadHead { display: flex; justify-content: space-between; align-items: center; }
.card { background: var(--card); border-radius: 14px; padding: 12px 14px; margin: 12px 0; box-shadow: 0 2px 6px rgba(0,0,0,.06); }
.card h3 { margin: 0 0 8px; font-size: 17px; }
.card p { margin: 6px 0; }
.row { display: flex; gap: 8px; }
.row input { flex: 1; font-size: 17px; padding: 8px 10px; border-radius: 10px; border: 2px solid #dde; }
.mono { font-family: ui-monospace, Menlo, monospace; }
ul { padding-left: 20px; }
.logRow { font-size: 15px; padding: 6px 0; border-top: 1px solid #eee; }
.tag { display: inline-block; background: #eef2f7; border-radius: 8px; padding: 2px 8px; font-size: 13px; margin-right: 4px; }

/* new input modes and map marks */
.pad.choice { grid-template-columns: 1fr 1fr; }
.pad.choice button.opt { font-size: 22px; padding: 12px 0; background: var(--blue); color: #fff; box-shadow: 0 3px 0 #144ea8; }
.pad.five { grid-template-columns: repeat(5, 1fr); }
.pad.five button.tall { grid-column: 5; grid-row: 1 / span 3; writing-mode: horizontal-tb; }
.pad.grid6 { grid-template-columns: repeat(6, 1fr); }
.pad.grid6 button { font-size: 18px; padding: 4px 0; }
.pad.grid4 button.letter { background: #eaf1ff; color: var(--blue); }
.gridLabel { font-size: 26px; font-weight: 800; text-anchor: middle; fill: #445; }
.hypo { stroke: var(--orange); stroke-width: 8; stroke-dasharray: 18 12; stroke-linecap: round; }
.triLabel { font-size: 30px; font-weight: 800; text-anchor: middle; fill: var(--blue); }
.turnMark { fill: none; stroke: var(--orange); stroke-width: 6; rx: 6; }
.flag { font-size: 40px; }
.typeList { display: flex; flex-direction: column; gap: 6px; }
.switch { font-size: 16px; display: flex; align-items: center; gap: 8px; }
.switch input { width: 22px; height: 22px; }
.muted { color: #667; font-size: 14px; margin: 0 0 8px; }

.panel.intro .speak, .panel.intro .answerBox { display: none; }
.panel.intro .qtext { text-align: center; }
