:root {
  --bone-background: #f3ebdd;
  --bone-surface: #fffdf8;
  --bone-border: #d8cbb8;
  --ink-primary: #292823;
  --ink-muted: #71685d;
  --accent-sage: #52675b;
  --accent-sage-light: #e2e9e0;
  --success: #476b50;
  --error: #985647;
  --shadow: 0 20px 50px rgb(73 57 37 / 0.1);
  color: var(--ink-primary);
  background: var(--bone-background);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Noto Sans Thai", "Tahoma", sans-serif;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: radial-gradient(circle at 15% 0%, #fffdf8 0, transparent 35rem), var(--bone-background);
}

button, input, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
  outline: 3px solid var(--accent-sage);
  outline-offset: 3px;
}

.page-shell { width: min(100% - 2.5rem, 72rem); min-height: 100vh; margin: 0 auto; display: flex; flex-direction: column; }
.site-header, footer { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.site-header { padding: 1.75rem 0 1rem; }
.brand { display: inline-flex; align-items: center; gap: .65rem; color: var(--ink-primary); font-weight: 760; letter-spacing: -.025em; text-decoration: none; }
.brand-mark { display: grid; width: 2rem; height: 2rem; place-items: center; border: 1px solid var(--bone-border); border-radius: 50%; background: var(--bone-surface); color: var(--accent-sage); }
.eyebrow { margin: 0; color: var(--ink-muted); font-size: .76rem; font-weight: 760; letter-spacing: .12em; text-transform: uppercase; }
main { flex: 1; display: grid; align-items: center; padding: 2rem 0 3rem; }
.screen { width: 100%; }
.setup-screen { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(23rem, .95fr); gap: 2rem; align-items: start; }
.intro-copy { padding: 2.5rem 1rem 1rem 0; }
h1, h2, p { margin-top: 0; }
h1 { max-width: 12ch; margin-bottom: 1.25rem; font-size: clamp(2.5rem, 5vw, 4.8rem); line-height: .98; letter-spacing: -.06em; }
.intro-copy > p:last-child, .results-heading > p:last-child { max-width: 48ch; color: var(--ink-muted); font-size: 1.05rem; line-height: 1.65; }
.setup-card, .method-note, .results-content > *, .summary-card { border: 1px solid var(--bone-border); border-radius: 1.25rem; background: color-mix(in srgb, var(--bone-surface) 92%, transparent); box-shadow: var(--shadow); }
.setup-card { padding: 1.5rem; }
fieldset { min-width: 0; margin: 0 0 1.4rem; padding: 0; border: 0; }
legend { margin-bottom: .65rem; font-weight: 760; }
.choice-grid { display: grid; gap: .7rem; }
.choice-grid--three { grid-template-columns: repeat(3, 1fr); }
.choice-grid--two { grid-template-columns: repeat(2, 1fr); }
.choice-card { min-height: 6.75rem; padding: .9rem; border: 1px solid var(--bone-border); border-radius: .9rem; background: #fffefa; transition: border-color .15s ease, background .15s ease, transform .15s ease; }
.choice-card:has(input:checked) { border-color: var(--accent-sage); background: var(--accent-sage-light); }
.choice-card:hover { transform: translateY(-1px); }
.choice-card input { accent-color: var(--accent-sage); }
.choice-card span, .choice-card small { display: block; }
.choice-card span { margin: .4rem 0 .25rem; font-weight: 740; }
.choice-card small { color: var(--ink-muted); line-height: 1.35; }
.form-row { margin-bottom: 1.4rem; }
.form-row label, .key-inputs label { display: grid; gap: .45rem; font-weight: 720; }
select, .key-inputs input { min-height: 2.75rem; border: 1px solid var(--bone-border); border-radius: .7rem; padding: .5rem .7rem; color: var(--ink-primary); background: #fffefa; }
.key-settings { margin-bottom: 1.4rem; padding: 1rem; border-radius: .9rem; background: #f8f1e6; }
.key-settings > p { margin-bottom: .85rem; color: var(--ink-muted); font-size: .9rem; line-height: 1.45; }
.key-inputs { display: grid; grid-template-columns: repeat(2, 1fr); gap: .7rem; }
.key-inputs input { width: 100%; text-align: center; text-transform: uppercase; font-weight: 800; }
.button { min-height: 3rem; border: 0; border-radius: .8rem; padding: .7rem 1rem; font-weight: 760; transition: transform .15s ease, background .15s ease; }
.button:hover { transform: translateY(-1px); }
.button--primary { width: 100%; background: var(--accent-sage); color: #fff; }
.button--primary:hover { background: #425648; }
.form-error { margin-bottom: 1rem; color: var(--error); font-weight: 700; }
.method-note { align-self: end; margin: 0; padding: 1.35rem 1.5rem; color: var(--ink-muted); box-shadow: none; }
.method-note h2 { margin-bottom: .75rem; color: var(--ink-primary); font-size: 1rem; }
.method-note ol { padding-left: 1.25rem; line-height: 1.6; }
.method-note p { margin-bottom: 0; font-size: .85rem; }

.activity-screen { display: grid; min-height: 39rem; grid-template-rows: auto auto 1fr auto auto; }
.activity-header { display: flex; justify-content: space-between; gap: 1rem; align-items: end; }
.activity-header h1 { max-width: none; margin: .4rem 0 0; font-size: clamp(2rem, 4vw, 3.5rem); }
.progress-text { margin: 0 0 .4rem; color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.activity-instruction, .response-hint { margin: 1rem 0; color: var(--ink-muted); }
.feedback { min-height: 1.5rem; color: var(--accent-sage); font-weight: 740; text-align: center; }
.feedback.is-error { color: var(--error); }
.trial-stage { display: grid; min-height: 20rem; grid-template-columns: 1fr 1fr; gap: clamp(1rem, 6vw, 6rem); align-items: center; padding: 1rem 0; }
.direction-card { display: grid; min-height: 11rem; width: min(100%, 25rem); place-items: center; border: 1px solid var(--bone-border); border-radius: 1.5rem; background: var(--bone-surface); box-shadow: var(--shadow); }
.direction-card--left { grid-column: 1; justify-self: end; }
.direction-card--right { grid-column: 2; justify-self: start; }
.direction-word { font-size: clamp(2.5rem, 7vw, 5.5rem); font-weight: 850; letter-spacing: -.05em; }
.response-area { display: grid; justify-items: center; }
.response-hint { min-height: 1.5rem; text-align: center; }
.mouse-responses { display: grid; width: min(100%, 22rem); gap: .65rem; }
.button--response { border: 1px solid var(--bone-border); background: var(--bone-surface); color: var(--ink-primary); }
.button--response:hover { border-color: var(--accent-sage); background: var(--accent-sage-light); }
.text-button { justify-self: center; border: 0; border-bottom: 1px solid currentColor; padding: .2rem; color: var(--ink-muted); background: transparent; }

.results-heading { margin-bottom: 1.75rem; }
.results-heading h1 { max-width: none; margin: .35rem 0 1rem; }
.results-content { display: grid; gap: 1rem; }
.overview-card, .language-card { padding: 1.3rem; }
.overview-card h2, .language-card h2 { margin-bottom: .25rem; font-size: 1.3rem; }
.overview-card p, .language-card > p { margin-bottom: 0; color: var(--ink-muted); }
.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .65rem; margin-top: 1rem; }
.metric { padding: .85rem; border-radius: .8rem; background: #f8f1e6; }
.metric span, .metric strong { display: block; }
.metric span { color: var(--ink-muted); font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.metric strong { margin-top: .3rem; font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.results-screen > .button { width: auto; min-width: 15rem; margin-top: 1.5rem; }
footer { padding: 1.2rem 0 1.75rem; color: var(--ink-muted); font-size: .8rem; }

@media (max-width: 760px) {
  .page-shell { width: min(100% - 1.5rem, 72rem); }
  .site-header, footer { align-items: flex-start; flex-direction: column; }
  .setup-screen { grid-template-columns: 1fr; }
  .intro-copy { padding: 1rem 0; }
  .choice-grid--three { grid-template-columns: 1fr; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .activity-screen { min-height: 34rem; }
  .trial-stage { min-height: 16rem; gap: .75rem; }
  .direction-card { min-height: 8rem; border-radius: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
