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

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

/* Header */
.fp-header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: linear-gradient(135deg, #DC2626, #F97316);
    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; }

.fp-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: fpBadgePulse 0.5s ease; }
.points-badge.pulse-big { animation: fpBadgePulseBig 0.6s ease; }

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

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

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

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

.screen.hidden { display: none; }

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

/* ===== Menu Screen ===== */
.menu-icon {
    text-align: center;
    font-size: 56px;
    margin-bottom: 4px;
    line-height: 1.2;
}

.menu-title {
    text-align: center;
    font-size: 28px;
    font-weight: 800;
    color: #DC2626;
    margin-bottom: 4px;
}

.menu-desc {
    text-align: center;
    font-size: 14px;
    color: #EA580C;
    margin-bottom: 20px;
}

.opt-group {
    max-width: 420px;
    margin: 0 auto 16px;
    width: 100%;
}

.opt-label {
    font-size: 13px;
    color: #9CA3AF;
    text-align: center;
    margin-bottom: 8px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Mode buttons */
.mode-btns {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mode-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: #fff;
    border: 2px solid #FED7AA;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    color: #C2410C;
    cursor: pointer;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.mode-btn i { font-size: 18px; color: #F97316; }
.mode-btn:active { transform: scale(0.97); }

.mode-btn.active {
    border-color: #F97316;
    background: #FFF7ED;
    box-shadow: 0 2px 8px rgba(249, 115, 22, 0.2);
}

/* Difficulty buttons */
.diff-btns {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.diff-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 10px 8px;
    background: #fff;
    border: 2px solid #FED7AA;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
    color: #C2410C;
    cursor: pointer;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.diff-btn .diff-icon { font-size: 16px; line-height: 1; }
.diff-btn small { font-size: 10px; color: #9CA3AF; font-weight: 400; }
.diff-btn:active { transform: scale(0.96); }

.diff-btn.active {
    border-color: #F97316;
    background: #FFF7ED;
    box-shadow: 0 2px 8px rgba(249, 115, 22, 0.2);
}

.start-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 16px auto 20px;
    padding: 14px 48px;
    background: linear-gradient(135deg, #DC2626, #F97316);
    border: none;
    border-radius: 16px;
    color: #fff;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(220, 38, 38, 0.3);
}

.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: #DC2626;
}

.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: 4px;
}

.game-progress-info {
    font-size: 14px;
    font-weight: 600;
    color: #C2410C;
}

.game-score {
    font-size: 14px;
    font-weight: 600;
    color: #16A34A;
}

.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: fpStreakPop 0.4s ease;
}

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

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

/* Progress Bar */
.game-progress-bar {
    height: 4px;
    background: #FED7AA;
    border-radius: 2px;
    margin-bottom: 8px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #DC2626, #F97316);
    border-radius: 2px;
    transition: width 0.3s ease;
    width: 0;
}

/* Question */
.question-area {
    text-align: center;
    margin-bottom: 12px;
}

.question-text {
    font-size: 18px;
    color: #1C1917;
    font-weight: 700;
    line-height: 1.4;
}

.question-text .fraction-highlight {
    color: #DC2626;
    font-size: 22px;
}

/* Pizza Container */
.pizza-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    min-height: 0;
    padding: 8px 0;
    -webkit-user-select: none;
    user-select: none;
}

.pizza-wrap {
    position: relative;
    width: 100%;
    max-width: 280px;
}

.pizza-wrap.half-size {
    max-width: 170px;
}

.pizza-wrap svg {
    width: 100%;
    height: auto;
    display: block;
    filter: drop-shadow(0 4px 12px rgba(0,0,0,0.12));
}

.pizza-label {
    text-align: center;
    font-size: 20px;
    font-weight: 800;
    color: #C2410C;
    margin-top: 6px;
}

/* Slice interactions */
.pizza-slice {
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: filter 0.15s;
}

.pizza-slice:hover {
    filter: brightness(1.08);
}

.pizza-slice.selected {
    filter: brightness(1.0);
}

/* Answer Area */
.answer-area {
    padding: 8px 0 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.answer-btn {
    padding: 12px 24px;
    min-width: 80px;
    background: #fff;
    border: 2px solid #FED7AA;
    border-radius: 14px;
    font-size: 20px;
    font-weight: 700;
    color: #C2410C;
    cursor: pointer;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
}

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

.answer-btn.correct {
    border-color: #16A34A;
    background: #DCFCE7;
    color: #16A34A;
    animation: fpBtnCorrect 0.4s ease;
}

.answer-btn.wrong {
    border-color: #DC2626;
    background: #FEE2E2;
    color: #DC2626;
    animation: fpBtnShake 0.4s ease;
}

.answer-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

@keyframes fpBtnCorrect {
    0% { transform: scale(1); }
    40% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

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

/* Done button for slice mode */
.done-btn {
    padding: 12px 40px;
    background: linear-gradient(135deg, #16A34A, #22C55E);
    border: none;
    border-radius: 14px;
    font-size: 17px;
    font-weight: 700;
    color: #fff;
    cursor: pointer;
    box-shadow: 0 3px 12px rgba(22, 163, 74, 0.3);
    -webkit-tap-highlight-color: transparent;
}

.done-btn:active { transform: scale(0.95); }
.done-btn:disabled { opacity: 0.4; cursor: default; }

/* Flash text */
.fp-flash {
    position: fixed;
    top: 45%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 22px;
    font-weight: 800;
    pointer-events: none;
    z-index: 200;
    animation: fpFlash 0.8s ease-out forwards;
    white-space: nowrap;
    padding: 8px 20px;
    border-radius: 12px;
}

.fp-flash.correct {
    color: #16A34A;
    background: rgba(255,255,255,0.95);
}

.fp-flash.wrong {
    color: #DC2626;
    background: rgba(255,255,255,0.95);
}

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

/* 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: fpPointsFly 0.8s ease-out forwards;
}

@keyframes fpPointsFly {
    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); }
}

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

@keyframes fpCompleteIn {
    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: #1C1917;
    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 #FED7AA;
    background: #fff;
    color: #C2410C;
    cursor: pointer;
    transition: all 0.2s;
}

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

.action-btn.primary {
    background: linear-gradient(135deg, #DC2626, #F97316);
    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(220, 38, 38, 0.1);
    max-width: 360px;
    margin: auto;
    width: 100%;
    animation: fpCompleteIn 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: fpGiftSpin 1.2s cubic-bezier(0.4, 0, 0.2, 1); }
.lottery-gift.opened { animation: fpGiftOpen 0.5s ease forwards; }

@keyframes fpGiftSpin {
    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 fpGiftOpen {
    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: #1C1917; 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; }

/* Responsive */
@media (max-width: 360px) {
    .question-text { font-size: 16px; }
    .answer-btn { padding: 10px 18px; font-size: 17px; }
    .pizza-wrap.half-size { max-width: 140px; }
    .menu-title { font-size: 24px; }
}

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