:root {
  color-scheme: light;
  --paper: #f5f2e9;
  --paper-soft: #fffefa;
  --ink: #202c29;
  --muted: #6d7972;
  --faint: #8b968f;
  --line: #dcded4;
  --accent: #d84d49;
  --accent-strong: #b83d3a;
  --green: #34775c;
  --yellow: #bd8a20;
  --shadow: #1d2a2716;
  --color-red: #c83e42;
  --color-orange: #a94d13;
  --color-yellow: #886500;
  --color-green: #18734c;
  --color-blue: #2869a2;
  --color-purple: #7950a7;
  --sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --display: 'Arial Rounded MT Bold', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: ui-monospace, 'Cascadia Code', 'Segoe UI Mono', Consolas, monospace;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #161c1b;
  --paper-soft: #202927;
  --ink: #edf0e7;
  --muted: #b2bdb5;
  --faint: #98a59c;
  --line: #39443e;
  --accent: #ff7771;
  --accent-strong: #ff9891;
  --green: #76c99b;
  --yellow: #f3cb68;
  --shadow: #00000038;
  --color-red: #ff7777;
  --color-orange: #ff9b62;
  --color-yellow: #f5d467;
  --color-green: #75d29d;
  --color-blue: #81bcff;
  --color-purple: #c19aff;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background-color: var(--paper);
  background-image: radial-gradient(color-mix(in srgb, var(--muted) 25%, transparent) .65px, transparent .65px);
  background-size: 17px 17px;
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  transition: background-color .2s ease, color .2s ease;
}
button, select, input { font: inherit; }
button:focus-visible, select:focus-visible, input:focus-visible, a:focus-visible { outline: 3px solid var(--green); outline-offset: 3px; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.page-shell { width: min(100% - 64px, 1120px); min-height: 100vh; margin: 0 auto; display: flex; flex-direction: column; }
.site-header { min-height: 80px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); }
.wordmark { display: inline-flex; gap: 10px; align-items: center; color: var(--ink); text-decoration: none; font-family: var(--display); font-size: 20px; font-weight: 750; letter-spacing: -1px; }
.wordmark-period { color: var(--accent); }
.wordmark-mark { position: relative; display: inline-flex; width: 23px; height: 23px; align-items: center; justify-content: center; }
.wordmark-mark span { position: absolute; width: 8px; height: 18px; border: 2px solid var(--accent); border-radius: 9px; transform: rotate(45deg); }
.wordmark-mark span:nth-child(2) { transform: rotate(-45deg); border-color: var(--green); }
.wordmark-mark span:nth-child(3) { width: 5px; height: 5px; border: 0; background: var(--yellow); border-radius: 50%; }
.header-controls { display: flex; align-items: center; gap: 8px; }
.select-wrap { position: relative; display: inline-flex; align-items: center; gap: 5px; }
.select-wrap::before { color: var(--faint); font-family: var(--mono); font-size: 11px; }
.select-wrap:first-child::before { content: '◐'; }
.select-wrap.language-wrap::before { content: 'A'; font-weight: 700; }
.select-wrap::after { position: absolute; top: 50%; right: 9px; color: var(--faint); content: '⌄'; font-size: 12px; pointer-events: none; transform: translateY(-56%); }
.select-wrap select { width: 120px; max-width: 120px; appearance: none; border: 1px solid var(--line); border-radius: 5px; padding: 8px 25px 8px 10px; color: var(--muted); background: var(--paper-soft); cursor: pointer; font-size: 11px; transition: border-color .15s ease, box-shadow .15s ease; }
.select-wrap select:hover, .select-wrap select:focus-visible { border-color: var(--faint); box-shadow: inset 0 0 0 1px var(--faint); }
.language-picker { position: relative; }
.language-trigger { width: 135px; height: 37px; display: flex; align-items: center; gap: 7px; border: 1px solid var(--line); border-radius: 5px; padding: 0 9px; color: var(--muted); background: var(--paper-soft); cursor: pointer; text-align: left; font-size: 11px; transition: border-color .15s ease, box-shadow .15s ease; }
.language-trigger:hover, .language-trigger:focus-visible { border-color: var(--faint); box-shadow: inset 0 0 0 1px var(--faint); }
.language-current { overflow: hidden; flex: 1; text-overflow: ellipsis; white-space: nowrap; }
.language-chevron { color: var(--faint); font-size: 12px; }
.language-flag { width: 18px; height: 12px; flex: 0 0 auto; border: 1px solid color-mix(in srgb, var(--ink) 12%, transparent); border-radius: 2px; object-fit: cover; }
.language-menu { position: absolute; z-index: 20; top: calc(100% + 7px); right: 0; width: 150px; max-height: min(65vh, 390px); overflow-y: auto; border: 1px solid var(--line); border-radius: 7px; padding: 5px; background: var(--paper-soft); box-shadow: 0 10px 30px var(--shadow); }
.language-option { width: 100%; min-height: 31px; display: grid; grid-template-columns: 20px minmax(0, 1fr) 14px; align-items: center; gap: 8px; border: 1px solid transparent; border-radius: 4px; padding: 4px 6px; color: var(--ink); background: transparent; cursor: pointer; text-align: start; font-size: 11px; }
.language-option [lang="ar"] { direction: ltr; text-align: left; }
:root[dir="rtl"] .language-option [lang="ar"] { direction: rtl; text-align: right; }
.language-option:hover, .language-option:focus-visible { border-color: var(--faint); background: color-mix(in srgb, var(--paper) 60%, var(--paper-soft)); }
.language-option[aria-selected="true"] { color: var(--accent-strong); font-weight: 650; }
.language-check { opacity: 0; color: var(--accent); text-align: center; }
.language-option[aria-selected="true"] .language-check { opacity: 1; }
.auto-language-icon { width: 18px; color: var(--faint); text-align: center; font-size: 17px; line-height: 12px; }

main { flex: 1; display: flex; }
.intro-screen { width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) 390px; align-content: center; align-items: center; column-gap: 72px; padding: 48px 5% 35px; }
.intro-copy { position: relative; z-index: 1; }
.eyebrow { display: flex; align-items: center; gap: 9px; margin: 0 0 19px; color: var(--muted); font-family: var(--mono); font-size: 10px; letter-spacing: .09em; text-transform: uppercase; }
.eyebrow-dot { width: 7px; height: 7px; flex: 0 0 auto; background: var(--accent); border-radius: 50%; box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 12%, transparent); }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 18px; font-family: var(--display); font-size: clamp(46px, 5.8vw, 70px); line-height: .99; letter-spacing: -4.5px; font-weight: 650; }
h1 > span { color: var(--accent); }
.intro-description { max-width: 450px; margin-bottom: 24px; color: var(--muted); font-size: 15px; line-height: 1.65; }
.round-picker { margin: 0 0 20px; border: 0; padding: 0; }
.round-picker legend { margin-bottom: 9px; color: var(--ink); font-size: 12px; font-weight: 700; }
.round-options { display: grid; grid-template-columns: repeat(4, minmax(65px, 1fr)); gap: 7px; max-width: 426px; }
.round-option, .custom-round { min-height: 57px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); background: var(--paper-soft); }
.round-option { cursor: pointer; transition: border-color .16s ease, background .16s ease; }
.round-option:hover, .custom-round:hover { border-color: var(--faint); }
.round-option.is-selected, .custom-round.is-selected { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); color: var(--ink); }
.round-option strong { font-family: var(--display); font-size: 17px; line-height: 1; }
.round-option span, .custom-round-top > span:last-child { font-size: 9px; }
.custom-round { padding: 3px 2px; cursor: pointer; }
.custom-round-top { display: flex; align-items: center; justify-content: center; gap: 4px; cursor: pointer; }
.custom-round-top input { width: 11px; height: 11px; margin: 0; accent-color: var(--accent); }
.custom-count { width: 100%; max-width: 72px; height: 27px; border: 0; border-radius: 0; padding: 0 2px; color: var(--ink); background: transparent; text-align: center; font-family: var(--display); font-size: 17px; font-weight: 700; line-height: 1; }
.round-help { min-height: 16px; margin: 7px 0 0; color: var(--faint); font-size: 10px; }
.round-help.is-error { color: var(--accent-strong); }
.button { min-height: 51px; display: inline-flex; align-items: center; justify-content: space-between; border: 0; border-radius: 6px; padding: 0 18px; cursor: pointer; font-size: 13px; font-weight: 700; transition: transform .16s ease, box-shadow .16s ease, background .16s ease; }
.button:hover { transform: translateY(-2px); }
.button-primary { color: #fff; background: #26342f; box-shadow: 0 5px 0 var(--shadow); }
:root[data-theme="dark"] .button-primary { color: #19221e; background: #dce7d9; }
.button-primary:hover { box-shadow: 0 7px 0 var(--shadow); }
.button-arrow { margin-left: 25px; font-size: 18px; font-weight: 400; }
.keyboard-note { margin: 9px 0 0; color: var(--faint); font-size: 10px; }
.record-preview { min-height: 16px; margin: 11px 0 0; color: var(--faint); font-size: 10px; }

.demo-card { position: relative; min-height: 290px; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; border: 1px solid var(--line); border-radius: 8px; padding: 19px 21px 18px; background: var(--paper-soft); box-shadow: 7px 8px 0 var(--shadow); transform: rotate(1.2deg); }
.demo-card::before { position: absolute; inset: 0; background: linear-gradient(135deg, transparent 48%, color-mix(in srgb, var(--paper) 65%, transparent) 48%, color-mix(in srgb, var(--paper) 65%, transparent) 49%, transparent 49%); content: ''; pointer-events: none; }
.demo-card-top { position: relative; display: flex; justify-content: space-between; color: var(--faint); font-family: var(--mono); font-size: 9px; letter-spacing: .1em; }
.demo-spark { color: var(--yellow); font-size: 18px; }
.demo-word { position: relative; align-self: center; margin-top: -4px; color: var(--color-red); font-family: var(--display); font-size: clamp(56px, 7vw, 81px); font-weight: 750; letter-spacing: .09em; }
.demo-caption { position: relative; display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 11px; }
.demo-caption-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--color-red); }
.demo-scribble { position: absolute; width: 36px; height: 36px; border: 1px solid color-mix(in srgb, var(--yellow) 45%, transparent); border-radius: 50%; }
.scribble-one { top: 70px; right: 28px; }.scribble-two { top: 75px; right: 34px; width: 26px; height: 26px; }
.intro-footer { grid-column: 1 / -1; display: flex; align-items: center; gap: 13px; margin-top: 39px; color: var(--muted); font-family: var(--mono); font-size: 10px; }
.footer-line { height: 1px; flex: 1; background: var(--line); }
.intro-footnote { grid-column: 1 / -1; max-width: 650px; margin: 11px auto 0; color: var(--faint); text-align: center; font-size: 11px; line-height: 1.65; }

.quiz-screen { width: min(100%, 760px); margin: 0 auto; padding: 37px 20px 48px; }
.quiz-topline { display: flex; align-items: center; justify-content: space-between; }
.text-button { display: inline-flex; align-items: center; gap: 8px; border: 0; padding: 6px 0; color: var(--muted); background: transparent; cursor: pointer; font-size: 12px; }
.text-button:hover, .footer-link:hover { color: var(--ink); }
.quiz-progress-label { color: var(--ink); font-family: var(--mono); font-size: 12px; }
.progress-divider { padding: 0 5px; color: var(--faint); }
.streak-pill { min-width: 85px; border: 1px solid var(--line); border-radius: 20px; padding: 7px 10px; color: var(--muted); text-align: center; font-size: 10px; }
.streak-pill > span:first-child { color: var(--yellow); }.streak-pill.is-active { border-color: color-mix(in srgb, var(--yellow) 55%, var(--line)); background: color-mix(in srgb, var(--yellow) 13%, var(--paper-soft)); }
.progress-track { height: 3px; overflow: hidden; margin: 15px 0 0; border-radius: 3px; background: var(--line); }
.progress-track > span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--accent); transition: width .25s ease; }
.question-area { display: flex; flex-direction: column; align-items: center; padding-top: 37px; text-align: center; }
.question-eyebrow { min-height: 12px; justify-content: center; margin-bottom: 9px; font-size: 9px; }
h2 { margin-bottom: 21px; font-family: var(--display); font-size: clamp(23px, 3.5vw, 30px); font-weight: 650; letter-spacing: -1px; }
.word-stage { position: relative; width: min(100%, 530px); min-height: 217px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 8px; background: var(--paper-soft); box-shadow: 4px 5px 0 var(--shadow); }
.color-word { font-family: var(--display); font-size: clamp(55px, 10vw, 90px); font-weight: 750; letter-spacing: .08em; user-select: none; }
.word-stage.pop .color-word { animation: pop .22s ease; }
.stage-corner { position: absolute; width: 13px; height: 13px; border-color: var(--line); border-style: solid; }
.corner-tl { top: 12px; left: 12px; border-width: 1px 0 0 1px; }.corner-br { right: 12px; bottom: 12px; border-width: 0 1px 1px 0; }
.answer-prompt { margin: 20px 0 11px; color: var(--muted); font-size: 11px; }
.answer-grid { width: min(100%, 530px); display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; direction: ltr; }
.answer-button { min-height: 48px; display: flex; align-items: center; justify-content: center; gap: 9px; border: 1px solid var(--line); border-radius: 6px; color: var(--ink); background: var(--paper-soft); cursor: pointer; font-size: 12px; font-weight: 650; transition: border-color .14s ease, transform .14s ease, background .14s ease; }
.answer-button:hover:not(:disabled) { transform: translateY(-2px); border-color: var(--faint); }
.answer-button:disabled { cursor: default; }
.answer-button.is-correct { border-color: var(--green); color: var(--green); background: color-mix(in srgb, var(--green) 12%, var(--paper-soft)); }
.answer-button.is-wrong { border-color: var(--accent); color: var(--accent-strong); background: color-mix(in srgb, var(--accent) 10%, var(--paper-soft)); }
.answer-key { width: 19px; height: 19px; display: inline-grid; place-items: center; border: 1px solid var(--line); border-radius: 4px; color: var(--faint); font-family: var(--mono); font-size: 10px; }
.answer-swatch { width: 9px; height: 9px; flex: 0 0 auto; border: 1px solid color-mix(in srgb, var(--ink) 18%, transparent); border-radius: 50%; }
.answer-button.is-correct .answer-key, .answer-button.is-wrong .answer-key { border-color: currentColor; color: inherit; }
.feedback { min-height: 19px; margin: 9px 0 0; color: var(--green); font-size: 11px; }
.feedback.is-wrong { color: var(--accent-strong); }

.result-screen { width: min(100%, 690px); margin: auto; padding: 45px 20px; text-align: center; }
.result-screen > .eyebrow { justify-content: center; }
.result-stamp { width: 49px; height: 49px; display: grid; place-items: center; margin: 0 auto 18px; border: 1px solid color-mix(in srgb, var(--yellow) 55%, var(--line)); border-radius: 50%; color: var(--yellow); background: color-mix(in srgb, var(--yellow) 12%, var(--paper-soft)); font-size: 23px; }
.result-screen h1 { margin-bottom: 9px; font-size: clamp(40px, 6.5vw, 57px); letter-spacing: -3px; }
.result-subtitle { margin-bottom: 23px; color: var(--muted); font-size: 13px; }
.score-card { display: flex; align-items: center; justify-content: space-around; gap: 8px; border: 1px solid var(--line); border-radius: 7px; margin-bottom: 11px; padding: 19px 10px; background: var(--paper-soft); }
.score-main, .score-detail { display: flex; flex-direction: column; align-items: center; gap: 7px; }
.score-label { color: var(--faint); font-family: var(--mono); font-size: 8px; letter-spacing: .07em; }
.score-value { color: var(--ink); font-family: var(--display); font-size: 33px; font-weight: 750; line-height: 1; }
.score-value span { color: var(--faint); font-size: 17px; font-weight: 500; }
.score-detail strong { color: var(--ink); font-family: var(--display); font-size: 19px; }
.score-divider { width: 1px; height: 34px; background: var(--line); }
.record-card { min-height: 24px; margin: 0 0 15px; color: var(--muted); font-size: 10px; line-height: 1.55; }
.record-card strong { color: var(--ink); font-weight: 650; }
.result-home { display: flex; margin: 10px auto 0; }

.site-footer { min-height: 58px; display: flex; align-items: center; gap: 9px; border-top: 1px solid var(--line); color: var(--faint); font-size: 10px; }
.site-footer > span:first-child { color: var(--muted); font-family: var(--display); font-weight: 700; }
.footer-separator { color: var(--line); }
.footer-links { display: flex; gap: 18px; margin-left: auto; }
.footer-link { border: 0; padding: 5px 0; color: var(--muted); background: transparent; cursor: pointer; font-size: 10px; }

.info-dialog { position: fixed; width: min(100% - 32px, 580px); max-height: min(82vh, 700px); overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; padding: clamp(22px, 5vw, 36px); color: var(--ink); background: var(--paper-soft); box-shadow: 0 18px 70px #0003; }
.info-dialog::backdrop { background: #151d1bb3; backdrop-filter: blur(3px); }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.dialog-heading .eyebrow { margin: 0; }
.dialog-close { position: relative; width: 32px; height: 32px; flex: 0 0 32px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; padding: 0; color: var(--muted); background: transparent; cursor: pointer; font-size: 0; line-height: 1; transition: transform .15s ease, border-color .15s ease, background .15s ease; }
.dialog-close:hover { transform: scale(1.06); border-color: var(--faint); background: color-mix(in srgb, var(--paper) 65%, var(--paper-soft)); }
.dialog-close::before, .dialog-close::after { position: absolute; width: 13px; height: 1.5px; border-radius: 2px; background: currentColor; content: ''; }
.dialog-close::before { transform: rotate(45deg); }.dialog-close::after { transform: rotate(-45deg); }
.info-dialog h2 { margin-bottom: 13px; font-size: 31px; }
.dialog-copy, .dialog-intro { color: var(--muted); font-size: 13px; line-height: 1.7; }
.dialog-copy p:last-child { margin-bottom: 16px; }
.external-link { color: var(--accent-strong); font-size: 12px; font-weight: 650; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.contact-dialog { width: min(100% - 32px, 680px); }
.contact-dialog h2 { margin-bottom: 6px; }
.dialog-intro { margin-bottom: 20px; }
.letterbird-container { min-height: 360px; }
.form-skeleton { min-height: 360px; display: grid; align-content: start; gap: 10px; padding-top: 2px; }
.skeleton-field, .skeleton-submit { display: block; height: 38px; border: 1px solid var(--line); border-radius: 5px; background: linear-gradient(100deg, var(--paper) 30%, color-mix(in srgb, var(--line) 60%, var(--paper-soft)) 50%, var(--paper) 70%); background-size: 220% 100%; animation: skeleton-shimmer 1.6s ease-in-out infinite; }
.skeleton-message { height: 112px; }
.skeleton-submit { width: 120px; height: 40px; margin-top: 4px; border-color: transparent; background: color-mix(in srgb, var(--ink) 13%, var(--paper-soft)); animation: none; }
.letterbird-placeholder { display: none; }
.letterbird-placeholder.is-error { display: block; color: var(--accent-strong); font-size: 12px; }
.contact-privacy { margin: 36px 0 0; color: var(--faint); font-size: 10px; text-align: center; }

@keyframes pop { 0% { transform: scale(.96); } 70% { transform: scale(1.025); } 100% { transform: scale(1); } }
@keyframes skeleton-shimmer { to { background-position-x: -220%; } }
@media (max-width: 820px) {
  .intro-screen { grid-template-columns: minmax(0, 1fr) 320px; column-gap: 36px; padding-inline: 2%; }
  .demo-card { min-height: 260px; }
}
@media (max-width: 680px) {
  .page-shell { width: min(100% - 36px, 510px); }
  .site-header { min-height: 69px; }.wordmark { font-size: 18px; }.header-controls { gap: 5px; }
  .select-wrap select { width: 104px; max-width: 104px; }
  .language-trigger { width: 119px; max-width: 119px; }
  .select-wrap select { padding: 7px 21px 7px 7px; font-size: 10px; }
  .language-trigger { height: 34px; gap: 5px; }
  .intro-screen { display: flex; flex-direction: column; align-items: stretch; justify-content: center; padding: 35px 2% 26px; }
  .eyebrow { margin-bottom: 15px; font-size: 9px; }
  h1 { font-size: clamp(43px, 11vw, 61px); letter-spacing: -3.4px; }
  .intro-description { margin-bottom: 19px; font-size: 13px; }
  .round-options { max-width: none; grid-template-columns: repeat(4, minmax(55px, 1fr)); gap: 6px; }
  .round-option, .custom-round { min-height: 53px; }
  .demo-card { min-height: 190px; margin: 28px 5px 0; padding: 14px 16px; }
  .demo-word { font-size: 57px; }.intro-footer { margin-top: 32px; }
  .intro-footnote { font-size: 10px; }
  .quiz-screen { padding: 25px 0 35px; }.question-area { padding-top: 32px; }.word-stage { min-height: 197px; }
  .answer-grid { gap: 7px; }.answer-button { min-height: 48px; gap: 6px; }
  .score-card { gap: 5px; padding-inline: 6px; }.score-label { font-size: 7px; letter-spacing: .03em; }.score-detail strong { font-size: 17px; }
  .site-footer { min-height: 53px; flex-wrap: wrap; gap: 6px; padding: 9px 0; font-size: 9px; }
  .footer-links { gap: 12px; }.footer-link { font-size: 9px; }
}
@media (max-width: 390px) {
  .page-shell { width: calc(100% - 28px); }.wordmark { gap: 6px; font-size: 16px; }.header-controls { gap: 3px; }
  .select-wrap select { width: 68px; max-width: 68px; padding: 7px 18px 7px 5px; font-size: 9px; }
  .language-trigger { width: 82px; max-width: 82px; padding: 7px 18px 7px 5px; font-size: 9px; }
  .language-trigger { height: 33px; gap: 4px; }
  .language-trigger .language-flag { width: 15px; height: 10px; }
  .round-option span, .custom-round-top > span:last-child { font-size: 8px; }
  .word-stage { min-height: 175px; }.color-word { font-size: 52px; }
  .footer-links { width: 100%; justify-content: center; margin: 2px 0 0; }
  .score-card { flex-wrap: wrap; row-gap: 14px; }.score-divider { height: 28px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
