:root {
  color-scheme: light;
  --bg: #f4f0e8;
  --surface: #fbf9f4;
  --surface-strong: #ffffff;
  --text: #171915;
  --text-soft: #686a63;
  --line: rgba(23, 25, 21, 0.12);
  --accent: #d94a32;
  --accent-soft: #f3d7cf;
  --success: #2f7155;
  --success-soft: #dcebe2;
  --unknown: #765b2e;
  --unknown-soft: #ede4cf;
  --shadow: 0 20px 70px rgba(40, 35, 25, 0.09);
  --radius-xl: 2rem;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  -webkit-tap-highlight-color: transparent;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101110;
  --surface: #181a18;
  --surface-strong: #20221f;
  --text: #f4f1e9;
  --text-soft: #a9aba4;
  --line: rgba(244, 241, 233, 0.12);
  --accent: #f07059;
  --accent-soft: #4a2923;
  --success: #8dc3a6;
  --success-soft: #21382d;
  --unknown: #d4b97f;
  --unknown-soft: #3b3322;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.26);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --bg: #101110;
    --surface: #181a18;
    --surface-strong: #20221f;
    --text: #f4f1e9;
    --text-soft: #a9aba4;
    --line: rgba(244, 241, 233, 0.12);
    --accent: #f07059;
    --accent-soft: #4a2923;
    --success: #8dc3a6;
    --success-soft: #21382d;
    --unknown: #d4b97f;
    --unknown-soft: #3b3322;
    --shadow: 0 24px 80px rgba(0, 0, 0, 0.26);
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
}

body {
  color: var(--text);
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}

button {
  color: inherit;
  font: inherit;
}

button,
[role="button"] {
  touch-action: manipulation;
}

[hidden] {
  display: none !important;
}

.noscript {
  margin: 0;
  padding: 1rem;
  background: var(--accent);
  color: white;
  text-align: center;
}

.app-shell,
.screen {
  min-height: 100dvh;
}

.app-shell {
  position: relative;
  isolation: isolate;
}

.screen {
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
}

.flow-screen {
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  padding: calc(var(--safe-top) + 0.8rem) calc(var(--safe-right) + 1rem)
    calc(var(--safe-bottom) + 1.5rem) calc(var(--safe-left) + 1rem);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
  animation: screen-in 220ms ease both;
}

.flow-header {
  display: flex;
  min-height: 3rem;
  align-items: center;
  justify-content: space-between;
}

.setup-content,
.result-content {
  width: min(100%, 42rem);
  margin: clamp(1.5rem, 7dvh, 5rem) auto 0;
}

.setup-content {
  padding-bottom: max(1rem, var(--safe-bottom));
}

.eyebrow {
  margin: 0 0 0.65rem;
  color: var(--accent);
  font-size: 0.74rem;
  font-weight: 780;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.setup-content h1,
.result-content h1 {
  max-width: 12ch;
  margin: 0;
  font-size: clamp(2.35rem, 10vw, 4.5rem);
  line-height: 0.98;
  letter-spacing: -0.055em;
}

.setup-explanation,
.result-message {
  max-width: 36rem;
  margin: 1rem 0 0;
  color: var(--text-soft);
  font-size: 1rem;
  line-height: 1.55;
}

.mode-section,
.topic-section,
.quantity-section {
  margin-top: 1.8rem;
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.section-heading h2 {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 760;
}

.section-heading > span {
  overflow: hidden;
  color: var(--text-soft);
  font-size: 0.72rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.section-help {
  margin: 0.35rem 0 0;
  color: var(--text-soft);
  font-size: 0.72rem;
}

.mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin-top: 0.75rem;
  gap: 0.65rem;
}

.mode-button {
  display: grid;
  min-height: 5.4rem;
  grid-template-columns: 2.3rem minmax(0, 1fr);
  align-items: center;
  padding: 0.8rem;
  gap: 0.65rem;
  border: 1px solid var(--line);
  border-radius: 1.25rem;
  background: var(--surface);
  cursor: pointer;
  text-align: left;
  transition: border-color 140ms ease, transform 140ms ease, background 140ms ease;
}

.mode-button > span:first-child {
  color: var(--accent);
  font-family: "Songti SC", "STSong", "Noto Serif CJK SC", serif;
  font-size: 2rem;
  text-align: center;
}

.mode-button > span:last-child,
.mode-button strong,
.mode-button small {
  display: block;
}

.mode-button strong {
  font-size: 0.88rem;
}

.mode-button small {
  margin-top: 0.2rem;
  color: var(--text-soft);
  font-size: 0.67rem;
  line-height: 1.25;
}

.mode-button.is-selected {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  background: var(--accent-soft);
}

.mode-button:active {
  transform: scale(0.98);
}

.match-option {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  align-items: center;
  margin-top: 0.7rem;
  padding: 0.8rem 0.9rem;
  gap: 0.15rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--surface);
  cursor: pointer;
}

.match-option[hidden] {
  display: none;
}

.match-option > span:first-child {
  grid-row: 1 / 3;
}

.match-option strong,
.match-option small {
  display: block;
}

.match-option strong {
  font-size: 0.82rem;
}

.match-option small {
  margin-top: 0.18rem;
  color: var(--text-soft);
  font-size: 0.69rem;
  line-height: 1.3;
}

.match-option input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
}

.switch {
  position: relative;
  display: block;
  width: 2.8rem;
  height: 1.65rem;
  grid-column: 2;
  grid-row: 1 / 3;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
  transition: border-color 160ms ease, background 160ms ease;
}

.switch::after {
  position: absolute;
  top: 0.17rem;
  left: 0.17rem;
  width: 1.17rem;
  height: 1.17rem;
  border-radius: 50%;
  background: var(--text-soft);
  content: "";
  transition: transform 160ms ease, background 160ms ease;
}

.match-option input:checked + .switch {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.match-option input:checked + .switch::after {
  background: var(--accent);
  transform: translateX(1.13rem);
}

.match-option input:focus-visible + .switch {
  outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: 3px;
}

.topic-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 0.75rem;
  gap: 0.55rem;
}

.topic-button {
  display: grid;
  min-height: 4.65rem;
  grid-template-columns: 2rem minmax(0, 1fr);
  grid-template-rows: auto auto;
  align-content: center;
  align-items: center;
  padding: 0.7rem 0.75rem;
  gap: 0.12rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 1.15rem;
  background: var(--surface);
  cursor: pointer;
  text-align: left;
  transition: border-color 140ms ease, transform 140ms ease, background 140ms ease;
}

.topic-button > span {
  grid-row: 1 / 3;
  color: var(--accent);
  font-family: "Songti SC", "STSong", "Noto Serif CJK SC", serif;
  font-size: 1.65rem;
  text-align: center;
}

.topic-button strong {
  align-self: end;
  font-size: 0.78rem;
  line-height: 1.15;
}

.topic-button small {
  align-self: start;
  color: var(--text-soft);
  font-size: 0.65rem;
}

.topic-button.is-selected {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  background: var(--accent-soft);
}

.topic-button:active {
  transform: scale(0.98);
}

.size-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 0.75rem;
  gap: 0.65rem;
}

.size-button {
  display: flex;
  min-height: 5.2rem;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  border-radius: 1.25rem;
  background: var(--surface);
  box-shadow: 0 10px 35px rgba(40, 35, 25, 0.045);
  cursor: pointer;
  text-align: left;
  transition: border-color 140ms ease, transform 140ms ease, background 140ms ease;
}

.size-button--wide {
  grid-column: 1 / -1;
}

.size-button strong {
  font-size: 1.65rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.035em;
}

.size-button span {
  color: var(--text-soft);
  font-size: 0.76rem;
}

.size-button:active {
  transform: scale(0.98);
}

.size-button:disabled {
  box-shadow: none;
  cursor: not-allowed;
  opacity: 0.34;
}

.custom-size-form {
  display: grid;
  margin-top: 1.35rem;
  gap: 0.55rem;
}

.custom-size-form label {
  color: var(--text-soft);
  font-size: 0.78rem;
  font-weight: 650;
}

.custom-size-form > div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.55rem;
}

.custom-size-form input,
.custom-size-form button {
  min-height: 3.5rem;
  border-radius: 1rem;
  font: inherit;
}

.custom-size-form input {
  min-width: 0;
  padding: 0 1rem;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
}

.custom-size-form button,
.primary-button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 730;
  cursor: pointer;
}

.custom-size-form button {
  padding: 0 1.15rem;
}

.form-error {
  margin: 0;
  color: var(--accent);
  font-size: 0.78rem;
}

.text-button {
  display: block;
  margin: 1.2rem auto 0;
  padding: 0.75rem;
  border: 0;
  background: transparent;
  color: var(--text-soft);
  font-size: 0.82rem;
  text-decoration: underline;
  text-underline-offset: 0.2em;
  cursor: pointer;
}

.study-screen {
  display: grid;
  height: 100dvh;
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr) auto;
  padding: calc(var(--safe-top) + 0.6rem) calc(var(--safe-right) + 0.8rem)
    calc(var(--safe-bottom) + 0.8rem) calc(var(--safe-left) + 0.8rem);
}

.study-header,
.stats-header {
  display: grid;
  align-items: center;
  min-height: 3rem;
}

.study-header {
  z-index: 2;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.75rem;
}

.brand {
  margin: 0;
  font-size: 0.74rem;
  font-weight: 750;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.brand span {
  color: var(--accent);
}

.study-progress {
  display: grid;
  min-width: 5rem;
  gap: 0.34rem;
  color: var(--text-soft);
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.progress-track {
  width: 100%;
  height: 3px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--line);
}

.progress-bar {
  display: block;
  width: 1%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 260ms ease;
}

.icon-button {
  display: inline-grid;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}

.study-header .icon-button {
  justify-self: end;
}

.icon-button svg {
  width: 1.32rem;
  height: 1.32rem;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.75;
}

.icon-button:focus-visible,
.study-card:focus-visible,
.answer-button:focus-visible,
.mode-button:focus-visible,
.topic-button:focus-visible,
.match-choice:focus-visible,
.size-button:focus-visible,
.custom-size-form input:focus-visible,
.custom-size-form button:focus-visible,
.text-button:focus-visible,
.primary-button:focus-visible,
.secondary-button:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: 3px;
}

.study-card {
  position: relative;
  display: grid;
  grid-template-rows: minmax(0, 1fr) 0;
  min-height: 0;
  padding: 0.5rem 0.4rem;
  overflow: hidden;
  cursor: pointer;
  user-select: none;
}

.character-stage {
  display: grid;
  min-height: 0;
  overflow: hidden;
  place-items: center;
}

.character {
  margin: 0;
  font-family: "Songti SC", "STSong", "Noto Serif CJK SC", "Source Han Serif SC", serif;
  font-size: clamp(11rem, 52dvh, 31rem);
  font-weight: 500;
  line-height: 0.9;
  letter-spacing: -0.08em;
  transform: translateX(-0.04em);
  transition: font-size 320ms cubic-bezier(0.22, 0.8, 0.28, 1), transform 320ms ease;
}

.character.character--phrase {
  max-width: 100%;
  letter-spacing: 0.01em;
  line-height: 1;
  text-align: center;
  transform: none;
}

.character.character--short {
  font-size: clamp(4rem, 22vw, 10rem);
}

.character.character--medium {
  font-size: clamp(3.4rem, 17vw, 8rem);
}

.character.character--long {
  font-size: clamp(2.7rem, 10.5vw, 5.4rem);
}

.character.character--xlong {
  font-size: clamp(2.05rem, 6.7vw, 3.8rem);
}

.answer {
  align-self: end;
  width: min(100%, 38rem);
  max-height: 0;
  margin: 0 auto;
  overflow: hidden;
  opacity: 0;
  transform: translateY(1rem);
  transition: max-height 320ms ease, opacity 220ms ease 70ms, transform 300ms ease;
}

.answer-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.pinyin,
.meaning,
.example,
.translation {
  margin: 0;
}

.pinyin {
  color: var(--accent);
  font-size: clamp(1.45rem, 5vw, 2rem);
  font-weight: 720;
  letter-spacing: 0.02em;
}

.category {
  padding: 0.38rem 0.66rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.meaning {
  margin-top: 0.25rem;
  font-size: clamp(1.2rem, 4vw, 1.55rem);
  font-weight: 650;
  line-height: 1.25;
}

.example-block {
  display: grid;
  margin-top: 0.9rem;
  padding: 0.85rem 1rem;
  gap: 0.15rem;
  border: 1px solid var(--line);
  border-radius: 1.15rem;
  background: color-mix(in srgb, var(--surface) 84%, transparent);
}

.example {
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: clamp(1.15rem, 4vw, 1.45rem);
  font-weight: 650;
}

.translation {
  color: var(--text-soft);
  font-size: 0.87rem;
  line-height: 1.4;
}

.tap-hint {
  position: absolute;
  right: 0;
  bottom: 0.5rem;
  left: 0;
  margin: 0;
  color: var(--text-soft);
  font-size: 0.75rem;
  letter-spacing: 0.01em;
  text-align: center;
  transition: opacity 160ms ease;
}

.study-screen.is-revealed .study-card {
  grid-template-rows: minmax(0, 1fr) auto;
}

.study-screen.is-revealed .character {
  font-size: clamp(7rem, 33dvh, 19rem);
  transform: translate(-0.04em, 0.02em);
}

.study-screen.is-revealed .character.character--phrase {
  transform: none;
}

.study-screen.is-revealed .character.character--short {
  font-size: clamp(3rem, 14vw, 7rem);
}

.study-screen.is-revealed .character.character--medium {
  font-size: clamp(2.7rem, 11vw, 5.5rem);
}

.study-screen.is-revealed .character.character--long {
  font-size: clamp(2.3rem, 8vw, 4.2rem);
}

.study-screen.is-revealed .character.character--xlong {
  font-size: clamp(1.85rem, 5.4vw, 3rem);
}

.study-screen.is-revealed .answer {
  max-height: 15.5rem;
  opacity: 1;
  transform: translateY(0);
}

.study-screen.is-revealed .tap-hint {
  opacity: 0;
}

.answer-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  max-height: 0;
  padding-top: 0;
  gap: 0.65rem;
  overflow: hidden;
  opacity: 0;
  transform: translateY(1rem);
  transition: max-height 280ms ease, padding 280ms ease, opacity 180ms ease 80ms, transform 280ms ease;
}

.study-screen.is-revealed .answer-actions {
  max-height: 5rem;
  padding-top: 0.75rem;
  opacity: 1;
  transform: translateY(0);
}

.answer-button {
  display: flex;
  min-height: 3.65rem;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 0.9rem;
  gap: 0.48rem;
  border: 1px solid transparent;
  border-radius: 1.15rem;
  font-size: 0.95rem;
  font-weight: 720;
  cursor: pointer;
  transition: transform 120ms ease, filter 120ms ease;
}

.answer-button--known {
  background: var(--success);
  color: #fff;
}

:root[data-theme="dark"] .answer-button--known {
  color: #132219;
}

.answer-button--unknown {
  background: var(--unknown-soft);
  color: var(--unknown);
}

.answer-button:active {
  transform: scale(0.975);
  filter: brightness(0.96);
}

.match-screen {
  display: grid;
  height: 100dvh;
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr);
  padding: calc(var(--safe-top) + 0.6rem) calc(var(--safe-right) + 0.8rem)
    calc(var(--safe-bottom) + 0.8rem) calc(var(--safe-left) + 0.8rem);
}

.match-content {
  width: min(100%, 46rem);
  min-height: 0;
  margin: 0 auto;
  padding: clamp(1rem, 4dvh, 2.5rem) 0 1rem;
  overflow-y: auto;
}

.match-heading h1 {
  margin: 0;
  font-size: clamp(2rem, 9vw, 3.8rem);
  line-height: 1;
  letter-spacing: -0.05em;
}

.match-feedback {
  min-height: 2.6em;
  margin: 0.65rem 0 0;
  color: var(--text-soft);
  font-size: 0.82rem;
  line-height: 1.35;
}

.match-board {
  display: grid;
  grid-template-columns: minmax(0, 0.82fr) minmax(0, 1.18fr);
  margin-top: 1rem;
  gap: 0.65rem;
}

.match-board section {
  min-width: 0;
}

.match-board h2 {
  margin: 0 0 0.5rem;
  color: var(--text-soft);
  font-size: 0.68rem;
  font-weight: 720;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.match-list {
  display: grid;
  gap: 0.55rem;
}

.match-choice {
  display: grid;
  width: 100%;
  min-height: 4.6rem;
  padding: 0.65rem 0.7rem;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 1.15rem;
  background: var(--surface);
  box-shadow: 0 8px 28px rgba(40, 35, 25, 0.045);
  cursor: pointer;
  line-height: 1.18;
  transition: opacity 220ms ease, transform 220ms ease, border-color 140ms ease, background 140ms ease;
}

.match-choice--hanzi {
  grid-auto-flow: column;
  grid-auto-columns: max-content;
  gap: clamp(0.35rem, 2vw, 0.7rem);
  font-family: "Songti SC", "STSong", "Noto Serif CJK SC", serif;
  font-size: clamp(1.75rem, 8vw, 2.65rem);
  text-align: center;
}

.match-hanzi-text {
  max-width: 100%;
  overflow-wrap: anywhere;
}

.match-pinyin {
  max-width: 10rem;
  color: var(--text-soft);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: clamp(0.66rem, 2.8vw, 0.84rem);
  font-weight: 650;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.match-choice--hanzi.match-choice--medium {
  font-size: clamp(1.25rem, 5vw, 1.75rem);
}

.match-choice--hanzi.match-choice--compact {
  font-size: clamp(0.9rem, 3.5vw, 1.25rem);
}

.match-choice--meaning {
  font-size: clamp(0.75rem, 3.3vw, 0.98rem);
  font-weight: 650;
  overflow-wrap: anywhere;
  text-align: center;
}

.match-choice.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.match-choice.is-wrong {
  border-color: var(--accent);
  animation: match-wrong 300ms ease both;
}

.match-choice.is-matched {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.82);
}

@keyframes match-wrong {
  0%, 100% { transform: translateX(0); }
  30% { transform: translateX(-0.3rem); }
  70% { transform: translateX(0.3rem); }
}

.result-screen {
  display: grid;
  place-items: center;
}

.result-content {
  margin: 0 auto;
  padding: 1rem 0;
}

.result-mark {
  display: grid;
  width: 5.5rem;
  aspect-ratio: 1;
  margin-bottom: 1.5rem;
  place-items: center;
  border-radius: 1.7rem;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: "Songti SC", "STSong", "Noto Serif CJK SC", serif;
  font-size: 2.8rem;
}

.result-content h1 {
  max-width: 14ch;
}

.result-topic {
  margin: 0.9rem 0 -0.55rem;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 720;
}

.result-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-top: 2rem;
  gap: 0.55rem;
}

.result-summary article {
  display: flex;
  min-width: 0;
  min-height: 6.5rem;
  flex-direction: column;
  justify-content: space-between;
  padding: 0.85rem;
  border: 1px solid var(--line);
  border-radius: 1.2rem;
  background: var(--surface);
}

.result-summary span {
  color: var(--text-soft);
  font-size: 0.7rem;
  line-height: 1.2;
}

.result-summary strong {
  font-size: clamp(1.7rem, 8vw, 2.6rem);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.05em;
}

.result-actions {
  display: grid;
  margin-top: 1.5rem;
  gap: 0.65rem;
}

.primary-button,
.secondary-button {
  min-height: 3.75rem;
  padding: 0.8rem 1rem;
  border-radius: 1.15rem;
  font-size: 0.94rem;
  cursor: pointer;
  transition: transform 120ms ease, filter 120ms ease;
}

.secondary-button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
}

.primary-button:active,
.secondary-button:active {
  transform: scale(0.985);
  filter: brightness(0.97);
}

.stats-screen {
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  padding: calc(var(--safe-top) + 0.8rem) calc(var(--safe-right) + 1rem)
    calc(var(--safe-bottom) + 1.5rem) calc(var(--safe-left) + 1rem);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
  animation: screen-in 220ms ease both;
}

.stats-header {
  grid-template-columns: 3rem 1fr 3rem;
  gap: 0.5rem;
}

.stats-header h1 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 720;
  text-align: center;
}

.icon-button--back {
  justify-self: start;
}

.theme-icon--moon,
:root[data-theme="dark"] .theme-icon--sun {
  display: none;
}

:root[data-theme="dark"] .theme-icon--moon {
  display: block;
}

.stats-content {
  width: min(100%, 42rem);
  margin: 1.2rem auto 0;
}

.stats-hero {
  display: grid;
  place-items: center;
  padding: 1rem 0 1.5rem;
  text-align: center;
}

.percentage-ring {
  display: grid;
  width: 10rem;
  aspect-ratio: 1;
  padding: 0.62rem;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(var(--accent) var(--percentage, 0%), var(--line) 0);
}

.percentage-ring::before {
  position: absolute;
  content: "";
}

.percentage-ring > div {
  display: grid;
  width: 100%;
  height: 100%;
  place-content: center;
  border-radius: 50%;
  background: var(--bg);
}

.percentage-ring strong,
.percentage-ring span {
  display: block;
}

.percentage-ring strong {
  font-size: 2.35rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em;
}

.percentage-ring span {
  margin-top: 0.1rem;
  color: var(--text-soft);
  font-size: 0.72rem;
  text-transform: uppercase;
}

.stats-hero p {
  margin: 0.85rem 0 0;
  color: var(--text-soft);
  font-size: 0.88rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem;
}

.stat-card,
.round-card {
  border: 1px solid var(--line);
  border-radius: 1.35rem;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.stat-card {
  display: flex;
  min-height: 7.2rem;
  flex-direction: column;
  justify-content: space-between;
  padding: 1rem;
}

.stat-card--wide {
  grid-column: 1 / -1;
  min-height: 8rem;
}

.stat-card span,
.round-card p {
  margin: 0;
  color: var(--text-soft);
  font-size: 0.78rem;
}

.stat-card strong {
  font-size: clamp(1.8rem, 8vw, 2.6rem);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.045em;
}

.stat-card small {
  color: var(--text-soft);
  font-size: 0.72rem;
}

.round-card {
  margin-top: 0.7rem;
  padding: 1rem;
}

.round-card > div:first-child {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.round-card strong {
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

.round-progress-track {
  height: 0.38rem;
  margin-top: 0.85rem;
  overflow: hidden;
  border-radius: 99px;
  background: var(--line);
}

.round-progress-track span {
  display: block;
  width: 1%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 260ms ease;
}

.stats-note {
  margin: 1rem 0 0;
  color: var(--text-soft);
  font-size: 0.72rem;
  text-align: center;
}

.stats-new-session {
  width: 100%;
  margin-top: 0.7rem;
}

@keyframes screen-in {
  from {
    opacity: 0;
    transform: translateX(0.8rem);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@media (min-width: 700px) {
  body {
    background:
      radial-gradient(circle at 15% 10%, color-mix(in srgb, var(--accent-soft) 38%, transparent), transparent 25rem),
      var(--bg);
  }

  .study-screen {
    padding-right: 1.5rem;
    padding-left: 1.5rem;
  }

  .match-screen {
    padding-right: 1.5rem;
    padding-left: 1.5rem;
  }

  .study-card {
    margin: 0.75rem 0;
    padding: 1rem 2rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-xl);
    background: color-mix(in srgb, var(--surface) 82%, transparent);
    box-shadow: var(--shadow);
  }

  .answer-actions {
    width: min(100%, 38rem);
    margin: 0 auto;
  }

  .size-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .topic-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .size-button--wide {
    grid-column: span 2;
  }

  .result-actions {
    grid-template-columns: 1.35fr 1fr;
  }

  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .stat-card--wide {
    grid-column: span 2;
  }
}

@media (max-height: 680px) {
  .character {
    font-size: clamp(9rem, 46dvh, 20rem);
  }

  .study-screen.is-revealed .character {
    font-size: clamp(5rem, 25dvh, 11rem);
  }

  .example-block {
    margin-top: 0.55rem;
    padding-top: 0.6rem;
    padding-bottom: 0.6rem;
  }
}

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