* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --primary: #58cc02;
    --primary-dark: #58a700;
    --primary-light: #e8f5ee;
    --bg: #f7f7f7;
    --text: #3c3c3c;
    --text-muted: #999999;
    --border: #e5e5e5;
    --purple: #a855f7;
    --purple-light: rgba(168, 85, 247, 0.1);
    --error: #ff4d4d;
}

body {
    min-height: 100vh;
    background: var(--bg);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", sans-serif;
    color: var(--text);
    padding-bottom: 30px;
    user-select: none;
}

.header {
    background: white;
    padding: 16px 20px;
    border-bottom: 2px solid var(--primary);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 500px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.back-link {
    color: var(--primary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
}

.header h1 {
    font-size: 14px; font-weight: 500;
    color: var(--primary);
    font-weight: 700;
}

.sound-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: background 0.2s;
    color: var(--primary);
}

.sound-btn:hover {
    background: rgba(88, 204, 2, 0.1);
}

.container {
    max-width: 500px;
    margin: 0 auto;
    padding: 20px;
}

.stats-bar {
    background: white;
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-around;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.stat-item {
    text-align: center;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.game-container {
    background: white;
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 20px;
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.empty-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 12px;
}

.empty-desc {
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.8;
    margin-bottom: 24px;
}

.tutorial-steps {
    text-align: left;
    background: var(--primary-light);
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 24px;
    width: 100%;
}

.tutorial-steps h3 {
    font-size: 14px;
    color: var(--primary);
    margin-bottom: 12px;
}

.tutorial-steps li {
    font-size: 14px;
    color: var(--text);
    margin-bottom: 8px;
    line-height: 1.5;
}

.btn {
    padding: 14px 32px;
    border-radius: 12px;
    border: none;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-block;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: white;
    color: var(--text);
    border: 2px solid var(--border);
}

.mode-buttons {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    width: 100%;
}

.mode-btn {
    flex: 1;
    padding: 16px 12px;
    border: 2px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-weight: 600;
    font-size: 15px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.mode-btn:active {
    transform: scale(0.98);
}

.mode-btn.normal-mode {
    border-color: var(--primary);
    background: var(--primary-light);
}

.mode-btn.master-mode {
    border-color: var(--purple);
    background: var(--purple-light);
}

/* 攻略按钮 */
.strategy-btn {
    width: 100%;
    padding: 14px 20px;
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border: 2px solid #38bdf8;
    color: #0369a1;
    font-weight: 600;
    font-size: 15px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.strategy-btn:hover {
    background: linear-gradient(135deg, #e0f2fe 0%, #bae6fd 100%);
}

.strategy-btn:active {
    transform: scale(0.98);
}

/* 攻略页面 - 全屏文章 */
.strategy-page {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 100px;
    background: var(--bg);
    z-index: 2000;
    overflow-y: auto;
}

.strategy-header {
    position: sticky;
    top: 0;
    background: white;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 2px solid var(--primary);
    z-index: 10;
}

.strategy-header h1 {
    font-size: 14px; font-weight: 500;
    font-weight: 700;
    color: var(--text);
}

.strategy-back {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 8px;
    transition: background 0.2s;
}

.strategy-back:hover {
    background: var(--primary-light);
}

.strategy-article {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px 16px 40px;
}

.strategy-intro {
    background: var(--primary-light);
    padding: 16px;
    border-radius: 12px;
    margin-bottom: 24px;
    border-left: 4px solid var(--primary);
}

.strategy-intro p {
    font-size: 15px;
    line-height: 1.7;
    color: var(--text);
    margin-bottom: 8px;
}

.strategy-intro p:last-child {
    margin-bottom: 100px;
    font-size: 14px;
    color: #666;
}

.strategy-method {
    margin-bottom: 32px;
}

.strategy-method h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--border);
}

.strategy-method h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    margin: 16px 0 10px;
}

.method-desc {
    font-size: 15px;
    color: #555;
    line-height: 1.6;
    margin-bottom: 16px;
}

.key-formulas {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.key-formula {
    background: white;
    border: 2px solid var(--primary);
    border-radius: 12px;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.formula-big {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary-dark);
    flex-shrink: 0;
}

.formula-tip {
    font-size: 14px;
    color: #666;
    text-align: right;
}

.formula-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

@media (max-width: 400px) {
    .formula-grid {
        grid-template-columns: 1fr;
    }
}

.formula-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
}

.formula-pattern {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary-dark);
    margin-bottom: 4px;
    font-family: monospace;
}

.formula-example {
    font-size: 13px;
    color: #666;
}

.example-box {
    background: white;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
}

.example-box.hard {
    /* 统一样式，不使用紫色区分 */
    border-color: var(--border);
    background: white;
}

.example-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 10px;
}

.example-solution p {
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 6px;
}

.example-step {
    font-size: 13px;
    color: #666;
    padding-left: 16px;
}

/* 分数样式 - 横线形式 */
.frac {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    vertical-align: middle;
    margin: 0 3px;
}

.frac-num {
    font-size: 12px;
    line-height: 1.2;
    padding-bottom: 1px;
    border-bottom: 1.5px solid var(--text);
    min-width: 16px;
    text-align: center;
    font-weight: 600;
    color: var(--text);
}

.frac-den {
    font-size: 12px;
    line-height: 1.2;
    padding-top: 1px;
    min-width: 16px;
    text-align: center;
    font-weight: 600;
    color: var(--text);
}

.example-step .frac-num,
.example-step .frac-den {
    font-size: 11px;
    color: #666;
}

.strategy-list {
    font-size: 15px;
    line-height: 2;
    padding-left: 24px;
    margin-bottom: 16px;
}

.tip-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

@media (max-width: 400px) {
    .tip-grid {
        grid-template-columns: 1fr;
    }
}

.tip-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
}

.tip-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

.tip-content p {
    font-size: 13px;
    color: #666;
    line-height: 1.5;
}

.tip-example {
    color: var(--primary-dark) !important;
    font-weight: 600;
    margin-top: 4px;
}

.warning-box {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 8px;
    padding: 12px 16px;
    margin: 16px 0;
    font-size: 14px;
    color: #856404;
}

.master-section h2 {
    color: var(--purple);
    border-color: rgba(168, 85, 247, 0.3);
}

.strategy-summary {
    background: white;
    border: 2px solid var(--primary);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 24px;
}

.strategy-summary h2 {
    font-size: 14px; font-weight: 500;
    margin-bottom: 16px;
    border: none;
    padding: 0;
}

.flow-chart {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.flow-step {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg);
    padding: 12px 16px;
    border-radius: 10px;
    width: 100%;
}

.flow-step.master {
    background: var(--purple-light);
    border: 1px solid var(--purple);
}

.flow-num {
    width: 32px;
    height: 32px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    flex-shrink: 0;
}

.flow-step.master .flow-num {
    background: var(--purple);
}

.flow-text {
    font-size: 14px;
    line-height: 1.4;
}

.flow-arrow {
    font-size: 20px;
    color: var(--primary);
}

.strategy-practice {
    text-align: center;
    padding-top: 16px;
    border-top: 2px solid var(--border);
}

.strategy-practice h2 {
    font-size: 14px; font-weight: 500;
    margin-bottom: 16px;
    border: none;
}

.practice-list {
    text-align: left;
    font-size: 15px;
    line-height: 2;
    padding-left: 24px;
    margin-bottom: 20px;
}

.btn-large {
    padding: 16px 32px;
    font-size: 16px;
}

.expression-display {
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 16px 24px;
    margin-bottom: 20px;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    flex-wrap: wrap;
}

.expression-item {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
    padding: 4px 6px;
    border-radius: 6px;
}

.expression-item.number {
    background: var(--primary-light);
    color: var(--primary);
}

.expression-item.operator {
    background: var(--purple-light);
    color: var(--purple);
}

.expression-item.equals {
    padding: 4px 4px;
}

.expression-item.result {
    background: #fef3c7;
    color: #d97706;
}

.expression-placeholder {
    color: var(--text-muted);
    font-size: 1.125rem;
}

.cards-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 24px;
    max-width: 320px;
    margin-left: auto;
    margin-right: auto;
}

.card {
    aspect-ratio: 1;
    background: var(--primary-light);
    border: 3px solid var(--primary);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary-dark);
    cursor: pointer;
    transition: all 0.2s;
}

.card:active {
    transform: scale(0.95);
}

.card.selected {
    background: var(--primary);
    color: white;
}

.card.used {
    opacity: 0.3;
    cursor: not-allowed;
}

.operators-container {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 24px;
}

.operator-btn {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    border: 2px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: 1.5rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.operator-btn:active {
    transform: scale(0.95);
}

.operator-btn.selected {
    border-color: var(--purple);
    background: var(--purple-light);
    color: var(--purple);
}

.controls {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.control-btn {
    padding: 12px 24px;
    border-radius: 12px;
    border: 2px solid var(--border);
    background: white;
    color: var(--text);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.control-btn:active {
    transform: scale(0.95);
}

.result-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 100px;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.result-modal.show {
    display: flex;
}

.result-content {
    background: white;
    border-radius: 20px;
    padding: 32px;
    text-align: center;
    max-width: 320px;
    width: 90%;
}

.result-icon {
    font-size: 56px;
    margin-bottom: 12px;
}

.result-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 12px;
}

.result-time {
    font-size: 36px;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 8px;
    border: 2px solid var(--primary);
    background: var(--primary-light);
    padding: 8px 20px;
    border-radius: 12px;
    display: inline-block;
}

.result-best {
    display: inline-block;
    background: #ffc800;
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 20px;
}

.result-expression {
    color: var(--text-muted);
    margin-bottom: 20px;
    font-size: 14px;
}

.result-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.result-buttons .btn {
    padding: 12px 24px;
    font-size: 14px;
}

.hint-panel {
    background: white;
    border: 2px solid #fbbf24;
    border-radius: 12px;
    padding: 16px 24px;
    margin-top: 16px;
    text-align: center;
}

.hint-title {
    color: #fbbf24;
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 14px;
}

.hint-text {
    color: var(--text);
    font-size: 1.25rem;
    font-family: ui-monospace, monospace;
}

.no-solution {
    color: var(--error);
    font-size: 1rem;
    margin-top: 12px;
}

.fraction {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    line-height: 1;
}

.fraction .num {
    font-size: 0.9em;
    border-bottom: 2px solid currentColor;
    padding: 0 2px;
}

.fraction .den {
    font-size: 0.9em;
    padding: 0 2px;
}

@keyframes popIn {
    0% { transform: scale(0); opacity: 0; }
    70% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.shake {
    animation: shake 0.3s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

@media (max-width: 480px) {
    .container { padding: 16px; }
    .stat-value { font-size: 24px; }
    .mode-buttons { flex-direction: column; }
    .cards-container { gap: 12px; max-width: 280px; }
    .card { font-size: 2rem; border-width: 2px; }
    .operator-btn { width: 48px; height: 48px; font-size: 1.25rem; }
    .result-buttons { flex-direction: column; }
    .result-buttons .btn { width: 100%; }
}

@media (max-width: 360px) {
    .cards-container { gap: 8px; max-width: 240px; }
    .card { font-size: 1.75rem; }
    .operator-btn { width: 40px; height: 40px; font-size: 1.1rem; }
}

/* 教程按钮 */
.tutorial-btn {
    background: rgba(251, 191, 36, 0.2);
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: background 0.2s;
    font-size: 14px; font-weight: 500;
}

.tutorial-btn:hover {
    background: rgba(251, 191, 36, 0.3);
}

/* 教程高亮 */
.tutorial-highlight {
    animation: tutorialPulse 1.5s ease-in-out infinite !important;
    box-shadow: 0 0 0 4px #fbbf24 !important;
    position: relative;
}

@keyframes tutorialPulse {
    0%, 100% { box-shadow: 0 0 0 4px #fbbf24; }
    50% { box-shadow: 0 0 20px 8px rgba(251, 191, 36, 0.6); }
}

/* 教程浮层 - 顶部提示框 */
.tutorial-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    z-index: 1000;
    padding: 16px;
}

.tutorial-content {
    background: white;
    border-radius: 16px;
    padding: 16px 20px;
    max-width: 400px;
    width: 100%;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    border: 2px solid #fbbf24;
}

.tutorial-text {
    font-size: 14px; font-weight: 500;
    line-height: 1.8;
    color: var(--text);
    margin-bottom: 24px;
    white-space: pre-line;
}

.tutorial-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.tutorial-buttons .btn {
    padding: 12px 24px;
    font-size: 15px;
}

/* 模式按钮显示教程状态 */
.mode-btn .mode-desc {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* 教程按钮图标 */
.tutorial-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    background: #fbbf24;
    color: white;
    border-radius: 50%;
    font-size: 12px;
    font-weight: bold;
    margin-right: 4px;
}

/* 教程退出提示 */
.tutorial-hint-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 100px;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.tutorial-hint-content {
    background: white;
    border-radius: 20px;
    padding: 32px;
    text-align: center;
    max-width: 300px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

.tutorial-hint-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.tutorial-hint-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 16px;
}

.tutorial-hint-text {
    font-size: 15px;
    color: #666;
    line-height: 1.8;
    margin-bottom: 24px;
}

.tutorial-hint-btn {
    display: inline-flex;
    align-items: center;
    background: rgba(251, 191, 36, 0.2);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 14px;
    color: var(--text);
    margin: 8px 0;
    animation: tutorialPulse 1.5s ease-in-out infinite;
}

/* 攻略按钮 */
.guide-btn {
    background: rgba(59, 130, 246, 0.15);
    border: none;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 8px;
    transition: background 0.2s;
    font-size: 14px;
    font-weight: 500;
    color: #3b82f6;
}

.guide-btn:hover {
    background: rgba(59, 130, 246, 0.25);
}
