/* Playful Design System — 开心格 */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700;900&family=Noto+Sans+SC:wght@400;500;700&display=swap');

:root {
  --red: #FF5A5A;
  --blue: #4A90FF;
  --green: #00C853;
  --yellow: #FFD93D;
  --dark: #2C3E50;
  --light: #F5F7FA;
  --white: #FFFFFF;
  --purple: #A78BFA;
  --orange: #FF9234;
  --shadow: 0 4px 12px rgba(0,0,0,0.1);
  --shadow-sm: 0 2px 6px rgba(0,0,0,0.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Inter', 'Noto Sans SC', sans-serif;
  background: var(--light);
  color: var(--dark);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Layout */
.container {
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  padding: 20px;
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: linear-gradient(135deg, #4A90FF, #00C853);
  color: var(--white);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header h1 {
  font-size: 1.4rem;
  font-weight: 900;
  letter-spacing: 1px;
}

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

.header .username {
  font-size: 0.85rem;
  opacity: 0.9;
}

/* Header avatar + profile trigger */
.user-profile-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 5px 14px 5px 6px;
  border-radius: 20px;
  background: rgba(255,255,255,0.15);
  transition: background 0.2s, transform 0.2s;
}

.user-profile-trigger:hover {
  background: rgba(255,255,255,0.28);
  transform: translateY(-1px);
}

.user-profile-trigger:active {
  transform: translateY(0);
}

.header-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.6);
  object-fit: cover;
  background: rgba(255,255,255,0.2);
}

/* Register avatar */
.register-avatar-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
}

.register-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 3px solid #e0e0e0;
  object-fit: cover;
  background: var(--light);
}

.avatar-refresh-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  border: 2px solid #e0e0e0;
  border-radius: 12px;
  background: var(--light);
  cursor: pointer;
  color: var(--blue);
  transition: all 0.2s;
}

.avatar-refresh-btn:hover {
  background: var(--yellow);
  transform: translateY(-1px);
}

/* Profile modal */
.profile-modal {
  max-width: 400px;
}

.profile-avatar-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.profile-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 3px solid #e0e0e0;
  object-fit: cover;
  background: var(--light);
}

.profile-avatar-actions {
  display: flex;
  gap: 8px;
}

.profile-upload-btn {
  cursor: pointer;
}

.profile-modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.profile-cancel-btn {
  color: var(--dark) !important;
  border-color: #ccc !important;
}

.profile-delete-btn {
  margin-left: auto;
  background: none;
  color: #aaa;
  border: none;
  font-size: 0.78rem;
  padding: 6px 12px;
}

.profile-delete-btn:hover {
  color: var(--red);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 26px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  border: 2px solid rgba(0,0,0,0.1);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  text-align: center;
}

.btn:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,0.15); }
.btn:active { transform: translateY(0); box-shadow: var(--shadow-sm); }

.btn-primary {
  background: var(--red);
  color: var(--white);
  box-shadow: var(--shadow);
}

.btn-secondary {
  background: var(--blue);
  color: var(--white);
  box-shadow: var(--shadow);
}

.btn-yellow {
  background: var(--yellow);
  color: var(--dark);
  box-shadow: var(--shadow);
}

.btn-small {
  padding: 8px 16px;
  font-size: 0.85rem;
  box-shadow: var(--shadow-sm);
}

.btn-outline {
  background: transparent;
  color: var(--white);
  border-color: rgba(255,255,255,0.5);
}

/* Forms */
.form-card {
  background: var(--white);
  border: 2px solid #e0e0e0;
  box-shadow: 0 8px 32px rgba(0,0,0,0.08);
  border-radius: 16px;
  padding: 40px;
  max-width: 420px;
  margin: 60px auto;
}

.form-card h2 {
  font-size: 1.6rem;
  font-weight: 900;
  margin-bottom: 24px;
  letter-spacing: 1px;
  text-align: center;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.form-group input, .form-group select {
  width: 100%;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 1rem;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  background: var(--light);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(74,144,255,0.2);
}

.form-error {
  color: var(--red);
  font-size: 0.85rem;
  font-weight: 600;
  margin-top: 8px;
}

.form-link {
  text-align: center;
  margin-top: 20px;
  font-size: 0.9rem;
}

.form-link a {
  color: var(--blue);
  font-weight: 700;
}

/* App Layout */
.app-layout {
  display: flex;
  min-height: calc(100vh - 62px);
  overflow-x: hidden;
}

.sidebar {
  width: clamp(140px, 13vw, 200px);
  background: var(--white);
  color: var(--dark);
  padding: 24px 0;
  flex-shrink: 0;
  border-right: 2px solid #e0e0e0;
}

.sidebar-section {
  padding: 0 14px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 1px;
  opacity: 0.4;
  margin-bottom: 16px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  text-decoration: none;
  color: var(--dark);
  font-weight: 600;
  border-left: 4px solid transparent;
  cursor: pointer;
  border-radius: 0 8px 8px 0;
  transition: all 0.2s;
}

.sidebar-item:hover {
  background: var(--light);
}

.sidebar-item.active {
  background: linear-gradient(135deg, rgba(74,144,255,0.12), rgba(0,200,83,0.08));
  border-left-color: var(--blue);
  color: var(--dark);
}

.sidebar-icon { font-size: 1.4rem; }
.sidebar-zh { font-size: 0.95rem; }
.sidebar-en { font-size: 0.72rem; opacity: 0.55; margin-top: 2px; }

/* Sidebar group + submenu */
.sidebar-group .sidebar-item { position: relative; }
.sidebar-arrow {
  margin-left: auto;
  display: flex;
  align-items: center;
  transition: transform 0.25s;
}
.sidebar-group.open .sidebar-arrow { transform: rotate(180deg); }
.sidebar-submenu {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.25s ease;
}
.sidebar-group.open .sidebar-submenu { max-height: 200px; }
.sidebar-subitem {
  display: block;
  padding: 9px 20px 9px 56px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--dark);
  opacity: 0.65;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  border-left: 4px solid transparent;
}
.sidebar-subitem:hover { opacity: 1; background: var(--light); }
.sidebar-subitem.active {
  opacity: 1;
  color: var(--blue);
  border-left-color: var(--blue);
  background: rgba(74,144,255,0.06);
}
.sidebar-subitem.disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}
.coming-soon-tag {
  display: inline-block;
  font-size: 0.6rem;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--light);
  color: var(--dark);
  opacity: 0.7;
  margin-left: 4px;
  vertical-align: middle;
}

.main-content {
  flex: 1;
  padding: 20px 24px 48px;
  overflow-y: auto;
  position: relative;
  min-width: 0;
}

.main-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.page-title-group {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.page-title {
  font-size: 1.1rem;
  font-weight: 900;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.page-mode-tag {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--blue);
  border: 2px solid var(--blue);
  padding: 2px 8px;
  border-radius: 8px;
  white-space: nowrap;
}

.header-right-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.difficulty-bar {
  display: flex;
  align-items: center;
  gap: 6px;
}

.diff-label {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #888;
  margin-right: 4px;
}

.diff-btn {
  padding: 4px 12px;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  background: var(--light);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.diff-btn:hover { background: var(--yellow); }

.diff-btn.active {
  background: var(--dark);
  color: var(--light);
  border-color: var(--dark);
}

/* Score counts in panel header */
.progress-counts {
  display: flex;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 700;
}

.count-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 6px 8px;
  border-radius: 6px;
  color: var(--white);
  border: none;
}

.count-correct {
  background: var(--green);
  box-shadow: 0 2px 8px rgba(0, 200, 83, 0.4);
}

.count-wrong {
  background: var(--red);
  box-shadow: 0 2px 8px rgba(255, 90, 90, 0.4);
}

.count-pending {
  background: #bbb;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Question Panel */
.question-panel {
  width: clamp(200px, 20vw, 300px);
  background: var(--white);
  border-left: 2px solid #e0e0e0;
  padding: 0 12px 24px;
  flex-shrink: 0;
  overflow-y: auto;
}

.panel-sticky-top {
  position: sticky;
  top: 0;
  background: var(--white);
  padding-top: 24px;
  padding-bottom: 12px;
  z-index: 10;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 1px;
  margin-bottom: 0px;
  padding-bottom: 10px;
  border-bottom: 2px solid #e0e0e0;
}

.question-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(32px, 1fr));
  gap: 6px;
  padding-top: 4px;
}

.q-card {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
  border: 2px solid #ccc;
  cursor: pointer;
  transition: all 0.2s ease;
  background: #eee;
  color: #999;
  border-radius: 8px;
}

.q-card:hover { transform: scale(1.08); box-shadow: var(--shadow-sm); }

.q-card.current {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px var(--blue);
  color: var(--dark);
}

.q-card.correct {
  background: #00C853;
  color: var(--white);
  border-color: #00a844;
}

.q-card.wrong {
  background: var(--red);
  color: var(--white);
  border-color: #e55a5a;
}

/* Puzzle Toolbar */
.puzzle-toolbar {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 12px;
}

.toolbar-btns {
  display: flex;
  gap: 8px;
}

.nav-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 2px solid #e0e0e0;
  background: var(--white);
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s;
  flex-shrink: 0;
}

.nav-arrow:hover:not(:disabled) {
  background: var(--yellow);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.nav-arrow:active:not(:disabled) {
  transform: translateY(0);
}

.nav-arrow:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.nav-arrow-side {
  width: 48px;
  height: 48px;
  align-self: center;
}

.puzzle-main-row {
  display: flex;
  justify-content: center;
  align-items: stretch;
  gap: 20px;
  max-width: 100%;
}

.puzzle-board-row {
  display: flex;
  align-items: center;
  gap: 16px;
}

.puzzle-label {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--dark);
  text-align: center;
}

.hint-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  border: 2px solid rgba(0,0,0,0.1);
  border-radius: 10px;
  background: var(--yellow);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
  white-space: nowrap;
}

.hint-btn svg {
  flex-shrink: 0;
}

.hint-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.15);
}

.hint-btn:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

.hint-overlay {
  position: fixed;
  inset: 0;
  background: rgba(44, 62, 80, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 200;
  cursor: pointer;
  animation: fadeIn 0.2s;
}

.hint-popup {
  background: var(--white);
  border: 2px solid #e0e0e0;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
  border-radius: 16px;
  padding: 28px;
  text-align: center;
}

.hint-popup img:not(.combined-hint-img) {
  width: 320px;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  object-position: left top;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  margin-bottom: 14px;
}

.hint-popup p {
  font-weight: 700;
  color: var(--dark);
  font-size: 2rem;
}

/* Override for combined hint — prevent parent .hint-popup p from applying */
.combined-hint-popup .combined-hint-text {
  font-size: 1.1rem;
  font-weight: 400;
  color: #444;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Text popup — interactive step-by-step */
.text-popup {
  padding: 56px 80px;
  min-width: 420px;
  cursor: pointer;
  user-select: none;
}

.text-step {
  margin-bottom: 16px;
}

.text-step-animate {
  animation: textReveal 0.4s ease-out;
}

@keyframes textReveal {
  from { opacity: 0; transform: translateY(12px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.text-popup-zh {
  font-size: 4.5rem;
  font-weight: 900;
  color: var(--dark);
  letter-spacing: 0.25em;
}

.text-popup-pinyin-ruby {
  font-size: 4.5rem;
  font-weight: 900;
  color: var(--dark);
  letter-spacing: 0.25em;
}

.text-popup-pinyin-ruby ruby rt {
  font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  font-size: 0.5em;
  font-weight: 600;
  color: var(--blue);
  letter-spacing: -0.02em;
}

.text-popup-en {
  font-size: 3.2rem;
  color: var(--red);
  margin-top: 16px;
  font-weight: 900;
  letter-spacing: 1px;
}

.text-tap-hint {
  font-size: 0.85rem;
  color: #aaa;
  margin-top: 16px;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

.text-step-hint {
  border-top: 1px dashed #ddd;
  padding-top: 14px;
  margin-top: 20px;
}

/* Puzzle Result Popup */
.puzzle-result-overlay {
  position: fixed;
  inset: 0;
  background: rgba(44, 62, 80, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 200;
  animation: fadeIn 0.2s;
}

.puzzle-result-modal {
  background: var(--white);
  border: 2px solid #e0e0e0;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
  border-radius: 16px;
  padding: 36px 48px;
  text-align: center;
  min-width: 260px;
}

.puzzle-result-icon {
  margin-bottom: 12px;
}

.puzzle-result-text {
  font-size: 1.5rem;
  font-weight: 900;
  margin-bottom: 24px;
  letter-spacing: 0.5px;
}

.puzzle-result-modal.correct .puzzle-result-text {
  color: #00C853;
}

.puzzle-result-modal.wrong .puzzle-result-text {
  color: var(--red);
}

.puzzle-result-btn {
  min-width: 120px;
}

/* Game Area */
.game-container {
  text-align: center;
  padding: 12px 0;
}

/* Puzzle Grid */
.puzzle-board {
  display: inline-grid;
  gap: 4px;
  background: var(--dark);
  border: 4px solid var(--dark);
  border-radius: 8px;
  padding: 4px;
}

.puzzle-slot {
  background: var(--light);
  border: 2px dashed #aaa;
  position: relative;
}

.puzzle-slot.filled {
  border: none;
  cursor: grab;
}

.puzzle-slot.dragging {
  opacity: 0.4;
}

.puzzle-slot.drag-over {
  background: var(--yellow);
  opacity: 0.7;
}

/* Puzzle Pieces */
.pieces-area {
  display: grid;
  align-content: start;
  justify-content: center;
  gap: 6px;
  padding: 8px;
  background: var(--white);
  border: 2px solid #ddd;
  border-radius: 12px;
  transition: all 0.3s ease;
  overflow: hidden;
}

.pieces-area.all-placed {
  border-style: dashed;
  border-color: #ddd;
}

.pieces-area.all-placed::after {
  content: '拼图块已全部放置';
  grid-column: 1 / -1;
  text-align: center;
  padding: 20px 0;
  color: #bbb;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.puzzle-piece {
  border: 2px solid var(--dark);
  border-radius: 4px;
  cursor: grab;
  transition: all 0.2s ease;
}

.puzzle-piece:hover {
  transform: scale(1.05);
  box-shadow: var(--shadow);
}

.puzzle-piece.dragging {
  opacity: 0.5;
}

/* Quiz Section */
.quiz-section {
  background: var(--white);
  border: 2px solid #ddd;
  border-radius: 16px;
  padding: 30px;
  margin: 32px auto 28px;
  max-width: 85%;
  box-shadow: var(--shadow-sm);
}

.quiz-section h3 {
  font-size: 1.2rem;
  margin-bottom: 20px;
  letter-spacing: 0.5px;
}

.quiz-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.quiz-option {
  padding: 18px 14px 14px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  border: 2px solid #e0e0e0;
  border-radius: 12px;
  background: var(--light);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
  text-align: center;
  line-height: 1.6;
}

.quiz-option:hover {
  background: var(--yellow);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.12);
}

.quiz-option:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

.quiz-option.correct {
  background: #00C853;
  color: var(--white);
  border-color: #00a844;
  animation: correctBounce 0.4s ease;
}

.quiz-option.wrong {
  background: var(--red);
  color: var(--white);
  border-color: #e55a5a;
  animation: gentleShake 0.4s ease;
}

@keyframes correctBounce {
  0% { transform: scale(1); }
  40% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

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

/* Result Card */
.result-card {
  background: var(--white);
  border: 2px solid #e0e0e0;
  box-shadow: 0 8px 32px rgba(0,0,0,0.08);
  border-radius: 16px;
  padding: 30px;
  text-align: center;
  margin: 32px auto 28px;
  max-width: 85%;
}

.result-flag {
  width: 300px;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  object-position: left top;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.result-name {
  font-size: 1.8rem;
  font-weight: 900;
  margin-bottom: 4px;
}

.result-name-ruby {
  margin-bottom: 8px;
}

.result-pinyin {
  font-size: 1.1rem;
  color: var(--blue);
  font-weight: 600;
  margin-bottom: 4px;
}

.result-layout {
  display: flex;
  gap: 28px;
  text-align: left;
}

.result-left {
  flex: 1;
  text-align: center;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.result-right {
  width: 35%;
  flex-shrink: 0;
  border-left: 2px solid #eee;
  padding-left: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.result-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 16px;
  width: 100%;
}

.result-actions .tts-btn {
  margin: 0;
}

.knowledge-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--blue);
  letter-spacing: 0.5px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--blue);
  margin-bottom: 4px;
}

.knowledge-fact {
  font-size: 1rem;
  font-weight: 600;
  color: var(--dark);
  line-height: 1.8;
  display: inline;
}

.knowledge-fact-wrap {
  line-height: 1.8;
}

.knowledge-tts-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--blue);
  vertical-align: middle;
  margin-left: 4px;
  padding: 0;
  box-shadow: none;
}

.knowledge-tts-btn:hover {
  color: var(--red);
}

.knowledge-img {
  width: 100%;
  border-radius: 8px;
  border: 2px solid #e0e0e0;
  object-fit: cover;
  object-position: left top;
  aspect-ratio: 3 / 2;
}

.knowledge-loading,
.knowledge-empty {
  font-size: 0.85rem;
  color: #aaa;
  text-align: center;
  padding: 20px 0;
}

.result-english {
  font-size: 3rem;
  font-weight: 900;
  color: var(--red);
  margin-bottom: 16px;
  letter-spacing: 1px;
}

/* Highlight difficult Chinese characters */
.char-hard {
  color: var(--red);
}

/* Ruby pinyin — shared styles */
ruby {
  ruby-align: center;
  letter-spacing: 0.15em;
}

ruby rt {
  font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  font-size: 0.5em;
  color: var(--blue);
  font-weight: 600;
  letter-spacing: -0.02em;
  padding-bottom: 5px;
}

.ruby-fallback {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
}

.ruby-fallback .ruby-pinyin {
  font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  font-size: 0.6em;
  color: var(--blue);
  font-weight: 600;
  letter-spacing: -0.02em;
}

/* Quiz option ruby */
.quiz-option-ruby {
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  display: block;
  margin-bottom: 4px;
}

.quiz-option-ruby ruby rt {
  font-size: 0.6em;
}

.quiz-option-en {
  display: block;
  font-size: 1.5rem;
  color: var(--blue);
  font-weight: 600;
  margin-top: 0;
  letter-spacing: 0.5px;
}

/* Result card ruby */
.result-ruby {
  font-size: 2.5rem;
  font-weight: 900;
  letter-spacing: 0.2em;
}

.result-ruby ruby rt {
  font-size: 0.6em;
}

.result-name-ruby {
  margin-bottom: 8px;
}

/* TTS Button */
.tts-btn {
  width: 50px;
  height: 50px;
  font-size: 1.5rem;
  border: 2px solid rgba(0,0,0,0.1);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--yellow);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  margin: 12px auto;
  transition: all 0.2s ease;
}

.tts-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.15);
}

.tts-btn:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

/* Admin Tabs */
.admin-tab {
  padding: 10px 24px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  border: none;
  border-bottom: 3px solid transparent;
  background: transparent;
  cursor: pointer;
  color: #888;
  margin-bottom: -3px;
  transition: all 0.2s;
  border-radius: 8px 8px 0 0;
}

.admin-tab:hover { color: var(--dark); }

.admin-tab.active {
  color: var(--dark);
  border-bottom-color: var(--blue);
}

.tab-content { }

/* Admin */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--white);
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.admin-table th, .admin-table td {
  padding: 10px 14px;
  border: 1px solid #e0e0e0;
  text-align: left;
  font-size: 0.9rem;
}

.admin-table th {
  background: var(--dark);
  color: var(--light);
  font-weight: 700;
  letter-spacing: 0.5px;
  font-size: 0.8rem;
}

.admin-table img {
  width: 48px;
  border: 2px solid #e0e0e0;
  border-radius: 4px;
}

.admin-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(44, 62, 80, 0.5);
  z-index: 100;
  justify-content: center;
  align-items: center;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: var(--white);
  border: 2px solid #e0e0e0;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
  border-radius: 16px;
  padding: 30px;
  width: 90%;
  max-width: 480px;
}

.modal h3 {
  margin-bottom: 20px;
  letter-spacing: 0.5px;
}

/* Progress bar */
.progress-bar {
  width: 100%;
  height: 27px;
  background: var(--light);
  border: 2px solid #e0e0e0;
  margin-bottom: 0;
  border-radius: 14px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #4A90FF, #00C853);
  transition: width 0.4s ease;
  border-radius: 12px;
}

/* Responsive */
@media (max-width: 960px) {
  .app-layout {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    padding: 12px 16px;
    flex-direction: row;
    display: flex;
    align-items: center;
    gap: 16px;
    border-right: none;
    border-bottom: 2px solid #e0e0e0;
  }
  .sidebar-section {
    margin-bottom: 0;
    white-space: nowrap;
  }
  .question-panel {
    width: 100%;
    border-left: none;
    border-top: 2px solid #e0e0e0;
    padding-top: 0;
  }
  .panel-sticky-top {
    position: static;
  }
  .question-cards {
    grid-template-columns: repeat(auto-fill, minmax(32px, 1fr));
  }
}

@media (max-width: 640px) {
  .puzzle-main-row {
    flex-direction: column;
    align-items: center;
  }
  .pieces-area {
    width: auto;
  }
  .quiz-options {
    grid-template-columns: 1fr;
  }
  .form-card {
    margin: 20px 10px;
    padding: 24px;
  }
  .header h1 {
    font-size: 1rem;
  }
  .main-header-row {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
  }
  .main-content {
    padding: 16px;
  }
}

/* Loading */
.loading {
  text-align: center;
  padding: 40px;
  font-weight: 700;
  font-size: 1.1rem;
}

/* Combined hint popup (text description + image reveal) */
.combined-hint-popup {
  max-width: 360px;
  padding: 20px 24px;
  cursor: default;
  text-align: left;
}

.combined-hint-text {
  font-size: 1.1rem;
  font-weight: 400;
  color: #444;
  line-height: 1.5;
  margin-bottom: 10px;
  letter-spacing: 0.02em;
}

.combined-hint-tts {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 2px solid var(--blue);
  background: rgba(74,144,255,0.08);
  cursor: pointer;
  color: var(--blue);
  font-size: 0.78rem;
  font-weight: 600;
  font-family: inherit;
  padding: 5px 14px;
  margin-bottom: 14px;
  border-radius: 20px;
  box-shadow: none;
  transition: all 0.15s;
}

.combined-hint-tts:hover {
  background: var(--blue);
  color: var(--white);
}

.combined-hint-img-area {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
}

.combined-hint-img-area.revealed {
  border: none;
}

.combined-hint-img {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  object-position: left top;
}

.combined-hint-img-cover {
  position: absolute;
  inset: 0;
  background: var(--light);
  border: 2px dashed #ccc;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 1;
  transition: opacity 0.3s;
}

.combined-hint-img-cover span {
  font-size: 0.78rem;
  font-weight: 500;
  color: #aaa;
  letter-spacing: 0.3px;
}

.combined-hint-img-cover:hover {
  border-color: var(--blue);
}

.combined-hint-img-cover:hover span { color: var(--blue); }

.combined-hint-img-cover.hidden {
  opacity: 0;
  pointer-events: none;
}

/* Reset button in panel header */
.reset-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: 2px solid #e0e0e0;
  border-radius: 6px;
  background: var(--light);
  cursor: pointer;
  color: #999;
  padding: 0;
  transition: all 0.2s;
  margin-left: 8px;
}

.reset-btn:hover {
  background: var(--yellow);
  color: var(--dark);
  border-color: var(--yellow);
  transform: translateY(-1px);
}

/* Site Footer */
.site-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 20px 24px;
  background: #e8f4f0;
  color: #3a6b5e;
  font-size: 0.78rem;
  letter-spacing: 0.2px;
  margin-top: auto;
}

.footer-sep {
  color: #a0c8ba;
}

.footer-link {
  color: #3a6b5e;
  text-decoration: none;
  transition: color 0.2s;
}

.footer-link:hover {
  color: var(--blue);
}

.footer-gongan {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.gongan-icon {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}

/* Hidden */
.hidden { display: none !important; }
