/* Math 24 - 速算24点 */
* { margin: 0; padding: 0; box-sizing: border-box; }

.m24-fullscreen {
    width: 100vw;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, #EEF2FF, #E0E7FF);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    overflow-x: hidden;
}

/* Header */
.m24-header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: linear-gradient(135deg, #6366F1, #8B5CF6);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 100;
    min-height: 52px;
}

.back-btn-wrap { position: relative; flex-shrink: 0; }

.back-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    color: #fff;
    text-decoration: none;
    font-size: 14px;
    padding: 4px 0;
}

.back-overlay {
    display: none;
    position: absolute;
    top: -8px; left: -8px; right: -8px; bottom: -8px;
    cursor: pointer;
    z-index: 1;
}

.back-overlay.active { display: block; }

.m24-header .title {
    flex: 1;
    text-align: center;
    font-size: 17px;
    font-weight: 600;
}

.header-actions {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.points-badge {
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(255,255,255,0.2);
    padding: 4px 10px;
    border-radius: 14px;
    font-size: 13px;
    color: #FFD700;
    font-weight: 600;
    cursor: pointer;
}

.points-badge i { font-size: 12px; }
.points-badge.pulse { animation: badgePulse 0.5s ease; }
.points-badge.pulse-big { animation: badgePulseBig 0.6s ease; }

@keyframes badgePulse {
    0% { transform: scale(1); }
    40% { transform: scale(1.25); background: rgba(255,215,0,0.5); }
    100% { transform: scale(1); }
}

@keyframes badgePulseBig {
    0% { transform: scale(1); }
    30% { transform: scale(1.4); background: rgba(255,100,0,0.6); }
    100% { transform: scale(1); }
}

/* Main */
.m24-main {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px 16px;
    animation: fadeIn 0.3s ease;
}

.screen.hidden { display: none; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== Menu Screen ===== */
.menu-title {
    text-align: center;
    font-size: 28px;
    font-weight: 800;
    color: #4338CA;
    margin-bottom: 4px;
}

.menu-desc {
    text-align: center;
    font-size: 14px;
    color: #7C3AED;
    margin-bottom: 24px;
}

.diff-group {
    max-width: 360px;
    margin: 0 auto 20px;
    width: 100%;
}

.diff-label {
    font-size: 13px;
    color: #6B7280;
    text-align: center;
    margin-bottom: 10px;
}

.diff-btns {
    display: flex;
    gap: 10px;
}

.diff-btn {
    flex: 1;
    padding: 14px 8px;
    background: #fff;
    border: 2px solid #E0E7FF;
    border-radius: 14px;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
}

.diff-btn:active { transform: scale(0.96); }

.diff-btn .diff-name {
    display: block;
    font-size: 16px;
    font-weight: 700;
    color: #4338CA;
}

.diff-btn .diff-range {
    display: block;
    font-size: 12px;
    color: #9CA3AF;
    margin-top: 2px;
}

.diff-btn.active {
    border-color: #6366F1;
    background: #EEF2FF;
    box-shadow: 0 2px 12px rgba(99, 102, 241, 0.2);
}

.start-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 0 auto 24px;
    padding: 14px 48px;
    background: linear-gradient(135deg, #6366F1, #8B5CF6);
    border: none;
    border-radius: 16px;
    color: #fff;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.3);
    transition: all 0.2s;
}

.start-btn:active { transform: scale(0.96); }

.menu-stats {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin-bottom: 20px;
}

.stat-item { text-align: center; }

.stat-value {
    font-size: 24px;
    font-weight: 800;
    color: #6366F1;
}

.stat-label {
    font-size: 12px;
    color: #9CA3AF;
    margin-top: 2px;
}

.lottery-entry-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 0 auto;
    padding: 12px 28px;
    background: linear-gradient(135deg, #F59E0B, #D97706);
    border: none;
    border-radius: 24px;
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(245, 158, 11, 0.3);
}

.lottery-entry-btn:active { transform: scale(0.96); }

/* ===== Game Screen ===== */
.game-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding: 0 4px;
}

.game-timer {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 16px;
    font-weight: 700;
    color: #6366F1;
}

.game-timer.urgent { color: #EF4444; animation: timerUrgent 0.5s ease infinite alternate; }

@keyframes timerUrgent {
    from { opacity: 1; }
    to { opacity: 0.5; }
}

.game-round {
    font-size: 15px;
    font-weight: 600;
    color: #4338CA;
}

.streak-badge {
    display: inline-block;
}

.streak-badge span {
    display: inline-block;
    background: linear-gradient(135deg, #FF6B35, #F7931E);
    color: #fff;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 700;
    animation: streakPop 0.4s ease;
}

.streak-badge.hidden { display: none; }
.streak-badge.fire span { background: linear-gradient(135deg, #FF4136, #FF6B35); }

@keyframes streakPop {
    0% { transform: scale(0.5); opacity: 0; }
    60% { transform: scale(1.15); }
    100% { transform: scale(1); opacity: 1; }
}

/* Number Cards */
.num-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    max-width: 300px;
    margin: 0 auto 12px;
    width: 100%;
}

.num-card {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border-radius: 18px;
    font-size: 42px;
    font-weight: 800;
    color: #1E1B4B;
    cursor: pointer;
    border: 3px solid #E0E7FF;
    box-shadow: 0 3px 10px rgba(99, 102, 241, 0.08);
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    position: relative;
}

.num-card:active:not(.inactive):not(.selected) {
    transform: scale(0.95);
}

.num-card.selected {
    border-color: #F59E0B;
    background: #FEF3C7;
    box-shadow: 0 4px 20px rgba(245, 158, 11, 0.35);
    transform: scale(1.04);
}

.num-card.inactive {
    opacity: 0;
    transform: scale(0.3);
    pointer-events: none;
    transition: all 0.4s ease;
}

.num-card.correct {
    border-color: #10B981;
    background: #D1FAE5;
    animation: cardCorrect 0.5s ease;
}

.num-card.wrong {
    border-color: #EF4444;
    background: #FEE2E2;
    animation: tileShake 0.4s ease;
}

.num-card.merge-in {
    animation: mergeIn 0.4s ease;
}

.num-card.fraction {
    font-size: 28px;
}

.num-card.small-num {
    font-size: 22px;
}

@keyframes cardCorrect {
    0% { transform: scale(1); }
    40% { transform: scale(1.12); box-shadow: 0 0 24px rgba(16, 185, 129, 0.5); }
    100% { transform: scale(1); }
}

@keyframes mergeIn {
    0% { transform: scale(0.8); opacity: 0.5; }
    50% { transform: scale(1.08); }
    100% { transform: scale(1); }
}

@keyframes tileShake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-5px); }
    40% { transform: translateX(5px); }
    60% { transform: translateX(-3px); }
    80% { transform: translateX(3px); }
}

/* Expression Steps */
.expr-steps {
    max-width: 300px;
    margin: 0 auto 6px;
    width: 100%;
    min-height: 20px;
}

.expr-step {
    font-size: 14px;
    color: #6B7280;
    text-align: center;
    padding: 2px 0;
    animation: fadeIn 0.3s ease;
}

.expr-step strong { color: #6366F1; }

/* Guide Text */
.guide-text {
    text-align: center;
    font-size: 13px;
    color: #9CA3AF;
    margin-bottom: 12px;
    min-height: 20px;
    transition: all 0.2s;
}

.guide-text.highlight {
    color: #6366F1;
    font-weight: 600;
}

.guide-text.success {
    color: #10B981;
    font-weight: 700;
    font-size: 16px;
}

.guide-text.error {
    color: #EF4444;
    font-weight: 600;
}

/* Operator Bar */
.op-bar {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-bottom: 16px;
}

.op-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 3px solid #C7D2FE;
    background: #fff;
    font-size: 24px;
    font-weight: 700;
    color: #6366F1;
    cursor: pointer;
    transition: all 0.15s;
    -webkit-tap-highlight-color: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
}

.op-btn:active { transform: scale(0.92); }

.op-btn.selected {
    background: linear-gradient(135deg, #6366F1, #8B5CF6);
    border-color: #6366F1;
    color: #fff;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.35);
    transform: scale(1.08);
}

.op-btn.disabled {
    opacity: 0.3;
    pointer-events: none;
}

/* Game Actions */
.game-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}

.game-action-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 600;
    background: #fff;
    border: 2px solid #C7D2FE;
    border-radius: 12px;
    color: #6366F1;
    cursor: pointer;
    transition: all 0.2s;
}

.game-action-btn:active { transform: scale(0.95); }

.game-action-btn.disabled {
    opacity: 0.35;
    pointer-events: none;
}

/* Points Popup */
.points-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 28px;
    font-weight: 800;
    color: #F59E0B;
    text-shadow: 0 2px 8px rgba(0,0,0,0.15);
    pointer-events: none;
    z-index: 200;
}

.points-popup.hidden { display: none; }

.points-popup.show {
    display: block;
    animation: pointsFly 0.8s ease-out forwards;
}

@keyframes pointsFly {
    0% { opacity: 1; transform: translate(-50%, -50%) scale(0.5); }
    30% { opacity: 1; transform: translate(-50%, -70%) scale(1.2); }
    100% { opacity: 0; transform: translate(-50%, -120%) scale(1); }
}

/* Success Flash */
.result-flash {
    position: fixed;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 48px;
    font-weight: 800;
    color: #10B981;
    text-shadow: 0 2px 12px rgba(16, 185, 129, 0.3);
    pointer-events: none;
    z-index: 200;
    animation: resultFlash 1s ease-out forwards;
}

@keyframes resultFlash {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
    20% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
    60% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -60%) scale(1); }
}

/* Solution Display */
.solution-display {
    text-align: center;
    margin: 8px auto;
    padding: 10px 16px;
    background: #FEF3C7;
    border-radius: 12px;
    max-width: 300px;
    animation: fadeIn 0.3s ease;
}

.solution-display .sol-title {
    font-size: 12px;
    color: #D97706;
    margin-bottom: 4px;
}

.solution-display .sol-step {
    font-size: 14px;
    color: #92400E;
    font-weight: 600;
}

/* ===== Summary Screen ===== */
.complete-card {
    background: #fff;
    border-radius: 20px;
    padding: 32px 24px;
    text-align: center;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.1);
    max-width: 360px;
    margin: auto;
    width: 100%;
    animation: completeIn 0.5s ease;
}

@keyframes completeIn {
    from { opacity: 0; transform: scale(0.9) translateY(20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.complete-icon { font-size: 48px; margin-bottom: 12px; }

.complete-title {
    font-size: 22px;
    font-weight: 700;
    color: #1E1B4B;
    margin-bottom: 12px;
}

.complete-stars {
    font-size: 36px;
    margin-bottom: 16px;
    letter-spacing: 8px;
    color: #F59E0B;
}

.complete-stars .star-empty { color: #E5E7EB; }

.complete-stats {
    font-size: 14px;
    color: #6B7280;
    line-height: 1.8;
    margin-bottom: 20px;
}

.complete-stats strong { color: #F59E0B; }

.complete-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.action-btn {
    padding: 14px 24px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 12px;
    border: 2px solid #C7D2FE;
    background: #fff;
    color: #6366F1;
    cursor: pointer;
    transition: all 0.2s;
}

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

.action-btn.primary {
    background: linear-gradient(135deg, #6366F1, #8B5CF6);
    border-color: transparent;
    color: #fff;
}

/* ===== Lottery ===== */
.lottery-card {
    background: #fff;
    border-radius: 20px;
    padding: 32px 24px;
    text-align: center;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.1);
    max-width: 360px;
    margin: auto;
    width: 100%;
    animation: completeIn 0.5s ease;
}

.lottery-title { font-size: 24px; font-weight: 700; color: #F59E0B; margin-bottom: 8px; }
.lottery-cost { font-size: 14px; color: #9CA3AF; margin-bottom: 4px; }
.lottery-cost strong { color: #F59E0B; }
.lottery-balance { font-size: 14px; color: #9CA3AF; margin-bottom: 20px; }
.lottery-balance strong { color: #F59E0B; font-size: 18px; }

.lottery-box {
    width: 120px; height: 120px;
    margin: 0 auto 16px;
    display: flex; align-items: center; justify-content: center;
}

.lottery-gift { font-size: 72px; line-height: 1; transition: transform 0.3s; }
.lottery-gift.spinning { animation: giftSpin 1.2s cubic-bezier(0.4, 0, 0.2, 1); }
.lottery-gift.opened { animation: giftOpen 0.5s ease forwards; }

@keyframes giftSpin {
    0% { transform: scale(1) rotate(0deg); }
    20% { transform: scale(1.1) rotate(-10deg); }
    40% { transform: scale(1.15) rotate(10deg); }
    60% { transform: scale(1.2) rotate(-8deg); }
    80% { transform: scale(1.25) rotate(6deg); }
    100% { transform: scale(1.3) rotate(0deg); }
}

@keyframes giftOpen {
    0% { transform: scale(1.3); }
    50% { transform: scale(1.5); }
    100% { transform: scale(1.1); }
}

.lottery-result { min-height: 56px; margin-bottom: 16px; opacity: 0; transition: opacity 0.3s; }
.lottery-result.show { opacity: 1; }
.lottery-result .prize-name { font-size: 22px; font-weight: 700; color: #1E1B4B; margin-bottom: 4px; }
.lottery-result .prize-desc { font-size: 14px; color: #9CA3AF; }
.lottery-draw-btn { margin-bottom: 10px; width: 100%; }
.lottery-draw-btn:disabled { opacity: 0.4; cursor: default; }

/* Hint Glow on cards */
.num-card.hint-glow {
    animation: hintGlow 1.5s ease;
    border-color: #8B5CF6;
    box-shadow: 0 0 16px rgba(139, 92, 246, 0.5);
}

@keyframes hintGlow {
    0%, 100% { box-shadow: 0 0 0 rgba(139, 92, 246, 0); border-color: #E0E7FF; }
    30%, 70% { box-shadow: 0 0 20px rgba(139, 92, 246, 0.6); border-color: #8B5CF6; }
}

/* Responsive */
@media (max-width: 360px) {
    .num-card { font-size: 36px; border-radius: 14px; }
    .num-cards { gap: 10px; }
    .op-btn { width: 48px; height: 48px; font-size: 20px; }
    .op-bar { gap: 10px; }
    .game-action-btn { padding: 7px 10px; font-size: 12px; }
}

@media (min-width: 500px) {
    .m24-main { max-width: 480px; margin: 0 auto; width: 100%; }
}
