.typing-journey {
  --typing-ink: #102a45;
  --typing-muted: #526a7e;
  --typing-line: #cbd9e3;
  --typing-soft: #eef5f8;
  --typing-accent: #197895;
  --typing-accent-dark: #0d536d;
  --typing-good: #197257;
  --typing-bad: #a23e49;
  width: min(1240px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px 0 64px;
  color: var(--typing-ink);
}

.typing-journey button,
.typing-journey input,
.typing-journey textarea { font: inherit; }

.typing-journey__header { display: grid; gap: 20px; }
.typing-link { width: fit-content; border: 0; background: transparent; padding: 6px 0; color: var(--typing-accent-dark); font-weight: 760; cursor: pointer; }
.typing-link:hover { text-decoration: underline; text-underline-offset: 4px; }
.typing-link:focus-visible,
.typing-journey button:focus-visible,
.typing-journey input:focus-visible,
.typing-journey textarea:focus-visible { outline: 3px solid rgba(25, 120, 149, .35); outline-offset: 3px; }

.typing-journey__title { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(280px, .65fr); gap: 36px; align-items: end; }
.typing-journey__title span { color: var(--typing-accent-dark); font-size: 12px; font-weight: 850; }
.typing-journey__title h1 { margin: 5px 0 0; font-size: 34px; line-height: 1.15; letter-spacing: -.025em; text-wrap: balance; }
.typing-journey__title p { max-width: 54ch; margin: 0; color: var(--typing-muted); line-height: 1.7; text-wrap: pretty; }

.typing-progress { display: flex; align-items: center; gap: 14px; }
.typing-progress__track { flex: 1; height: 6px; overflow: hidden; background: #dbe6ec; }
.typing-progress__track i { display: block; width: 0; height: 100%; background: var(--typing-accent); transition: width 220ms cubic-bezier(.22, 1, .36, 1); }
.typing-progress > span { min-width: 112px; color: var(--typing-muted); font-size: 11px; text-align: right; }

.typing-journey__summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 24px; border-block: 1px solid var(--typing-line); }
.typing-journey__summary > div { min-width: 0; padding: 14px 20px; border-right: 1px solid var(--typing-line); }
.typing-journey__summary > div:first-child { padding-left: 0; }
.typing-journey__summary > div:last-child { border-right: 0; }
.typing-journey__summary small,
.typing-journey__summary strong,
.typing-journey__summary span { display: block; }
.typing-journey__summary small { color: var(--typing-muted); font-size: 10px; }
.typing-journey__summary strong { margin-top: 2px; font-size: 18px; }
.typing-journey__summary span { margin-top: 1px; color: var(--typing-muted); font-size: 9px; }

.typing-journey__workspace { min-height: 530px; margin-top: 22px; background: #fff; border: 1px solid var(--typing-line); }
.typing-loading,
.typing-error { min-height: 530px; display: flex; align-items: center; justify-content: center; gap: 16px; padding: 40px; text-align: left; }
.typing-loading i { width: 24px; height: 24px; border: 3px solid #cddde5; border-top-color: var(--typing-accent); border-radius: 50%; animation: typing-spin .8s linear infinite; }
.typing-loading strong,
.typing-error strong { display: block; font-size: 18px; }
.typing-loading p,
.typing-error p { margin: 4px 0 0; color: var(--typing-muted); }
.typing-error { flex-direction: column; text-align: center; }

.typing-save-status { margin: 10px 0 0; color: var(--typing-muted); font-size: 10px; text-align: right; }
.typing-save-status[data-state="saved"] { color: var(--typing-good); }
.typing-save-status[data-state="error"] { color: var(--typing-bad); }

.typing-intro { display: grid; grid-template-columns: minmax(0, .85fr) minmax(380px, 1.15fr); gap: 32px 52px; padding: 44px; }
.typing-intro__copy > span,
.typing-recommendation .typing-result-band > span,
.typing-defense-intro > div > span,
.typing-fingering > div > span,
.typing-defense-head span,
.typing-final-result .typing-result-band > span { color: var(--typing-accent-dark); font-size: 11px; font-weight: 850; }
.typing-intro h2,
.typing-recommendation h2,
.typing-fingering h2,
.typing-defense-intro h2,
.typing-defense-head h2,
.typing-final-result h2 { margin: 8px 0 12px; font-size: 28px; line-height: 1.2; letter-spacing: -.02em; text-wrap: balance; }
.typing-intro p,
.typing-recommendation p,
.typing-fingering p,
.typing-defense-intro p,
.typing-final-result p { max-width: 65ch; margin: 0; color: var(--typing-muted); line-height: 1.7; }

.typing-mode-picker { min-width: 0; margin: 0; padding: 0; border: 0; }
.typing-mode-picker legend { margin-bottom: 10px; font-size: 12px; font-weight: 850; }
.typing-mode-picker label { position: relative; display: block; }
.typing-mode-picker label + label { margin-top: 8px; }
.typing-mode-picker input { position: absolute; opacity: 0; pointer-events: none; }
.typing-mode-picker label span { display: block; padding: 16px 18px; border: 1px solid var(--typing-line); cursor: pointer; transition: border-color 160ms ease-out, background 160ms ease-out; }
.typing-mode-picker label span:hover { border-color: #80aabd; }
.typing-mode-picker input:checked + span { border-color: var(--typing-accent); background: var(--typing-soft); }
.typing-mode-picker input:focus-visible + span { outline: 3px solid rgba(25, 120, 149, .35); outline-offset: 3px; }
.typing-mode-picker strong,
.typing-mode-picker small { display: block; }
.typing-mode-picker strong { font-size: 14px; }
.typing-mode-picker small { max-width: 55ch; margin-top: 4px; color: var(--typing-muted); line-height: 1.45; }

.typing-route-preview { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 0; border-block: 1px solid var(--typing-line); color: var(--typing-muted); font-size: 11px; }
.typing-route-preview span { color: var(--typing-ink); font-weight: 760; }
.typing-route-preview i { color: #91a8b8; font-style: normal; }
.typing-actions { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; }
.typing-actions small { color: var(--typing-muted); }

.typing-run { padding: 34px 40px 38px; }
.typing-run__top { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
.typing-run__top span { color: var(--typing-accent-dark); font-size: 11px; font-weight: 850; }
.typing-run__top h2 { margin: 6px 0 0; font-size: 26px; }
.typing-timer { min-width: 104px; padding-left: 22px; border-left: 1px solid var(--typing-line); text-align: right; }
.typing-timer small,
.typing-timer strong { display: block; }
.typing-timer small { color: var(--typing-muted); }
.typing-timer strong { margin-top: 2px; font: 800 25px/1.1 ui-monospace, SFMono-Regular, Consolas, monospace; font-variant-numeric: tabular-nums; }
.typing-instruction { max-width: 68ch; margin: 10px 0 24px; color: var(--typing-muted); }

.typing-target { min-height: 122px; padding: 22px 24px; background: #f2f6f8; font: 650 23px/1.8 ui-monospace, SFMono-Regular, Consolas, "Microsoft YaHei", sans-serif; letter-spacing: .02em; overflow-wrap: anywhere; }
.typing-target span { border-bottom: 2px solid transparent; }
.typing-target span.is-current { border-bottom-color: var(--typing-accent); background: #d6edf3; }
.typing-target span.is-correct { color: var(--typing-good); background: #e4f3ed; }
.typing-target span.is-wrong { color: var(--typing-bad); background: #fae7e9; text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 4px; }

.typing-input-field { display: block; margin-top: 18px; }
.typing-input-field > span,
.typing-defense-input > span { display: block; margin-bottom: 7px; font-size: 11px; font-weight: 820; }
.typing-input-field textarea,
.typing-defense-input input { width: 100%; min-height: 116px; resize: vertical; border: 1px solid #9db7c8; border-radius: 8px; background: #fff; padding: 14px 16px; color: var(--typing-ink); font: 600 18px/1.65 ui-monospace, SFMono-Regular, Consolas, "Microsoft YaHei", sans-serif; }
.typing-input-field textarea:disabled { background: #e8eef2; color: #6c8191; }
.typing-live-stats { display: flex; flex-wrap: wrap; gap: 16px 26px; margin: 12px 0 20px; color: var(--typing-muted); font-size: 10px; }
.typing-live-stats strong { color: var(--typing-ink); }
.typing-run .typing-actions { justify-content: flex-end; }
.typing-journey__workspace.is-paused .typing-target { opacity: .62; }

.typing-recommendation,
.typing-final-result { padding: 40px; }
.typing-result-band { padding-bottom: 25px; border-bottom: 1px solid var(--typing-line); }
.typing-metrics { display: flex; flex-wrap: wrap; margin: 0; border-bottom: 1px solid var(--typing-line); }
.typing-metrics > div { min-width: 170px; flex: 1; padding: 22px; border-right: 1px solid var(--typing-line); }
.typing-metrics > div:first-child { padding-left: 0; }
.typing-metrics > div:last-child { border-right: 0; }
.typing-metrics dt { color: var(--typing-muted); font-size: 10px; }
.typing-metrics dd { margin: 5px 0 0; font-size: 25px; font-weight: 850; }
.typing-weak { padding: 25px 0; }
.typing-weak h3 { margin: 0 0 12px; font-size: 15px; }
.typing-weak ul { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.typing-weak li { display: flex; align-items: center; gap: 9px; padding: 8px 10px; background: var(--typing-soft); color: var(--typing-muted); font-size: 10px; }
.typing-weak kbd { min-width: 28px; padding: 4px 6px; border: 1px solid #9fb7c6; border-bottom-width: 2px; border-radius: 5px; background: #fff; color: var(--typing-ink); font: 750 11px ui-monospace, SFMono-Regular, Consolas, monospace; text-align: center; }

.typing-fingering { padding: 40px; }
.typing-fingering ol { max-width: 780px; margin: 28px 0; padding: 0; list-style: none; }
.typing-fingering li { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 12px; align-items: center; padding: 13px 0; border-bottom: 1px solid var(--typing-line); }
.typing-fingering li > span { width: 28px; height: 28px; display: grid; place-items: center; background: var(--typing-soft); color: var(--typing-accent-dark); font-weight: 850; }
.typing-hands { display: flex; align-items: center; gap: 7px; margin-bottom: 28px; padding: 22px; background: #f2f6f8; }
.typing-hands kbd,
.typing-hands > span { min-width: 45px; padding: 12px 10px; border: 1px solid #a8bdca; border-bottom-width: 3px; border-radius: 7px; background: #fff; color: var(--typing-ink); font-weight: 820; text-align: center; }
.typing-hands i { flex: 1; }

.typing-countdown { min-height: 530px; display: grid; place-items: center; align-content: center; padding: 40px; text-align: center; }
.typing-countdown span { color: var(--typing-accent-dark); font-weight: 820; }
.typing-countdown strong { margin: 22px 0; font: 900 94px/1 ui-monospace, SFMono-Regular, Consolas, monospace; color: var(--typing-accent-dark); }
.typing-countdown p { margin: 0; color: var(--typing-muted); }

.typing-defense-intro { padding: 42px; }
.typing-defense-rules { display: flex; margin: 28px 0 20px; padding: 0; border-block: 1px solid var(--typing-line); list-style: none; }
.typing-defense-rules li { flex: 1; padding: 18px; border-right: 1px solid var(--typing-line); }
.typing-defense-rules li:first-child { padding-left: 0; }
.typing-defense-rules li:last-child { border-right: 0; }
.typing-defense-rules strong,
.typing-defense-rules span { display: block; }
.typing-defense-rules strong { font-size: 25px; }
.typing-defense-rules span { color: var(--typing-muted); font-size: 10px; }
.typing-runtime-note,
.typing-notice { max-width: none !important; padding: 12px 14px; background: #eef5f8; color: #35586c !important; font-size: 10px; }
.typing-notice { margin: 18px 0 0 !important; background: #fff4dd; color: #73571c !important; }
.typing-defense-intro .typing-actions { margin-top: 20px; }

.typing-defense { padding: 26px 30px 30px; }
.typing-defense-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
.typing-defense-head h2 { margin-bottom: 0; font-size: 23px; }
.typing-defense-status { display: flex; justify-content: space-between; gap: 16px; margin: 18px 0 12px; color: var(--typing-muted); font: 750 12px/1.4 ui-monospace, SFMono-Regular, Consolas, monospace; }
.typing-defense-field { position: relative; min-height: 310px; overflow: hidden; background: #102a45; }
.typing-phaser-stage { width: 100%; min-height: 310px; overflow: hidden; background: #102a45; }
.typing-phaser-stage canvas { display: block; width: 100% !important; height: auto !important; margin: 0 auto; }
.typing-screen-keyboard { margin-top: 12px; }
.typing-defense-field::before { content: ""; position: absolute; inset: 0; background-image: radial-gradient(circle, rgba(255,255,255,.34) 1px, transparent 1px); background-size: 44px 44px; opacity: .35; }
.typing-defense-target { --fall: 0%; position: absolute; z-index: 1; top: calc(18px + var(--fall) * 2.25); left: 50%; min-width: 150px; translate: -50% 0; padding: 13px 18px; background: #fff; border-radius: 10px; text-align: center; transition: top 100ms linear; }
.typing-defense-target strong,
.typing-defense-target small { display: block; }
.typing-defense-target strong { font-size: 26px; }
.typing-defense-target small { min-height: 17px; margin-top: 4px; color: var(--typing-accent-dark); font: 700 12px ui-monospace, SFMono-Regular, Consolas, monospace; }
.typing-defense-line { position: absolute; z-index: 1; right: 22px; bottom: 34px; left: 22px; height: 4px; background: #58c4df; }
.typing-defense-line span { position: absolute; right: 0; bottom: 10px; color: #d4eef4; font-size: 10px; font-weight: 820; }
.typing-defense-input { display: block; margin-top: 14px; }
.typing-defense-input input { min-height: 50px; resize: none; }
.typing-defense .typing-runtime-note { margin: 14px 0 0; }
.typing-phaser-host { min-height: 430px; overflow: hidden; background: #102a45; }
.typing-phaser-host canvas { display: block; max-width: 100%; margin: auto; }

.typing-complete { min-height: 530px; display: grid; place-items: center; align-content: center; padding: 40px; text-align: center; }
.typing-complete > span { width: 64px; height: 64px; display: grid; place-items: center; background: var(--typing-good); border-radius: 50%; color: #fff; font-size: 32px; }
.typing-complete h2 { margin: 20px 0 10px; font-size: 29px; }
.typing-complete p { max-width: 62ch; margin: 0; color: var(--typing-muted); line-height: 1.7; }
.typing-complete .typing-actions { justify-content: center; margin-top: 24px; }

@keyframes typing-spin { to { transform: rotate(360deg); } }

@media (max-width: 840px) {
  .typing-journey__title,
  .typing-intro { grid-template-columns: 1fr; }
  .typing-route-preview { justify-content: flex-start; overflow-x: auto; }
  .typing-route-preview span { white-space: nowrap; }
  .typing-intro { padding: 32px 28px; }
  .typing-run,
  .typing-recommendation,
  .typing-final-result,
  .typing-fingering,
  .typing-defense-intro { padding: 30px 28px; }
}

@media (max-width: 600px) {
  .typing-journey { width: 100%; padding: 18px 0 40px; }
  .typing-journey__header,
  .typing-save-status { padding-inline: 16px; }
  .typing-journey__title h1 { font-size: 28px; }
  .typing-journey__summary { grid-template-columns: 1fr 1fr; }
  .typing-journey__summary > div { padding: 12px 16px; }
  .typing-journey__summary > div:first-child { padding-left: 16px; }
  .typing-journey__summary > div:last-child { grid-column: 1 / -1; border-top: 1px solid var(--typing-line); }
  .typing-journey__workspace { min-height: 500px; border-inline: 0; }
  .typing-intro,
  .typing-run,
  .typing-recommendation,
  .typing-final-result,
  .typing-fingering,
  .typing-defense-intro { padding: 26px 18px; }
  .typing-run__top,
  .typing-defense-head { flex-direction: column; }
  .typing-timer { padding-left: 0; border-left: 0; text-align: left; }
  .typing-target { padding: 18px; font-size: 19px; }
  .typing-actions { align-items: stretch; flex-direction: column; }
  .typing-actions .btn { width: 100%; }
  .typing-metrics { display: grid; grid-template-columns: 1fr 1fr; }
  .typing-metrics > div,
  .typing-metrics > div:first-child { min-width: 0; padding: 16px; border-bottom: 1px solid var(--typing-line); }
  .typing-fingering { overflow: hidden; }
  .typing-hands { overflow-x: auto; }
  .typing-defense-rules { display: grid; grid-template-columns: repeat(3, 1fr); }
  .typing-defense-rules li { padding: 14px; }
  .typing-defense { padding: 22px 16px; }
  .typing-defense-field { min-height: 280px; }
  .typing-complete { padding: 34px 18px; }
}

@media (prefers-reduced-motion: reduce) {
  .typing-progress__track i,
  .typing-mode-picker label span,
  .typing-defense-target { transition: none; }
  .typing-loading i { animation-duration: 1.8s; }
}
