@font-face {
  font-family: "LexiFlip Sans SC";
  src: url("./assets/lexiflip-sans-sc.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;
  --canvas: #f7f7f7;
  --paper: #fff;
  --ink: #171717;
  --muted: #575757;
  --wash: #f0f0f0;
  --line: #d7d7d7;
  --outline: 2px solid var(--ink);
  --lift: 0 3px 0 var(--ink);
  --radius: 20px;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, "LexiFlip Sans SC", sans-serif;
  font-synthesis: weight;
  -webkit-font-smoothing: antialiased;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-width: 320px; overscroll-behavior-x: none; }
body {
  min-height: 100vh;
  margin: 0;
  overflow-x: clip;
  background: var(--canvas);
  color: var(--ink);
  -webkit-user-select: none;
  user-select: none;
}
button, input, select { font: inherit; }
button, select { cursor: pointer; }
button, input, select, fieldset { margin: 0; }
button, select, .mode-option, .count-slider, .results-details summary {
  -webkit-tap-highlight-color: transparent;
}
.answer-form input {
  -webkit-user-select: text;
  user-select: text;
}
fieldset { min-width: 0; padding: 0; border: 0; }
legend { padding: 0; }
h1, h2, p { margin: 0; }
:focus-visible { outline: 2px dashed var(--ink); outline-offset: 4px; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.icon-library { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon {
  display: block;
  flex: none;
  width: 1.125em;
  height: 1.125em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.frame { width: min(1040px, calc(100% - 80px)); margin-inline: auto; }

.site-header { padding-top: 32px; }
.wordmark { display: inline-flex; align-items: center; gap: 10px; }
.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 11px;
  background: var(--ink);
  color: var(--paper);
  font-size: 1.25rem;
}
.brand-name { font-size: 1.08rem; font-weight: 800; letter-spacing: -.035em; }
.brand-name span { margin-left: 4px; color: var(--muted); font-size: .875rem; font-weight: 650; }

.page { padding-block: clamp(40px, 6.1vw, 84px) 68px; }
.page > section:not([hidden]) { animation: view-in .23s cubic-bezier(.2, .75, .25, 1) both; }
@keyframes view-in {
  from { transform: translateY(7px); }
  to { transform: translateY(0); }
}
.home-heading { margin-bottom: clamp(30px, 4.3vw, 57px); }
.home-heading h1 {
  font-size: clamp(2.7rem, 6.35vw, 5.15rem);
  font-weight: 850;
  line-height: 1.12;
  letter-spacing: -.065em;
  overflow-wrap: anywhere;
}
.home-heading h1:focus, .card-prompt:focus, .score-panel h1:focus { outline: none; }
.setup-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.67fr) minmax(300px, 1fr);
  align-items: end;
  gap: clamp(20px, 3vw, 36px);
}
.section-title { font-size: clamp(1.28rem, 2vw, 1.6rem); line-height: 1.35; font-weight: 800; letter-spacing: -.035em; }
.section-description { margin-top: 6px; color: var(--muted); font-size: .9375rem; line-height: 1.6; }
.mode-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 16px; }
.mode-option { position: relative; min-width: 0; cursor: pointer; }
.mode-option input {
  position: absolute;
  inset: 0 auto auto 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.mode-face {
  display: grid;
  grid-template-columns: 1fr auto;
  align-content: space-between;
  align-items: start;
  gap: 13px 7px;
  min-height: 126px;
  height: 100%;
  padding: 14px 16px 16px;
  border: var(--outline);
  border-radius: var(--radius);
  background: var(--paper);
  transition: background-color .15s;
}
.mode-option input:checked + .mode-face { background: var(--wash); }
.mode-option input:focus-visible + .mode-face {
  outline: 2px dashed var(--ink);
  outline-offset: 4px;
}
.mode-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  font-size: 1.08rem;
}
.check-mark {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: var(--outline);
  border-radius: 6px;
  background: var(--paper);
}
.mode-option input:checked + .mode-face .check-mark { background: var(--ink); }
.mode-option input:checked + .mode-face .check-mark::after {
  content: "";
  width: 6px;
  height: 11px;
  border: solid var(--paper);
  border-width: 0 2px 2px 0;
  transform: translateY(-1px) rotate(45deg);
}
.mode-copy { display: grid; grid-column: 1 / -1; gap: 4px; }
.mode-copy strong { font-size: 1.02rem; font-weight: 770; line-height: 1.38; }
.mode-copy small { color: var(--muted); font-size: .875rem; line-height: 1.45; }
.mode-section .form-message { margin-top: 11px; }

.setup-panel {
  display: flex;
  flex-direction: column;
  gap: 21px;
  justify-content: center;
  min-width: 0;
  padding: clamp(20px, 2.7vw, 30px);
  border: var(--outline);
  border-radius: 24px;
  background: var(--paper);
}
.field-line { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.field-label { display: block; font-size: .95rem; font-weight: 750; line-height: 1.45; }
.field-meta { color: var(--muted); font-size: .875rem; font-variant-numeric: tabular-nums; }
.select-wrap { position: relative; margin-top: 8px; }
.select-chevron {
  position: absolute;
  top: 50%;
  right: 13px;
  transform: translateY(-50%);
  pointer-events: none;
}
select, #answer-input {
  display: block;
  width: 100%;
  min-height: 47px;
  border: var(--outline);
  border-radius: 12px;
  background: var(--paper);
  color: var(--ink);
}
select { appearance: none; padding: 9px 36px 9px 12px; }
.count-slider {
  display: block;
  width: 100%;
  min-height: 44px;
  margin-top: 4px;
  accent-color: var(--ink);
  cursor: pointer;
}
.count-slider:disabled { cursor: default; }
.setup-actions { display: grid; gap: 8px; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 9px 15px;
  border: var(--outline);
  border-radius: 12px;
  background: var(--paper);
  color: var(--ink);
  font-weight: 750;
  line-height: 1.35;
  text-align: center;
  transition: background-color .15s;
}
.button.primary { background: var(--ink); color: var(--paper); }
.button.quiet { border-color: transparent; background: transparent; color: var(--muted); }
.button:disabled { opacity: .46; cursor: not-allowed; }
.start-button {
  width: 100%;
  min-height: 52px;
  margin-top: 2px;
  border-radius: 13px;
  box-shadow: var(--lift);
}

.session { width: min(620px, 100%); margin-inline: auto; }
.session-top, .position { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.exit-button { min-height: 44px; margin-left: -10px; padding-inline: 8px; font-size: .9rem; }
.position { color: var(--muted); font-size: .875rem; }
.position strong { color: var(--ink); font-size: 1.02rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.progress-track {
  width: 100%;
  height: 9px;
  margin-top: 3px;
  overflow: hidden;
  border: 1px solid var(--ink);
  border-radius: 99px;
  background: var(--wash);
}
.progress-fill {
  width: var(--progress, 0%);
  height: 100%;
  background: var(--ink);
  transition: width .28s cubic-bezier(.21, .65, .3, 1);
}
.deck-viewport {
  --air: 48px;
  width: 100vw;
  width: 100dvw;
  margin-inline: calc(50% - 50vw);
  margin-inline: calc(50% - 50dvw);
  margin-block: calc(24px - var(--air)) calc(22px - var(--air));
  padding-block: var(--air);
  overflow: hidden;
  overflow: clip;
  pointer-events: none;
  touch-action: pan-y pinch-zoom;
}
.card-stack {
  position: relative;
  isolation: isolate;
  width: min(620px, calc(100% - 80px));
  margin-inline: auto;
}
.question-card, .card-underlay {
  display: grid;
  min-height: 243px;
  padding: 30px 21px;
  place-items: center;
  border: 3px solid var(--ink);
  border-radius: 26px;
  background: var(--paper);
  text-align: center;
}
.card-underlay {
  position: absolute;
  inset: 0;
  padding-block: 0;
  border-width: 2px;
  transition: transform .24s cubic-bezier(.2, .72, .28, 1), background-color .24s;
}
#card-underlay-next {
  z-index: 1;
  background: #eeeeee;
  transform: translateY(calc(10px - 5px * var(--stack-progress, 0))) scale(calc(.967 + .022 * var(--stack-progress, 0)));
}
#card-underlay-later {
  z-index: 0;
  background: #dfdfdf;
  transform: translateY(calc(18px - 4px * var(--stack-progress, 0))) scale(calc(.931 + .021 * var(--stack-progress, 0)));
}
.card-stack:has(.dragging):not([data-transition]) .card-underlay { transition: none; }
.card-stack[data-transition] #card-underlay-next { transform: translateY(0) scale(1); background: var(--paper); }
.card-stack[data-transition] #card-underlay-later { transform: translateY(10px) scale(.967); background: #eeeeee; }
.question-card {
  position: relative;
  z-index: 2;
  pointer-events: auto;
  touch-action: pan-y pinch-zoom;
  cursor: grab;
  transform: translateX(var(--drag-x, 0px)) rotate(var(--drag-angle, 0deg));
  transition: transform .23s cubic-bezier(.2, .79, .35, 1.13);
}
.question-card.dragging { cursor: grabbing; transition: none; }
.question-card[data-transition] {
  cursor: default;
  pointer-events: none;
  animation: card-throw .26s cubic-bezier(.34, .02, .69, .58) both;
}
@keyframes card-throw {
  from { opacity: 1; transform: translateX(var(--drag-x, 0px)) rotate(var(--drag-angle, 0deg)); }
  62% { opacity: 1; }
  to { opacity: 0; transform: translateX(var(--throw-x, 70vw)) rotate(var(--throw-angle, 15deg)); }
}
.card-prompt, .card-underlay-prompt {
  max-width: 100%;
  font-size: clamp(2.15rem, 7vw, 4.2rem);
  font-weight: 820;
  line-height: 1.13;
  letter-spacing: -.05em;
  overflow-wrap: anywhere;
}
.swipe-feedback {
  display: none;
  position: absolute;
  inset: 16px auto auto 17px;
  padding: 5px 10px;
  border: var(--outline);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  font-size: .875rem;
  font-weight: 750;
}
.question-card[data-swipe] .swipe-feedback { display: block; }
.question-card[data-swipe="submit"] .swipe-feedback,
.question-card[data-swipe="defer"] .swipe-feedback {
  left: auto;
  right: 17px;
  background: var(--ink);
  color: var(--paper);
}
.gesture-guide {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin: 0 2px 21px;
  color: var(--muted);
  font-size: .875rem;
  line-height: 1.45;
}
.gesture-guide span:last-child { text-align: end; }
.answer-form {
  display: grid;
  gap: 11px;
  padding: clamp(14px, 3.1vw, 23px);
  border: var(--outline);
  border-radius: 22px;
  background: var(--paper);
}
#answer-input { padding: 10px 13px; font-size: 1rem; }
#answer-input::placeholder { color: var(--muted); }
.choices-panel { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.choice-option {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 49px;
  padding: 8px 10px;
  border: var(--outline);
  border-radius: 11px;
  background: var(--paper);
  color: var(--ink);
  text-align: start;
  line-height: 1.35;
  transition: background-color .15s, color .15s;
}
.choice-option[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.choice-option span:last-child { min-width: 0; overflow-wrap: anywhere; }
.choice-key {
  display: grid;
  flex: none;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 5px;
  background: var(--wash);
  color: var(--ink);
  font-size: .8125rem;
  font-weight: 800;
}
.choice-option[aria-pressed="true"] .choice-key { background: var(--paper); }
.form-message { color: var(--muted); font-size: .9125rem; line-height: 1.55; }
.form-message:empty { display: none; }
.form-message[data-status="error"], #mode-error { color: var(--ink); font-weight: 700; }
.answer-feedback { min-block-size: 1.45em; }
.answer-feedback .form-message:empty { display: block; }
#answer-form[data-defer-guidance="true"] #answer-message:not(:empty) {
  padding-inline-start: 9px;
  border-inline-start: 2px solid #bfbfbf;
  animation: note-in .21s ease-out both;
}
@keyframes note-in {
  from { opacity: .35; transform: translateY(3px); }
  to { opacity: 1; transform: translateY(0); }
}
.quiz-controls, .result-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.quiz-controls { margin-top: 2px; }
.quiz-controls .button:disabled {
  opacity: 1;
  cursor: default;
}

.score-panel {
  padding: clamp(25px, 4.6vw, 43px) clamp(16px, 4.6vw, 35px) 25px;
  border: 3px solid var(--ink);
  border-radius: 27px;
  background: var(--paper);
  box-shadow: var(--lift);
  text-align: center;
}
.score-panel h1 { color: var(--muted); font-size: 1.08rem; font-weight: 730; }
.score-main { margin-top: 8px; }
.accuracy {
  font-size: clamp(4rem, 13vw, 7.35rem);
  font-weight: 850;
  font-variant-numeric: tabular-nums;
  line-height: 1.07;
  letter-spacing: -.085em;
}
.accuracy-label { margin-top: 4px; color: var(--muted); font-size: .95rem; font-weight: 650; }
.score-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 24px 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.score-stats div + div { border-left: 1px solid var(--line); }
.score-stats dt { color: var(--muted); font-size: .875rem; }
.score-stats dd { margin: 3px 0 0; font-size: 1.35rem; font-variant-numeric: tabular-nums; font-weight: 800; }
.settlement-status { margin: 19px 2px 0; }
.settlement-retry { margin-top: 8px; }
.result-actions { margin-top: 22px; }
.export-mistakes { grid-column: 1 / -1; }
.results-details { margin-top: 16px; border: var(--outline); border-radius: 18px; background: var(--paper); }
.results-details summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 52px;
  padding: 11px 15px;
  border-radius: 15px;
  font-weight: 750;
  line-height: 1.45;
  list-style: none;
  cursor: pointer;
}
.results-details summary::-webkit-details-marker { display: none; }
.results-details summary .icon { transition: transform .15s; }
.results-details[open] summary .icon { transform: rotate(180deg); }
.table-scroll { overflow: auto; border-top: var(--outline); border-radius: 0 0 16px 16px; }
table { width: 100%; border-collapse: collapse; text-align: start; font-size: .875rem; line-height: 1.5; }
th, td { padding: 11px 10px; border-bottom: 1px solid var(--line); text-align: start; overflow-wrap: anywhere; }
th { background: var(--wash); color: var(--muted); font-weight: 720; white-space: nowrap; }
td:first-child, td:last-child { white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
.result-status {
  display: inline-flex;
  padding: 2px 7px;
  border: 1px solid var(--ink);
  border-radius: 7px;
  font-size: .8125rem;
  font-weight: 750;
  white-space: nowrap;
}
.result-status[data-status="correct"] { background: var(--ink); color: var(--paper); }
.result-status[data-status="skipped"] { border-style: dashed; }

@media (hover: hover) and (pointer: fine) {
  .mode-option:hover .mode-face { background: #e7e7e7; }
  select:hover, #answer-input:hover { background: var(--wash); }
  .button.primary:not(:disabled):hover { background: #363636; }
  .button.outline:not(:disabled):hover,
  .choice-option[aria-pressed="false"]:not(:disabled):hover,
  .results-details summary:hover { background: var(--wash); }
  .button.quiet:not(:disabled):hover { background: #e9e9e9; color: var(--ink); }
  tbody tr:hover { background: #fafafa; }
}
.button.primary:not(:disabled):active { background: #4a4a4a; }
.button.outline:not(:disabled):active,
.button.quiet:not(:disabled):active,
.choice-option[aria-pressed="false"]:not(:disabled):active { background: #e5e5e5; }

@media (max-width: 820px) {
  .frame { width: calc(100% - 48px); }
  .setup-grid { grid-template-columns: minmax(0, 1.42fr) minmax(269px, 1fr); }
}

@media (max-width: 690px) {
  .frame { width: calc(100% - 34px); }
  .site-header { padding-top: 21px; }
  .brand-mark { width: 35px; height: 35px; }
  .page { padding-block: 35px 43px; }
  .home-heading { margin-bottom: 28px; }
  .home-heading h1 { font-size: clamp(2.4rem, 9.3vw, 4.15rem); }
  .setup-grid { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .mode-grid { gap: 10px; margin-top: 13px; }
  .mode-face { min-height: 111px; gap: 9px 6px; padding: 11px 12px 13px; border-radius: 18px; }
  .mode-icon { width: 31px; height: 31px; }
  .mode-copy strong { font-size: .975rem; }
  .setup-panel { gap: 17px; }
  .deck-viewport { margin-block: calc(19px - var(--air)) calc(20px - var(--air)); }
  .card-stack { width: min(620px, calc(100% - 34px)); }
  .question-card, .card-underlay { min-height: 178px; border-radius: 23px; }
  .card-prompt, .card-underlay-prompt { font-size: clamp(2.05rem, 8vw, 3.65rem); }
  .gesture-guide { margin-bottom: 15px; }
}

@media (max-width: 570px) {
  .answer-feedback { min-block-size: 2.85em; }
  .table-scroll { overflow: visible; }
  table, tbody { display: block; }
  thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
  }
  tbody tr {
    display: grid;
    gap: 4px;
    padding: 13px;
    border-bottom: 1px solid var(--line);
  }
  tbody tr:last-child { border-bottom: 0; }
  td {
    display: grid;
    grid-template-columns: minmax(68px, .42fr) minmax(0, 1fr);
    align-items: baseline;
    justify-items: start;
    gap: 8px;
    padding: 4px 3px;
    border: 0;
  }
  td::before { content: attr(data-label); content: attr(data-label) / ""; color: var(--muted); font-size: .875rem; }
  td:first-child { font-weight: 750; }
}

@media (max-width: 370px) {
  .frame { width: calc(100% - 28px); }
  .card-stack { width: calc(100% - 28px); }
  .mode-copy strong { font-size: .925rem; }
  .choice-option { padding-inline: 7px; }
  .choice-key { width: 20px; height: 22px; }
}

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