/* 身體測驗 (physical-ui.js). Everything is under .physical; the page tokens (style.css) are used when present.
   Sized for a phone held upright (390 × 844): header, one line, the canvas, the tries, the controls. */
.physical{--ph-ink:var(--ink,#1d2a2a);--ph-paper:var(--paper,#f6f7f1);--ph-accent:var(--accent,#f2b705);
  --ph-accent-dark:var(--accent-dark,#8a6400);--ph-accent-shadow:var(--accent-shadow,#c48f00);--ph-muted:var(--muted,#556464);
  --ph-good:var(--green,#2f8f4e);--ph-bad:var(--red,#d4402b);--ph-ease:var(--ease-out,cubic-bezier(0.23,1,0.32,1));
  display:flex;flex-direction:column;gap:8px;width:100%;max-width:620px;margin:0 auto;
  padding:10px max(12px,var(--safe-right,0px)) max(14px,var(--safe-bottom,0px)) max(12px,var(--safe-left,0px));
  color:var(--ph-ink);font-family:var(--sans,system-ui,sans-serif);font-size:14px;line-height:1.45;
  user-select:none;-webkit-user-select:none;-webkit-touch-callout:none}
.physical *{box-sizing:border-box}
.physical [hidden]{display:none!important}

/* ── header ── */
.physical .ph-head{display:grid;gap:1px}
.physical .ph-kicker{margin:0;font-weight:800;font-size:12.5px;letter-spacing:.06em;color:var(--ph-accent-dark)}
.physical .ph-title{margin:0;font-size:22px;font-weight:900;line-height:1.2}
.physical .ph-pips{list-style:none;margin:5px 0 0;padding:0;display:flex;flex-wrap:wrap;gap:4px}
.physical .ph-pip{padding:2px 9px;border-radius:999px;background:#e2dbc6;color:var(--ph-muted);font-size:11.5px;font-weight:800}
.physical .ph-pip[data-state="now"]{background:var(--ph-ink);color:#fff}
.physical .ph-pip[data-state="ok"]{background:#e3f3e6;color:var(--ph-good)}
.physical .ph-pip[data-state="bad"]{background:#fbe3df;color:var(--ph-bad)}

/* ── line, canvas, note ── */
.physical .ph-line{margin:0;min-height:2.8em;font-size:15px;font-weight:700;line-height:1.4;word-break:keep-all;overflow-wrap:anywhere}
.physical .ph-canvas{display:block;width:100%;height:clamp(180px,40svh,400px);border-radius:14px;background:#141c1c;touch-action:none}
.physical .ph-note{margin:-2px 0 0;font-size:12px;color:var(--ph-muted)}

/* ── tries: three per row (the colour test has nine) ── */
.physical .ph-tries{list-style:none;margin:0;padding:0;display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:4px}
.physical .ph-tries[data-kind="summary"]{grid-template-columns:repeat(2,minmax(0,1fr))}
.physical .ph-try{display:flex;align-items:center;gap:5px;min-height:30px;padding:3px 8px;border-radius:8px;background:rgba(29,42,42,.05);
  color:var(--ph-muted);font-size:12.5px;font-weight:700;font-variant-numeric:tabular-nums;white-space:nowrap;overflow:hidden}
.physical .ph-try-text{overflow:hidden;text-overflow:ellipsis}
.physical .ph-try[data-state="now"]{background:rgba(29,42,42,.12);color:var(--ph-ink)}
.physical .ph-try[data-state="ok"]{background:#e3f3e6;color:var(--ph-good)}
.physical .ph-try[data-state="bad"]{background:#fbe3df;color:var(--ph-bad)}
.physical .ph-icon{width:16px;height:16px;flex:none;fill:none;stroke:currentColor;stroke-width:2.2;stroke-linecap:round;stroke-linejoin:round}
.physical .ph-try[data-state="open"] .ph-icon,.physical .ph-try[data-state="now"] .ph-icon{stroke-width:1.6;opacity:.6}

/* ── buttons ── */
.physical .ph-btn{font:inherit;color:inherit;cursor:pointer;border:0;margin:0;min-height:52px;padding:10px 14px;border-radius:12px;
  display:inline-flex;align-items:center;justify-content:center;gap:8px;font-size:16px;font-weight:800;
  touch-action:manipulation;-webkit-tap-highlight-color:transparent;transition:transform 140ms var(--ph-ease),box-shadow 140ms var(--ph-ease)}
.physical .ph-btn:focus-visible{outline:3px solid var(--ph-accent-dark);outline-offset:3px}
.physical .ph-btn:disabled{cursor:not-allowed;opacity:.45}
.physical .ph-primary{background:var(--ph-accent);color:var(--ph-ink);box-shadow:0 3px 0 var(--ph-accent-shadow)}
.physical .ph-primary:not(:disabled):active{transform:translateY(3px);box-shadow:0 0 0 var(--ph-accent-shadow)}
.physical .ph-secondary{background:rgba(255,255,255,.6);border:1px solid #bdb59c}
.physical .ph-secondary:not(:disabled):active,.physical .ph-choice:not(:disabled):active{transform:scale(.97)}
.physical .ph-choice{background:#fff;border:1px solid #bdb59c;font-size:18px}
@media(hover:hover){
  .physical .ph-primary:not(:disabled):hover{background:#ffc61a}
  .physical .ph-secondary:not(:disabled):hover,.physical .ph-choice:not(:disabled):hover{background:#f1ead3}
}

/* ── controls ── */
.physical .ph-controls{display:grid;gap:8px}
.physical .ph-pedals{display:grid;grid-template-columns:1fr 1fr;gap:12px}
.physical .ph-pedal{min-height:clamp(96px,15svh,140px);border-radius:16px;color:#fff;font-size:21px;font-weight:900;touch-action:none;
  box-shadow:0 5px 0 rgba(0,0,0,.28)}
.physical .ph-pedal[data-key="brake"]{background:var(--ph-bad)}
.physical .ph-pedal[data-key="throttle"]{background:#3d4140}
.physical .ph-pedal[data-held]{transform:translateY(4px);box-shadow:0 1px 0 rgba(0,0,0,.28);filter:brightness(.9)}
.physical .ph-pedal:active{transform:translateY(4px);box-shadow:0 1px 0 rgba(0,0,0,.28)}
.physical .ph-field{display:grid;grid-template-columns:1fr 1fr;gap:12px}
.physical .ph-col{display:grid;gap:6px;padding:4px;border-radius:12px}
.physical .ph-col[data-picked]{background:var(--ph-accent-soft,#fdf0c4)}
.physical .ph-col-head{text-align:center;font-size:12.5px;font-weight:800;color:var(--ph-muted)}
.physical .ph-col .ph-choice{min-height:48px}
.physical .ph-colours{display:grid;grid-template-columns:repeat(3,1fr);gap:10px}
.physical .ph-colours .ph-choice{min-height:68px;font-size:22px}
.physical .ph-nudge{display:grid;grid-template-columns:1fr 1fr;gap:8px}
.physical .ph-nudge .ph-btn{touch-action:none}
.physical .ph-nudge .ph-btn[data-fine]{min-height:46px;font-size:14px}
.physical .ph-nudge .ph-icon{width:20px;height:20px}
.physical .ph-keys{display:none;margin:0;text-align:center;font-size:11.5px;color:var(--ph-muted)}
@media(hover:hover) and (pointer:fine){
  .physical .ph-keys{display:block}
}
.physical .ph-actions{display:grid;grid-template-columns:repeat(auto-fit,minmax(140px,1fr));gap:8px}

/* ── larger screens and short landscape phones ── */
@media(min-width:700px){
  .physical{padding-top:16px;gap:10px}
  .physical .ph-canvas{height:clamp(260px,42vh,420px)}
}
@media(orientation:landscape) and (max-height:520px){
  .physical .ph-canvas{height:clamp(150px,46vh,240px)}
  .physical .ph-line{min-height:0}
  .physical .ph-pedal{min-height:84px}
}
@media(prefers-reduced-motion:reduce){
  .physical .ph-btn{transition:none}
}
