/**
 * Chinese Number Reading Tool — Styles
 * macOS 26 inspired, QMF variables, responsive
 */

/* ============================================
   PAGE LAYOUT
   ============================================ */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    background: var(--qmf-bg-gradient);
    color: #1e293b;
    min-height: 100vh;
    overflow-x: hidden;
}

.page-container {
    max-width: 960px;
    margin: 0 auto;
    padding: 72px 20px 60px;
}

/* ============================================
   HEADER — gradient, not black
   ============================================ */
.tool-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    height: 56px;
    background: linear-gradient(135deg, rgba(255,255,255,0.92), rgba(224,242,254,0.88));
    backdrop-filter: blur(20px) saturate(1.8);
    -webkit-backdrop-filter: blur(20px) saturate(1.8);
    border-bottom: 1px solid rgba(59,130,246,0.12);
    transition: all 0.25s ease;
}

body.dark-mode .tool-header {
    background: linear-gradient(135deg, rgba(15,23,42,0.92), rgba(30,58,95,0.88));
    border-bottom-color: rgba(59,130,246,0.2);
}

.header-inner {
    max-width: 960px;
    margin: 0 auto;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
}

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

.header-left a {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: #1e293b;
}

body.dark-mode .header-left a {
    color: #f1f5f9;
}

.header-left .logo {
    height: 28px;
    width: auto;
}

.header-title {
    font-size: 15px;
    font-weight: 600;
    color: #1e293b;
}

body.dark-mode .header-title {
    color: #f1f5f9;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: #64748b;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 15px;
}

body.dark-mode .header-btn {
    color: #94a3b8;
}

.header-btn:hover {
    background: rgba(59,130,246,0.12);
    color: #3b82f6;
    transform: translateY(-1px);
}

/* ============================================
   PAGE HERO / TITLE — compact & colorful
   ============================================ */
.page-hero {
    text-align: center;
    padding: 12px 0 16px;
    animation: heroEntry 0.7s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes heroEntry {
    0% { opacity: 0; transform: translateY(-20px) scale(0.96); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

.page-hero h1 {
    font-size: 1.6rem;
    font-weight: 800;
    margin: 0 0 6px;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6, #ec4899);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.02em;
    animation: gradientShift 4s ease infinite;
    background-size: 200% 200%;
}

@keyframes gradientShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.page-hero .subtitle {
    font-size: 0.88rem;
    color: #64748b;
    max-width: 560px;
    margin: 0 auto;
    line-height: 1.5;
}

body.dark-mode .page-hero .subtitle {
    color: #94a3b8;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    margin-top: 8px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 999px;
    background: rgba(59,130,246,0.12);
    color: #3b82f6;
    animation: badgePop 0.5s 0.3s both;
}

@keyframes badgePop {
    0% { opacity: 0; transform: scale(0.7); }
    70% { transform: scale(1.08); }
    100% { opacity: 1; transform: scale(1); }
}

/* ============================================
   MODE TABS (macOS segmented control)
   ============================================ */
.mode-tabs {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: #e2e8f0;
    border-radius: 14px;
    margin: 0 auto 24px;
    max-width: 480px;
    animation: fadeSlideUp 0.5s 0.15s both;
}

body.dark-mode .mode-tabs {
    background: #334155;
}

@keyframes fadeSlideUp {
    0% { opacity: 0; transform: translateY(12px); }
    100% { opacity: 1; transform: translateY(0); }
}

.mode-tab {
    flex: 1;
    padding: 11px 16px;
    font-size: 14px;
    font-weight: 600;
    color: #64748b;
    background: transparent;
    border: none;
    border-radius: 11px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
}

body.dark-mode .mode-tab {
    color: #94a3b8;
}

.mode-tab:hover {
    color: #1e293b;
}

body.dark-mode .mode-tab:hover {
    color: #f1f5f9;
}

.mode-tab.active {
    background: #ffffff;
    color: #3b82f6;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

body.dark-mode .mode-tab.active {
    background: #1e293b;
    color: #60a5fa;
}

/* ============================================
   PANELS — smooth switch
   ============================================ */
.panel {
    display: none;
    animation: panelSwitch 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes panelSwitch {
    0% { opacity: 0; transform: translateX(16px); }
    100% { opacity: 1; transform: translateX(0); }
}

.panel.active {
    display: block;
}

/* ============================================
   TYPE SELECTOR (pill chips) — staggered animation
   ============================================ */
.type-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 24px;
    justify-content: center;
}

.type-chip {
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    color: #64748b;
    background: #ffffff;
    border: 1.5px solid #e2e8f0;
    border-radius: 999px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
    animation: chipReveal 0.4s both;
}

body.dark-mode .type-chip {
    color: #94a3b8;
    background: #1e293b;
    border-color: #334155;
}

.type-chip:nth-child(1)  { animation-delay: 0.05s; }
.type-chip:nth-child(2)  { animation-delay: 0.08s; }
.type-chip:nth-child(3)  { animation-delay: 0.11s; }
.type-chip:nth-child(4)  { animation-delay: 0.14s; }
.type-chip:nth-child(5)  { animation-delay: 0.17s; }
.type-chip:nth-child(6)  { animation-delay: 0.2s;  }
.type-chip:nth-child(7)  { animation-delay: 0.23s; }
.type-chip:nth-child(8)  { animation-delay: 0.26s; }
.type-chip:nth-child(9)  { animation-delay: 0.29s; }
.type-chip:nth-child(10) { animation-delay: 0.32s; }

@keyframes chipReveal {
    0% { opacity: 0; transform: translateY(8px) scale(0.9); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

.type-chip:hover {
    border-color: #3b82f6;
    color: #3b82f6;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59,130,246,0.15);
}

body.dark-mode .type-chip:hover {
    border-color: #60a5fa;
    color: #60a5fa;
}

.type-chip.active {
    background: #3b82f6;
    color: #ffffff;
    border-color: #3b82f6;
    box-shadow: 0 3px 10px rgba(59, 130, 246, 0.35);
    transform: translateY(-1px);
}

.type-chip .chip-icon {
    font-size: 14px;
}

/* ============================================
   CHALLENGE CARD (Mode 1 — Practice) — slide-up entrance
   ============================================ */
.challenge-card {
    background: #ffffff;
    border-radius: 20px;
    padding: 32px;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -1px rgba(0,0,0,0.04);
    border: 1px solid #e2e8f0;
    margin-bottom: 20px;
    transition: all 0.25s ease;
    position: relative;
    overflow: hidden;
    animation: cardEnter 0.5s 0.2s both;
}

body.dark-mode .challenge-card {
    background: #1e293b;
    border-color: #334155;
}

@keyframes cardEnter {
    0% { opacity: 0; transform: translateY(24px); }
    100% { opacity: 1; transform: translateY(0); }
}

.challenge-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6);
    opacity: 0;
    transition: opacity 0.25s ease;
}

.challenge-card.active-challenge::before {
    opacity: 1;
}

.challenge-number {
    text-align: center;
    font-size: 3.5rem;
    font-weight: 800;
    margin: 16px 0 8px;
    color: #1e293b;
    letter-spacing: 0.02em;
    font-variant-numeric: tabular-nums;
    animation: numberPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    word-break: break-all;
}

body.dark-mode .challenge-number {
    color: #f1f5f9;
}

@keyframes numberPop {
    0% { opacity: 0; transform: scale(0.6); }
    100% { opacity: 1; transform: scale(1); }
}

.challenge-type-label {
    text-align: center;
    font-size: 13px;
    color: #94a3b8;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.challenge-type-label .type-badge {
    padding: 3px 10px;
    border-radius: 999px;
    background: rgba(139,92,246,0.12);
    color: #8b5cf6;
    font-weight: 600;
    font-size: 11px;
}

/* INPUT AREA */
.answer-area {
    margin: 20px 0;
}

.answer-input-wrapper {
    position: relative;
}

.answer-input {
    width: 100%;
    padding: 16px 20px;
    font-size: 22px;
    font-family: 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: #ffffff;
    color: #1e293b;
    border: 2px solid #e2e8f0;
    border-radius: 14px;
    transition: all 0.2s ease;
    text-align: center;
    letter-spacing: 0.05em;
    ime-mode: active;
}

body.dark-mode .answer-input {
    background: #1e293b;
    color: #f1f5f9;
    border-color: #334155;
}

.answer-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 4px rgba(59,130,246,0.12);
}

.answer-input.correct {
    border-color: #10b981;
    box-shadow: 0 0 0 4px rgba(16,185,129,0.12);
    animation: correctPulse 0.5s ease-out;
}

.answer-input.incorrect {
    border-color: #ef4444;
    box-shadow: 0 0 0 4px rgba(239,68,68,0.12);
    animation: shake 0.4s ease-out;
}

@keyframes correctPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-8px); }
    40% { transform: translateX(8px); }
    60% { transform: translateX(-6px); }
    80% { transform: translateX(6px); }
}

.answer-hint {
    text-align: center;
    margin-top: 8px;
    font-size: 13px;
    color: #94a3b8;
}

/* ============================================
   BUTTONS — explicit colors, no inheritance issues
   ============================================ */
.challenge-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
    justify-content: center;
    flex-wrap: wrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
    line-height: 1.4;
}

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

.btn-primary {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: #ffffff !important;
    box-shadow: 0 4px 14px rgba(59, 130, 246, 0.35);
}

.btn-primary:hover {
    box-shadow: 0 6px 22px rgba(59, 130, 246, 0.45);
    transform: translateY(-2px);
}

.btn-secondary {
    background: rgba(59,130,246,0.1);
    color: #3b82f6 !important;
}

body.dark-mode .btn-secondary {
    background: rgba(59,130,246,0.2);
    color: #60a5fa !important;
}

.btn-secondary:hover {
    background: rgba(59, 130, 246, 0.18);
    transform: translateY(-1px);
}

.btn-ghost {
    background: transparent;
    color: #64748b !important;
    border: 1.5px solid #e2e8f0;
}

body.dark-mode .btn-ghost {
    color: #94a3b8 !important;
    border-color: #334155;
}

.btn-ghost:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    transform: translateY(-1px);
}

body.dark-mode .btn-ghost:hover {
    background: #334155;
    border-color: #475569;
}

.btn-success {
    background: linear-gradient(135deg, #10b981, #059669);
    color: #ffffff !important;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.3);
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

/* RESULT FEEDBACK — animated entrance */
.feedback-area {
    margin-top: 20px;
    padding: 16px 20px;
    border-radius: 14px;
    display: none;
    animation: feedbackSlide 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes feedbackSlide {
    0% { opacity: 0; transform: translateY(12px) scale(0.97); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

.feedback-area.show {
    display: block;
}

.feedback-area.correct {
    background: rgba(16,185,129,0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.feedback-area.incorrect {
    background: rgba(239,68,68,0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.feedback-icon {
    font-size: 24px;
    margin-right: 8px;
}

.feedback-text {
    font-size: 15px;
    font-weight: 600;
    color: #1e293b;
}

body.dark-mode .feedback-text {
    color: #f1f5f9;
}

.feedback-detail {
    margin-top: 8px;
    font-size: 13px;
    color: #64748b;
    line-height: 1.6;
}

body.dark-mode .feedback-detail {
    color: #94a3b8;
}

.expected-answer {
    display: inline-block;
    margin-top: 6px;
    padding: 6px 14px;
    font-size: 20px;
    font-family: 'Noto Sans SC', 'PingFang SC', sans-serif;
    background: #ffffff;
    border-radius: 10px;
    letter-spacing: 0.05em;
    border: 1px solid #e2e8f0;
}

body.dark-mode .expected-answer {
    background: #1e293b;
    border-color: #334155;
}

.alternatives-text {
    margin-top: 6px;
    font-size: 12px;
    color: #94a3b8;
}

/* STATS BAR — slide up with bounce */
.stats-bar {
    display: flex;
    gap: 16px;
    padding: 14px 20px;
    background: #ffffff;
    border-radius: 14px;
    border: 1px solid #e2e8f0;
    margin-bottom: 20px;
    justify-content: center;
    flex-wrap: wrap;
    animation: cardEnter 0.45s 0.1s both;
}

body.dark-mode .stats-bar {
    background: #1e293b;
    border-color: #334155;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #64748b;
}

body.dark-mode .stat-item {
    color: #94a3b8;
}

.stat-value {
    font-weight: 700;
    color: #1e293b;
    font-variant-numeric: tabular-nums;
    transition: transform 0.2s ease;
}

body.dark-mode .stat-value {
    color: #f1f5f9;
}

.stat-value.correct-count { color: #10b981; }
.stat-value.incorrect-count { color: #ef4444; }

/* ============================================
   CONVERTER CARD (Mode 2) — entrance
   ============================================ */
.converter-card {
    background: #ffffff;
    border-radius: 20px;
    padding: 32px;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -1px rgba(0,0,0,0.04);
    border: 1px solid #e2e8f0;
    margin-bottom: 20px;
    animation: cardEnter 0.5s 0.2s both;
}

body.dark-mode .converter-card {
    background: #1e293b;
    border-color: #334155;
}

.converter-form {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.form-group {
    flex: 1;
    min-width: 180px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #64748b;
    margin-bottom: 6px;
}

body.dark-mode .form-group label {
    color: #94a3b8;
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    font-size: 15px;
    background: #ffffff;
    color: #1e293b;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    transition: all 0.2s ease;
}

body.dark-mode .form-input {
    background: #0f172a;
    color: #f1f5f9;
    border-color: #334155;
}

.form-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 4px rgba(59,130,246,0.12);
}

.form-select {
    width: 100%;
    padding: 12px 16px;
    font-size: 15px;
    background: #ffffff;
    color: #1e293b;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
    transition: all 0.2s ease;
}

body.dark-mode .form-select {
    background-color: #0f172a;
    color: #f1f5f9;
    border-color: #334155;
}

.form-select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 4px rgba(59,130,246,0.12);
}

/* Fraction inputs */
.fraction-inputs {
    display: none;
    gap: 8px;
    align-items: center;
    margin-top: 12px;
    flex-wrap: wrap;
}

.fraction-inputs.show {
    display: flex;
}

.fraction-inputs .form-input {
    width: 80px;
    flex: 0 0 auto;
    text-align: center;
}

.fraction-separator {
    font-size: 24px;
    color: #94a3b8;
    font-weight: 300;
}

/* Date inputs */
.date-inputs {
    display: none;
    gap: 8px;
    align-items: center;
    margin-top: 12px;
    flex-wrap: wrap;
}

.date-inputs.show {
    display: flex;
}

.date-inputs .form-input {
    width: 90px;
    flex: 0 0 auto;
    text-align: center;
}

.date-separator {
    font-size: 16px;
    color: #94a3b8;
}

/* RESULT DISPLAY */
.convert-result {
    margin-top: 24px;
    display: none;
    animation: resultReveal 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes resultReveal {
    0% { opacity: 0; transform: translateY(16px) scale(0.97); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

.convert-result.show {
    display: block;
}

.result-card {
    background: linear-gradient(135deg, rgba(59,130,246,0.08), rgba(139,92,246,0.08));
    border-radius: 16px;
    padding: 24px;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.result-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #94a3b8;
    margin-bottom: 8px;
}

.result-chinese {
    font-size: 2rem;
    font-weight: 700;
    font-family: 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', serif;
    color: #1e293b;
    letter-spacing: 0.08em;
    line-height: 1.5;
    word-break: break-all;
}

body.dark-mode .result-chinese {
    color: #f1f5f9;
}

.result-explanation {
    margin-top: 12px;
    font-size: 13px;
    color: #64748b;
    line-height: 1.6;
    padding: 12px;
    background: #ffffff;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
}

body.dark-mode .result-explanation {
    background: #1e293b;
    color: #94a3b8;
    border-color: #334155;
}

.result-rule {
    margin-top: 8px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 999px;
    background: rgba(245,158,11,0.12);
    color: #f59e0b;
}

/* ============================================
   RULES POPUP / MODAL
   ============================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    padding: 20px;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: #ffffff;
    border-radius: 24px;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.15);
    max-width: 640px;
    width: 100%;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: scale(0.92) translateY(20px);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

body.dark-mode .modal {
    background: #1e293b;
}

.modal-overlay.active .modal {
    transform: scale(1) translateY(0);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
}

body.dark-mode .modal-header {
    border-color: #334155;
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 700;
    color: #1e293b;
    margin: 0;
}

body.dark-mode .modal-header h2 {
    color: #f1f5f9;
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 8px;
    background: #e2e8f0;
    color: #64748b;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 16px;
}

body.dark-mode .modal-close {
    background: #334155;
    color: #94a3b8;
}

.modal-close:hover {
    background: rgba(239,68,68,0.12);
    color: #ef4444;
}

.modal-body {
    padding: 20px 24px;
    overflow-y: auto;
    flex: 1;
}

.rule-section {
    margin-bottom: 24px;
}

.rule-section h3 {
    font-size: 15px;
    font-weight: 700;
    color: #3b82f6;
    margin: 0 0 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.rule-section .rule-content {
    font-size: 13.5px;
    line-height: 1.8;
    color: #64748b;
    white-space: pre-line;
    padding: 12px 16px;
    background: #f8fafc;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
}

body.dark-mode .rule-section .rule-content {
    background: #0f172a;
    color: #94a3b8;
    border-color: #334155;
}

.rule-section .rule-content code {
    background: rgba(59,130,246,0.12);
    color: #3b82f6;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 13px;
    font-family: 'Noto Sans SC', monospace;
}

/* DIGIT TABLE IN MODAL */
.digit-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    margin: 8px 0;
}

.digit-table th {
    background: rgba(59,130,246,0.1);
    color: #3b82f6;
    font-weight: 600;
    padding: 8px 12px;
    text-align: center;
    font-size: 12px;
}

.digit-table td {
    padding: 8px 12px;
    text-align: center;
    border-bottom: 1px solid #e2e8f0;
    color: #1e293b;
}

body.dark-mode .digit-table td {
    border-color: #334155;
    color: #f1f5f9;
}

.digit-table td:nth-child(2) {
    font-family: 'Noto Sans SC', serif;
    font-size: 18px;
    font-weight: 600;
}

.digit-table tr:hover td {
    background: rgba(59,130,246,0.06);
}

/* ============================================
   HELP BUTTON (floating) — breathing glow
   ============================================ */
.help-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 52px;
    height: 52px;
    border-radius: 16px;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    color: #ffffff !important;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.4);
    transition: all 0.25s ease;
    z-index: 50;
    animation: fabBreath 3s ease-in-out infinite;
}

@keyframes fabBreath {
    0%, 100% { box-shadow: 0 4px 20px rgba(59, 130, 246, 0.4); }
    50% { box-shadow: 0 4px 28px rgba(59, 130, 246, 0.6); }
}

.help-fab:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 8px 30px rgba(59, 130, 246, 0.5);
}

/* ============================================
   STREAK ANIMATION
   ============================================ */
.streak-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    border-radius: 999px;
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    color: white;
    font-size: 12px;
    font-weight: 700;
    animation: qmf-pulse 1.5s infinite;
}

/* ============================================
   CONFETTI BURST (correct answer)
   ============================================ */
@keyframes confettiFall {
    0% { transform: translateY(-10px) rotate(0deg); opacity: 1; }
    100% { transform: translateY(60px) rotate(360deg); opacity: 0; }
}

.confetti-burst {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    pointer-events: none;
    display: flex;
    gap: 4px;
}

.confetti-piece {
    width: 8px;
    height: 8px;
    border-radius: 2px;
    animation: confettiFall 1s ease-out forwards;
}

/* ============================================
   KEYBOARD HINT
   ============================================ */
.keyboard-hint {
    text-align: center;
    margin-top: 8px;
    font-size: 12px;
    color: #94a3b8;
}

.kbd {
    display: inline-flex;
    align-items: center;
    padding: 2px 7px;
    font-size: 11px;
    font-family: monospace;
    background: #e2e8f0;
    border-radius: 4px;
    border: 1px solid #cbd5e1;
    margin: 0 2px;
    color: #475569;
}

body.dark-mode .kbd {
    background: #334155;
    border-color: #475569;
    color: #94a3b8;
}

/* ============================================
   FOOTER
   ============================================ */
.page-footer {
    text-align: center;
    padding: 32px 0;
    font-size: 12px;
    color: #94a3b8;
    border-top: 1px solid #e2e8f0;
    margin-top: 40px;
}

body.dark-mode .page-footer {
    border-color: #334155;
}

.page-footer a {
    color: #3b82f6;
    text-decoration: none;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .page-container {
        padding: 72px 14px 40px;
    }

    .page-hero h1 {
        font-size: 1.5rem;
    }

    .challenge-number {
        font-size: 2.2rem;
    }

    .answer-input {
        font-size: 18px;
        padding: 14px 16px;
    }

    .converter-form {
        flex-direction: column;
    }

    .form-group {
        min-width: 100%;
    }

    .result-chinese {
        font-size: 1.5rem;
    }

    .mode-tabs {
        max-width: 100%;
    }

    .mode-tab {
        padding: 10px 12px;
        font-size: 13px;
    }

    .modal {
        max-height: 90vh;
        border-radius: 16px;
    }

    .modal-body {
        padding: 16px;
    }

    .stats-bar {
        gap: 10px;
        padding: 12px 16px;
    }

    .challenge-card {
        padding: 20px;
    }

    .converter-card {
        padding: 20px;
    }

    .help-fab {
        bottom: 16px;
        right: 16px;
        width: 44px;
        height: 44px;
        border-radius: 12px;
    }
}

@media (max-width: 480px) {
    .type-selector {
        gap: 6px;
    }

    .type-chip {
        padding: 6px 12px;
        font-size: 12px;
    }

    .challenge-number {
        font-size: 1.8rem;
    }

    .challenge-actions {
        flex-direction: column;
    }

    .challenge-actions .btn {
        width: 100%;
    }
}

/* ============================================
   REDUCED MOTION
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
