/* Global Styles */
:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --secondary: #10b981;
    --accent: #f59e0b;
    --danger: #ef4444;
    --success: #22c55e;
    --bg-dark: #0f172a;
    --bg-card: #1e293b;
    --bg-light: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --gradient-1: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-2: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --gradient-special: linear-gradient(135deg, #f5af19 0%, #f12711 100%);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Top Navigation */
.top-nav {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 1000;
    display: flex;
    gap: 10px;
    padding: 12px 20px;
}

.nav-btn {
    background: var(--primary);
    color: #fff;
    text-decoration: none;
    padding: 8px 18px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    transition: background 0.3s, transform 0.2s;
}

.nav-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Screen Management */
.screen {
    display: none;
    animation: fadeIn 0.3s ease;
}

.screen.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Home Screen */
.hero {
    text-align: center;
    padding: 60px 20px;
    background: var(--gradient-1);
    border-radius: 20px;
    margin-bottom: 40px;
}

.title {
    font-size: 3rem;
    font-weight: 800;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.subtitle {
    font-size: 1.2rem;
    opacity: 0.9;
}

.chinese-title {
    font-size: 1.5rem;
    margin-top: 15px;
    opacity: 0.9;
}

.menu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.menu-card {
    background: var(--bg-card);
    border: none;
    border-radius: 16px;
    padding: 30px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
    color: var(--text-primary);
}

.menu-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(99, 102, 241, 0.3);
}

.menu-card.special {
    background: var(--gradient-special);
}

.menu-card.special:hover {
    box-shadow: 0 10px 30px rgba(245, 175, 25, 0.4);
}

.card-icon {
    font-size: 3rem;
    margin-bottom: 15px;
}

.menu-card h3 {
    font-size: 1.5rem;
    margin-bottom: 10px;
}

.menu-card p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.menu-card.special p {
    color: rgba(255,255,255,0.85);
}

/* Back Button */
.back-btn {
    background: var(--bg-light);
    border: none;
    color: var(--text-primary);
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 20px;
    transition: background 0.3s;
}

.back-btn:hover {
    background: var(--primary);
}

/* Lesson Tabs */
.lesson-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.tab-btn {
    background: var(--bg-card);
    border: none;
    color: var(--text-secondary);
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.tab-btn:hover, .tab-btn.active {
    background: var(--primary);
    color: var(--text-primary);
}

/* Lesson Content */
.lesson-content {
    display: none;
}

.lesson-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

/* Info Boxes */
.info-box {
    background: var(--bg-card);
    padding: 25px;
    border-radius: 12px;
    margin-bottom: 25px;
    border-left: 4px solid var(--primary);
}

.formula-box {
    text-align: center;
}

.formula-box h4 {
    color: var(--accent);
    margin-bottom: 15px;
}

.formula {
    font-size: 1.3rem;
    color: var(--secondary);
    font-weight: bold;
    margin-top: 15px;
    padding: 15px;
    background: var(--bg-light);
    border-radius: 8px;
}

/* Example Boxes */
.example-box {
    background: var(--bg-card);
    padding: 25px;
    border-radius: 12px;
    margin-bottom: 25px;
}

.example-box h4 {
    color: var(--accent);
    margin-bottom: 15px;
}

.step-by-step {
    margin: 15px 0;
}

.step {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 10px 0;
    border-bottom: 1px solid var(--bg-light);
}

.step:last-child {
    border-bottom: none;
}

.step-num {
    background: var(--primary);
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    flex-shrink: 0;
}

.result {
    background: var(--gradient-1);
    padding: 15px 20px;
    border-radius: 8px;
    font-weight: bold;
    margin-top: 15px;
}

/* Tip Box */
.tip-box {
    background: linear-gradient(135deg, #065f46 0%, #047857 100%);
    padding: 25px;
    border-radius: 12px;
    margin-top: 30px;
}

.tip-box h4 {
    margin-bottom: 15px;
}

.tip-box ul {
    list-style: none;
}

.tip-box li {
    padding: 8px 0;
    padding-left: 25px;
    position: relative;
}

.tip-box li::before {
    content: "✓";
    position: absolute;
    left: 0;
    color: var(--secondary);
}

/* Strategy Cards */
.strategy-card {
    background: var(--bg-card);
    padding: 25px;
    border-radius: 12px;
    margin-bottom: 20px;
}

.strategy-card h4 {
    color: var(--accent);
    margin-bottom: 15px;
}

.strategy-card.highlight {
    background: var(--gradient-special);
}

.divisibility-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}

.divisibility-table th, .divisibility-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--bg-light);
}

.divisibility-table th {
    background: var(--bg-light);
    color: var(--secondary);
}

.mini-example {
    background: var(--bg-light);
    padding: 15px;
    border-radius: 8px;
    margin-top: 15px;
}

/* Practice Screen */
.practice-options {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    margin-bottom: 30px;
}

.practice-btn {
    background: var(--bg-card);
    border: 2px solid var(--primary);
    color: var(--text-primary);
    padding: 15px 30px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 1rem;
}

.practice-btn:hover {
    background: var(--primary);
}

.practice-area, .challenge-area {
    animation: fadeIn 0.3s ease;
}

.hidden {
    display: none !important;
}

/* Progress Bar */
.progress-bar {
    background: var(--bg-card);
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 20px;
}

.progress-fill {
    background: var(--gradient-1);
    height: 100%;
    width: 0%;
    transition: width 0.3s ease;
}

.question-counter {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

/* Question Box */
.question-box {
    background: var(--bg-card);
    padding: 30px;
    border-radius: 12px;
    margin-bottom: 25px;
    font-size: 1.2rem;
    text-align: center;
}

.question-box .question-text {
    margin-bottom: 15px;
}

.question-box .question-number {
    font-size: 2.5rem;
    color: var(--primary);
    font-weight: bold;
}

/* Answer Section */
.answer-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.answer-btn {
    background: var(--bg-card);
    border: 2px solid var(--bg-light);
    color: var(--text-primary);
    padding: 20px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 1.1rem;
}

.answer-btn:hover {
    border-color: var(--primary);
    background: var(--bg-light);
}

.answer-btn.correct {
    background: var(--success);
    border-color: var(--success);
}

.answer-btn.wrong {
    background: var(--danger);
    border-color: var(--danger);
}

.answer-btn.disabled {
    pointer-events: none;
    opacity: 0.6;
}

/* Input Answer */
.answer-input {
    width: 100%;
    padding: 15px;
    font-size: 1.2rem;
    border: 2px solid var(--bg-light);
    border-radius: 10px;
    background: var(--bg-card);
    color: var(--text-primary);
    text-align: center;
}

.answer-input:focus {
    outline: none;
    border-color: var(--primary);
}

.submit-answer-btn {
    background: var(--primary);
    border: none;
    color: white;
    padding: 15px 40px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1.1rem;
    margin-top: 15px;
    transition: background 0.3s;
}

.submit-answer-btn:hover {
    background: var(--primary-dark);
}

/* Feedback Box */
.feedback-box {
    padding: 20px;
    border-radius: 10px;
    margin-top: 20px;
    text-align: center;
}

.feedback-box.correct {
    background: rgba(34, 197, 94, 0.2);
    border: 2px solid var(--success);
}

.feedback-box.wrong {
    background: rgba(239, 68, 68, 0.2);
    border: 2px solid var(--danger);
}

.feedback-box h4 {
    margin-bottom: 10px;
}

.next-btn {
    background: var(--primary);
    border: none;
    color: white;
    padding: 15px 40px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1.1rem;
    margin-top: 20px;
    transition: all 0.3s;
}

.next-btn:hover {
    background: var(--primary-dark);
    transform: translateX(5px);
}

/* Practice Result */
.practice-result, .challenge-result {
    text-align: center;
    padding: 40px;
    background: var(--bg-card);
    border-radius: 16px;
    animation: fadeIn 0.3s ease;
}

.score-display {
    font-size: 4rem;
    font-weight: bold;
    margin: 30px 0;
    color: var(--primary);
}

.retry-btn {
    background: var(--primary);
    border: none;
    color: white;
    padding: 15px 40px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1.1rem;
    margin: 10px;
    transition: background 0.3s;
}

.retry-btn:hover {
    background: var(--primary-dark);
}

.back-btn-secondary {
    background: var(--bg-light);
    border: none;
    color: var(--text-primary);
    padding: 15px 40px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1.1rem;
    margin: 10px;
    transition: background 0.3s;
}

/* Challenge Screen */
.challenge-select {
    text-align: center;
}

.challenge-select h3 {
    margin-bottom: 30px;
}

.difficulty-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--bg-card);
    border: none;
    padding: 25px 40px;
    border-radius: 12px;
    cursor: pointer;
    margin: 10px;
    transition: all 0.3s;
    color: var(--text-primary);
    width: 200px;
}

.challenge-select {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
}

.difficulty-btn:hover {
    transform: translateY(-5px);
}

.difficulty-btn.easy { border-left: 4px solid var(--success); }
.difficulty-btn.medium { border-left: 4px solid var(--accent); }
.difficulty-btn.hard { border-left: 4px solid var(--danger); }
.difficulty-btn.olympiad { border-left: 4px solid var(--primary); }

.diff-icon {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.diff-name {
    font-size: 1.3rem;
    font-weight: bold;
    margin-bottom: 5px;
}

.diff-desc {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Challenge Area */
.challenge-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding: 20px;
    background: var(--bg-card);
    border-radius: 12px;
}

.timer {
    font-size: 2rem;
    font-weight: bold;
    color: var(--accent);
}

.timer-icon {
    margin-right: 10px;
}

.challenge-score {
    font-size: 1.5rem;
    color: var(--secondary);
}

.final-score {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 30px 0;
}

.score-label {
    color: var(--text-secondary);
    font-size: 1.2rem;
}

#final-score-value {
    font-size: 5rem;
    font-weight: bold;
    color: var(--accent);
}

/* Special 1001 Screen */
.special-screen {
    background: linear-gradient(180deg, var(--bg-dark) 0%, #1a1a2e 100%);
}

.special-subtitle {
    text-align: center;
    color: var(--accent);
    margin-bottom: 30px;
    font-size: 1.2rem;
}

.special-tabs {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.special-tab {
    background: var(--bg-card);
    border: none;
    color: var(--text-secondary);
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.special-tab:hover, .special-tab.active {
    background: var(--gradient-special);
    color: white;
}

.special-section {
    display: none;
    animation: fadeIn 0.3s ease;
}

.special-section.active {
    display: block;
}

/* Big Reveal */
.big-reveal {
    text-align: center;
    padding: 50px;
    background: var(--bg-card);
    border-radius: 20px;
    margin-bottom: 30px;
}

.number-display {
    font-size: 5rem;
    font-weight: 900;
    background: var(--gradient-special);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.equals {
    font-size: 3rem;
    margin: 20px 0;
    color: var(--text-secondary);
}

.factors-display {
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--secondary);
}

.info-card {
    background: var(--bg-card);
    padding: 25px;
    border-radius: 12px;
    margin-bottom: 20px;
}

.info-card h3 {
    color: var(--accent);
    margin-bottom: 15px;
}

.info-card ul {
    list-style: none;
}

.info-card li {
    padding: 10px 0;
    padding-left: 30px;
    position: relative;
}

.info-card li::before {
    content: "★";
    position: absolute;
    left: 0;
    color: var(--accent);
}

.fun-fact {
    background: linear-gradient(135deg, #1e3a5f 0%, #2d5a87 100%);
    padding: 25px;
    border-radius: 12px;
}

.fun-fact h4 {
    color: var(--accent);
    margin-bottom: 10px;
}

/* Property Cards */
.property-card {
    background: var(--bg-card);
    padding: 25px;
    border-radius: 12px;
    margin-bottom: 20px;
    border-left: 4px solid var(--accent);
}

.property-card h4 {
    color: var(--accent);
    margin-bottom: 15px;
}

.property-content {
    padding-left: 15px;
}

.property-example {
    background: var(--bg-light);
    padding: 15px;
    border-radius: 8px;
    margin: 15px 0;
}

.property-conclusion {
    color: var(--success);
    font-weight: bold;
    margin-top: 15px;
}

/* Trick Cards */
.trick-card {
    background: var(--bg-card);
    padding: 25px;
    border-radius: 12px;
    margin-bottom: 20px;
}

.trick-card h4 {
    color: var(--accent);
    margin-bottom: 15px;
}

.trick-steps {
    margin: 20px 0;
}

.trick-step {
    display: flex;
    gap: 15px;
    padding: 15px 0;
    border-bottom: 1px solid var(--bg-light);
}

.trick-step:last-child {
    border-bottom: none;
}

.trick-example {
    background: var(--bg-light);
    padding: 20px;
    border-radius: 8px;
    margin-top: 15px;
}

.trick-card.olympiad-problem {
    background: var(--gradient-special);
}

/* Special Practice */
.start-special-practice {
    background: var(--gradient-special);
    border: none;
    color: white;
    padding: 20px 50px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 1.2rem;
    transition: transform 0.3s;
}

.start-special-practice:hover {
    transform: scale(1.05);
}

/* Special 11 Screen */
.eleven-screen {
    background: linear-gradient(180deg, var(--bg-dark) 0%, #1a2e1a 100%);
}

.menu-card.eleven {
    background: linear-gradient(135deg, #059669 0%, #10b981 100%);
}

.menu-card.eleven:hover {
    box-shadow: 0 10px 30px rgba(16, 185, 129, 0.4);
}

.eleven-screen .special-tab:hover,
.eleven-screen .special-tab.active {
    background: linear-gradient(135deg, #059669 0%, #10b981 100%);
}

.eleven-reveal .number-display {
    background: linear-gradient(135deg, #059669 0%, #10b981 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.rule-highlight {
    background: linear-gradient(135deg, #059669 0%, #10b981 100%);
    padding: 20px;
    border-radius: 12px;
    margin: 20px 0;
    text-align: center;
    font-size: 1.1rem;
}

.rule-formula {
    background: var(--bg-light);
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    font-family: 'Courier New', monospace;
    font-size: 1.2rem;
    margin-top: 15px;
}

.result-no {
    background: linear-gradient(135deg, #dc2626 0%, #ef4444 100%) !important;
}

.highlight-example {
    border-left: 4px solid var(--success);
}

.final-verified {
    border-left: 4px solid var(--primary);
}

.verified-list p {
    padding: 8px 0;
    border-bottom: 1px solid var(--bg-light);
}

.verified-list p:last-child {
    border-bottom: none;
}

/* Full Divisibility Table */
.divisibility-master-table {
    overflow-x: auto;
    margin: 20px 0;
}

.full-divisibility-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border-radius: 12px;
    overflow: hidden;
}

.full-divisibility-table th,
.full-divisibility-table td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid var(--bg-light);
}

.full-divisibility-table th {
    background: var(--bg-light);
    color: var(--accent);
    font-weight: bold;
}

.full-divisibility-table tr:hover {
    background: var(--bg-light);
}

.full-divisibility-table .highlight-row {
    background: rgba(99, 102, 241, 0.1);
}

.full-divisibility-table .eleven-row {
    background: rgba(16, 185, 129, 0.2);
}

.full-divisibility-table td:first-child {
    font-size: 1.3rem;
    color: var(--primary);
}

/* Memory Tips Box */
.memory-tips {
    background: linear-gradient(135deg, #1e3a5f 0%, #2d5a87 100%);
    margin-top: 30px;
}

/* Game Link Section */
.game-link-section {
    background: var(--bg-card);
    padding: 30px;
    border-radius: 12px;
    text-align: center;
    margin-top: 30px;
    border: 2px dashed var(--primary);
}

.game-link-section h4 {
    color: var(--accent);
    margin-bottom: 15px;
}

.game-link-btn {
    display: inline-block;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
    text-decoration: none;
    padding: 15px 40px;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: bold;
    margin-top: 15px;
    transition: all 0.3s;
}

.game-link-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 10px 30px rgba(99, 102, 241, 0.4);
}

/* Eleven Practice Button */
.eleven-start {
    background: linear-gradient(135deg, #059669 0%, #10b981 100%);
}

.eleven-start:hover {
    transform: scale(1.05);
}

/* Responsive Design */
@media (max-width: 768px) {
    .title {
        font-size: 2rem;
    }

    .menu-grid {
        grid-template-columns: 1fr;
    }

    .answer-section {
        grid-template-columns: 1fr;
    }

    .number-display {
        font-size: 3rem;
    }

    .factors-display {
        font-size: 1.5rem;
    }

    .lesson-tabs {
        flex-direction: column;
    }

    .challenge-select {
        flex-direction: column;
        align-items: center;
    }

    .difficulty-btn {
        width: 100%;
        max-width: 300px;
    }
}
