:root {
  --paper: #f4efe4;
  --paper-deep: #e9e0d0;
  --ink: #20201d;
  --muted: #6e6a61;
  --line: rgba(42, 40, 35, .16);
  --red: #a83c2f;
  --red-dark: #7e2a23;
  --gold: #b68745;
  --white: #fffdf8;
  --shadow: 0 28px 80px rgba(55, 45, 30, .12);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: "PingFang HK", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  min-height: 100vh;
}
body.test-active { overflow: hidden; }
button, input, textarea { font: inherit; }
button { color: inherit; }
.paper-noise {
  position: fixed; inset: 0; pointer-events: none; opacity: .2; z-index: 9;
  background-image: repeating-linear-gradient(90deg, transparent 0 3px, rgba(70,50,20,.035) 4px), repeating-linear-gradient(0deg, transparent 0 5px, rgba(255,255,255,.2) 6px);
  mix-blend-mode: multiply;
}
.is-hidden { display: none !important; }

.site-header {
  height: 84px; padding: 0 clamp(24px, 5vw, 80px); display: flex; align-items: center;
  justify-content: space-between; border-bottom: 1px solid var(--line); position: relative; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand-seal, .ime-mark {
  display: grid; place-items: center; width: 42px; height: 42px; color: #fff8eb; background: var(--red);
  border-radius: 3px; font-family: "Songti TC", "STSong", serif; font-size: 24px; box-shadow: inset 0 0 0 2px rgba(255,255,255,.18);
}
.brand strong { display: block; font: 700 20px/1.1 "Songti TC", "STSong", serif; letter-spacing: .18em; }
.brand small { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; letter-spacing: .22em; }
nav { display: flex; align-self: stretch; gap: 34px; }
.nav-link { border: 0; background: none; padding: 0 4px; cursor: pointer; position: relative; color: var(--muted); font-size: 14px; }
.nav-link.active { color: var(--ink); }
.nav-link.active::after { content: ""; position: absolute; left: 2px; right: 2px; bottom: -1px; height: 2px; background: var(--red); }
.sound-toggle { border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,.25); padding: 8px 13px; cursor: pointer; font-size: 12px; }
.sound-dot { display: inline-block; width: 6px; height: 6px; margin-right: 5px; background: var(--red); border-radius: 50%; }
.sound-toggle[aria-pressed="false"] .sound-dot { background: #aaa49b; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.account-button { padding: 9px 14px; color: #fff; border: 0; border-radius: 999px; background: var(--ink); cursor: pointer; font-size: 11px; white-space: nowrap; }
.account-button.member { color: var(--red-dark); border: 1px solid rgba(168,60,47,.28); background: #f4e4df; }

.hero {
  min-height: calc(100vh - 84px); display: grid; grid-template-columns: minmax(0, 1fr) minmax(380px, 510px);
  gap: clamp(50px, 8vw, 130px); align-items: center; padding: 72px clamp(24px, 8vw, 130px) 90px; position: relative; overflow: hidden;
}
.hero::before {
  content: "倉"; position: absolute; left: -45px; bottom: -150px; font: 500 410px/1 "Songti TC", "STSong", serif;
  color: rgba(77, 68, 54, .035); transform: rotate(-8deg); pointer-events: none;
}
.hero::after { content: ""; position: absolute; top: 12%; right: -6%; width: 330px; height: 330px; border: 1px solid rgba(168,60,47,.1); border-radius: 50%; pointer-events: none; }
.hero-copy { position: relative; z-index: 1; max-width: 680px; }
.eyebrow { margin: 0 0 18px; color: var(--red); font-size: 12px; font-weight: 700; letter-spacing: .2em; }
.eyebrow span { display: inline-block; width: 28px; height: 1px; margin-right: 9px; vertical-align: middle; background: var(--red); }
.hero h1 { margin: 0; font: 500 clamp(54px, 6.7vw, 100px)/1.1 "Songti TC", "STSong", serif; letter-spacing: .02em; }
.hero h1 em { color: var(--red); font-style: normal; position: relative; }
.hero h1 em::after { content: ""; position: absolute; left: 2%; right: -2%; bottom: -10px; height: 8px; border-top: 2px solid var(--red); transform: rotate(-1deg); opacity: .55; }
.hero-lead { max-width: 540px; margin: 38px 0; color: var(--muted); font-size: 16px; line-height: 2; }
.hero-facts { display: flex; gap: clamp(28px, 5vw, 64px); }
.hero-facts div { display: grid; gap: 5px; }
.hero-facts strong { font: 500 26px/1 "Songti TC", "STSong", serif; }
.hero-facts span { color: var(--muted); font-size: 11px; letter-spacing: .12em; }

.setup-card { background: rgba(255,253,248,.72); border: 1px solid rgba(255,255,255,.65); padding: 34px; box-shadow: var(--shadow); position: relative; z-index: 2; backdrop-filter: blur(10px); }
.setup-card::before { content: ""; position: absolute; inset: 8px; border: 1px solid rgba(78,68,52,.08); pointer-events: none; }
.card-topline { display: flex; justify-content: space-between; color: var(--red); font-size: 11px; letter-spacing: .12em; }
.edition { color: var(--muted); }
.setup-card h2 { margin: 24px 0 22px; font: 600 27px/1.3 "Songti TC", "STSong", serif; }
.article-picker { margin-bottom: 16px; }
.article-picker > label { display: block; margin-bottom: 8px; color: var(--muted); font-size: 11px; letter-spacing: .08em; }
.article-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.article-options button { min-width: 0; padding: 10px 6px; border: 1px solid var(--line); background: rgba(244,239,228,.55); cursor: pointer; text-align: center; }
.article-options strong, .article-options small { display: block; }
.article-options strong { font-size: 11px; white-space: nowrap; }
.article-options small { margin-top: 4px; color: var(--muted); font-size: 8px; white-space: nowrap; }
.article-options button.selected { color: #fff; border-color: var(--ink); background: var(--ink); }
.article-options button.selected small { color: rgba(255,255,255,.68); }
.mode-switch { display: grid; gap: 10px; }
.mode-option { width: 100%; padding: 16px; display: grid; grid-template-columns: 44px 1fr 18px; align-items: center; gap: 13px; text-align: left; cursor: pointer; background: rgba(244,239,228,.6); border: 1px solid transparent; transition: .2s ease; }
.mode-option:hover { transform: translateX(3px); }
.mode-option.selected { border-color: rgba(168,60,47,.55); background: rgba(168,60,47,.055); }
.mode-icon { width: 40px; height: 40px; display: grid; place-items: center; background: var(--paper-deep); font: 500 18px "Songti TC", serif; }
.mode-option.selected .mode-icon { color: #fff; background: var(--red); }
.mode-option strong, .mode-option small { display: block; }
.mode-option strong { margin-bottom: 4px; font-size: 14px; }
.mode-option small { color: var(--muted); font-size: 11px; }
.mode-option i { width: 16px; height: 16px; border: 1px solid #aaa49a; border-radius: 50%; position: relative; }
.mode-option.selected i { border-color: var(--red); }
.mode-option.selected i::after { content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--red); }
.time-options { margin-top: 20px; }
.time-options > label, .name-field > span { display: block; margin-bottom: 9px; color: var(--muted); font-size: 11px; letter-spacing: .08em; }
.time-chips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.time-chips button { padding: 9px; border: 1px solid var(--line); background: transparent; cursor: pointer; font-size: 12px; }
.time-chips button.selected { color: #fff; background: var(--ink); border-color: var(--ink); }
.name-field { display: block; margin-top: 20px; }
.name-field small { color: #9b958c; }
.name-field input { width: 100%; padding: 12px 14px; border: 1px solid var(--line); outline: none; background: rgba(255,255,255,.44); }
.name-field input:focus { border-color: var(--red); box-shadow: 0 0 0 3px rgba(168,60,47,.08); }
.primary-button, .secondary-button { border: 0; min-height: 48px; padding: 0 22px; cursor: pointer; font-weight: 700; }
.primary-button { width: 100%; display: flex; justify-content: space-between; align-items: center; margin-top: 22px; color: #fff; background: var(--red); box-shadow: 0 9px 20px rgba(126,42,35,.16); }
.primary-button:hover { background: var(--red-dark); }
.primary-button span { font-size: 20px; font-weight: 400; }
.input-note { margin: 16px 0 0; color: var(--muted); text-align: center; font-size: 10px; }
.input-note span { color: var(--red); border: 1px solid rgba(168,60,47,.45); padding: 2px 3px; margin-right: 3px; }

.test-panel {
  height: calc(100dvh - 84px); min-height: 0; display: grid;
  grid-template-rows: auto 3px minmax(0, 1fr); overflow: hidden;
  background: #efe8dc; position: relative;
}
.test-toolbar { min-height: 92px; padding: 18px clamp(24px, 5vw, 75px); display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; border-bottom: 1px solid var(--line); background: rgba(255,253,248,.68); }
.test-toolbar > div:first-child strong, .status-live { display: block; }
.status-live { margin-bottom: 6px; color: var(--red); font-size: 10px; letter-spacing: .13em; }
.status-live i { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--red); animation: pulse 1.4s infinite; }
.status-live.waiting { color: var(--gold); }
.status-live.waiting i { background: var(--gold); animation: none; }
@keyframes pulse { 50% { opacity: .25; } }
.test-toolbar > div:first-child strong { font: 600 17px "Songti TC", serif; }
.live-metrics { display: flex; align-items: center; }
.live-metrics > div { min-width: 118px; padding: 0 28px; text-align: center; border-left: 1px solid var(--line); }
.live-metrics > div:last-child { border-right: 1px solid var(--line); }
.live-metrics span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 10px; }
.live-metrics strong { font: 500 20px "Songti TC", serif; }
.live-metrics strong b { font: inherit; }
.quit-button { justify-self: end; border: 1px solid var(--line); background: transparent; padding: 9px 15px; cursor: pointer; font-size: 11px; }
.test-actions { justify-self: end; display: flex; gap: 7px; }
.pause-button { padding: 9px 15px; color: var(--red-dark); border: 1px solid rgba(168,60,47,.35); background: #f4e4df; cursor: pointer; font-size: 11px; }
.pause-overlay { position: fixed; inset: 84px 0 0; z-index: 30; display: grid; place-content: center; justify-items: center; color: #f4efe4; background: #252521; text-align: center; }
.pause-seal { width: 62px; height: 62px; display: grid; place-items: center; color: #fff; background: var(--red); font: 500 30px "Songti TC", serif; transform: rotate(-3deg); }
.pause-overlay p { margin: 22px 0 8px; color: var(--gold); font-size: 11px; letter-spacing: .18em; }
.pause-overlay h2 { margin: 0 0 26px; font: 500 clamp(27px, 4vw, 45px) "Songti TC", serif; }
.pause-overlay .primary-button { width: 210px; margin: 0; }
.test-panel.paused .typing-stage { opacity: .08; filter: blur(18px); pointer-events: none; user-select: none; }
.progress-track { height: 3px; background: rgba(0,0,0,.07); }
.progress-track span { display: block; height: 100%; width: 0; background: var(--red); transition: width .2s ease; }
.typing-stage {
  width: min(1600px, calc(100% - clamp(32px, 8vw, 120px))); height: 100%; min-height: 0;
  margin: 0 auto; padding: 26px 0 18px; display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto; gap: 16px; overflow: hidden;
}
.poem-heading { display: flex; justify-content: space-between; align-items: end; margin: 0; }
.poem-heading span { color: var(--muted); font-size: 11px; letter-spacing: .15em; }
.poem-heading h2 { margin: 7px 0 0; font: 500 35px "Songti TC", serif; letter-spacing: .14em; }
.poem-heading p { color: var(--muted); font-size: 12px; }
.poem-heading p b { color: var(--red); font-size: 20px; }
.poem-heading-tools { display: flex; align-items: center; justify-content: flex-end; gap: 12px; flex-wrap: wrap; }
.poem-heading-tools p { margin: 0; white-space: nowrap; }
.text-size-controls {
  display: inline-flex; align-items: center; overflow: hidden;
  border: 1px solid var(--line); border-radius: 999px; background: rgba(255,253,248,.72);
}
.text-size-controls button {
  width: 39px; height: 34px; padding: 0; color: var(--ink); border: 0; background: transparent;
  cursor: pointer; font-size: 12px; font-weight: 700;
}
.text-size-controls button:hover:not(:disabled) { color: #fff; background: var(--red); }
.text-size-controls button:focus-visible { outline: 2px solid var(--red); outline-offset: -3px; }
.text-size-controls button:disabled { color: #aaa49b; cursor: not-allowed; opacity: .55; }
.text-size-controls span {
  min-width: 47px; color: var(--red-dark); border-right: 1px solid var(--line); border-left: 1px solid var(--line);
  font: 700 10px/34px ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0; text-align: center;
}
.poem-text {
  min-height: 0; padding: 34px 46px; overflow-y: auto; overscroll-behavior: contain;
  scrollbar-gutter: stable; background: rgba(255,253,248,.66);
  border: 1px solid rgba(255,255,255,.7); box-shadow: 0 20px 60px rgba(60,45,25,.07);
  font: 400 clamp(20px,2.3vw,28px)/2.25 "Songti TC", "STSong", serif; letter-spacing: .16em;
}
.poem-text[data-text-size="small"] { font-size: clamp(16px, 1.85vw, 22px); line-height: 2.3; }
.poem-text[data-text-size="medium"] { font-size: clamp(20px, 2.3vw, 28px); line-height: 2.25; }
.poem-text[data-text-size="large"] { font-size: clamp(24px, 2.85vw, 35px); line-height: 2.05; }
.poem-text[data-text-size="xlarge"] { font-size: clamp(28px, 3.4vw, 42px); line-height: 1.9; }
.poem-text[data-text-size="size-175"] { font-size: clamp(35px, 4vw, 49px); line-height: 1.8; }
.poem-text[data-text-size="size-200"] { font-size: clamp(40px, 4.6vw, 56px); line-height: 1.7; }
.poem-text[data-text-size="size-225"] { font-size: clamp(45px, 5.2vw, 63px); line-height: 1.6; }
.poem-text[data-text-size="size-250"] { font-size: clamp(50px, 5.8vw, 70px); line-height: 1.5; }
.poem-text[data-text-size="size-275"] { font-size: clamp(55px, 6.35vw, 77px); line-height: 1.42; }
.poem-text[data-text-size="size-300"] { font-size: clamp(60px, 6.9vw, 84px); line-height: 1.35; }
.poem-line { display: block; }
.poem-char { display: inline-block; min-width: .95em; text-align: center; border-bottom: 2px solid transparent; transition: .15s ease; }
.poem-char.done { color: #aaa195; }
.poem-char.current { color: var(--red); background: rgba(168,60,47,.08); border-bottom-color: var(--red); transform: translateY(-2px); }
.poem-char.error { color: #fff; background: var(--red); animation: shake .22s linear; }
.punctuation { color: #9a9388; letter-spacing: 0; }
@keyframes shake { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
.ime-console {
  width: 100%; margin: 0; border: 1px solid rgba(168,60,47,.36);
  background: var(--white); position: relative; box-shadow: 0 14px 40px rgba(60,45,25,.14);
  z-index: 3; isolation: isolate;
}
.ime-composer { min-height: 66px; padding: 12px 16px; display: flex; align-items: center; gap: 13px; cursor: text; position: relative; background: var(--white); }
.ime-mark { width: 36px; height: 36px; font-size: 18px; flex: 0 0 auto; }
.code-readout { min-width: 0; flex: 1; }
.code-readout span, .code-readout strong { display: block; }
.code-readout span { color: var(--red); font: 700 16px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .18em; text-transform: uppercase; }
.code-readout strong { margin-top: 5px; font: 500 13px "Songti TC", serif; letter-spacing: .12em; }
.ime-hints { display: flex; align-items: center; gap: 14px; color: var(--muted); font-size: 9px; white-space: nowrap; }
.ime-hints kbd { padding: 2px 5px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 3px; background: var(--paper); font: 9px ui-monospace, monospace; }
.hint-button { flex: 0 0 auto; padding: 8px 13px; color: #fff; border: 0; border-radius: 2px; background: var(--red); cursor: pointer; font-size: 11px; font-weight: 700; animation: hintIn .22s ease both; }
.hint-button:hover { background: var(--red-dark); }
.poem-hint-button {
  min-height: 34px; padding: 8px 17px; border-radius: 999px; letter-spacing: .08em;
  box-shadow: 0 5px 14px rgba(168,60,47,.24);
}
@keyframes hintIn { from { opacity: 0; transform: translateY(4px); } }
.ime-composer input { position: absolute; opacity: .01; width: 2px; height: 2px; left: 62px; bottom: 8px; border: 0; }
.candidate-list { min-height: 46px; padding: 8px 15px; display: flex; gap: 7px; align-items: center; overflow-x: auto; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--paper); }
.candidate-empty { color: #9b958c; font-size: 10px; }
.candidate { flex: 0 0 auto; min-width: 42px; padding: 6px 8px; display: inline-flex; align-items: center; justify-content: center; gap: 5px; border: 1px solid transparent; background: var(--white); font: 500 18px "Songti TC", serif; }
.candidate b { color: #9c968d; font: 8px sans-serif; }
.candidate.target { color: var(--red); border-color: rgba(168,60,47,.45); background: #f4e4df; }
.hint-panel { padding: 11px 15px; color: var(--red-dark); border-bottom: 1px solid rgba(168,60,47,.2); background: #f4e4df; font: 600 13px "Songti TC", serif; letter-spacing: .08em; text-align: center; }
.hint-panel b { margin: 0 4px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .14em; }
.root-keyboard { padding: 9px 14px 11px; display: grid; grid-template-columns: repeat(13, minmax(0, 1fr)); gap: 4px; background: var(--white); }
.root-key { min-width: 0; padding: 5px 2px; display: grid; place-items: center; gap: 2px; border: 1px solid rgba(45,42,36,.11); background: #f8f4ec; color: var(--muted); }
.root-key b { font: 700 8px ui-monospace, monospace; }
.root-key span { color: var(--ink); font: 500 13px "Songti TC", serif; }
.root-key.active { color: #fff; border-color: var(--red); background: var(--red); transform: translateY(1px); }
.root-key.active span { color: #fff; }
.ime-console.invalid { animation: shake .22s linear; border-color: var(--red); }
.ime-warning { margin: 0; padding: 7px 14px; color: #fff; background: var(--red); font-size: 10px; text-align: center; }

.results-section { min-height: calc(100vh - 84px); padding: 100px clamp(24px, 8vw, 130px); background: #252521; color: #f4efe4; }
.section-heading { display: flex; justify-content: space-between; align-items: end; gap: 30px; margin-bottom: 44px; }
.section-heading h2 { margin: 0; font: 500 clamp(32px,4vw,54px) "Songti TC", serif; }
.section-heading > p { margin: 0; color: #aaa69d; font-size: 12px; line-height: 1.8; }
.member-area { margin-bottom: 20px; }
.guest-callout, .member-summary { padding: 22px 26px; border: 1px solid rgba(255,255,255,.1); background: rgba(255,255,255,.035); }
.guest-callout { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.guest-callout strong, .guest-callout span { display: block; }
.guest-callout strong { font: 500 18px "Songti TC", serif; }
.guest-callout span { margin-top: 5px; color: #8f8a81; font-size: 10px; }
.guest-callout button, .member-summary-head button { padding: 9px 14px; color: #fff3dd; border: 1px solid rgba(255,255,255,.14); background: transparent; cursor: pointer; font-size: 10px; }
.member-summary-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.member-summary-head span, .mistake-lab-head > div > span { color: var(--gold); font-size: 9px; letter-spacing: .17em; }
.member-summary-head h3 { margin: 5px 0 0; font: 500 22px "Songti TC", serif; }
.member-stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); }
.member-stat-grid div { padding: 7px 18px; border-left: 1px solid rgba(255,255,255,.09); }
.member-stat-grid div:first-child { border-left: 0; padding-left: 0; }
.member-stat-grid strong, .member-stat-grid span { display: block; }
.member-stat-grid strong { color: #fff3dd; font: 500 30px "Songti TC", serif; }
.member-stat-grid span { margin-top: 4px; color: #88837b; font-size: 9px; }
.mistake-lab { margin-bottom: 20px; padding: 28px; border: 1px solid rgba(255,255,255,.1); background: rgba(255,255,255,.035); }
.mistake-lab-head { display: flex; align-items: end; justify-content: space-between; gap: 20px; }
.mistake-lab-head h3 { margin: 5px 0 0; font: 500 23px "Songti TC", serif; }
.mistake-scopes { display: flex; border: 1px solid rgba(255,255,255,.11); }
.mistake-scopes button { padding: 8px 12px; color: #8f8a81; border: 0; background: transparent; cursor: pointer; font-size: 10px; }
.mistake-scopes button.selected { color: #252521; background: #e9e0d0; }
.mistake-list { min-height: 84px; margin: 21px 0 18px; display: flex; flex-wrap: wrap; gap: 8px; align-content: flex-start; }
.mistake-list > p { width: 100%; margin: auto; color: #77736d; text-align: center; font-size: 11px; }
.mistake-chip { min-width: 72px; padding: 10px 12px; color: #f4efe4; border: 1px solid rgba(255,255,255,.1); background: #30302b; text-align: center; }
.mistake-chip strong { display: block; font: 500 25px "Songti TC", serif; }
.mistake-chip span { display: block; margin-top: 4px; color: #928d84; font-size: 8px; }
.mistake-practice-button { width: 100%; min-height: 44px; padding: 0 16px; display: flex; align-items: center; justify-content: space-between; color: #fff; border: 0; background: var(--red); cursor: pointer; font-weight: 700; }
.mistake-practice-button:disabled { opacity: .35; cursor: not-allowed; }
.results-grid { display: grid; grid-template-columns: 270px 1fr; gap: 20px; }
.result-card { border: 1px solid rgba(255,255,255,.1); background: rgba(255,255,255,.035); }
.best-card { min-height: 290px; padding: 30px; display: flex; flex-direction: column; justify-content: center; text-align: center; position: relative; }
.card-kicker { position: absolute; top: 20px; left: 22px; color: var(--gold); font-size: 10px; letter-spacing: .16em; }
.best-card strong { color: #fff3dd; font: 500 72px/1 "Songti TC", serif; }
.best-card small { margin-top: 7px; color: #8f8a81; font-size: 10px; letter-spacing: .12em; }
.best-card p { margin: 27px 0 0; color: #c8c2b8; font-size: 12px; }
.table-card { padding: 25px 28px; }
.table-head { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid rgba(255,255,255,.09); padding-bottom: 17px; }
.table-head h3 { margin: 0; font: 500 18px "Songti TC", serif; }
.table-head button { color: #aaa69d; background: transparent; border: 0; cursor: pointer; font-size: 11px; }
.result-row { display: grid; grid-template-columns: 36px 1fr 110px 90px; align-items: center; min-height: 56px; border-bottom: 1px solid rgba(255,255,255,.07); font-size: 12px; }
.result-row:last-child { border-bottom: 0; }
.rank { color: var(--gold); font: 500 17px "Songti TC", serif; }
.result-player strong, .result-player small { display: block; }
.result-player small { margin-top: 3px; color: #7e7a73; font-size: 9px; }
.result-mode { color: #aaa69d; }
.result-speed { text-align: right; color: #fff3dd; font: 500 18px "Songti TC", serif; }
.result-speed small { color: #7e7a73; font: 9px sans-serif; }
.empty-results { min-height: 180px; display: grid; place-items: center; color: #77736d; font-size: 12px; text-align: center; }

.result-dialog, .ready-dialog { width: min(530px, calc(100% - 28px)); padding: 45px; color: var(--ink); background: var(--white); border: 0; box-shadow: 0 30px 100px rgba(0,0,0,.3); }
.result-dialog { max-height: calc(100dvh - 28px); overflow-y: auto; text-align: center; }
.result-dialog::backdrop, .ready-dialog::backdrop { background: rgba(28,27,24,.72); backdrop-filter: blur(4px); }
.dialog-close { position: absolute; top: 12px; right: 15px; border: 0; background: none; font-size: 24px; color: #8e887f; cursor: pointer; }
.result-dialog .eyebrow { text-align: left; }
.grade-seal { width: 58px; height: 58px; margin: 6px auto 18px; display: grid; place-items: center; color: #fff; background: var(--red); font: 500 29px "Songti TC", serif; transform: rotate(-4deg); box-shadow: inset 0 0 0 3px rgba(255,255,255,.22); }
.result-dialog h2 { margin: 0; font: 600 32px "Songti TC", serif; }
.result-dialog > p { color: var(--muted); }
.score-main { margin: 25px 0; }
.score-main strong { display: block; color: var(--red); font: 500 80px/.9 "Songti TC", serif; }
.score-main span { color: var(--muted); font-size: 10px; letter-spacing: .16em; }
.score-details { display: grid; grid-template-columns: repeat(4, 1fr); padding: 17px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.score-details div + div { border-left: 1px solid var(--line); }
.score-details span, .score-details strong { display: block; }
.score-details span { color: var(--muted); font-size: 9px; }
.score-details strong { margin-top: 5px; font: 500 18px "Songti TC", serif; }
.result-rewards { display: grid; grid-template-columns: repeat(var(--reward-columns, 3), minmax(0, 1fr)); gap: 8px; margin-top: 12px; text-align: left; }
.result-rewards > div { min-width: 0; padding: 11px 12px; border: 1px solid rgba(168,60,47,.18); background: rgba(168,60,47,.045); }
.result-rewards span, .result-rewards strong { display: block; }
.result-rewards span { color: var(--muted); font-size: 9px; }
.result-rewards strong { margin-top: 5px; overflow-wrap: anywhere; color: var(--red); font: 600 16px "Songti TC", serif; }
.result-rewards > .point-change-reward { align-content: center; padding: 3px 0; border: 0; background: transparent; }
.point-change-reward > span { margin-bottom: 7px; }
.points-change-badge { position: relative; display: inline-flex; align-items: center; gap: 6px; width: max-content; margin: 0; padding: 7px 11px; overflow: visible; color: var(--ink); background: #ffc21c; border: 0; border-radius: 7px; cursor: pointer; font: 700 19px/1 sans-serif; }
.points-change-badge::before { content: ""; position: absolute; top: -6px; left: 14px; border-right: 6px solid transparent; border-bottom: 7px solid #ffc21c; border-left: 6px solid transparent; }
.points-change-badge i { font-size: 21px; font-style: normal; line-height: 1; }
.points-change-badge b { font: inherit; }
.points-change-badge:hover { filter: brightness(.97); transform: translateY(-1px); }
.points-change-badge:active { transform: translateY(0); }
.save-status { min-height: 18px; font-size: 10px; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1.5fr; gap: 9px; margin-top: 18px; }
.dialog-actions .primary-button { margin: 0; }
.secondary-button { border: 1px solid var(--line); background: transparent; }
.ready-dialog h2 { margin: 5px 0 12px; font: 600 30px "Songti TC", serif; }
.ready-intro { margin: 0 0 22px; color: var(--muted); font-size: 12px; line-height: 1.8; }
.ready-list { display: grid; gap: 8px; margin-bottom: 20px; }
.ready-item { padding: 12px 14px; display: flex; align-items: center; gap: 11px; border: 1px solid var(--line); background: var(--paper); }
.ready-item i { width: 25px; height: 25px; display: grid; place-items: center; flex: 0 0 auto; color: var(--muted); border: 1px solid var(--line); border-radius: 50%; font-style: normal; }
.ready-item.ready i { color: #fff; border-color: #66785f; background: #66785f; }
.ready-item.warning i { color: #fff; border-color: var(--gold); background: var(--gold); }
.ready-item strong, .ready-item small { display: block; }
.ready-item strong { font-size: 12px; }
.ready-item small { margin-top: 3px; color: var(--muted); font-size: 9px; }
.keyboard-check { display: block; padding: 16px; border: 1px solid rgba(168,60,47,.3); background: rgba(168,60,47,.045); }
.keyboard-check > span { display: block; margin-bottom: 9px; color: var(--red); font-size: 10px; font-weight: 700; letter-spacing: .12em; }
.keyboard-check input { width: 100%; padding: 12px 13px; border: 1px solid var(--line); background: #fff; outline: none; text-align: center; text-transform: uppercase; }
.keyboard-check input:focus { border-color: var(--red); box-shadow: 0 0 0 3px rgba(168,60,47,.08); }
.keyboard-check small { display: block; margin-top: 8px; color: var(--muted); font-size: 9px; text-align: center; }
.keyboard-check.ready { border-color: rgba(102,120,95,.5); background: rgba(102,120,95,.07); }
.keyboard-check.ready small { color: #52644c; }
.ready-actions { display: grid; grid-template-columns: 1fr 1.45fr; gap: 8px; margin-top: 20px; }
.ready-actions .primary-button { margin: 0; }
.ready-actions .primary-button:disabled { cursor: not-allowed; opacity: .38; box-shadow: none; }
.auth-dialog { width: min(510px, calc(100% - 28px)); padding: 40px; color: var(--ink); background: var(--white); border: 0; box-shadow: 0 30px 100px rgba(0,0,0,.3); }
.auth-dialog::backdrop { background: rgba(28,27,24,.72); backdrop-filter: blur(4px); }
.auth-dialog h2 { margin: 5px 0 20px; font: 600 28px "Songti TC", serif; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.auth-tabs button { padding: 11px; border: 0; border-bottom: 2px solid transparent; background: transparent; cursor: pointer; color: var(--muted); }
.auth-tabs button.selected { color: var(--red); border-bottom-color: var(--red); }
.auth-form { display: grid; gap: 13px; }
.auth-form label > span, .auth-form label > small { display: block; }
.auth-form label > span { margin-bottom: 6px; color: var(--muted); font-size: 10px; }
.auth-form label > span small { color: #9e978d; }
.auth-form label > small { margin-top: 4px; color: #9e978d; font-size: 8px; }
.auth-form input, .auth-form select { width: 100%; min-height: 42px; padding: 9px 11px; border: 1px solid var(--line); background: #fff; outline: none; }
.auth-form input:focus, .auth-form select:focus { border-color: var(--red); }
.auth-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.auth-form .primary-button { margin-top: 5px; }
.auth-status { min-height: 18px; margin: 12px 0 0; color: var(--red); text-align: center; font-size: 10px; }
.auth-member { text-align: center; }
.auth-member .grade-seal { margin: 0 auto 18px; }
.auth-member h2 { margin-bottom: 7px; }
.auth-member p { color: var(--muted); font-size: 11px; }
.member-rewards { display: grid; grid-template-columns: 1fr; gap: 10px; margin: 20px 0 4px; text-align: left; }
.member-rewards > div { padding: 12px; background: var(--paper); border: 1px solid var(--line); }
.member-rewards span { display: block; margin-bottom: 4px; color: var(--muted); font-size: 10px; }
.member-rewards strong { font-size: 14px; }
.auth-member .secondary-button { width: 100%; margin-top: 18px; }
.points-detail-dialog { width: min(440px, calc(100% - 28px)); padding: 34px; color: var(--ink); background: var(--white); border: 0; box-shadow: 0 30px 100px rgba(0,0,0,.34); }
.points-detail-dialog::backdrop { background: rgba(28,27,24,.72); backdrop-filter: blur(4px); }
.points-detail-dialog .eyebrow { margin: 0; text-align: left; }
.points-detail-dialog h2 { margin: 8px 0 5px; font: 600 28px "Songti TC", serif; }
.points-detail-intro { margin: 0 0 18px; color: var(--muted); font-size: 11px; line-height: 1.65; }
.points-detail-total { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 15px 16px; background: #fff0b8; border: 1px solid rgba(201,145,0,.24); }
.points-detail-total span { color: var(--muted); font-size: 10px; }
.points-detail-total strong { color: #8a5d00; font-size: 22px; }
.points-detail-list { margin-top: 12px; border: 1px solid var(--line); }
.points-detail-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; min-height: 52px; padding: 11px 13px; }
.points-detail-row + .points-detail-row { border-top: 1px solid var(--line); }
.points-detail-row span { color: var(--muted); font-size: 11px; line-height: 1.5; }
.points-detail-row strong { flex: 0 0 auto; font-size: 12px; }
.points-detail-row strong.positive { color: #3f7f61; }
.points-detail-row strong.negative { color: var(--red); }
.points-detail-empty { margin: 0; padding: 16px; color: var(--muted); font-size: 11px; }
.points-detail-balance { display: flex; justify-content: space-between; gap: 15px; margin-top: 12px; padding: 12px 2px 0; border-top: 1px solid var(--line); }
.points-detail-balance span { color: var(--muted); font-size: 10px; }
.points-detail-balance strong { font-size: 14px; }
footer { min-height: 90px; padding: 0 clamp(24px, 8vw, 130px); display: flex; align-items: center; justify-content: space-between; background: #1d1d1a; color: #77736d; border-top: 1px solid rgba(255,255,255,.06); font-size: 10px; }
footer span { color: #d4cbbb; font: 500 18px "Songti TC", serif; letter-spacing: .18em; }

@media (max-width: 900px) {
  .site-header nav { gap: 14px; }
  .nav-link { font-size: 12px; }
  .hero { grid-template-columns: 1fr; padding-top: 55px; }
  .hero-copy { text-align: center; margin: 0 auto; }
  .hero-lead { margin-left: auto; margin-right: auto; }
  .hero-facts { justify-content: center; }
  .setup-card { width: min(530px, 100%); margin: 0 auto; }
  .test-toolbar { grid-template-columns: 1fr auto; }
  .live-metrics { grid-row: 2; grid-column: 1 / -1; margin-top: 18px; justify-content: center; }
  .results-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .site-header { height: 70px; }
  .brand small, .sound-toggle { display: none; }
  .account-button { padding: 8px 10px; font-size: 9px; }
  .pause-overlay { top: 70px; }
  .test-panel { height: calc(100dvh - 70px); }
  .hero { min-height: calc(100vh - 70px); gap: 45px; padding-bottom: 60px; }
  .hero h1 { font-size: 49px; }
  .hero-lead { font-size: 14px; }
  .setup-card { padding: 25px 21px; }
  .test-toolbar { padding: 15px 18px; }
  .live-metrics { width: 100%; }
  .live-metrics > div { min-width: 0; flex: 1; padding: 0 9px; }
  .typing-stage { width: calc(100% - 24px); padding: 14px 0 10px; gap: 10px; }
  .poem-heading h2 { font-size: 27px; }
  .poem-heading-tools { align-items: flex-end; gap: 6px; }
  .poem-hint-button { order: -1; width: 100%; min-height: 30px; padding: 6px 13px; }
  .text-size-controls button { width: 35px; height: 30px; }
  .text-size-controls span { min-width: 43px; line-height: 30px; }
  .poem-text { padding: 24px 20px; letter-spacing: .1em; }
  .ime-hints { display: none; }
  .root-keyboard { grid-template-columns: repeat(9, minmax(0, 1fr)); padding-left: 8px; padding-right: 8px; }
  .section-heading { display: block; }
  .section-heading > p { margin-top: 18px; }
  .results-section { padding-top: 70px; padding-bottom: 70px; }
  .result-row { grid-template-columns: 30px 1fr 72px; }
  .result-mode { display: none; }
  .result-dialog { padding: 38px 23px 25px; }
  .score-main strong { font-size: 68px; }
  .result-rewards { grid-template-columns: 1fr; }
  .guest-callout, .mistake-lab-head { align-items: stretch; flex-direction: column; }
  .member-stat-grid { grid-template-columns: repeat(2, 1fr); gap: 14px 0; }
  .member-stat-grid div:nth-child(3) { border-left: 0; padding-left: 0; }
  .mistake-scopes { width: 100%; }
  .mistake-scopes button { flex: 1; }
  .auth-dialog { padding: 34px 22px 24px; }
  .points-detail-dialog { padding: 31px 22px 24px; }
}
