/* Human Impact Town Planner (Foundations). Play-area text 18 px or more; tap targets 48 px or more. */
.tp {
  --tp-acc: #1f6f5c; --tp-acc-strong: #175848; --tp-acc-tint: #e2f2ec; --tp-ink: var(--tlg-text, #161a2e);
  --tp-card: var(--tlg-surface, #fff); --tp-sunk: var(--tlg-surface-2, #eef0f6); --tp-line: var(--tlg-border, #d3d7e3);
  --tp-muted: var(--tlg-text-muted, #3f4558); --tp-ok: #166534; --tp-ok-bg: #dcfce7; --tp-no: #9a3412; --tp-no-bg: #ffedd5;
  max-width: 1340px; margin: 0 auto; padding: 10px 16px 32px; color: var(--tp-ink); font-family: var(--tlg-font, system-ui, sans-serif);
  font-size: 18px; line-height: 1.45; box-sizing: border-box;
}
html[data-theme="dark"] .tp { --tp-acc: #7fd1b5; --tp-acc-strong: #2c8a70; --tp-acc-tint: #15302a; --tp-ok: #86efac; --tp-ok-bg: #12301f; --tp-no: #fdba74; --tp-no-bg: #3a2312; }
.tp *, .tp *::before, .tp *::after { box-sizing: border-box; }
.tp h1, .tp h2, .tp h3 { margin: 0; line-height: 1.2; }
.tp-muted { color: var(--tp-muted); }
.tp [hidden] { display: none !important; }

/* top bar */
.tp-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-bottom: 8px; }
.tp-titles { flex: 1 1 auto; min-width: 0; }
.tp-eyebrow { margin: 0; font-size: 16px; font-weight: 700; letter-spacing: .06em; color: var(--tp-acc); }
.tp-bar h1 { font-size: 26px; }
.tp-level { display: inline-flex; align-items: center; min-height: 32px; padding: 2px 14px; border-radius: 999px; background: var(--tp-acc-strong); color: #fff; font-weight: 700; font-size: 18px; }
.tp-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* buttons */
.tp-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 48px; padding: 8px 16px; border-radius: 10px;
  border: 2px solid var(--tlg-border-strong, #737b8f); background: var(--tp-card); color: var(--tp-ink); font: inherit; font-size: 18px; font-weight: 700; cursor: pointer; text-align: center; }
.tp-btn:hover { background: var(--tp-sunk); }
.tp-btn:focus-visible, .tp button:focus-visible, .tp textarea:focus-visible { outline: 3px solid var(--tlg-focus, #6b3fa0); outline-offset: 2px; }
.tp-btn--pri, .tp-btn.is-next { background: var(--tp-acc-strong); border-color: var(--tp-acc-strong); color: #fff; }
.tp-btn--pri:hover, .tp-btn.is-next:hover { background: #10463a; }
.tp-btn--ghost { font-size: 16px; min-height: 48px; padding: 6px 12px; }
.tp-btn--small { min-height: 48px; font-size: 18px; padding: 6px 12px; align-self: flex-start; }
.tp-btn:disabled { opacity: .5; cursor: not-allowed; }
.tp-say { display: inline-flex; align-items: center; justify-content: center; width: 48px; height: 48px; flex: 0 0 48px; border-radius: 50%; border: 2px solid var(--tp-line); background: var(--tp-card); font-size: 20px; cursor: pointer; vertical-align: middle; }
.tp.no-voice .tp-say { display: none; }
.tp-say-row { display: flex; gap: 10px; align-items: flex-start; }
.tp-say-row > span { flex: 1 1 auto; min-width: 0; }

/* start */
.tp-start { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 24px; align-items: start; background: var(--tp-card); border: 1px solid var(--tp-line); border-radius: 16px; padding: 20px; }
.tp-start-art canvas { display: block; width: 100%; height: 440px; border-radius: 12px; }
.tp-start h2 { font-size: 26px; margin-bottom: 10px; }
.tp-how { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 28px; padding-left: 26px; margin: 8px 0 14px; }
.tp-start-labs { display: grid; gap: 10px; }
.tp-big { flex-direction: column; align-items: flex-start; text-align: left; padding: 10px 16px; }
.tp-big span { font-weight: 400; font-size: 18px; }

/* modes + tabs */
.tp-nav { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 18px; border-bottom: 2px solid var(--tp-line); margin-bottom: 12px; }
.tp-modes { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding-bottom: 6px; }
.tp-modes button, .tp-tabs button { min-height: 48px; padding: 6px 14px; border-radius: 10px; border: 2px solid var(--tp-line); background: var(--tp-card); color: var(--tp-ink); font: inherit; font-size: 18px; font-weight: 700; cursor: pointer; }
.tp-modes button.is-on { background: var(--tp-acc-tint); border-color: var(--tp-acc); color: var(--tp-ink); }
.tp-modes button:disabled { opacity: .45; cursor: not-allowed; }
.tp-modes-note { font-size: 18px; color: var(--tp-muted); }
.tp-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }
.tp-tabs button { border-bottom: none; border-radius: 10px 10px 0 0; margin-bottom: -2px; }
.tp-tabs button[aria-selected="true"] { background: var(--tp-acc-strong); border-color: var(--tp-acc-strong); color: #fff; }

.tp-panel { background: var(--tp-card); border: 1px solid var(--tp-line); border-radius: 16px; padding: 14px; }

/* bench */
.tp-bench { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 14px; align-items: start; }
.tp-scene canvas { display: block; width: 100%; height: 400px; border-radius: 12px; }
.tp-runbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.tp-runbar .tp-btn { flex: 1 1 auto; }
.tp-day { min-width: 92px; text-align: center; font-weight: 700; font-size: 18px; padding: 8px 12px; border-radius: 999px; background: var(--tp-sunk); }
.tp-pots { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 10px; }
.tp-potCard { margin: 0; border: 2px solid var(--tp-line); border-radius: 12px; padding: 6px 10px 10px; min-width: 0; }
.tp-potCard legend { font-weight: 800; padding: 0 6px; font-size: 18px; }
.tp-row { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 6px; align-items: center; margin-top: 6px; }
.tp-row > span { font-weight: 700; font-size: 18px; }
.tp-seg { display: flex; flex-wrap: wrap; gap: 4px; }
.tp-seg button { flex: 1 1 auto; min-height: 48px; min-width: 48px; padding: 4px 8px; border-radius: 8px; border: 2px solid var(--tp-line); background: var(--tp-sunk); color: var(--tp-ink); font: inherit; font-size: 18px; cursor: pointer; }
.tp-seg button[aria-pressed="true"] { background: var(--tp-acc-strong); border-color: var(--tp-acc-strong); color: #fff; font-weight: 700; }
.tp-seg button.is-target { box-shadow: 0 0 0 3px #f0b429; }
.tp-step { display: flex; align-items: center; gap: 6px; }
.tp-step button { width: 48px; height: 48px; border-radius: 8px; border: 2px solid var(--tp-line); background: var(--tp-sunk); color: var(--tp-ink); font-size: 24px; font-weight: 800; cursor: pointer; }
.tp-step output { min-width: 64px; text-align: center; font-weight: 800; font-size: 20px; }
.tp-fixed { font-size: 18px; color: var(--tp-muted); }

.tp-side { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.tp-coach { border: 3px solid var(--tp-acc); background: var(--tp-acc-tint); border-radius: 14px; padding: 12px; }
.tp-coach .tp-stepNo { margin: 0 0 4px; font-size: 18px; font-weight: 800; letter-spacing: .04em; color: var(--tp-acc-strong); }
html[data-theme="dark"] .tp-coach .tp-stepNo { color: var(--tp-acc); }
.tp-coach p { margin: 0; }
.tp-coach .tp-warn { margin-top: 8px; padding: 8px 10px; border-radius: 10px; background: var(--tp-no-bg); color: var(--tp-no); font-weight: 700; }
.tp-choices { display: grid; gap: 8px; margin-top: 10px; }
.tp-choice { display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 8px 12px; border-radius: 10px; border: 2px solid var(--tp-line); background: var(--tp-card); color: var(--tp-ink); font: inherit; font-size: 18px; text-align: left; cursor: pointer; width: 100%; }
.tp-choice[aria-pressed="true"] { border-color: var(--tp-acc-strong); background: var(--tp-acc-tint); font-weight: 700; }
.tp-choice.ok { border-color: var(--tp-ok); background: var(--tp-ok-bg); }
.tp-choice.no { border-color: var(--tp-no); background: var(--tp-no-bg); }
.tp-choice:disabled { cursor: default; }
.tp-feedback { margin-top: 8px; padding: 10px 12px; border-radius: 10px; font-weight: 600; }
.tp-feedback.ok { background: var(--tp-ok-bg); color: var(--tp-ok); }
.tp-feedback.no { background: var(--tp-no-bg); color: var(--tp-no); }
.tp-coachBtns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.tp-checks { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 4px; }
.tp-checks li::before { content: '○ '; }
.tp-checks li.done::before { content: '✓ '; color: var(--tp-ok); font-weight: 800; }

.tp-read { width: 100%; border-collapse: collapse; font-size: 18px; }
.tp-read th, .tp-read td { padding: 6px 8px; border-bottom: 1px solid var(--tp-line); text-align: left; vertical-align: top; }
.tp-read thead th { background: var(--tp-sunk); }
.tp-read td { font-weight: 700; }
.tp-note { margin: 0; font-size: 18px; color: var(--tp-muted); }

/* data */
.tp-dataHead { display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: baseline; margin-bottom: 8px; }
.tp-dataHead p { margin: 0; }
.tp-tableWrap { overflow-x: auto; border: 1px solid var(--tp-line); border-radius: 10px; }
.tp-table { width: 100%; border-collapse: collapse; font-size: 18px; }
.tp-table th, .tp-table td { padding: 8px 10px; border-bottom: 1px solid var(--tp-line); text-align: left; vertical-align: top; }
.tp-table th { background: var(--tp-sunk); white-space: nowrap; }
.tp-table td.num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
.tp-table .tp-setup { font-size: 18px; color: var(--tp-muted); }
.tp-empty { padding: 16px; margin: 0; }
.tp-graph { margin-top: 14px; }
.tp-graph canvas { display: block; width: 100%; height: 340px; }
.tp-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 6px; font-size: 18px; }
.tp-legend span { display: inline-flex; align-items: center; gap: 6px; }

/* CER */
.tp-cer h2 { font-size: 24px; margin-bottom: 6px; }
.tp-q { font-size: 20px; font-weight: 700; margin: 6px 0 12px; }
.tp-cerGrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.tp-cerBox { display: flex; flex-direction: column; gap: 6px; }
.tp-cerHead { font-size: 18px; }
.tp-cerBox textarea { width: 100%; min-height: 150px; resize: vertical; padding: 10px; border-radius: 10px; border: 2px solid var(--tlg-border-strong, #737b8f); background: var(--tp-card); color: var(--tp-ink); font: inherit; font-size: 18px; }
.tp-cerBox small { font-size: 18px; color: var(--tp-muted); }
.tp-words { margin-top: 12px; }
.tp-words summary { cursor: pointer; font-weight: 700; min-height: 48px; display: flex; align-items: center; list-style: none; }
.tp-words summary::-webkit-details-marker { display: none; }
.tp-words summary::before { content: '▸'; margin-right: 8px; }
.tp-words[open] summary::before { content: '▾'; }
.tp-done { margin-top: 14px; padding: 14px; border-radius: 14px; background: var(--tp-ok-bg); }
.tp-done h3 { margin-bottom: 6px; }
.tp-turnin { margin-top: 12px; }

/* test */
.tp-qGrid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.tp-qRight .tp-q { margin-top: 10px; }
.tp-qScene.is-read canvas { height: 460px; }
@media (max-width: 1000px) { .tp-qGrid { grid-template-columns: 1fr; gap: 0; } }
.tp-testHead { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 14px; align-items: baseline; }
.tp-testHead h2 { font-size: 24px; }
.tp-progress { flex: 1 1 160px; max-width: 280px; height: 12px; border-radius: 6px; background: var(--tp-sunk); overflow: hidden; }
.tp-progress i { display: block; height: 100%; background: var(--tp-acc); }
.tp-qScene canvas { display: block; width: 100%; height: 340px; border-radius: 12px; margin-top: 10px; }
.tp-qSetups { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 6px; font-size: 18px; }
.tp-qSetups.one { grid-template-columns: 1fr; }
.tp-qSetups div { padding: 6px 10px; border-radius: 10px; background: var(--tp-sunk); }
.tp-qNav { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; margin-top: 12px; }
.tp-review { padding-left: 22px; }
.tp-review li { margin-bottom: 10px; }
.tp-review .ok b { color: var(--tp-ok); }
.tp-review .no b { color: var(--tp-no); }

/* dialogs + toast */
.tp-dialog { max-width: min(680px, calc(100vw - 32px)); border: none; border-radius: 16px; padding: 20px; background: var(--tp-card); color: var(--tp-ink); font-size: 18px; }
.tp-dialog::backdrop { background: rgb(10 15 25 / .55); }
.tp-dialog h2 { margin-bottom: 8px; }
.tp-dialog h3 { margin: 12px 0 4px; }
.tp-legendList { padding-left: 20px; margin: 6px 0; }
.tp-legendList li { margin-bottom: 4px; }
.tp-dialogFoot { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; margin-top: 14px; }
.tp-toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 50; max-width: min(92vw, 520px); padding: 12px 18px; border-radius: 12px; background: #143b32; color: #fff; font-weight: 700; box-shadow: 0 6px 24px rgba(0,0,0,.35); }

@media (max-width: 1100px) {
  .tp-bench { grid-template-columns: 1fr; }
  .tp-side { order: -1; display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); align-items: start; }
  .tp-side .tp-coach { grid-row: span 2; }
  .tp-side .tp-note { grid-column: 1 / -1; }
}
@media (max-width: 900px) {
  .tp-start { grid-template-columns: 1fr; }
  .tp-start-art canvas { height: 320px; }
  .tp-cerGrid { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .tp-side { display: flex; }
  .tp-pots { grid-template-columns: 1fr; }
  .tp-scene canvas { height: 340px; }
  .tp-tabs { margin-left: 0; }
  .tp-qScene canvas { height: 260px; }
  .tp-bar h1 { font-size: 24px; }
  .tp { padding: 8px 12px 24px; }
}
@media (prefers-reduced-motion: reduce) { .tp * { transition: none !important; animation: none !important; } }

.tp-test .tp-eyebrow { font-size: 18px; }
.tp-dialog .tp-btn { font-size: 18px; }
.tp-dialogFoot .tlgfr-btn { font-size: 18px; min-height: 48px; }
.tp-res { margin: 8px 0 0; padding: 8px 10px; border-radius: 10px; background: var(--tp-sunk); display: grid; gap: 2px 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.tp-res div { display: flex; flex-wrap: wrap; gap: 0 8px; }
.tp-res dt { color: var(--tp-muted); }
.tp-res dd { margin: 0; font-weight: 800; }
.tp-res .tp-resWait { color: var(--tp-muted); grid-column: 1 / -1; }
.tp-res .wide { grid-column: 1 / -1; }


/* ── Town Planner additions ── */
.tp-start-art canvas { height: 460px; }
.tp-sceneCol { min-width: 0; }
.tp-scene canvas { height: 470px; }
.tp-key { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 18px; }
.tp-key li { display: inline-flex; align-items: center; gap: 6px; }
.tp-key canvas { width: 44px; height: 26px; border-radius: 5px; flex: 0 0 auto; }
.tp-setup { margin: 10px 0 0; border: 2px solid var(--tp-line); border-radius: 12px; padding: 6px 12px 12px; min-width: 0; }
.tp-setup legend { font-weight: 800; padding: 0 6px; font-size: 18px; }
#controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 6px 18px; }
.tp-row { grid-template-columns: 170px minmax(0, 1fr); }
.tp-row > span { display: flex; align-items: center; gap: 8px; line-height: 1.2; }
.tp-row > span small, .tp-res dt small { display: block; font-weight: 400; font-size: 18px; color: var(--tp-muted); }
.tp-row--wide { grid-column: 1 / -1; }
.tp-tile { width: 46px; height: 30px; border-radius: 6px; flex: 0 0 auto; }
.tp-step output { min-width: 72px; }
.tp-step.is-target { box-shadow: 0 0 0 3px #f0b429; border-radius: 10px; }
.tp-seg button:disabled { opacity: .45; cursor: not-allowed; }
.tp-fixed { grid-column: 1 / -1; margin: 6px 0 0; }
.tp-runbar .tp-btn { flex: 1 1 150px; }
.tp-res { margin: 0; padding: 10px 12px; border-radius: 12px; background: var(--tp-sunk); display: grid; gap: 6px; grid-template-columns: 1fr; }
.tp-res div { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0 10px; padding: 4px 8px; border-radius: 8px; border-left: 5px solid transparent; }
.tp-res div.ok { border-left-color: var(--tp-ok); background: var(--tp-ok-bg); }
.tp-res div.no { border-left-color: var(--tp-no); background: var(--tp-no-bg); }
.tp-res dt { font-weight: 700; }
.tp-res dd { margin: 0; font-weight: 800; white-space: nowrap; }
.tp-mark { display: inline-block; min-width: 1.2em; text-align: center; }
.tp-res .ok .tp-mark { color: var(--tp-ok); } .tp-res .no .tp-mark { color: var(--tp-no); }
.tp-resHead { font-weight: 800; color: var(--tp-acc-strong); }
html[data-theme="dark"] .tp-resHead { color: var(--tp-acc); }
.tp-resNote { margin: 0; color: var(--tp-muted); }
.tp-resScore { margin: 0; font-weight: 800; font-size: 20px; }
.tp-resScore.ok { color: var(--tp-ok); } .tp-resScore.no { color: var(--tp-no); }
/* data */
.tp-table td.bad { color: var(--tp-no); background: var(--tp-no-bg); }
.tp-graphs { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; margin-top: 14px; }
.tp-graph { margin-top: 0; }
.tp-graph h3 { font-size: 18px; margin-bottom: 4px; }
.tp-graph canvas { height: 300px; }
.tp-sw { display: inline-block; width: 22px; height: 16px; border-radius: 3px; }
.tp-sw.ok { background: #2366a8; } .tp-sw.no { background: repeating-linear-gradient(45deg, #c2410c 0 5px, #e8a27f 5px 8px); }
.tp-sw.goal { height: 0; border-top: 3px dashed #1f7a3a; }
html[data-theme="dark"] .tp-sw.ok { background: #6fb6e8; } html[data-theme="dark"] .tp-sw.goal { border-top-color: #9be38a; }
/* help */
.tp-keyList { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 8px; }
.tp-keyList li { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 10px; align-items: center; }
.tp-keyList canvas { width: 76px; height: 40px; border-radius: 6px; }
/* test */
.tp-qGrid { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); }
.tp-qScene canvas { height: 380px; }
.tp-qScene.is-two canvas { height: 330px; }
.tp-qSetups { display: grid; grid-template-columns: 1fr; gap: 8px; margin-top: 8px; font-size: 18px; }
.tp-qSetups.is-two { grid-template-columns: 1fr 1fr; }
.tp-qSetups div { padding: 6px 10px; border-radius: 10px; background: var(--tp-sunk); }
.tp-qNav--start { justify-content: flex-start; margin-top: 6px; }
.tp-qWait { margin: 10px 0 0; color: var(--tp-muted); }
.tp-qCards { display: grid; gap: 10px; margin-top: 10px; }
.tp-qCards.is-two { grid-template-columns: 1fr 1fr; }
.tp-qCard { margin: 0; padding: 8px; border-radius: 12px; background: var(--tp-sunk); display: grid; gap: 4px; min-width: 0; }
.tp-qCard > div { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0 8px; padding: 2px 6px; border-radius: 6px; border-left: 4px solid transparent; }
.tp-qCard > div.ok { border-left-color: var(--tp-ok); } .tp-qCard > div.no { border-left-color: var(--tp-no); background: var(--tp-no-bg); }
.tp-qCard dd { margin: 0; font-weight: 800; }
.tp-qCardHead { font-weight: 800; color: var(--tp-acc-strong); }
html[data-theme="dark"] .tp-qCardHead { color: var(--tp-acc); }
@media (max-width: 1100px) {
  .tp-bench { display: flex; flex-direction: column; align-items: stretch; gap: 12px; }
  .tp-sceneCol, .tp-bench .tp-side { display: contents; }
  .tp-coach { order: 1; } .tp-scene { order: 2; } .tp-runbar { order: 3; } .tp-res { order: 4; } .tp-setup { order: 5; margin-top: 0; } .tp-key { order: 6; margin-top: 0; } .tp-note { order: 7; }
  .tp-scene canvas { height: 440px; }
}
@media (max-width: 700px) {
  .tp-scene canvas, .tp-start-art canvas { height: 330px; }
  .tp-row { grid-template-columns: 1fr; gap: 2px; }
  #controls { grid-template-columns: 1fr; }
  .tp-qScene canvas { height: 300px; }
  .tp-qScene.is-two canvas { height: 560px; }
  .tp-qSetups.is-two, .tp-qCards.is-two { grid-template-columns: 1fr; }
  .tp-graphs { grid-template-columns: 1fr; }
  .tp-key canvas { width: 40px; height: 24px; }
}
