:root {
  color-scheme: dark;
  --bg: #121110;
  --surface: #1b1917;
  --surface-2: #24211f;
  --surface-3: #2c2926;
  --text: #f5f1eb;
  --muted: #aaa39a;
  --line: rgba(255, 255, 255, 0.09);
  --accent: #ef6246;
  --accent-strong: #ff7659;
  --accent-soft: rgba(239, 98, 70, 0.14);
  --success: #67d2a0;
  --danger: #ff776d;
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.42);
  font-family: "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--text);
  background:
    radial-gradient(circle at 50% 0%, rgba(239, 98, 70, 0.08), transparent 38%),
    linear-gradient(160deg, #151311 0%, #0f0e0d 100%);
}

button,
input,
select {
  font: inherit;
}

button,
select {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(255, 118, 89, 0.4);
  outline-offset: 3px;
}

.ambient {
  position: fixed;
  z-index: 0;
  width: 28rem;
  height: 28rem;
  border-radius: 50%;
  filter: blur(100px);
  pointer-events: none;
  opacity: 0.1;
}

.ambient-one {
  top: -16rem;
  right: -10rem;
  background: #f06449;
}

.ambient-two {
  bottom: -18rem;
  left: -14rem;
  background: #9b3f2f;
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(100% - 32px, 720px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 38px 0;
  display: grid;
  align-items: center;
}

.screen {
  width: 100%;
  animation: screen-in 360ms ease-out both;
}

.is-hidden {
  display: none !important;
}

.start-card,
.result-card {
  padding: clamp(28px, 6vw, 52px);
  border: 1px solid var(--line);
  border-radius: 30px;
  background: rgba(27, 25, 23, 0.88);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
  text-align: center;
}

.brand-icon {
  width: 116px;
  height: 116px;
  margin: 0 auto 12px;
  display: block;
  object-fit: contain;
}

.eyebrow {
  margin: 0 0 9px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.16em;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 9px;
  font-size: clamp(38px, 8vw, 58px);
  line-height: 1.08;
  letter-spacing: -0.055em;
}

.training-title {
  margin: 0 auto 30px;
  font-size: clamp(28px, 6vw, 42px);
  line-height: 1.22;
  letter-spacing: -0.04em;
}

.rule-demo {
  padding: 20px 22px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.025);
  text-align: left;
}

.demo-flow {
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(7px, 2vw, 14px);
  color: var(--muted);
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: clamp(15px, 3.7vw, 20px);
  font-weight: 700;
}

.demo-flow i {
  color: #69635d;
  font-style: normal;
}

.demo-flow .current-demo {
  color: var(--text);
}

.rule-demo p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.75;
  text-align: center;
}

.rule-demo strong {
  color: var(--text);
}

.settings-grid {
  margin: 26px 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  text-align: left;
}

.setting-block {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.setting-wide {
  grid-column: 1 / -1;
}

.setting-block legend,
.setting-block > span {
  display: block;
  margin: 0 0 9px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 5px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #141210;
}

.segment {
  min-height: 44px;
  border: 0;
  border-radius: 10px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-weight: 800;
  transition: 150ms ease;
}

.segment:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.segment.is-selected {
  color: #fff;
  background: var(--accent);
  box-shadow: 0 7px 18px rgba(239, 98, 70, 0.2);
}

select {
  width: 100%;
  height: 50px;
  padding: 0 42px 0 15px;
  border: 1px solid var(--line);
  border-radius: 13px;
  color: var(--text);
  background: #141210;
  cursor: pointer;
}

select option {
  color: var(--text);
  background: #1b1917;
}

.primary-button,
.secondary-button,
.icon-button,
.text-button {
  border: 0;
  cursor: pointer;
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease;
}

.primary-button {
  min-height: 52px;
  padding: 0 22px;
  border-radius: 14px;
  color: #fff;
  background: var(--accent);
  font-weight: 800;
  box-shadow: 0 12px 30px rgba(239, 98, 70, 0.2);
}

.primary-button:hover {
  background: var(--accent-strong);
  transform: translateY(-1px);
}

.primary-button:active,
.secondary-button:active,
.icon-button:active {
  transform: translateY(1px);
}

.start-button {
  width: 100%;
  height: 58px;
  font-size: 16px;
}

.start-button span,
.primary-button span {
  margin-left: 5px;
  opacity: 0.76;
}

.game-footnote {
  margin: 15px 0 0;
  color: #77716b;
  font-size: 12px;
  text-align: center;
}

.game-header {
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mini-brand {
  font-size: 15px;
  font-weight: 800;
}

.mini-brand span {
  margin-right: 7px;
  color: var(--accent-strong);
  font-size: 23px;
  vertical-align: -2px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.icon-button,
.text-button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.03);
}

.icon-button {
  width: 42px;
}

.text-button {
  padding: 0 14px;
}

.icon-button:hover,
.text-button:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
}

.status-bar {
  margin-bottom: 12px;
  padding: 14px 18px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(27, 25, 23, 0.72);
}

.status-bar > div {
  min-width: 0;
  text-align: center;
}

.status-label {
  display: block;
  margin-bottom: 3px;
  color: #77716b;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.status-bar strong {
  display: block;
  overflow: hidden;
  color: #ddd7cf;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.play-card {
  position: relative;
  min-height: 500px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: rgba(27, 25, 23, 0.92);
  box-shadow: var(--shadow);
}

.screen.is-paused .play-card {
  visibility: hidden;
}

.challenge-zone {
  min-height: 285px;
  padding: 42px 28px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--line);
  background:
    radial-gradient(circle at 50% 25%, rgba(239, 98, 70, 0.09), transparent 48%),
    rgba(255, 255, 255, 0.012);
}

.stage-label {
  margin-bottom: 20px;
  padding: 6px 10px;
  border-radius: 999px;
  color: var(--accent-strong);
  background: var(--accent-soft);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.05em;
}

.current-instruction {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.equation {
  color: #fffdf8;
  font-family: Consolas, "SFMono-Regular", "Roboto Mono", monospace;
  font-size: clamp(50px, 11vw, 76px);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.05em;
  text-align: center;
  text-shadow: 0 12px 38px rgba(0, 0, 0, 0.28);
}

.memory-dots {
  min-height: 10px;
  margin-top: 26px;
  display: flex;
  gap: 7px;
}

.memory-dot {
  width: 7px;
  height: 7px;
  border: 1px solid #5b554f;
  border-radius: 50%;
  background: transparent;
  transition: 180ms ease;
}

.memory-dot.is-filled {
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: 0 0 10px rgba(239, 98, 70, 0.35);
}

.warmup-panel,
.answer-panel {
  min-height: 214px;
  padding: 28px clamp(22px, 6vw, 52px);
}

.warmup-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.warmup-panel p {
  margin-bottom: 20px;
  color: var(--muted);
  font-size: 14px;
}

.warmup-panel .primary-button {
  min-width: 230px;
}

.answer-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.answer-panel > label {
  display: block;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.answer-panel label strong {
  color: var(--text);
}

.answer-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

#answerInput {
  min-width: 0;
  height: 58px;
  padding: 0 18px;
  border: 1px solid #4c4641;
  border-radius: 14px;
  color: #fff;
  background: #12100f;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 24px;
  font-weight: 800;
  transition: 140ms ease;
}

#answerInput::placeholder {
  color: #5f5953;
  font-family: "Segoe UI", "Microsoft YaHei UI", sans-serif;
  font-size: 15px;
  font-weight: 600;
}

#answerInput:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(239, 98, 70, 0.1);
}

.submit-button {
  min-width: 116px;
  height: 58px;
}

.input-hint {
  margin: 10px 0 0;
  color: #77716b;
  font-size: 12px;
}

.feedback {
  position: absolute;
  z-index: 2;
  left: 50%;
  bottom: 18px;
  max-width: calc(100% - 32px);
  padding: 9px 14px;
  border: 1px solid transparent;
  border-radius: 10px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 8px);
  transition: 160ms ease;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
}

.feedback.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.feedback.is-correct {
  border-color: rgba(103, 210, 160, 0.22);
  color: var(--success);
  background: rgba(26, 76, 56, 0.88);
}

.feedback.is-wrong {
  border-color: rgba(255, 119, 109, 0.2);
  color: #ffb3ac;
  background: rgba(91, 38, 34, 0.9);
}

.pause-overlay {
  position: fixed;
  z-index: 20;
  inset: 0;
  padding: 24px;
  display: grid;
  place-items: center;
  background: rgba(10, 9, 8, 0.9);
  backdrop-filter: blur(16px);
}

.pause-card {
  width: min(100%, 420px);
  padding: 40px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: center;
}

.pause-icon {
  width: 54px;
  height: 54px;
  margin: 0 auto 18px;
  display: grid;
  place-items: center;
  border-radius: 17px;
  color: var(--accent-strong);
  background: var(--accent-soft);
  font-weight: 900;
}

.pause-card h2 {
  margin-bottom: 9px;
  font-size: 28px;
}

.pause-card p {
  margin-bottom: 24px;
  color: var(--muted);
  line-height: 1.7;
}

.pause-card .primary-button {
  width: 100%;
}

.result-card h2 {
  margin-bottom: 25px;
  font-size: clamp(29px, 6vw, 42px);
}

.score-orb {
  width: 150px;
  height: 150px;
  margin: 0 auto 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(239, 98, 70, 0.22);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(239, 98, 70, 0.16), rgba(239, 98, 70, 0.02) 70%);
  box-shadow: 0 0 50px rgba(239, 98, 70, 0.08);
}

.score-orb strong {
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 42px;
  line-height: 1;
}

.score-orb span {
  margin-top: 9px;
  color: var(--muted);
  font-size: 12px;
}

.result-metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
}

.result-metrics > div {
  padding: 16px 8px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.018);
}

.result-metrics > div:last-child {
  border-right: 0;
}

.result-metrics span,
.result-metrics strong {
  display: block;
}

.result-metrics span {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 11px;
}

.result-metrics strong {
  font-size: 15px;
}

.best-score-line {
  margin: 15px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.mistakes-section {
  margin-top: 25px;
  text-align: left;
}

.mistakes-section h3 {
  margin-bottom: 10px;
  font-size: 14px;
}

.mistakes-list {
  max-height: 190px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.mistake-item {
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.mistake-item:last-child {
  border-bottom: 0;
}

.mistake-equation {
  color: var(--text);
  font-family: Consolas, "SFMono-Regular", monospace;
  font-weight: 800;
}

.mistake-answer {
  text-align: right;
}

.mistake-answer em {
  color: var(--danger);
  font-style: normal;
}

.result-actions {
  margin-top: 28px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.secondary-button {
  min-height: 52px;
  padding: 0 22px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.035);
  font-weight: 800;
}

.secondary-button:hover {
  border-color: rgba(255, 255, 255, 0.17);
  background: rgba(255, 255, 255, 0.07);
}

@keyframes screen-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes bump {
  0% { transform: scale(1); }
  45% { transform: scale(1.025); }
  100% { transform: scale(1); }
}

.play-card.bump {
  animation: bump 180ms ease-out;
}

@media (max-width: 620px) {
  .app-shell {
    width: min(100% - 20px, 720px);
    padding: 18px 0;
  }

  .start-card,
  .result-card {
    border-radius: 23px;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .setting-wide {
    grid-column: auto;
  }

  .status-bar {
    padding-inline: 8px;
  }

  .status-bar strong {
    font-size: 11px;
  }

  .play-card {
    min-height: 480px;
    border-radius: 23px;
  }

  .challenge-zone {
    min-height: 270px;
  }

  .answer-row {
    grid-template-columns: 1fr;
  }

  .submit-button {
    width: 100%;
  }

  .feedback {
    bottom: 11px;
    font-size: 12px;
  }

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

  .result-metrics > div:nth-child(2) {
    border-right: 0;
  }

  .result-metrics > div:nth-child(-n+2) {
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 400px) {
  .demo-flow {
    gap: 5px;
  }

  .rule-demo {
    padding-inline: 12px;
  }

  .challenge-zone {
    padding-inline: 16px;
  }

  .answer-panel,
  .warmup-panel {
    padding-inline: 18px;
  }

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

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