:root {
  --bg: #f3effa;
  --surface: #faf7f1;
  --text: #241f45;
  --muted: #645c8a;
  --accent: #5b34d6;
  --accent-soft: #e8dfff;
  --fun: #ff8a65;
  --fun-soft: #ffe8dd;
  --success: #22c55e;
  --border: #ded0fb;
  --shadow: 0 10px 28px rgba(91, 52, 214, 0.18);
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15112b;
    --surface: #211a3f;
    --text: #f1eeff;
    --muted: #a89fd6;
    --accent: #8b5cf6;
    --accent-soft: #2d2158;
    --fun: #ff9d7a;
    --fun-soft: #40291f;
    --success: #4ade80;
    --border: #352a5e;
    --shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  }
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  background: #7c3aed;
}

.brand-title {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.6rem;
}

.brand-logo {
  display: block;
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
  flex-shrink: 0;
  object-fit: contain;
}

.brand-logo-zhong {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  padding: 4px;
}

.brand-logo-kt {
  width: auto;
  height: 56px;
  border-radius: 8px;
  padding: 4px 8px;
}

.brand-title-text {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}

.brand-zh-main {
  font-size: 1.25rem;
  font-weight: 700;
  color: #ffffff;
}

.brand-zh-sub {
  font-size: 0.95rem;
  font-weight: 600;
  color: #ffe08a;
}

.brand-en {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.75);
}

.header-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.guide-link {
  font-size: 0.85rem;
  color: #ffffff;
  text-decoration: none;
  border: 1.5px solid rgba(255, 255, 255, 0.6);
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  white-space: nowrap;
}

.guide-link:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: #ffffff;
}

.header-links .public-intent-toggle-btn {
  font-size: 0.85rem;
  color: #ffffff;
  background: transparent;
  border: 1.5px solid rgba(255, 255, 255, 0.6);
  white-space: nowrap;
}

.header-links .public-intent-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: #ffffff;
  color: #ffffff;
}

.mode-tabs {
  display: flex;
  gap: 0.25rem;
  padding: 0.25rem;
  background: #ffffff;
  border: none;
  border-radius: 999px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

.mode-tab {
  border: none;
  background: transparent;
  border-radius: 999px;
  padding: 0.45rem 1rem;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: #6f6795;
  cursor: pointer;
}

.mode-tab:hover {
  color: #7c3aed;
}

.mode-tab.active {
  background: #7c3aed;
  color: white;
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.35);
}

.topbar .account-widget > button {
  background: #ffffff;
  color: #7c3aed;
  border: none;
  font-weight: 600;
}

.topbar .account-widget > button:hover {
  background: #f4eeff;
}

.account-widget {
  position: relative;
}

.account-panel {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  width: 260px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 1rem;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.account-tabs {
  display: flex;
  gap: 0.25rem;
  padding: 0.2rem;
  background: var(--bg);
  border-radius: 8px;
}

.account-tab {
  flex: 1;
  border: none;
  background: transparent;
  border-radius: 6px;
  padding: 0.35rem;
  font: inherit;
  font-size: 0.8rem;
  color: var(--muted);
  cursor: pointer;
}

.account-tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

#auth-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

#auth-form input {
  font: inherit;
  padding: 0.5rem 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

#auth-submit {
  background: var(--accent);
  color: white;
  border: none;
}

.account-profile {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.account-profile p {
  margin: 0;
  font-size: 0.9rem;
}

.account-error {
  font-size: 0.8rem;
  color: #dc2626;
  margin: 0;
}

.preview-hint {
  margin: 0;
  padding: 0.6rem 1.5rem;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  padding: 0.85rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  min-width: 0;
  max-width: 100%;
}

.toolbar-group select {
  min-width: 0;
  max-width: 100%;
}

.toolbar-group label {
  font-size: 0.85rem;
  color: var(--muted);
}

.stat-chip {
  font-size: 0.8rem;
  color: var(--muted);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.ghost-btn {
  background: transparent;
}

select, button {
  font: inherit;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

button:hover, select:hover {
  border-color: var(--accent);
}

@media (prefers-reduced-motion: no-preference) {
  button:hover {
    transform: translateY(-1px);
  }
  button:active {
    transform: translateY(0);
  }
}

#flip-btn {
  background: var(--accent);
  color: white;
  border: none;
  box-shadow: 0 6px 16px rgba(91, 52, 214, 0.35);
}

#flip-btn:hover {
  opacity: 0.9;
}

.danger-btn {
  background: #dc2626;
  color: white;
  border: none;
}

.danger-btn:hover {
  background: #b91c1c;
}

.mastered-btn {
  background: var(--success);
  color: white;
  border: none;
}

.mastered-btn:hover {
  filter: brightness(0.92);
}

@media (prefers-color-scheme: dark) {
  .danger-btn {
    background: #ef4444;
  }
  .danger-btn:hover {
    background: #dc2626;
  }
}

.speak-btn {
  font: inherit;
  font-size: 0.85rem;
  border: 1px solid var(--border);
  background: var(--accent-soft);
  color: var(--text);
  border-radius: 999px;
  padding: 0.3rem 0.7rem;
  cursor: pointer;
}

.speak-btn:hover {
  border-color: var(--accent);
}

.card-front .speak-btn {
  position: absolute;
  top: 0.9rem;
  right: 1.1rem;
}

.speak-row {
  display: flex;
  gap: 0.5rem;
}

.switch {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  user-select: none;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-track {
  position: relative;
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: var(--border);
  transition: background 0.2s ease;
  flex-shrink: 0;
}

.switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s ease;
}

.switch input:checked + .switch-track {
  background: var(--accent);
}

.switch input:checked + .switch-track .switch-thumb {
  transform: translateX(16px);
}

.switch input:focus-visible + .switch-track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.switch-label {
  font-size: 0.85rem;
  color: var(--muted);
}

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem 1rem;
  gap: 1.25rem;
}

.progress-wrap {
  width: 100%;
  max-width: 640px;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.progress-bar {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}

#progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.2s ease;
}

#progress-label {
  font-size: 0.85rem;
  color: var(--muted);
  white-space: nowrap;
}

.stage {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: 100%;
  max-width: 640px;
}

.nav-btn {
  font-size: 1.5rem;
  line-height: 1;
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
}

.card {
  flex: 1;
  height: 380px;
  perspective: 1200px;
  cursor: pointer;
  outline: none;
}

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.5s;
  transform-style: preserve-3d;
}

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

.card.eliminating {
  transition: transform 0.25s ease, opacity 0.25s ease;
  transform: scale(0.9);
  opacity: 0.25;
}

.card-face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 2rem;
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
  backface-visibility: hidden;
  text-align: center;
  border-top: 6px solid var(--accent);
}

.card-back {
  border-top-color: var(--fun);
}

.card-back {
  transform: rotateY(180deg);
}

.face-label {
  position: absolute;
  top: 1rem;
  left: 1.25rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.hanzi {
  font-size: 3rem;
  font-weight: 700;
}

.pinyin {
  font-size: 1.1rem;
  color: var(--muted);
}

.hint {
  position: absolute;
  bottom: 1rem;
  font-size: 0.75rem;
  color: var(--muted);
}

/* ---------- random draw (抽读) ---------- */

.random-draw-panel {
  width: 100%;
  max-width: 720px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.random-draw-setup {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.random-draw-setup label {
  font-size: 0.85rem;
  color: var(--muted);
}

#random-draw-count {
  width: 5rem;
}

.random-draw-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.75rem;
}

.random-draw-item {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.85rem 0.6rem 0.6rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
}

.random-draw-index {
  position: absolute;
  top: 0.4rem;
  left: 0.55rem;
  font-size: 0.7rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.random-draw-hanzi {
  font-size: 1.6rem;
  font-weight: 700;
  margin-top: 0.5rem;
}

.random-draw-answer {
  display: none;
  flex-direction: column;
  gap: 0.15rem;
}

.random-draw-list.reveal .random-draw-answer {
  display: flex;
}

.random-draw-answer .random-draw-pinyin {
  font-size: 0.85rem;
  color: var(--muted);
}

.random-draw-answer .random-draw-meaning {
  font-size: 0.8rem;
  color: var(--text);
}

.meaning {
  font-size: 1.35rem;
  font-weight: 600;
  max-width: 26rem;
}

.example-block {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-width: 26rem;
  margin-top: 0.25rem;
}

.example {
  font-size: 0.95rem;
  max-width: 26rem;
}

.example-cn {
  color: var(--text);
}

.example-en {
  color: var(--muted);
  font-style: italic;
}

.bottom-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
}

#card-index-label {
  font-size: 0.85rem;
  color: var(--muted);
}

.study-complete {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  width: 100%;
  max-width: 640px;
  padding: 3rem 2rem;
  text-align: center;
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.study-complete p {
  font-size: 1.1rem;
  margin: 0;
}

#study-view,
#match-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  width: 100%;
}

.match-intro {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0;
}

.match-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  width: 100%;
  max-width: 640px;
}

.match-col-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 0 0.6rem;
  text-align: center;
}

.match-tiles {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.match-tile {
  font: inherit;
  padding: 0.65rem 0.9rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-align: center;
  transition: transform 0.1s ease, background 0.15s ease, border-color 0.15s ease, opacity 0.2s ease;
}

.match-tile-pinyin {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
}

.match-tile-meaning {
  display: block;
}

.match-tile:hover:not(.matched) {
  border-color: var(--accent);
}

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

.match-tile.matched {
  background: transparent;
  border-color: transparent;
  color: transparent;
  opacity: 0;
  pointer-events: none;
}

.match-tile.wrong {
  background: #fee2e2;
  border-color: #dc2626;
  animation: shake 0.3s ease;
}

@media (prefers-color-scheme: dark) {
  .match-tile.wrong {
    background: #3f1d1d;
  }
}

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

.match-complete {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 2rem;
  text-align: center;
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.match-complete p {
  font-size: 1.1rem;
  margin: 0;
}

.percentile-note {
  font-size: 0.95rem !important;
  color: var(--accent);
  font-weight: 600;
}

.match-complete button {
  background: var(--accent);
  color: white;
  border: none;
}

.report-signed-out {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 3rem 2rem;
  text-align: center;
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 640px;
}

.report-content {
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
  width: 100%;
  max-width: min(1100px, 95vw);
}

.report-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
}

.report-stat-tile {
  background: var(--surface);
  border-radius: 12px;
  padding: 1rem;
  box-shadow: var(--shadow);
  text-align: center;
}

.report-stat-tile .value {
  font-size: 1.6rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.report-stat-tile .label {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 0.25rem;
}

.report-block h2 {
  font-size: 1rem;
  margin: 0 0 0.75rem;
}

.report-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.admin-activity-header {
  margin-top: 1.5rem;
}

.admin-activity-header h3 {
  margin: 0;
  font-size: 0.9rem;
}

.report-block-header h2,
.report-block-header h3 {
  margin: 0;
}

.report-block-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.results-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.results-header-row h2 {
  margin: 0;
}

.parent-email-row {
  align-items: center;
  margin: 0.6rem 0;
}

.report-table input,
.report-table select {
  width: 100%;
  font-size: 0.82rem;
  padding: 0.3rem 0.4rem;
}

.cell-actions {
  white-space: nowrap;
}

.cell-actions button {
  font-size: 0.78rem;
  padding: 0.3rem 0.55rem;
}

.report-block-header select {
  font-size: 0.85rem;
  padding: 0.35rem 0.6rem;
}

/* ---------- typing test ---------- */

#typing-main {
  max-width: 760px;
}

.typing-instructions {
  background: var(--accent-soft);
  border-radius: 10px;
  padding: 0.6rem 0.9rem;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.9rem;
}

.typing-instructions p {
  margin: 0.2rem 0;
}

.typing-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.9rem;
}

.typing-toolbar label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.typing-toolbar select {
  font: inherit;
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

.typing-toolbar button {
  padding: 0.5rem 0.9rem;
}

#typing-start-btn {
  background: var(--accent);
  color: white;
  border: none;
}

.typing-article-picker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  background: var(--accent-soft);
  border-radius: 10px;
  padding: 0.75rem;
  margin-bottom: 0.9rem;
}

.typing-article-picker select {
  font: inherit;
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

.typing-passage {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 0.25rem 0.35rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.1rem;
  margin-top: 0.9rem;
  min-height: 6rem;
  max-height: 45vh;
  overflow-y: auto;
  scroll-behavior: smooth;
}

.typing-token {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.15rem 0.3rem;
  border-radius: 8px;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.typing-token-hanzi {
  font-size: 1.5rem;
  font-weight: 600;
}

.typing-token-pinyin {
  font-size: 0.7rem;
  color: var(--muted);
}

.typing-token-punct {
  padding-left: 0.05rem;
  padding-right: 0.05rem;
}

.typing-token-punct .typing-token-hanzi {
  font-weight: 400;
  color: var(--muted);
}

.typing-passage.hide-pinyin .typing-token-pinyin {
  visibility: hidden;
}

.typing-token.current {
  background: var(--accent-soft);
}

.typing-token.current .typing-token-hanzi {
  color: var(--accent);
}

.typing-token.correct .typing-token-hanzi {
  color: var(--success);
}

.typing-token.wrong .typing-token-hanzi {
  color: #e5484d;
}

.typing-input {
  position: sticky;
  top: 0.5rem;
  z-index: 5;
  width: 100%;
  font: inherit;
  font-size: 1.1rem;
  padding: 0.7rem 0.9rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  box-shadow: var(--shadow);
}

.typing-input:disabled {
  opacity: 0.6;
}

.typing-results {
  margin-top: 1.2rem;
}

.typing-results h3 {
  margin: 0 0 0.4rem;
}

.report-block-note {
  font-size: 0.8rem;
  color: var(--muted);
  margin: -0.4rem 0 0.75rem;
}

.host-toggle-btn {
  font-size: 0.8rem;
  padding: 0.3rem 0.7rem;
}

.host-toggle-btn.is-on {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.footer-stats {
  margin-top: 0.35rem;
  font-size: 0.75rem;
}

/* ---------- assessment ---------- */

#assessment-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  width: 100%;
}

.assessment-signed-out,
.typing-signed-out {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 3rem 2rem;
  text-align: center;
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 640px;
}

.assessment-home {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  width: 100%;
  max-width: 640px;
  justify-content: center;
}

.assessment-card {
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 1.5rem;
  width: 100%;
  max-width: 420px;
  flex: 1 1 260px;
}

.assessment-card h2 {
  margin: 0 0 0.75rem;
  font-size: 1.05rem;
}

.assessment-form {
  display: flex;
  gap: 0.6rem;
}

.assessment-form input,
.assessment-form select {
  flex: 1;
  font: inherit;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

.assessment-form button {
  background: var(--accent);
  color: white;
  border: none;
  padding: 0.55rem 1.1rem;
}

.assessment-form-grid {
  flex-direction: column;
  align-items: stretch;
}

.assessment-form-grid label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.85rem;
}

.host-play-check {
  flex-direction: row !important;
  align-items: center;
  gap: 0.5rem !important;
}

#host-new-btn {
  background: var(--accent);
  color: white;
  border: none;
  width: 100%;
  padding: 0.6rem;
}

.assessment-error {
  color: #dc2626;
  font-size: 0.8rem;
  margin: 0.6rem 0 0;
}

.lobby-code-block {
  text-align: center;
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 2rem;
  width: 100%;
  max-width: 420px;
}

.lobby-code-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.lobby-code {
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  font-variant-numeric: tabular-nums;
  margin: 0.4rem 0;
}

.assessment-lobby {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  width: 100%;
  max-width: 420px;
}

.assessment-lobby-actions {
  display: flex;
  gap: 0.75rem;
}

#lobby-start-btn,
#host-again-btn {
  background: var(--accent);
  color: white;
  border: none;
}

.assessment-running {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  width: 100%;
  max-width: 640px;
}

.running-top {
  display: flex;
  gap: 0.75rem;
}

#running-timer {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.assessment-question {
  width: 100%;
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  text-align: center;
}

.question-prompt {
  font-size: 1.5rem;
  font-weight: 600;
  max-width: 30rem;
  line-height: 1.5;
}

.no-copy {
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

.question-prompt .blank {
  display: inline-block;
  min-width: 2.4em;
  border-bottom: 2px solid var(--accent);
}

.question-prompt .meaning {
  display: block;
  font-size: 1.1rem;
  color: var(--muted);
  font-weight: 500;
  margin-bottom: 0.4rem;
}

.question-prompt .en-sentence {
  display: block;
  font-size: 0.95rem;
  color: var(--muted);
  font-style: italic;
  font-weight: 400;
  margin-top: 0.4rem;
}

#answer-input {
  text-align: center;
  font-size: 1.1rem;
}

.answer-feedback {
  font-weight: 600;
  margin: 0;
}

.answer-feedback.correct {
  color: #16a34a;
}

.answer-feedback.wrong {
  color: #dc2626;
}

.podium {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 1rem;
  width: 100%;
  max-width: 480px;
}

.podium-place {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  flex: 1;
}

.podium-name {
  font-weight: 600;
  font-size: 0.9rem;
  text-align: center;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.podium-score {
  font-size: 0.8rem;
  color: var(--muted);
}

.podium-bar {
  width: 100%;
  border-radius: 10px 10px 0 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 0.5rem;
  font-size: 1.5rem;
}

.podium-place.gold .podium-bar {
  height: 110px;
  background: linear-gradient(180deg, #fde68a, #f59e0b);
}

.podium-place.silver .podium-bar {
  height: 80px;
  background: linear-gradient(180deg, #e5e7eb, #9ca3af);
}

.podium-place.bronze .podium-bar {
  height: 60px;
  background: linear-gradient(180deg, #fbc79a, #c2703d);
}

.report-table-wrap {
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow-x: auto;
}

.report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.report-table th,
.report-table td {
  text-align: left;
  padding: 0.6rem 0.9rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.report-table th {
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.report-table tbody tr:last-child td {
  border-bottom: none;
}

.report-table tr.report-me {
  background: var(--accent-soft);
}

.report-table td:nth-child(3),
.report-table td:nth-child(4),
.report-table td:nth-child(5) {
  font-variant-numeric: tabular-nums;
}

footer {
  text-align: center;
  padding: 1rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.footer-feedback {
  margin-top: 0.4rem;
}

.footer-feedback a {
  color: var(--accent);
  text-decoration: none;
}

.footer-feedback a:hover {
  text-decoration: underline;
}

.footer-copyright {
  margin-top: 0.6rem;
  font-size: 0.72rem;
  color: var(--muted);
  opacity: 0.8;
}

@media (max-width: 640px) {
  .topbar {
    padding: 0.6rem 0.75rem;
    gap: 0.5rem;
  }

  .brand-zh-main { font-size: 1rem; }
  .brand-zh-sub { font-size: 0.75rem; }
  .brand-en { font-size: 0.6rem; }

  .guide-link {
    font-size: 0.68rem;
    padding: 0.3rem 0.55rem;
  }

  .header-links .public-intent-toggle-btn {
    font-size: 0.68rem;
    padding: 0.3rem 0.55rem;
  }

  .mode-tabs {
    width: 100%;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.15rem;
    padding: 0.2rem;
  }

  .mode-tab {
    font-size: 0.68rem;
    padding: 0.35rem 0.5rem;
  }

  .topbar .account-widget > button {
    font-size: 0.78rem;
    padding: 0.4rem 0.7rem;
  }
}

@media (max-width: 480px) {
  .card { height: 420px; }
  .hanzi { font-size: 2.25rem; }
  .meaning { font-size: 1.15rem; }
  .example { font-size: 0.85rem; }
  .match-columns { grid-template-columns: 1fr; gap: 2rem; }

  .account-panel {
    position: fixed;
    top: auto;
    left: 1rem;
    right: 1rem;
    width: auto;
  }
}

/* ---------- paywall ---------- */

.paywall-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(15, 23, 42, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  overflow-y: auto;
}

.paywall-card {
  background: var(--surface);
  color: var(--text);
  border-radius: 16px;
  box-shadow: var(--shadow);
  max-width: 480px;
  width: 100%;
  padding: 1.75rem;
  margin: auto;
}

.paywall-card h2 {
  margin-top: 0;
  font-size: 1.25rem;
}

.paywall-section {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
  margin-top: 1rem;
}

.paywall-section h3 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
}

.paywall-section p {
  margin: 0.35rem 0;
}

.paywall-note {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.6rem !important;
}

.paywall-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.paywall-form input,
.paywall-form select {
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
}

.paywall-form button {
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.paywall-lead-msg.success { color: #16a34a; }
.paywall-lead-msg.error { color: #dc2626; }

.paywall-promo ul {
  margin: 0.5rem 0;
  padding-left: 1.2rem;
}

.paywall-promo li {
  margin: 0.4rem 0;
}

/* ---------- public intent forms (no sign-in required) ---------- */

.public-intent {
  border-bottom: 1px solid var(--border);
  background: var(--accent-soft);
  padding: 0.75rem 1.5rem;
}

.public-intent-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.public-intent-toggle-btn {
  display: inline-block;
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--accent);
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  text-decoration: none;
  cursor: pointer;
}

.public-intent-toggle-btn:hover {
  background: var(--accent);
  color: #fff;
}

.public-intent-panel {
  max-width: 480px;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.public-intent-panel h2 {
  font-size: 1rem;
  margin: 0 0 0.4rem;
}

.public-intent-panel p {
  margin: 0.3rem 0;
}

.i18n-en {
  color: var(--muted);
  font-size: 0.85em;
  margin-top: 0.15rem !important;
}

#paywall-signout-btn {
  margin-top: 1.25rem;
}

/* ---------- student overview (answer report) ---------- */

#student-overview-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.student-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.75rem 1rem;
}

.student-row.report-me {
  border-color: var(--accent);
}

.student-row-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.student-name {
  font-weight: 600;
  font-size: 1.05rem;
}

.student-stats {
  display: flex;
  gap: 0.5rem;
}

.stat-tile {
  min-width: 3.25rem;
  text-align: center;
  padding: 0.4rem 0.7rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-family: inherit;
  font-size: 1rem;
}

.stat-correct { color: #16a34a; }
.stat-wrong { color: #dc2626; cursor: pointer; }
.stat-wrong:disabled { cursor: default; opacity: 0.5; }
.stat-accuracy { color: var(--accent); }

.student-wrong-panel {
  margin-top: 0.75rem;
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
}

.student-wrong-panel .report-table-wrap {
  box-shadow: none;
  border: 1px solid var(--border);
}
