:root {
  --bg: #100909;
  --bg-soft: #180f0d;
  --panel: #211614;
  --panel-2: #2b1b17;
  --paper: #f6e8c9;
  --paper-dim: #cbb894;
  --red: #c9362c;
  --red-soft: rgba(201, 54, 44, 0.18);
  --gold: #d8a84f;
  --gold-soft: rgba(216, 168, 79, 0.18);
  --jade: #4fb286;
  --jade-soft: rgba(79, 178, 134, 0.18);
  --muted: #9a8872;
  --error: #ff6767;
  --shadow: rgba(0, 0, 0, 0.35);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --transition: 170ms ease;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(201, 54, 44, 0.18), transparent 32rem),
    radial-gradient(circle at bottom right, rgba(216, 168, 79, 0.12), transparent 30rem),
    var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--paper);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.025), transparent),
    var(--bg);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100dvh;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding: 28px 28px 42px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent),
    var(--panel);
  border-right: 1px solid rgba(246, 232, 201, 0.08);
  box-shadow: 18px 0 40px rgba(0, 0, 0, 0.22);
  z-index: 20;
}

.sidebar::-webkit-scrollbar {
  width: 10px;
}

.sidebar::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.025);
}

.sidebar::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 999px;
  background: rgba(216, 168, 79, 0.35);
  background-clip: padding-box;
}

.sidebar::-webkit-scrollbar-thumb:hover {
  background: rgba(216, 168, 79, 0.55);
  background-clip: padding-box;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 36px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  overflow: hidden;
  border-radius: 18px;
  color: var(--paper);
  font-size: 30px;
  font-weight: 900;
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.18), transparent 45%),
    linear-gradient(135deg, var(--red), #8b1d18);
  box-shadow:
    0 16px 28px rgba(201, 54, 44, 0.28),
    inset 0 0 0 1px rgba(255, 255, 255, 0.15);
}
/*
.logo-mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}*/
.logo-mark img {
  width: 82%;
  height: 82%;
  object-fit: contain;
}

.logo-mark:has(img) {
  background: rgba(255, 255, 255, 0.04);
}

.brand h1 {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: 0.02em;
}

.brand p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.panel-section {
  margin-bottom: 28px;
}

.panel-section h2 {
  margin: 0 0 12px;
  color: var(--gold);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.button-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.option-button {
  border: 1px solid rgba(246, 232, 201, 0.11);
  border-radius: 14px;
  padding: 12px 10px;
  color: var(--paper-dim);
  background: rgba(255, 255, 255, 0.035);
  transition:
    transform var(--transition),
    border-color var(--transition),
    background var(--transition),
    color var(--transition);
}

.option-button:hover {
  transform: translateY(-1px);
  border-color: rgba(216, 168, 79, 0.35);
  color: var(--paper);
  background: rgba(255, 255, 255, 0.055);
}

.option-button.active {
  border-color: rgba(216, 168, 79, 0.6);
  color: var(--paper);
  background:
    linear-gradient(135deg, rgba(216, 168, 79, 0.22), rgba(201, 54, 44, 0.14));
  box-shadow: 0 10px 24px rgba(216, 168, 79, 0.08);
}

.select {
  width: 100%;
  border: 1px solid rgba(246, 232, 201, 0.11);
  border-radius: 14px;
  padding: 13px 14px;
  color: var(--paper);
  background: #1a100f;
  outline: none;
}

.muted-section {
  opacity: 0.85;
}

.mini-list {
  display: grid;
  gap: 9px;
}

.mini-list span {
  padding: 10px 12px;
  border: 1px dashed rgba(246, 232, 201, 0.12);
  border-radius: 12px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.025);
}

.main {
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.topbar-title {
  display: flex;
  align-items: center;
  gap: 13px;
}

.seal {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  color: var(--bg);
  font-weight: 900;
  background: var(--gold);
  box-shadow: 0 12px 28px rgba(216, 168, 79, 0.22);
}

.topbar-title strong {
  display: block;
  font-size: 1rem;
}

.topbar-title small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

.mobile-menu-button {
  display: none;
  border: 1px solid rgba(246, 232, 201, 0.14);
  border-radius: 12px;
  padding: 10px 13px;
  color: var(--paper);
  background: rgba(255, 255, 255, 0.04);
}

.restart-button {
  border: 1px solid rgba(216, 168, 79, 0.35);
  border-radius: 14px;
  padding: 11px 16px;
  color: var(--paper);
  background:
    linear-gradient(135deg, rgba(216, 168, 79, 0.18), rgba(201, 54, 44, 0.14));
  transition:
    transform var(--transition),
    background var(--transition),
    border-color var(--transition);
}

.restart-button:hover {
  transform: translateY(-1px);
  border-color: rgba(216, 168, 79, 0.7);
  background:
    linear-gradient(135deg, rgba(216, 168, 79, 0.26), rgba(201, 54, 44, 0.2));
}

.restart-button.large {
  padding: 14px 18px;
  font-weight: 800;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.stat-card {
  min-height: 92px;
  padding: 18px;
  border: 1px solid rgba(246, 232, 201, 0.09);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.02)),
    var(--panel);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.18);
}

.stat-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.stat-card strong {
  font-size: clamp(1.75rem, 4vw, 2.6rem);
  line-height: 1;
}

.typing-stage {
  position: relative;
  overflow: hidden;
  min-height: 520px;
  padding: clamp(22px, 4vw, 42px);
  border: 1px solid rgba(246, 232, 201, 0.1);
  border-radius: var(--radius-xl);
  background:
    radial-gradient(circle at 50% 0%, rgba(216, 168, 79, 0.1), transparent 34rem),
    linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.018)),
    var(--bg-soft);
  box-shadow:
    0 28px 70px rgba(0, 0, 0, 0.28),
    inset 0 0 0 1px rgba(255, 255, 255, 0.025);
}

.stage-glow {
  position: absolute;
  inset: auto -10% -42% -10%;
  height: 340px;
  pointer-events: none;
  background:
    radial-gradient(circle, rgba(201, 54, 44, 0.17), transparent 58%),
    radial-gradient(circle, rgba(216, 168, 79, 0.11), transparent 48%);
  filter: blur(14px);
}

.instruction-box {
  position: relative;
  z-index: 1;
  display: inline-flex;
  max-width: 100%;
  margin-bottom: 28px;
  padding: 12px 15px;
  border: 1px solid rgba(216, 168, 79, 0.2);
  border-radius: 999px;
  color: var(--paper-dim);
  background: rgba(0, 0, 0, 0.18);
  font-size: 0.92rem;
}

.instruction-box strong {
  color: var(--gold);
}

.word-stream {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-content: flex-start;
  min-height: 250px;
  margin-bottom: 30px;
}

.word-card {
  position: relative;
  width: min(160px, calc(50vw - 38px));
  min-height: 112px;
  padding: 13px 12px 12px;
  border: 1px solid rgba(246, 232, 201, 0.085);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.035);
  transition:
    transform var(--transition),
    border-color var(--transition),
    background var(--transition),
    opacity var(--transition);
}

.word-card.active {
  transform: translateY(-3px);
  border-color: rgba(216, 168, 79, 0.62);
  background:
    linear-gradient(180deg, rgba(216, 168, 79, 0.13), rgba(255, 255, 255, 0.035));
  box-shadow:
    0 18px 34px rgba(0, 0, 0, 0.2),
    0 0 0 4px rgba(216, 168, 79, 0.05);
}

.word-card.done {
  opacity: 0.48;
}

.word-card.correct {
  border-color: rgba(79, 178, 134, 0.35);
}

.word-card.wrong {
  border-color: rgba(255, 103, 103, 0.45);
  background: rgba(255, 103, 103, 0.065);
}

.hanzi-line {
  min-height: 34px;
  color: var(--paper);
  font-size: 1.6rem;
  font-weight: 800;
  text-align: center;
  letter-spacing: 0.08em;
}

.pinyin-line {
  min-height: 26px;
  margin-top: 6px;
  color: var(--gold);
  font-size: 1.05rem;
  font-weight: 700;
  text-align: center;
}

.english-line {
  min-height: 20px;
  margin-top: 7px;
  color: var(--muted);
  font-size: 0.84rem;
  text-align: center;
    display: -webkit-box;
  overflow: hidden;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.char.correct-char {
  color: var(--jade);
  text-shadow: 0 0 16px rgba(79, 178, 134, 0.34);
}

.char.wrong-char {
  color: var(--error);
  text-shadow: 0 0 14px rgba(255, 103, 103, 0.26);
}

.char.current-char {
  position: relative;
  color: var(--paper);
}

.char.current-char::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -4px;
  height: 2px;
  border-radius: 999px;
  background: var(--gold);
  box-shadow: 0 0 10px rgba(216, 168, 79, 0.7);
}

.input-wrap {
  position: relative;
  z-index: 1;
}

.typing-input {
  width: 100%;
  border: 0;
  border-radius: 18px;
  padding: 20px 22px;
  color: var(--paper);
  background: rgba(0, 0, 0, 0.22);
  outline: none;
  font-size: clamp(1.15rem, 3vw, 1.55rem);
  box-shadow:
    inset 0 0 0 1px rgba(246, 232, 201, 0.12),
    0 16px 34px rgba(0, 0, 0, 0.18);
}

.typing-input:focus {
  box-shadow:
    inset 0 0 0 1px rgba(216, 168, 79, 0.46),
    0 16px 34px rgba(0, 0, 0, 0.18),
    0 0 0 4px rgba(216, 168, 79, 0.07);
}

.typing-input:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.input-underline {
  height: 3px;
  width: 0;
  margin: 8px auto 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--red), var(--gold), var(--jade));
  transition: width var(--transition);
}

.typing-input:focus + .input-underline {
  width: 96%;
}

.current-hint {
  position: relative;
  z-index: 1;
  margin-top: 18px;
  color: var(--muted);
  font-size: 0.95rem;
  text-align: center;
}

.result-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 22px;
  padding: 22px;
  border: 1px solid rgba(216, 168, 79, 0.24);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(135deg, rgba(216, 168, 79, 0.13), rgba(201, 54, 44, 0.1)),
    var(--panel);
}

.result-panel h2 {
  margin: 0 0 6px;
}

.result-panel p {
  margin: 0;
  color: var(--paper-dim);
}

.hidden {
  display: none;
}

.sidebar-backdrop {
  display: none;
}

@keyframes wrongShake {
  0%, 100% {
    transform: translateX(0);
  }

  30% {
    transform: translateX(-4px);
  }

  60% {
    transform: translateX(4px);
  }
}

.shake {
  animation: wrongShake 160ms ease;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

    .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(330px, 86vw);
    height: 100dvh;
    overflow-y: auto;
    transform: translateX(-105%);
    transition: transform 220ms ease;
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    display: block;
    pointer-events: none;
    opacity: 0;
    background: rgba(0, 0, 0, 0.58);
    transition: opacity 220ms ease;
    z-index: 10;
  }

  body.sidebar-open .sidebar-backdrop {
    pointer-events: auto;
    opacity: 1;
  }

  .mobile-menu-button {
    display: inline-flex;
  }

  .main {
    padding: 18px;
  }

  .topbar {
    align-items: center;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .typing-stage {
    min-height: 500px;
  }

  .instruction-box {
    border-radius: 16px;
  }
}

@media (max-width: 620px) {
  .main {
    padding: 14px;
  }

  .topbar {
    gap: 10px;
  }

  .topbar-title {
    min-width: 0;
  }

  .topbar-title small {
    max-width: 190px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .restart-button {
    padding: 10px 12px;
  }

  .stats-grid {
    gap: 10px;
  }

  .stat-card {
    min-height: 80px;
    padding: 14px;
  }

  .typing-stage {
    padding: 18px;
    border-radius: 22px;
  }

  .word-stream {
    gap: 10px;
  }

  .word-card {
    width: calc(50% - 5px);
    min-height: 108px;
    padding: 11px 9px;
  }

  .hanzi-line {
    font-size: 1.38rem;
  }

  .pinyin-line {
    font-size: 0.98rem;
  }

  .english-line {
    font-size: 0.78rem;
  }

  .result-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .result-panel .restart-button {
    width: 100%;
  }
}





.hidden-control {
  display: none;
}

body.story-practice #timeSection {
  display: none;
}

body.story-practice #storyLevelSection {
  display: block;
}

body.random-practice #storyLevelSection {
  display: none;
}

.story-title-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
  padding: 10px 13px;
  border: 1px solid rgba(216, 168, 79, 0.2);
  border-radius: 999px;
  color: var(--gold);
  background: rgba(216, 168, 79, 0.08);
  font-size: 0.9rem;
  font-weight: 800;
}








body.mistakes-practice #timeSection {
  display: none;
}

body.mistakes-practice #storyLevelSection {
  display: none;
}

.side-note {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.side-note strong {
  color: var(--gold);
}

.subtle-button {
  width: 100%;
  border: 1px solid rgba(246, 232, 201, 0.11);
  border-radius: 14px;
  padding: 11px 12px;
  color: var(--paper-dim);
  background: rgba(255, 255, 255, 0.035);
  transition:
    transform var(--transition),
    border-color var(--transition),
    color var(--transition),
    background var(--transition);
}

.subtle-button:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 103, 103, 0.38);
  color: var(--paper);
  background: rgba(255, 103, 103, 0.08);
}

.empty-state {
  width: 100%;
  padding: 28px;
  border: 1px dashed rgba(216, 168, 79, 0.25);
  border-radius: 22px;
  color: var(--paper-dim);
  background: rgba(255, 255, 255, 0.025);
  text-align: center;
}

.empty-state strong {
  display: block;
  margin-bottom: 8px;
  color: var(--gold);
  font-size: 1.15rem;
}






.line-hidden {
  color: rgba(246, 232, 201, 0.24);
  font-style: italic;
  letter-spacing: 0.04em;
}

.prompt-primary {
  color: var(--paper);
  font-size: 1.05rem;
  font-weight: 900;
}

.reveal-badge {
  display: inline-flex;
  align-items: center;
  margin-left: 6px;
  padding: 2px 7px;
  border: 1px solid rgba(216, 168, 79, 0.2);
  border-radius: 999px;
  color: var(--gold);
  background: rgba(216, 168, 79, 0.08);
  font-size: 0.72rem;
  font-weight: 800;
}







.tone-syllable {
  display: inline-block;
  margin-inline: 1px;
  transition:
    color var(--transition),
    text-shadow var(--transition),
    transform var(--transition);
}

.word-card.active .tone-syllable {
  transform: translateY(-1px);
}

.tone-1 {
  color: #f1c86a;
  text-shadow: 0 0 14px rgba(241, 200, 106, 0.22);
}

.tone-2 {
  color: #67d39b;
  text-shadow: 0 0 14px rgba(103, 211, 155, 0.2);
}

.tone-3 {
  color: #7fb7ff;
  text-shadow: 0 0 14px rgba(127, 183, 255, 0.2);
}

.tone-4 {
  color: #ff7a70;
  text-shadow: 0 0 14px rgba(255, 122, 112, 0.22);
}

.tone-0 {
  color: var(--paper-dim);
  text-shadow: none;
}

.infinity-mark {
  color: var(--gold);
  font-weight: 900;
}






.custom-pack-panel {
  display: none;
}

body.custom-pack-selected .custom-pack-panel {
  display: block;
}

.custom-pack-input {
  width: 100%;
  min-height: 190px;
  resize: vertical;
  border: 1px solid rgba(246, 232, 201, 0.11);
  border-radius: 14px;
  padding: 12px 13px;
  color: var(--paper);
  background: rgba(0, 0, 0, 0.22);
  outline: none;
  font: inherit;
  font-size: 0.9rem;
  line-height: 1.45;
}

.custom-pack-input:focus {
  border-color: rgba(216, 168, 79, 0.46);
  box-shadow: 0 0 0 4px rgba(216, 168, 79, 0.07);
}

.custom-action-row {
  display: grid;
  grid-template-columns: 1fr 0.7fr;
  gap: 8px;
  margin-top: 10px;
}

.danger-button:hover {
  border-color: rgba(255, 103, 103, 0.55);
  background: rgba(255, 103, 103, 0.12);
}

body.custom-pack-selected .mini-list span:first-child {
  border-color: rgba(79, 178, 134, 0.3);
  color: var(--jade);
}







.story-progress-note {
  margin-top: 10px;
  padding: 10px 11px;
  border: 1px solid rgba(246, 232, 201, 0.09);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.025);
}

.story-progress-note strong {
  color: var(--jade);
}

.story-progress-note .gold {
  color: var(--gold);
}

.story-progress-note .muted {
  color: var(--muted);
}







.story-meta-card {
  width: 100%;
  margin-bottom: 4px;
  padding: 18px 20px;
  border: 1px solid rgba(216, 168, 79, 0.22);
  border-radius: 22px;
  background:
    radial-gradient(circle at top left, rgba(216, 168, 79, 0.13), transparent 22rem),
    linear-gradient(135deg, rgba(201, 54, 44, 0.08), rgba(255, 255, 255, 0.025));
  box-shadow:
    0 18px 36px rgba(0, 0, 0, 0.16),
    inset 0 0 0 1px rgba(255, 255, 255, 0.025);
}

.story-meta-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 8px;
}

.story-meta-title {
  color: var(--paper);
  font-size: clamp(1rem, 2.5vw, 1.25rem);
  font-weight: 900;
}

.story-meta-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
}

.story-meta-badge {
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(216, 168, 79, 0.25);
  border-radius: 999px;
  padding: 5px 9px;
  color: var(--gold);
  background: rgba(216, 168, 79, 0.08);
  font-size: 0.76rem;
  font-weight: 800;
}

.story-meta-goal {
  margin: 0;
  color: var(--paper-dim);
  font-size: 0.94rem;
  line-height: 1.45;
}

.story-meta-progress {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.84rem;
}

.story-meta-progress strong {
  color: var(--jade);
}

@media (max-width: 620px) {
  .story-meta-top {
    align-items: flex-start;
    flex-direction: column;
  }

  .story-meta-badges {
    justify-content: flex-start;
  }
}









.story-filter-select {
  margin-bottom: 14px;
}

.story-level-heading {
  margin-top: 16px !important;
}

.story-progress-note .danger {
  color: var(--error);
}

.story-progress-note .jade {
  color: var(--jade);
}


.progress-panel {
  padding: 14px;
  border: 1px solid rgba(246, 232, 201, 0.08);
  border-radius: 20px;
  background:
    radial-gradient(circle at top left, rgba(216, 168, 79, 0.09), transparent 16rem),
    rgba(255, 255, 255, 0.025);
}

.progress-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.progress-tile {
  min-height: 66px;
  padding: 11px 10px;
  border: 1px solid rgba(246, 232, 201, 0.08);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.14);
}

.progress-tile span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.progress-tile strong {
  color: var(--paper);
  font-size: 1.25rem;
  line-height: 1;
}

.progress-tile:nth-child(1) strong,
.progress-tile:nth-child(2) strong {
  color: var(--jade);
}

.progress-tile:nth-child(5) strong,
.progress-tile:nth-child(6) strong {
  color: var(--gold);
}

.dashboard-note {
  margin-top: 12px;
  margin-bottom: 0;
  font-size: 0.82rem;
}



.pack-note {
  margin-top: 10px;
  padding: 10px 11px;
  border: 1px solid rgba(246, 232, 201, 0.09);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.025);
}

.pack-note strong {
  color: var(--gold);
}

.pack-note .jade {
  color: var(--jade);
}

.pack-note .danger {
  color: var(--error);
}






body:not(.random-practice) #wordPackSection,
body:not(.random-practice) #customPackSection {
  display: none;
}




.backup-panel {
  padding: 16px;
  margin-bottom: 28px;
  border: 1px solid rgba(79, 178, 134, 0.18);
  border-radius: 20px;
  background:
    radial-gradient(circle at top left, rgba(79, 178, 134, 0.1), transparent 13rem),
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.012));
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.025),
    0 14px 28px rgba(0, 0, 0, 0.12);
}

.backup-panel h2 {
  margin-bottom: 9px;
}

.backup-panel > .side-note {
  margin-bottom: 12px;
  font-size: 0.86rem;
  line-height: 1.45;
}

.backup-action-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.backup-action-row .subtle-button {
  min-height: 46px;
  padding: 10px 8px;
  border-radius: 14px;
  color: var(--paper);
  font-size: 0.84rem;
  font-weight: 900;
  white-space: nowrap;
  background:
    linear-gradient(135deg, rgba(79, 178, 134, 0.12), rgba(216, 168, 79, 0.08));
}

.backup-action-row .subtle-button:hover {
  border-color: rgba(79, 178, 134, 0.45);
  background:
    linear-gradient(135deg, rgba(79, 178, 134, 0.18), rgba(216, 168, 79, 0.12));
}

.backup-note {
  margin: 12px 0 0;
  padding: 9px 10px;
  border: 1px solid rgba(79, 178, 134, 0.14);
  border-radius: 12px;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.12);
  font-size: 0.82rem;
}

.backup-note strong {
  color: var(--jade);
}

@media (max-width: 520px) {
  .backup-action-row {
    grid-template-columns: 1fr;
  }
}






.word-card.has-audio {
  padding-top: 32px;
}

.audio-button {
  position: absolute;
  top: 8px;
  right: 8px;
  display: grid;
  place-items: center;
  width: 30px;
  height: 28px;
  border: 1px solid rgba(216, 168, 79, 0.26);
  border-radius: 10px;
  color: var(--gold);
  background: rgba(0, 0, 0, 0.18);
  font-size: 0.78rem;
  font-weight: 900;
  line-height: 1;
  transition:
    transform var(--transition),
    border-color var(--transition),
    background var(--transition),
    color var(--transition);
}

.audio-button:hover {
  transform: translateY(-1px);
  border-color: rgba(216, 168, 79, 0.58);
  color: var(--paper);
  background: rgba(216, 168, 79, 0.16);
}

.audio-button:active {
  transform: translateY(0);
}






.custom-preview {
  margin: 9px 0 12px;
  padding: 9px 10px;
  border: 1px solid rgba(246, 232, 201, 0.08);
  border-radius: 12px;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.14);
  font-size: 0.82rem;
  line-height: 1.4;
}

.custom-preview strong {
  color: var(--jade);
}

.custom-preview .danger {
  color: var(--error);
}

.custom-action-row-three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.custom-action-row-three .subtle-button {
  padding-inline: 8px;
  font-size: 0.84rem;
  font-weight: 800;
}

@media (max-width: 520px) {
  .custom-action-row-three {
    grid-template-columns: 1fr;
  }
}







@media (max-width: 760px) {
  .main {
    padding: 12px;
    padding-bottom: 24px;
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 8;
    margin: -12px -12px 14px;
    padding: 12px;
    background: rgba(16, 9, 9, 0.86);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid rgba(246, 232, 201, 0.07);
  }

  .topbar-title {
    gap: 10px;
  }

  .seal {
    width: 40px;
    height: 40px;
    border-radius: 12px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
    margin-bottom: 12px;
  }

  .stat-card {
    min-height: 76px;
    padding: 12px;
    border-radius: 16px;
  }

  .stat-label {
    margin-bottom: 6px;
    font-size: 0.72rem;
  }

  .typing-stage {
    min-height: calc(100dvh - 230px);
    padding: 14px;
    border-radius: 20px;
  }

  .instruction-box {
    display: block;
    width: 100%;
    margin-bottom: 14px;
    border-radius: 14px;
    font-size: 0.82rem;
    line-height: 1.4;
  }

  .word-stream {
    gap: 8px;
    margin-bottom: 14px;
  }

  .word-card {
    width: calc(50% - 4px);
    min-height: 118px;
    padding: 12px 8px;
    border-radius: 16px;
  }

  .word-card.has-audio {
    padding-top: 34px;
  }

  .hanzi-line {
    font-size: 1.3rem;
  }

  .pinyin-line {
    font-size: 0.9rem;
  }

  .english-line {
    font-size: 0.75rem;
  }

  .typing-input {
    padding: 16px;
    border-radius: 16px;
    font-size: 1.05rem;
  }

  .current-hint {
    margin-top: 12px;
    font-size: 0.84rem;
    line-height: 1.45;
  }
}

@media (max-width: 380px) {
  .word-card {
    width: 100%;
  }

  .topbar-title small {
    max-width: 145px;
  }
}





.method-note {
  margin-top: 10px;
  border: 1px solid rgba(216, 168, 79, 0.13);
  border-radius: 13px;
  background: rgba(0, 0, 0, 0.12);
  overflow: hidden;
}

.method-note summary {
  padding: 10px 11px;
  color: var(--gold);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 900;
  list-style-position: inside;
}

.method-note p {
  margin: 0;
  padding: 0 11px 11px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.method-note strong {
  color: var(--paper);
}





/* =========================================================
   THEME SYSTEM — Classic Ink + Dragon Neon
   ========================================================= */

:root,
:root[data-theme="classic"] {
  --bg: #100909;
  --bg-soft: #180f0d;
  --panel: #211614;
  --panel-2: #2b1b17;
  --paper: #f6e8c9;
  --paper-dim: #cbb894;
  --red: #c9362c;
  --red-soft: rgba(201, 54, 44, 0.18);
  --gold: #d8a84f;
  --gold-soft: rgba(216, 168, 79, 0.18);
  --jade: #4fb286;
  --jade-soft: rgba(79, 178, 134, 0.18);
  --muted: #9a8872;
  --error: #ff6767;

  --theme-accent-1: rgba(216, 168, 79, 0.16);
  --theme-accent-2: rgba(201, 54, 44, 0.14);
  --theme-accent-3: rgba(79, 178, 134, 0.08);
  --theme-border: rgba(246, 232, 201, 0.11);
  --theme-glow: rgba(216, 168, 79, 0.18);
}

:root[data-theme="dragon"] {
  --bg: #070712;
  --bg-soft: #101024;
  --panel: #141426;
  --panel-2: #1d1735;
  --paper: #fff3dc;
  --paper-dim: #ddd2ff;
  --red: #ff315a;
  --red-soft: rgba(255, 49, 90, 0.2);
  --gold: #ffd166;
  --gold-soft: rgba(255, 209, 102, 0.2);
  --jade: #43f2a6;
  --jade-soft: rgba(67, 242, 166, 0.18);
  --muted: #a99fcf;
  --error: #ff5d7a;

  --theme-accent-1: rgba(255, 209, 102, 0.18);
  --theme-accent-2: rgba(255, 49, 90, 0.2);
  --theme-accent-3: rgba(71, 197, 255, 0.14);
  --theme-border: rgba(255, 209, 102, 0.16);
  --theme-glow: rgba(255, 49, 90, 0.18);
}

/* Better base atmosphere */
html {
  background:
    radial-gradient(circle at 14% 8%, var(--theme-accent-2), transparent 34rem),
    radial-gradient(circle at 88% 18%, var(--theme-accent-1), transparent 30rem),
    radial-gradient(circle at 55% 100%, var(--theme-accent-3), transparent 34rem),
    var(--bg);
}

body {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.035), transparent 45%),
    var(--bg);
}

/* Cleaner panels */
.sidebar,
.stat-card,
.typing-stage,
.progress-panel,
.result-panel,
.story-meta-card,
.backup-panel {
  border-color: var(--theme-border);
}

.sidebar {
  background:
    radial-gradient(circle at 0% 0%, var(--theme-accent-1), transparent 22rem),
    linear-gradient(180deg, rgba(255, 255, 255, 0.045), transparent),
    var(--panel);
}

.brand-mark,
.seal {
  box-shadow:
    0 16px 34px var(--theme-glow),
    inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

/* Main stage gets brighter, but no layout changes */
.typing-stage {
  background:
    radial-gradient(circle at 18% 0%, var(--theme-accent-1), transparent 30rem),
    radial-gradient(circle at 88% 10%, var(--theme-accent-3), transparent 24rem),
    radial-gradient(circle at 50% 100%, var(--theme-accent-2), transparent 32rem),
    linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.018)),
    var(--bg-soft);
  box-shadow:
    0 28px 70px rgba(0, 0, 0, 0.3),
    0 0 50px var(--theme-glow),
    inset 0 0 0 1px rgba(255, 255, 255, 0.03);
}

/* Lightweight animated ambient glow */
.stage-glow {
  opacity: 0.9;
  animation: stagePulse 7s ease-in-out infinite;
}

@keyframes stagePulse {
  0%, 100% {
    transform: translate3d(0, 0, 0) scale(1);
    opacity: 0.65;
  }

  50% {
    transform: translate3d(0, -10px, 0) scale(1.04);
    opacity: 0.95;
  }
}

/* Cards: more color, no pseudo layout tricks */
.word-card {
  border-color: rgba(246, 232, 201, 0.12);
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 255, 255, 0.055), transparent 7rem),
    rgba(255, 255, 255, 0.04);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.018),
    0 12px 24px rgba(0, 0, 0, 0.12);
}

.word-card:hover {
  border-color: rgba(216, 168, 79, 0.34);
  background:
    radial-gradient(circle at 50% 0%, var(--theme-accent-1), transparent 7rem),
    rgba(255, 255, 255, 0.048);
}

.word-card.active {
  border-color: rgba(255, 209, 102, 0.74);
  background:
    radial-gradient(circle at 50% 0%, var(--theme-accent-1), transparent 8rem),
    radial-gradient(circle at 100% 100%, var(--theme-accent-3), transparent 9rem),
    rgba(255, 255, 255, 0.055);
  box-shadow:
    0 18px 34px rgba(0, 0, 0, 0.22),
    0 0 0 4px var(--theme-accent-1),
    0 0 38px var(--theme-glow);
}

.word-card.correct {
  border-color: rgba(67, 242, 166, 0.46);
  background:
    radial-gradient(circle at 50% 0%, var(--jade-soft), transparent 7rem),
    rgba(255, 255, 255, 0.035);
}

.word-card.wrong {
  border-color: rgba(255, 93, 122, 0.55);
  background:
    radial-gradient(circle at 50% 0%, var(--red-soft), transparent 7rem),
    rgba(255, 103, 103, 0.07);
}

/* Stat cards get tasteful accent glows */
.stat-card {
  background:
    radial-gradient(circle at 100% 0%, var(--theme-accent-1), transparent 10rem),
    linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.018)),
    var(--panel);
}

.stat-card:nth-child(2) {
  background:
    radial-gradient(circle at 100% 0%, var(--jade-soft), transparent 10rem),
    linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.018)),
    var(--panel);
}

.stat-card:nth-child(3) {
  background:
    radial-gradient(circle at 100% 0%, var(--theme-accent-3), transparent 10rem),
    linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.018)),
    var(--panel);
}

.stat-card:nth-child(4) {
  background:
    radial-gradient(circle at 100% 0%, var(--theme-accent-2), transparent 10rem),
    linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.018)),
    var(--panel);
}

/* Buttons/selects become more alive */
.option-button,
.subtle-button,
.restart-button,
.select,
.custom-pack-input,
.typing-input,
.pack-note,
.method-note,
.custom-preview,
.story-progress-note {
  border-color: var(--theme-border);
}

.option-button.active,
.restart-button {
  background:
    linear-gradient(135deg, var(--theme-accent-1), var(--theme-accent-2));
  box-shadow:
    0 10px 24px var(--theme-glow),
    inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.typing-input:focus,
.custom-pack-input:focus,
.select:focus {
  box-shadow:
    inset 0 0 0 1px rgba(216, 168, 79, 0.5),
    0 16px 34px rgba(0, 0, 0, 0.18),
    0 0 0 4px var(--theme-accent-1),
    0 0 28px var(--theme-glow);
}

/* Dragon-only extra punch */
:root[data-theme="dragon"] .hanzi-line {
  color: #fff8e8;
  text-shadow:
    0 0 12px rgba(255, 209, 102, 0.16),
    0 0 22px rgba(255, 49, 90, 0.12);
}

:root[data-theme="dragon"] .pinyin-line {
  color: #ffd166;
}

:root[data-theme="dragon"] .tone-2 {
  color: #43f2a6;
}

:root[data-theme="dragon"] .tone-3 {
  color: #47c5ff;
}

:root[data-theme="dragon"] .tone-4 {
  color: #ff5d7a;
}

:root[data-theme="dragon"] .input-underline {
  background: linear-gradient(90deg, #ff315a, #ffd166, #43f2a6, #47c5ff);
}

/* Classic gets a small premium bump */
:root[data-theme="classic"] .hanzi-line {
  text-shadow: 0 0 12px rgba(216, 168, 79, 0.08);
}

:root[data-theme="classic"] .typing-stage {
  box-shadow:
    0 28px 70px rgba(0, 0, 0, 0.28),
    0 0 36px rgba(216, 168, 79, 0.07),
    inset 0 0 0 1px rgba(255, 255, 255, 0.03);
}

/* Respect weak/mobile devices */
@media (max-width: 760px) {
  .stage-glow {
    animation: none;
    opacity: 0.6;
  }

  .word-card:hover {
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .stage-glow {
    animation: none;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
  }
}











.about-panel {
  padding: 16px;
  margin-bottom: 28px;
  border: 1px solid rgba(216, 168, 79, 0.18);
  border-radius: 20px;
  background:
    radial-gradient(circle at top left, var(--theme-accent-1, rgba(216, 168, 79, 0.1)), transparent 13rem),
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.012));
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.025),
    0 14px 28px rgba(0, 0, 0, 0.12);
}

.about-panel h2 {
  margin-bottom: 9px;
}

.contact-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.contact-list a,
.contact-list span {
  display: block;
  padding: 9px 10px;
  border: 1px solid rgba(246, 232, 201, 0.1);
  border-radius: 12px;
  color: var(--paper);
  background: rgba(0, 0, 0, 0.13);
  font-size: 0.84rem;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.contact-list a:hover {
  border-color: rgba(216, 168, 79, 0.42);
  color: var(--gold);
  background: rgba(216, 168, 79, 0.08);
}







.sidebar-close-button {
  display: none;
  position: absolute;
  top: 14px;
  right: 14px;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(246, 232, 201, 0.12);
  border-radius: 13px;
  color: var(--paper);
  background: rgba(0, 0, 0, 0.18);
  font-size: 1.45rem;
  line-height: 1;
  z-index: 3;
}

.sidebar-close-button:hover {
  border-color: rgba(216, 168, 79, 0.45);
  color: var(--gold);
  background: rgba(216, 168, 79, 0.09);
}

@media (max-width: 980px) {
  .sidebar {
    width: min(300px, 82vw);
    padding-top: 58px;
  }

  .sidebar-close-button {
    display: grid;
    place-items: center;
  }
}

@media (max-width: 420px) {
  .sidebar {
    width: min(286px, 84vw);
  }
}




/* Keep typing input visible on small screens and laptops */
.typing-stage {
  min-height: 430px;
}

.word-stream {
  min-height: 170px;
}

@media (max-width: 1180px) {
  .typing-stage {
    min-height: 390px;
  }

  .word-stream {
    min-height: 140px;
  }
}

@media (max-width: 760px) {
  .typing-stage {
    min-height: auto;
  }

  .word-stream {
    min-height: 0;
  }
}




/*
@media (max-width: 760px) {
  .input-wrap,
  .typing-input {
    scroll-margin-top: 220px;
    scroll-margin-bottom: 22px;
  }

  .word-stream {
    margin-bottom: 12px;
  }

  .current-hint {
    margin-top: 10px;
  }
}*/

@media (max-width: 760px) {
  .input-wrap,
  .typing-input {
    scroll-margin-top: clamp(140px, 24vh, 220px);
    scroll-margin-bottom: 22px;
  }

  .word-stream {
    margin-bottom: 12px;
  }

  .current-hint {
    margin-top: 10px;
  }
}

