/* ⭕ 圈出分組遊戲 - 美食主題 */

:root {
    --primary: #ff6b6b;
    --primary-dark: #ff5252;
    --accent: #ffd93d;
    --accent-orange: #ff9a56;
    --accent-dark: #f5c400;
    --bg-gradient: linear-gradient(135deg, #fff8f0 0%, #ffe5cc 50%, #ffd9b3 100%);
    --card-bg: rgba(255, 255, 255, 0.98);
    --text-dark: #2d3436;
    --text-muted: #636e72;
    --text-light: #ff9a56;
    --success: #51cf66;
    --error: #f44336;
}

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

body {
    font-family: 'Nunito', 'Microsoft JhengHei', sans-serif;
    min-height: 100vh;
    background: var(--bg-gradient);
    overflow-x: hidden;
    touch-action: manipulation;
    position: relative;
}

/* 食物背景裝飾 */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image: 
        radial-gradient(circle at 15% 25%, rgba(255, 154, 86, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 85% 75%, rgba(255, 107, 107, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 50% 60%, rgba(255, 217, 61, 0.12) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

.bg-pattern {
    position: fixed;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}

.circle-deco {
    position: absolute;
    border-radius: 50%;
    opacity: 0.15;
    animation: float 10s ease-in-out infinite;
}

.c1 { width: 200px; height: 200px; background: rgba(255, 154, 86, 0.3); top: 5%; left: -50px; }
.c2 { width: 150px; height: 150px; background: rgba(255, 107, 107, 0.3); top: 50%; right: -30px; animation-delay: 3s; }
.c3 { width: 100px; height: 100px; background: rgba(255, 217, 61, 0.3); bottom: 10%; left: 30%; animation-delay: 5s; }

@keyframes float {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-20px) scale(1.05); }
}

.game-container {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    padding: 15px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.screen {
    display: none;
    width: 100%;
    max-width: 800px;
    animation: fadeIn 0.4s ease-out;
}

.screen.active { display: block; }

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

/* ==================== 登入畫面 ==================== */

.login-card {
    background: var(--card-bg);
    border-radius: 28px;
    padding: 30px;
    box-shadow: 0 15px 50px rgba(255, 107, 107, 0.25);
    border: 3px solid var(--accent);
}

.login-header { 
    text-align: center; 
    margin-bottom: 25px; 
}

.logo-container {
    position: relative;
    display: inline-block;
    margin-bottom: 15px;
}

.title-icon {
    font-size: 80px;
    display: block;
    animation: iconFloat 3s ease-in-out infinite;
    filter: drop-shadow(0 8px 20px rgba(255, 107, 107, 0.4));
    position: relative;
    z-index: 2;
}

.icon-ring {
    position: absolute;
    inset: -15px;
    border: 4px dashed var(--accent);
    border-radius: 50%;
    animation: spinRing 10s linear infinite;
    opacity: 0.7;
}

@keyframes spinRing {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes iconFloat {
    0%, 100% { transform: translateY(0) rotate(-5deg) scale(1); }
    50% { transform: translateY(-15px) rotate(5deg) scale(1.05); }
}

.food-deco {
    position: absolute;
    font-size: 35px;
    opacity: 0.8;
    animation: floatAround 4s ease-in-out infinite;
}

.food-1 {
    top: -15px;
    left: -60px;
    animation-delay: 0s;
}

.food-2 {
    top: -15px;
    right: -60px;
    animation-delay: 1.3s;
}

.food-3 {
    bottom: -25px;
    left: 50%;
    transform: translateX(-50%);
    animation-delay: 2.6s;
}

@keyframes floatAround {
    0%, 100% { transform: translateY(0) translateX(0) rotate(0deg); }
    25% { transform: translateY(-15px) translateX(10px) rotate(10deg); }
    50% { transform: translateY(-5px) translateX(-5px) rotate(-5deg); }
    75% { transform: translateY(-20px) translateX(-10px) rotate(-10deg); }
}

.game-title {
    font-size: 32px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent-orange) 50%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 10px 0 5px;
}

.game-subtitle {
    color: var(--text-muted);
    font-size: 15px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.subtitle-icon {
    font-size: 18px;
    animation: subtitleBounce 1.5s ease-in-out infinite;
}

.subtitle-icon:nth-child(2) {
    animation-delay: 0.3s;
}

@keyframes subtitleBounce {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-5px) scale(1.1); }
}

.mascot-section { text-align: center; margin-bottom: 18px; }

.mascot-preview { font-size: 55px; }

.section-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    margin: 8px 0;
}

.mascot-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
    padding: 10px;
    background: linear-gradient(135deg, #fff8f0 0%, #ffe5cc 100%);
    border-radius: 15px;
    border: 2px solid var(--accent);
}

.mascot-btn {
    font-size: 24px;
    padding: 8px;
    background: white;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
    text-align: center;
}

.mascot-btn:hover { transform: scale(1.1); border-color: var(--primary); }
.mascot-btn.selected { 
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent-orange) 100%); 
    border-color: var(--primary-dark); 
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 18px;
}

.form-field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 5px;
}

.form-field select {
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
    font-family: inherit;
    border: 2px solid var(--accent);
    border-radius: 10px;
    background: white;
    cursor: pointer;
}

.form-field select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(255, 107, 107, 0.2);
}

.start-btn {
    width: 100%;
    padding: 15px;
    font-size: 18px;
    font-weight: 700;
    font-family: inherit;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent-orange) 100%);
    color: white;
    border: 2px solid white;
    border-radius: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.3s;
    box-shadow: 0 8px 25px rgba(255, 107, 107, 0.35);
}

.start-btn:hover { transform: translateY(-3px); box-shadow: 0 12px 35px rgba(255, 107, 107, 0.45); }
.btn-icon { font-size: 22px; }

.login-links {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 18px;
}

.link-item {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    padding: 8px 15px;
    border-radius: 8px;
    transition: all 0.2s;
    border: 2px solid var(--accent);
}

.link-item:hover { background: rgba(255, 107, 107, 0.1); border-color: var(--primary); }

/* ==================== 遊戲畫面 ==================== */

.game-panel {
    background: var(--card-bg);
    border-radius: 28px;
    padding: 20px;
    box-shadow: 0 15px 50px rgba(255, 107, 107, 0.25);
    border: 3px solid var(--accent);
}

.game-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 12px;
    border-bottom: 2px dashed #c8e6c9;
}

.player-badge { display: flex; align-items: center; gap: 8px; }
.player-mascot { font-size: 28px; }
.player-info { font-size: 13px; font-weight: 600; color: var(--text-muted); }

.progress-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: linear-gradient(135deg, #fff8f0 0%, #ffe5cc 100%);
    padding: 6px 18px;
    border-radius: 10px;
    border: 2px solid var(--accent);
}

.progress-label { font-size: 10px; color: var(--text-muted); font-weight: 600; }
.progress-num { font-size: 16px; font-weight: 700; color: var(--primary); }

.score-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, var(--accent) 0%, #ffb84d 100%);
    padding: 8px 18px;
    border-radius: 25px;
    border: 2px solid white;
}

.score-star { font-size: 20px; }
.score-num { font-size: 22px; font-weight: 700; color: var(--text-dark); }

.question-box {
    background: linear-gradient(135deg, #fff8f0 0%, #ffe5cc 100%);
    border-radius: 15px;
    padding: 15px;
    margin-bottom: 15px;
    text-align: center;
    border: 3px solid var(--accent);
}

.question-icon { font-size: 35px; margin-bottom: 5px; }

.question-text {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 5px;
}

.question-text .highlight {
    display: inline-block;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent-orange) 100%);
    color: white;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 20px;
}

.question-hint {
    font-size: 14px;
    color: var(--text-muted);
    font-weight: 600;
}

/* 畫圈區域 */
.drawing-area {
    position: relative;
    width: 100%;
    aspect-ratio: 5/3;
    background: linear-gradient(180deg, #fff8f0 0%, #ffe5cc 60%, #ffd9b3 100%);
    border-radius: 18px;
    margin-bottom: 15px;
    overflow: hidden;
    border: 3px solid var(--accent);
    touch-action: none;
    cursor: crosshair;
}

#drawingCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
}

.foods-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
    pointer-events: none;
}

.food-item {
    position: absolute;
    font-size: 32px;
    transform: translate(-50%, -50%);
    transition: all 0.3s;
    filter: drop-shadow(1px 2px 2px rgba(0,0,0,0.15));
}

.food-item.hidden {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0);
}

/* 已分組顯示 */
.groups-display {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 15px;
    padding: 12px 15px;
    background: linear-gradient(135deg, #fff8f0 0%, #ffe5cc 100%);
    border-radius: 12px;
    flex-wrap: wrap;
    border: 2px solid var(--accent);
}

.groups-label {
    font-size: 14px;
    font-weight: 700;
    color: var(--primary);
}

.groups-boxes {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    flex: 1;
}

.group-box {
    display: flex;
    align-items: center;
    gap: 4px;
    background: white;
    padding: 6px 12px;
    border-radius: 20px;
    border: 2px solid var(--primary);
    animation: groupPop 0.3s ease-out;
}

@keyframes groupPop {
    from { transform: scale(0); }
    to { transform: scale(1); }
}

.group-box .food-icon { font-size: 18px; }
.group-box .count { font-size: 16px; font-weight: 700; color: var(--primary); }

.groups-summary {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
    white-space: nowrap;
}

/* 遊戲按鈕 */
.game-buttons {
    display: flex;
    gap: 12px;
}

.game-btn {
    flex: 1;
    padding: 14px;
    font-size: 16px;
    font-weight: 700;
    font-family: inherit;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
}

.undo-btn {
    background: linear-gradient(135deg, #ffb74d 0%, #ffa726 100%);
    color: white;
    border: 2px solid white;
}

.check-btn {
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent-orange) 100%);
    color: white;
    flex: 2;
    box-shadow: 0 6px 20px rgba(255, 107, 107, 0.35);
    border: 2px solid white;
}

.game-btn:hover { transform: translateY(-2px); }
.game-btn:active { transform: scale(0.98); }

/* ==================== 結果畫面 ==================== */

.result-card {
    background: var(--card-bg);
    border-radius: 28px;
    padding: 30px;
    text-align: center;
    box-shadow: 0 15px 50px rgba(255, 107, 107, 0.25);
    border: 3px solid var(--accent);
}

.result-header { margin-bottom: 18px; }
.trophy-icon { font-size: 65px; }
.result-header h2 { font-size: 28px; color: var(--text-dark); margin-top: 10px; }

.result-player {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 18px;
}

.result-mascot { font-size: 40px; }
.result-name { font-size: 18px; font-weight: 600; color: var(--text-muted); }

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

.stat-box {
    background: linear-gradient(135deg, #f5f5f5 0%, #e0e0e0 100%);
    border-radius: 15px;
    padding: 18px 30px;
}

.stat-icon { font-size: 28px; margin-bottom: 6px; }
.stat-val { font-size: 32px; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 12px; color: #999; font-weight: 600; }

.result-msg {
    background: linear-gradient(135deg, #fff8f0 0%, #ffe5cc 100%);
    padding: 10px 18px;
    border-radius: 10px;
    font-size: 15px;
    color: var(--text-muted);
    margin-bottom: 18px;
    font-weight: 600;
    border: 2px solid var(--accent);
}

.ranking-box {
    background: linear-gradient(135deg, #fff8f0 0%, #ffe5cc 100%);
    border: 3px solid var(--accent);
    border-radius: 15px;
    padding: 15px;
    margin-bottom: 18px;
    text-align: left;
}

.ranking-box h3 { text-align: center; font-size: 16px; color: var(--primary); margin-bottom: 10px; font-weight: 700; }

.ranking-list { max-height: 160px; overflow-y: auto; }

.ranking-loading { text-align: center; color: #f57f17; padding: 15px; }

.ranking-item {
    display: flex;
    align-items: center;
    background: white;
    border-radius: 8px;
    padding: 8px 10px;
    margin-bottom: 5px;
}

.ranking-item.current-user {
    background: linear-gradient(135deg, var(--accent) 0%, #ffb84d 100%);
    border: 2px solid var(--primary);
}

.ranking-rank { font-size: 13px; font-weight: 700; min-width: 30px; color: #999; }
.ranking-rank.rank-1::before { content: '🥇 '; }
.ranking-rank.rank-2::before { content: '🥈 '; }
.ranking-rank.rank-3::before { content: '🥉 '; }

.ranking-mascot { font-size: 22px; margin: 0 8px; }
.ranking-info { flex: 1; }
.ranking-student { font-size: 12px; font-weight: 600; color: #333; }
.ranking-details { font-size: 10px; color: #999; }
.ranking-score { font-size: 18px; font-weight: 700; color: var(--primary); }

.result-buttons { display: flex; gap: 10px; flex-wrap: wrap; }

.result-btn {
    flex: 1;
    min-width: 90px;
    padding: 12px 15px;
    font-size: 14px;
    font-weight: 700;
    font-family: inherit;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.result-btn.primary { 
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent-orange) 100%); 
    color: white; 
    border: 2px solid white;
}
.result-btn.secondary { 
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent-orange) 100%); 
    color: white; 
    border: 2px solid white;
}
.result-btn.tertiary { 
    background: linear-gradient(135deg, #bdbdbd 0%, #9e9e9e 100%); 
    color: white; 
    border: 2px solid white;
}
.result-btn:hover { transform: translateY(-2px); }

/* ==================== 反饋彈窗 ==================== */

.feedback-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.feedback-overlay.show { display: flex; }

.feedback-modal {
    background: white;
    border-radius: 20px;
    padding: 30px 45px;
    text-align: center;
    animation: popIn 0.3s ease-out;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

@keyframes popIn {
    0% { transform: scale(0); }
    100% { transform: scale(1); }
}

.feedback-icon { font-size: 55px; margin-bottom: 10px; }
.feedback-text { font-size: 18px; font-weight: 700; color: #333; }

.feedback-modal.correct { border: 4px solid var(--success); }
.feedback-modal.correct .feedback-text { color: var(--success); }
.feedback-modal.incorrect { border: 4px solid var(--error); }
.feedback-modal.incorrect .feedback-text { color: var(--error); }

/* ==================== 響應式 ==================== */

/* iPad Air 橫向適配 (1024px - 1200px, 高度≤900px) */
@media (min-width: 1024px) and (max-width: 1200px) and (max-height: 900px) {
    .game-container { padding: 10px; }
    .game-panel { padding: 15px; }
    .game-topbar { margin-bottom: 8px; gap: 10px; }
    .stat-box { padding: 6px 12px; }
    .stat-val { font-size: 18px; }
    .question-box { padding: 10px; margin-bottom: 10px; }
    .question-text { font-size: 15px; }
    .question-text .highlight { font-size: 17px; padding: 2px 8px; }
    .drawing-area { aspect-ratio: 5/2; margin-bottom: 10px; }
    .flower { font-size: 28px; }
    .groups-display { padding: 8px 12px; gap: 8px; margin-bottom: 10px; }
    .group-box { padding: 4px 8px; }
    .group-box .food-icon { font-size: 16px; }
    .group-box .count { font-size: 13px; }
    .game-buttons { gap: 10px; }
    .game-btn { padding: 10px; font-size: 14px; }
}

/* iPad Mini 橫向適配 (768px - 1024px, 高度≤800px) */
@media (min-width: 768px) and (max-width: 1024px) and (max-height: 800px) {
    .game-container { padding: 8px; }
    .game-panel { padding: 12px; }
    .game-topbar { margin-bottom: 6px; gap: 8px; }
    .stat-box { padding: 5px 10px; }
    .stat-val { font-size: 16px; }
    .question-box { padding: 8px; margin-bottom: 8px; }
    .question-text { font-size: 14px; }
    .question-text .highlight { font-size: 16px; padding: 2px 6px; }
    .drawing-area { aspect-ratio: 5/2; margin-bottom: 8px; }
    .flower { font-size: 24px; }
    .groups-display { padding: 6px 10px; gap: 6px; margin-bottom: 8px; }
    .group-box { padding: 3px 6px; }
    .group-box .food-icon { font-size: 14px; }
    .group-box .count { font-size: 12px; }
    .game-buttons { gap: 8px; }
    .game-btn { padding: 8px; font-size: 13px; }
}

/* iPad 直向適配 (768px - 1024px, 高度>800px) */
@media (min-width: 768px) and (max-width: 1024px) and (min-height: 801px) {
    .game-container { padding: 15px; }
    .game-panel { padding: 18px; }
    .question-box { padding: 12px; margin-bottom: 12px; }
    .drawing-area { aspect-ratio: 4/3; margin-bottom: 12px; }
    .flower { font-size: 30px; }
    .groups-display { padding: 10px 14px; gap: 10px; margin-bottom: 12px; }
    .game-btn { padding: 12px; font-size: 15px; }
}

@media (max-width: 768px) {
    .game-container { padding: 10px; align-items: flex-start; padding-top: 15px; }
    .login-card, .game-panel, .result-card { padding: 18px 15px; border-radius: 20px; }
    .title-icon { font-size: 60px; }
    .food-deco {
        font-size: 28px;
    }
    .food-1, .food-2 {
        display: none;
    }
    .game-title { font-size: 26px; }
    .mascot-preview { font-size: 45px; }
    .mascot-grid { grid-template-columns: repeat(4, 1fr); gap: 6px; }
    .mascot-btn { font-size: 22px; padding: 7px; }
    .form-row { grid-template-columns: 1fr; gap: 10px; }
    .game-topbar { flex-wrap: wrap; gap: 8px; justify-content: center; }
    .question-text { font-size: 16px; }
    .question-text .highlight { font-size: 18px; }
    .drawing-area { aspect-ratio: 4/3; }
    .flower { font-size: 26px; }
    .groups-display { padding: 10px 12px; gap: 8px; }
    .group-box { padding: 5px 10px; }
    .group-box .food-icon { font-size: 16px; }
    .group-box .count { font-size: 14px; }
    .game-btn { padding: 12px; font-size: 15px; }
    .stats-row { gap: 12px; }
    .stat-box { padding: 15px 22px; }
    .stat-val { font-size: 28px; }
    .result-buttons { flex-direction: column; }
}

@media (max-width: 400px) {
    .mascot-grid { grid-template-columns: repeat(3, 1fr); }
    .flower { font-size: 22px; }
    .game-buttons { flex-direction: column; }
}

/* ==================== Magic UI 增強動畫效果 ==================== */

/* 粒子背景 */
#particles-bg {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
}

/* 浮動美食裝飾 */
.floating-foods {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.float-food {
    position: absolute;
    font-size: 30px;
    opacity: 0.4;
    animation: floatUpDown 8s ease-in-out infinite;
}

.f1 { top: 10%; left: 5%; animation-delay: 0s; }
.f2 { top: 25%; right: 8%; animation-delay: 1.5s; }
.f3 { top: 50%; left: 3%; animation-delay: 3s; }
.f4 { top: 70%; right: 5%; animation-delay: 4.5s; }
.f5 { bottom: 15%; left: 10%; animation-delay: 2s; }
.f6 { bottom: 30%; right: 12%; animation-delay: 5s; }

@keyframes floatUpDown {
    0%, 100% { transform: translateY(0) rotate(0deg); opacity: 0.4; }
    25% { transform: translateY(-30px) rotate(10deg); opacity: 0.6; }
    50% { transform: translateY(-15px) rotate(-5deg); opacity: 0.5; }
    75% { transform: translateY(-40px) rotate(8deg); opacity: 0.7; }
}

/* Sparkle 閃爍效果 */
.sparkle-container {
    position: relative;
}

.sparkle {
    position: absolute;
    font-size: 20px;
    animation: sparkleFloat 2s ease-in-out infinite;
    opacity: 0;
}

.s1 { top: -20px; left: -30px; animation-delay: 0s; }
.s2 { top: -10px; right: -35px; animation-delay: 0.7s; }
.s3 { bottom: -15px; left: 50%; animation-delay: 1.4s; }

@keyframes sparkleFloat {
    0%, 100% { opacity: 0; transform: scale(0.5) translateY(0); }
    50% { opacity: 1; transform: scale(1.2) translateY(-10px); }
}

/* Pulse Glow 脈動光暈 */
.pulse-glow {
    animation: iconFloat 3s ease-in-out infinite, pulseGlow 2s ease-in-out infinite alternate;
}

@keyframes pulseGlow {
    0% { filter: drop-shadow(0 0 10px rgba(255, 107, 107, 0.5)); }
    100% { filter: drop-shadow(0 0 25px rgba(255, 154, 86, 0.8)) drop-shadow(0 0 40px rgba(255, 217, 61, 0.4)); }
}

/* Rainbow Ring 彩虹環 */
.rainbow-ring {
    background: linear-gradient(90deg, #ff6b6b, #ff9a56, #ffd93d, #4ecdc4, #45b7d1, #ff6b6b);
    background-size: 200% 100%;
    -webkit-mask: 
        radial-gradient(farthest-side, transparent calc(100% - 4px), #fff calc(100% - 4px));
    mask: 
        radial-gradient(farthest-side, transparent calc(100% - 4px), #fff calc(100% - 4px));
    animation: spinRing 8s linear infinite, rainbowShift 3s linear infinite;
}

@keyframes rainbowShift {
    0% { background-position: 0% 50%; }
    100% { background-position: 200% 50%; }
}

/* Bounce Float 彈跳浮動 */
.bounce-float {
    animation: bounceFloat 3s ease-in-out infinite;
}

.food-1.bounce-float { animation-delay: 0s; }
.food-2.bounce-float { animation-delay: 0.5s; }
.food-3.bounce-float { animation-delay: 1s; }

@keyframes bounceFloat {
    0%, 100% { transform: translateY(0) scale(1); }
    25% { transform: translateY(-20px) scale(1.1); }
    50% { transform: translateY(-10px) scale(1.05); }
    75% { transform: translateY(-25px) scale(1.08); }
}

/* Aurora Text 極光文字 */
.aurora-text {
    background: linear-gradient(135deg, #ff6b6b, #ff9a56, #ffd93d, #ff6b6b);
    background-size: 300% 300%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: auroraShift 4s ease-in-out infinite;
}

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

/* Wiggle 搖擺效果 */
.wiggle {
    display: inline-block;
    animation: wiggle 1s ease-in-out infinite;
}

.subtitle-icon.wiggle:nth-child(2) { animation-delay: 0.5s; }

@keyframes wiggle {
    0%, 100% { transform: rotate(-10deg); }
    50% { transform: rotate(10deg); }
}

/* Shimmer Button 增強 */
.shimmer-btn {
    position: relative;
    overflow: hidden;
}

.shimmer-btn .btn-shine {
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.5), transparent);
    animation: shimmerSlide 2s ease-in-out infinite;
}

@keyframes shimmerSlide {
    0% { left: -100%; }
    50%, 100% { left: 100%; }
}

/* Rocket Launch 火箭發射 */
.rocket-launch {
    display: inline-block;
    animation: rocketLaunch 2s ease-in-out infinite;
}

@keyframes rocketLaunch {
    0%, 100% { transform: translateY(0) rotate(-45deg); }
    50% { transform: translateY(-8px) rotate(-45deg) scale(1.2); }
}

/* Glow Pulse 光暈脈動 */
.glow-pulse {
    animation: glowPulse 2s ease-in-out infinite;
}

@keyframes glowPulse {
    0%, 100% { box-shadow: 0 5px 20px rgba(255, 217, 61, 0.4); }
    50% { box-shadow: 0 8px 35px rgba(255, 217, 61, 0.7), 0 0 20px rgba(255, 154, 86, 0.3); }
}

/* Spin Slow 慢速旋轉 */
.spin-slow {
    animation: spinSlow 4s linear infinite;
}

@keyframes spinSlow {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Number Ticker 數字跳動 */
.number-ticker {
    display: inline-block;
    transition: transform 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.number-ticker.tick {
    animation: tickerBounce 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes tickerBounce {
    0% { transform: scale(1); }
    30% { transform: scale(1.4) rotate(5deg); }
    60% { transform: scale(0.9) rotate(-3deg); }
    100% { transform: scale(1) rotate(0deg); }
}

/* Celebration 慶祝效果 */
.celebration {
    position: relative;
}

.confetti-burst {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.bounce-in {
    animation: bounceIn 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes bounceIn {
    0% { transform: scale(0) rotate(-180deg); opacity: 0; }
    60% { transform: scale(1.3) rotate(10deg); opacity: 1; }
    80% { transform: scale(0.9) rotate(-5deg); }
    100% { transform: scale(1) rotate(0deg); }
}

.result-title-glow {
    animation: titleGlow 2s ease-in-out infinite alternate;
}

@keyframes titleGlow {
    0% { text-shadow: 0 0 10px rgba(255, 107, 107, 0.5); }
    100% { text-shadow: 0 0 25px rgba(255, 107, 107, 0.8), 0 0 50px rgba(255, 154, 86, 0.4); }
}

.stars-rain {
    position: absolute;
    width: 100%;
    display: flex;
    justify-content: space-around;
    top: -20px;
}

.stars-rain span {
    animation: starsRain 2s ease-in-out infinite;
    opacity: 0;
}

.stars-rain span:nth-child(1) { animation-delay: 0s; }
.stars-rain span:nth-child(2) { animation-delay: 0.3s; }
.stars-rain span:nth-child(3) { animation-delay: 0.6s; }
.stars-rain span:nth-child(4) { animation-delay: 0.9s; }
.stars-rain span:nth-child(5) { animation-delay: 1.2s; }

@keyframes starsRain {
    0% { transform: translateY(-20px) rotate(0deg); opacity: 0; }
    50% { opacity: 1; }
    100% { transform: translateY(30px) rotate(180deg); opacity: 0; }
}

/* Shimmer Button 效果 */
.start-btn {
    position: relative;
    overflow: hidden;
}

.start-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    transition: left 0.5s;
}

.start-btn:hover::before {
    left: 100%;
}

/* Border Beam 效果 */
.login-card {
    position: relative;
}

.login-card::after {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 28px;
    padding: 3px;
    background: linear-gradient(135deg, #ff6b6b, #ff9a56, #ffd93d, #ff6b6b);
    background-size: 200% 200%;
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    animation: borderBeam 3s linear infinite;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: -1;
}

.login-card:hover::after {
    opacity: 1;
}

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

/* Animated Shiny Text 效果 */
.game-title {
    position: relative;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.8), transparent);
    background-size: 200% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    animation: shinyText 3s linear infinite;
}

@keyframes shinyText {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* Ripple Button 效果 */
.start-btn, .game-btn {
    position: relative;
    overflow: hidden;
}

.start-btn .ripple,
.game-btn .ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.6);
    transform: scale(0);
    animation: rippleEffect 0.6s ease-out;
    pointer-events: none;
}

@keyframes rippleEffect {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

/* Number Ticker 動畫 */
#scoreNum {
    transition: transform 0.3s ease-out;
}

#scoreNum.tick {
    animation: numberTick 0.5s ease-out;
}

@keyframes numberTick {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.3) rotate(5deg); }
}

/* Confetti 容器 */
#confetti-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
}

/* Magic Card 懸停效果 */
.mascot-btn {
    position: relative;
    transition: all 0.3s ease;
}

.mascot-btn::before {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 10px;
    background: linear-gradient(135deg, #ff6b6b, #ff9a56, #ffd93d);
    opacity: 0;
    transition: opacity 0.3s;
    z-index: -1;
}

.mascot-btn:hover::before {
    opacity: 0.5;
    filter: blur(8px);
}

/* 閃亮文字效果增強 */
.highlight {
    position: relative;
    animation: highlightShine 2s ease-in-out infinite;
}

@keyframes highlightShine {
    0%, 100% { filter: brightness(1) drop-shadow(0 0 5px rgba(255, 107, 107, 0.5)); }
    50% { filter: brightness(1.2) drop-shadow(0 0 15px rgba(255, 154, 86, 0.8)); }
}

/* 問題框 Border Beam 效果 */
.question-box {
    position: relative;
}

.question-box::before {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 20px;
    padding: 2px;
    background: linear-gradient(135deg, #ffd93d, #ff9a56, #ff6b6b, #ffd93d);
    background-size: 200% 200%;
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    animation: questionBeam 4s linear infinite;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: -1;
}

.question-box:hover::before {
    opacity: 0.4;
}

@keyframes questionBeam {
    0% { background-position: 0% 50%; }
    100% { background-position: 200% 50%; }
}
