/* ─────────────── Base ─────────────── */
:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --ink: #1e293b;
  --muted: #5b6577;
  --line: #e2e8f0;
  --primary: #4338ca;
  --primary-ink: #ffffff;
  --success: #15803d;
  --danger: #b91c1c;
  --warn: #b45309;
  --dark: #1f2333;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(15, 23, 42, 0.08);
  --topbar-h: 60px;
  --branch: var(--primary);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
}

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

body {
  margin: 0;
  min-height: 100vh;
}

a {
  color: var(--primary);
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

:focus-visible {
  outline: 3px solid #f59e0b;
  outline-offset: 2px;
}

h1:focus,
h2:focus {
  outline: none;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 8px;
  z-index: 100;
  background: var(--dark);
  color: #fff;
  padding: 8px 14px;
  border-radius: 8px;
}

.skip-link:focus {
  left: 8px;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.875rem;
}

.noscript {
  padding: 2rem;
  text-align: center;
}

/* ─────────────── Top bar ─────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  background: var(--dark);
  color: #fff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  text-decoration: none;
  font-size: 1.1rem;
  white-space: nowrap;
}

.nav {
  display: flex;
  gap: 4px;
  margin-left: 8px;
}

.nav a {
  color: #cbd5e1;
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 10px;
  white-space: nowrap;
}

.nav a:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.nav a[aria-current="page"] {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-weight: 600;
}

.stats {
  margin-left: auto;
  display: flex;
  gap: 14px;
  font-size: 0.95rem;
  color: #e2e8f0;
}

.stat {
  white-space: nowrap;
}

@media (max-width: 720px) {
  .brand-text,
  .nav a span,
  .stat-label {
    display: none;
  }
  .topbar {
    gap: 8px;
    padding: 0 10px;
  }
  .nav a {
    padding: 8px 10px;
    font-size: 1.15rem;
  }
  .stats {
    gap: 8px;
    font-size: 0.85rem;
  }
}

/* ─────────────── Buttons & pills ─────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 12px;
  border: 2px solid transparent;
  font-weight: 600;
  text-decoration: none;
  background: var(--surface);
  color: var(--ink);
  transition: transform 0.08s ease, background 0.15s ease;
}

.btn:active {
  transform: scale(0.97);
}

.btn.block {
  display: flex;
  width: 100%;
  margin-top: 12px;
}

.btn.small {
  padding: 6px 12px;
  font-size: 0.9rem;
}

.btn-primary {
  background: var(--branch);
  color: #fff;
}

.btn-primary:hover {
  filter: brightness(1.08);
}

.btn-outline {
  border-color: var(--line);
}

.btn-outline:hover {
  border-color: var(--branch);
}

.btn-success {
  background: #dcfce7;
  border-color: #86efac;
  color: var(--success);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.icon-btn {
  border: none;
  background: transparent;
  font-size: 1.1rem;
  width: 36px;
  height: 36px;
  border-radius: 50%;
}

.icon-btn:hover {
  background: var(--bg);
}

.pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--bg);
  font-size: 0.82rem;
  color: var(--muted);
  white-space: nowrap;
}

.pill.best {
  background: #fef3c7;
  color: var(--warn);
}

.speak-btn {
  flex: none;
  border: none;
  background: #eef2ff;
  border-radius: 50%;
  width: 34px;
  height: 34px;
  font-size: 0.95rem;
}

.speak-btn:hover:not(:disabled) {
  background: #e0e7ff;
}

.speak-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ─────────────── Toast ─────────────── */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 140%);
  background: var(--dark);
  color: #fff;
  padding: 12px 20px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  transition: transform 0.25s ease;
  z-index: 50;
  pointer-events: none;
  max-width: calc(100vw - 32px);
}

.toast.show {
  transform: translate(-50%, 0);
}

/* ─────────────── Mindmap view ─────────────── */
.map-view {
  display: grid;
  grid-template-columns: 1fr;
  height: calc(100vh - var(--topbar-h));
  height: calc(100dvh - var(--topbar-h));
  overflow: hidden;
}

@media (min-width: 960px) {
  .map-view.panel-open {
    grid-template-columns: 1fr minmax(380px, 34%);
  }
}

.map-host {
  position: relative;
  min-width: 0;
  min-height: 0;
  background-color: #f8fafc;
  background-image: radial-gradient(#d7deea 1px, transparent 1px);
  background-size: 22px 22px;
}

.mindmap-svg {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  user-select: none;
  cursor: grab;
}

.mindmap-svg.dragging {
  cursor: grabbing;
}

.node {
  cursor: pointer;
}

.node .node-box {
  transition: filter 0.15s ease;
  filter: drop-shadow(0 2px 3px rgba(15, 23, 42, 0.12));
}

.node:hover .node-box {
  filter: drop-shadow(0 4px 10px rgba(15, 23, 42, 0.25));
}

.node.selected .node-box {
  stroke: #f59e0b;
  stroke-width: 4px;
}

.node:focus {
  outline: none;
}

.node:focus-visible .node-box {
  stroke: #f59e0b;
  stroke-width: 4px;
  stroke-dasharray: 6 3;
}

.node text {
  pointer-events: none;
}

.toggle {
  cursor: pointer;
}

.toggle:hover circle {
  fill: #f1f5f9;
}

.link {
  opacity: 0.85;
}

.map-toolbar {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: flex-start;
  pointer-events: none;
  z-index: 2;
}

.map-toolbar > * {
  pointer-events: auto;
}

.map-search {
  position: relative;
  flex: 1 1 220px;
  max-width: 360px;
}

.map-search-input {
  width: 100%;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.map-search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  max-height: 320px;
  overflow: auto;
}

.map-search-results li {
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
}

.map-search-results li.active,
.map-search-results li:hover {
  background: #eef2ff;
}

.res-path {
  font-size: 0.78rem;
  color: var(--muted);
}

.tool-group {
  display: flex;
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  overflow: hidden;
}

.tool-btn {
  border: none;
  background: transparent;
  width: 40px;
  height: 40px;
  font-size: 1.05rem;
}

.tool-btn + .tool-btn {
  border-left: 1px solid var(--line);
}

.tool-btn:hover {
  background: var(--bg);
}

.map-hint {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(31, 35, 51, 0.75);
  color: #fff;
  font-size: 0.8rem;
  white-space: nowrap;
  pointer-events: none;
}

@media (max-width: 600px) {
  .map-hint {
    display: none;
  }
}

/* ─────────────── Panel ─────────────── */
.panel {
  background: var(--surface);
  overflow-y: auto;
  border-left: 1px solid var(--line);
  display: none;
  overscroll-behavior: contain;
}

.panel-open .panel {
  display: block;
}

@media (max-width: 959px) {
  .panel-open .panel {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 72vh;
    height: 72dvh;
    border-radius: 20px 20px 0 0;
    border-left: none;
    box-shadow: 0 -10px 40px rgba(15, 23, 42, 0.25);
    z-index: 30;
    animation: sheet-up 0.22s ease-out;
  }
}

@keyframes sheet-up {
  from {
    transform: translateY(40px);
    opacity: 0;
  }
}

.panel-head {
  position: sticky;
  top: 0;
  background: var(--surface);
  padding: 14px 20px 14px;
  border-bottom: 1px solid var(--line);
  border-top: 5px solid var(--branch);
  z-index: 1;
}

.panel-head-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.crumbs {
  flex: 1;
  font-size: 0.82rem;
  color: var(--muted);
}

.crumb {
  border: none;
  background: none;
  padding: 0;
  color: var(--primary);
  text-decoration: underline;
  font-size: inherit;
}

.crumb.current {
  color: var(--muted);
  text-decoration: none;
}

.panel-title {
  margin: 6px 0 0;
  font-size: 1.4rem;
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel-en {
  margin: 2px 0 8px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
  font-style: italic;
}

.panel-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.panel-body {
  padding: 8px 20px 32px;
}

.panel-desc {
  font-size: 1.02rem;
}

.panel-section {
  margin-top: 22px;
}

.panel-section h3 {
  font-size: 1rem;
  margin: 0 0 10px;
  padding-left: 10px;
  border-left: 4px solid var(--branch);
}

.tips,
.formula {
  margin: 0;
  padding-left: 20px;
}

.tips li,
.formula li {
  margin: 6px 0;
}

.formula code {
  font-family: "Cascadia Code", Consolas, monospace;
  background: #f1f5f9;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.9rem;
  display: inline-block;
}

.letters {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(62px, 1fr));
  gap: 6px;
}

.letter {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 10px;
  padding: 6px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.letter strong {
  font-size: 1.25rem;
}

.letter small {
  color: var(--muted);
  font-size: 0.75rem;
}

.letter:hover,
.sound:hover {
  border-color: var(--branch);
  background: #f8fafc;
}

.sounds {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 6px;
}

.sound {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 10px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
}

.sound .ipa {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--branch);
}

.sound .hint {
  font-size: 0.75rem;
  color: var(--muted);
}

.vocab-list,
.sentence-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.vocab-list li {
  display: grid;
  grid-template-columns: 34px minmax(80px, auto) 1fr;
  grid-template-areas:
    "spk en ipa"
    "spk vi vi";
  column-gap: 10px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px dashed var(--line);
}

.vocab-list .speak-btn {
  grid-area: spk;
}

.v-en {
  grid-area: en;
  font-weight: 700;
}

.v-ipa {
  grid-area: ipa;
  color: var(--muted);
  font-size: 0.88rem;
}

.v-vi {
  grid-area: vi;
  font-size: 0.92rem;
}

.sentence-list li {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 8px 0;
  border-bottom: 1px dashed var(--line);
}

.sentence-list p {
  margin: 0;
}

.s-en {
  font-weight: 600;
}

.s-vi {
  color: var(--muted);
  font-size: 0.92rem;
}

.child-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.child-link {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  padding: 6px 12px;
}

.child-link:hover {
  border-color: var(--branch);
}

.child-link.done {
  background: #f0fdf4;
  border-color: #86efac;
}

.mini-games {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
}

.mini-game {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid var(--line);
  text-decoration: none;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 600;
}

a.mini-game:hover {
  border-color: var(--branch);
  background: #f8fafc;
}

.mini-game.disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.mg-icon {
  font-size: 1.3rem;
}

/* ─────────────── Pages ─────────────── */
.page {
  max-width: 980px;
  margin: 0 auto;
  padding: 24px 16px 64px;
}

.page h1 {
  margin: 0 0 6px;
  font-size: 1.7rem;
}

.lead {
  color: var(--muted);
  margin-top: 0;
}

.empty {
  text-align: center;
  padding: 40px 16px;
  background: var(--surface);
  border-radius: var(--radius);
}

/* Outline */
.progress-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  padding: 14px 18px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin: 18px 0;
}

.progress-bar {
  flex: 1;
  height: 12px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #22c55e, #16a34a);
  border-radius: 999px;
  transition: width 0.3s ease;
}

.outline-branch {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 12px;
  overflow: hidden;
}

.outline-branch summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  cursor: pointer;
  border-left: 6px solid var(--branch);
}

.outline-branch summary::-webkit-details-marker {
  display: none;
}

.ob-icon {
  font-size: 1.6rem;
}

.ob-title {
  flex: 1;
  font-weight: 700;
  font-size: 1.1rem;
  display: flex;
  flex-direction: column;
}

.ob-title small {
  font-weight: 400;
  color: var(--muted);
  font-size: 0.85rem;
}

.ob-count {
  font-weight: 700;
  color: var(--muted);
}

.ob-desc {
  margin: 0;
  padding: 0 18px 8px 24px;
}

.outline-list {
  list-style: none;
  margin: 0;
  padding: 0 0 8px;
}

.outline-list li {
  display: flex;
  align-items: center;
  border-top: 1px solid var(--line);
}

.outline-list li a:first-child {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px 10px 24px;
  color: var(--ink);
  text-decoration: none;
}

.outline-list li a:first-child:hover {
  background: #f8fafc;
}

.outline-list li.overview .ol-title {
  font-style: italic;
}

.ol-title {
  flex: 1;
}

.ol-meta {
  font-size: 0.8rem;
  color: var(--muted);
}

.ol-play {
  padding: 10px 18px;
  text-decoration: none;
  font-size: 1.15rem;
}

/* Hub */
.scope-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin: 16px 0 20px;
}

.scope-row label {
  font-weight: 600;
}

.scope-select {
  flex: 1 1 260px;
  max-width: 480px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.game-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  text-decoration: none;
  color: var(--ink);
  border: 2px solid transparent;
  transition: transform 0.12s ease, border-color 0.12s ease;
}

a.game-card:hover {
  transform: translateY(-3px);
  border-color: var(--primary);
}

.game-card.disabled {
  opacity: 0.55;
}

.gc-icon {
  font-size: 2.2rem;
}

.gc-name {
  margin: 6px 0 4px;
  font-size: 1.15rem;
}

.gc-desc {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.92rem;
  flex: 1;
}

.gc-foot {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.gc-play {
  margin-left: auto;
  font-weight: 700;
  color: var(--primary);
}

.gc-reason {
  margin-left: auto;
  font-size: 0.8rem;
  color: var(--danger);
}

/* ─────────────── Game shell ─────────────── */
.game-page {
  max-width: 760px;
}

.game-head {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 4px solid var(--branch);
}

.back-link {
  text-decoration: none;
  font-weight: 600;
}

.g-title {
  flex: 1;
  min-width: 180px;
}

.g-title h1 {
  font-size: 1.4rem;
  margin: 0;
}

.g-title p {
  margin: 0;
}

.g-stats {
  display: flex;
  gap: 12px;
  align-items: center;
  font-weight: 700;
}

.g-progress {
  color: var(--muted);
  font-weight: 600;
}

.g-score-wrap {
  background: #fef3c7;
  color: var(--warn);
  padding: 4px 12px;
  border-radius: 999px;
}

.game-body {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  min-height: 320px;
}

.game-prompt {
  text-align: center;
  margin: 8px 0 20px;
}

.game-prompt .label {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0;
}

.game-prompt .big {
  font-size: clamp(1.6rem, 6vw, 2.4rem);
  font-weight: 800;
  margin: 6px 0;
  word-break: break-word;
}

.game-prompt .ipa {
  color: var(--muted);
}

.options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.option {
  padding: 14px 16px;
  border-radius: 12px;
  border: 2px solid var(--line);
  background: var(--surface);
  font-size: 1.05rem;
  font-weight: 600;
  text-align: left;
  display: flex;
  gap: 10px;
  align-items: center;
}

.option:hover:not(:disabled) {
  border-color: var(--branch);
}

.option kbd {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: var(--bg);
  font-size: 0.8rem;
  font-family: inherit;
  color: var(--muted);
}

.option.correct {
  border-color: #22c55e;
  background: #f0fdf4;
}

.option.wrong {
  border-color: #ef4444;
  background: #fef2f2;
}

.option:disabled {
  cursor: default;
}

.feedback {
  min-height: 28px;
  margin: 14px 0 0;
  text-align: center;
  font-weight: 600;
}

.feedback.good {
  color: var(--success);
}

.feedback.bad {
  color: var(--danger);
}

.game-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 18px;
}

.big-speak {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  border: none;
  background: var(--branch);
  color: #fff;
  font-size: 2.2rem;
  box-shadow: var(--shadow);
}

.big-speak:active {
  transform: scale(0.95);
}

/* Flashcard */
.flashcard {
  perspective: 1000px;
  max-width: 440px;
  margin: 0 auto;
}

.flashcard-inner {
  position: relative;
  width: 100%;
  height: 240px;
  transition: transform 0.45s ease;
  transform-style: preserve-3d;
  border: none;
  background: none;
  padding: 0;
}

.flashcard.flipped .flashcard-inner {
  transform: rotateY(180deg);
}

.fc-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 18px;
  box-shadow: var(--shadow);
  border: 2px solid var(--line);
  background: var(--surface);
}

.fc-front .fc-word {
  font-size: 2.2rem;
  font-weight: 800;
}

.fc-back {
  transform: rotateY(180deg);
  background: var(--branch);
  color: #fff;
  border-color: transparent;
}

.fc-back .fc-word {
  font-size: 1.8rem;
  font-weight: 700;
}

.fc-hint {
  font-size: 0.8rem;
  opacity: 0.75;
}

@media (prefers-reduced-motion: reduce) {
  .flashcard-inner {
    transition: none;
  }
}

/* Memory */
.memory-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

@media (max-width: 520px) {
  .memory-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.mem-card {
  aspect-ratio: 4 / 3;
  border-radius: 12px;
  border: 2px solid var(--line);
  background: linear-gradient(135deg, var(--branch), #1f2333);
  color: transparent;
  font-weight: 700;
  font-size: 0.95rem;
  padding: 6px;
  word-break: break-word;
  transition: transform 0.15s ease, background 0.2s ease;
}

.mem-card .q {
  color: rgba(255, 255, 255, 0.6);
  font-size: 1.6rem;
}

.mem-card.open,
.mem-card.matched {
  background: var(--surface);
  color: var(--ink);
}

.mem-card.open {
  border-color: var(--branch);
}

.mem-card.matched {
  border-color: #22c55e;
  background: #f0fdf4;
  cursor: default;
}

.mem-card.miss {
  border-color: #ef4444;
  animation: shake 0.35s;
}

.mem-card .lang {
  display: block;
  font-size: 0.7rem;
  color: var(--muted);
  font-weight: 500;
}

@keyframes shake {
  25% {
    transform: translateX(-4px);
  }
  75% {
    transform: translateX(4px);
  }
}

/* Spelling */
.spell-form {
  display: flex;
  gap: 8px;
  max-width: 460px;
  margin: 0 auto;
}

.spell-input {
  flex: 1;
  padding: 12px 14px;
  font-size: 1.2rem;
  border-radius: 12px;
  border: 2px solid var(--line);
  min-width: 0;
}

.spell-input:focus {
  border-color: var(--branch);
  outline: none;
}

.mask {
  font-family: "Cascadia Code", Consolas, monospace;
  letter-spacing: 0.08em;
  font-size: 1.3rem;
  text-align: center;
  color: var(--branch);
  margin: 6px 0 14px;
}

/* Scramble */
.scramble-answer,
.scramble-bank {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 60px;
  padding: 10px;
  border-radius: 12px;
  justify-content: center;
  align-items: center;
}

.scramble-answer {
  border: 2px dashed var(--line);
  background: #f8fafc;
  margin-bottom: 14px;
}

.scramble-answer.correct {
  border-color: #22c55e;
  background: #f0fdf4;
}

.scramble-answer.wrong {
  border-color: #ef4444;
  background: #fef2f2;
}

.chip {
  border: 2px solid var(--line);
  background: var(--surface);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 1.05rem;
  font-weight: 600;
}

.chip:hover:not(:disabled) {
  border-color: var(--branch);
}

.chip.used {
  visibility: hidden;
}

.placeholder {
  color: var(--muted);
  font-size: 0.9rem;
}

/* Speed */
.timer {
  height: 10px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 18px;
}

.timer-fill {
  height: 100%;
  background: var(--branch);
  width: 100%;
  transition: width 0.25s linear;
}

.timer-fill.low {
  background: #ef4444;
}

.tf-card {
  text-align: center;
  padding: 24px 12px;
  border-radius: 16px;
  border: 2px solid var(--line);
  margin-bottom: 18px;
}

.tf-card.flash-good {
  border-color: #22c55e;
  background: #f0fdf4;
}

.tf-card.flash-bad {
  border-color: #ef4444;
  background: #fef2f2;
}

.tf-card .tf-en {
  font-size: 2rem;
  font-weight: 800;
}

.tf-card .tf-eq {
  color: var(--muted);
  margin: 4px 0;
}

.tf-card .tf-vi {
  font-size: 1.4rem;
  font-weight: 600;
}

.tf-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.tf-btn {
  padding: 18px;
  border-radius: 14px;
  border: none;
  font-size: 1.2rem;
  font-weight: 800;
  color: #fff;
}

.tf-btn.yes {
  background: #16a34a;
}

.tf-btn.no {
  background: #dc2626;
}

.tf-btn:active {
  transform: scale(0.97);
}

/* Result */
.result {
  text-align: center;
}

.stars {
  font-size: 3rem;
  letter-spacing: 6px;
}

.stars .on {
  color: #f59e0b;
}

.stars .off {
  color: #e2e8f0;
}

.result h2 {
  margin: 4px 0 14px;
}

.result-stats {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.result-stats div {
  background: var(--bg);
  border-radius: 12px;
  padding: 10px 18px;
  min-width: 96px;
  display: flex;
  flex-direction: column;
}

.result-stats strong {
  font-size: 1.5rem;
}

.result-stats span {
  color: var(--muted);
  font-size: 0.85rem;
}

.record {
  font-weight: 700;
  color: var(--warn);
}

.review {
  text-align: left;
  margin: 20px auto 0;
  max-width: 520px;
}

.result-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 22px;
}

.start-screen {
  text-align: center;
  padding: 20px 0;
}

.start-screen p {
  max-width: 460px;
  margin: 0 auto 16px;
}

.toggle-row {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.toggle-row button[aria-pressed="true"] {
  border-color: var(--branch);
  background: #eef2ff;
}
