/* 🧺 拖拉分組遊戲 - 美食主題 */

:root {
    --primary: #ff6b6b;
    --primary-dark: #ff5252;
    --primary-light: #ff8787;
    --accent: #ffd93d;
    --accent-orange: #ff9a56;
    --accent-dark: #f5c400;
    --bg-top: #fff8f0;
    --bg-mid: #ffe5cc;
    --bg-bottom: #ffd9b3;
    --wood: #8D6E63;
    --wood-dark: #6D4C41;
    --text-dark: #2d3436;
    --text-light: #fff;
    --text-muted: #636e72;
    --shadow: rgba(255, 107, 107, 0.2);
    --basket-bg: #fff8f0;
    --basket-border: #ffd93d;
}

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

body {
    font-family: 'Nunito', 'Microsoft JhengHei', sans-serif;
    min-height: 100vh;
    background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg-mid) 50%, var(--bg-bottom) 100%);
    overflow-x: hidden;
    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-decorations {
    position: fixed;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 0;
}

.cloud {
    position: absolute;
    font-size: 50px;
    opacity: 0.3;
    animation: floatCloud 20s linear infinite;
}

.cloud-1 { top: 5%; left: -10%; animation-duration: 25s; content: '🍎'; }
.cloud-2 { top: 12%; left: 30%; animation-duration: 30s; animation-delay: -10s; content: '🍊'; }
.cloud-3 { top: 8%; left: 60%; animation-duration: 22s; animation-delay: -5s; font-size: 45px; content: '🍓'; }

@keyframes floatCloud {
    from { transform: translateX(0) rotate(0deg); }
    to { transform: translateX(120vw) rotate(360deg); }
}

.sun {
    position: absolute;
    top: 3%;
    right: 8%;
    font-size: 70px;
    animation: sunPulse 4s ease-in-out infinite;
    content: '🍊';
}

@keyframes sunPulse {
    0%, 100% { transform: scale(1) rotate(0deg); filter: drop-shadow(0 0 20px rgba(255, 154, 86, 0.5)); }
    50% { transform: scale(1.1) rotate(10deg); filter: drop-shadow(0 0 40px rgba(255, 154, 86, 0.7)); }
}

.grass {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 120px;
    background: linear-gradient(180deg, transparent 0%, rgba(255, 217, 61, 0.2) 100%);
}

/* 遊戲容器 */
.game-container {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* 畫面切換 */
.screen {
    display: none;
    width: 100%;
    max-width: 1100px;
    animation: fadeIn 0.5s 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);
    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%; }
}

.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: 20px;
    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: 25px;
    flex-wrap: wrap;
}

.link-btn {
    display: inline-block;
    padding: 12px 25px;
    font-size: 16px;
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
    background: rgba(255, 107, 107, 0.1);
    border-radius: 10px;
    transition: all 0.3s;
    border: 2px solid var(--accent);
}

.link-btn:hover {
    background: rgba(255, 107, 107, 0.2);
    transform: translateY(-2px);
    border-color: var(--primary);
}

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

#gameScreen {
    background: rgba(255, 255, 255, 0.98);
    border-radius: 32px;
    padding: 30px;
    box-shadow: 0 20px 60px var(--shadow);
    border: 3px solid var(--accent);
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 3px dashed #E0E0E0;
}

.player-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.player-mascot {
    font-size: 36px;
}

.player-name {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-dark);
}

.progress-badge {
    background: linear-gradient(135deg, #fff8f0 0%, #ffe5cc 100%);
    padding: 10px 25px;
    border-radius: 50px;
    border: 2px solid var(--accent);
}

.progress-text {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
}

.score-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    background: linear-gradient(135deg, var(--accent) 0%, #ffb84d 100%);
    padding: 12px 30px;
    border-radius: 50px;
    box-shadow: 0 5px 20px rgba(255, 217, 61, 0.4);
    border: 2px solid white;
}

.score-icon {
    font-size: 28px;
}

.score-value {
    font-size: 32px;
    font-weight: 800;
    color: var(--text-dark);
}

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

.question-fruit {
    font-size: 40px;
    margin-bottom: 8px;
    animation: wobble 2s ease-in-out infinite;
}

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

.question-text {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-dark);
}

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

/* 遊戲區域 */
.game-area {
    margin-bottom: 25px;
}

.zone-label {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 15px;
    padding-left: 10px;
}

/* 水果區 */
.fruits-zone {
    margin-bottom: 25px;
}

.fruits-pool {
    background: linear-gradient(180deg, #fff8f0 0%, #ffe5cc 100%);
    border: 3px dashed var(--accent);
    border-radius: 20px;
    padding: 18px;
    min-height: 100px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    align-items: center;
    transition: all 0.3s;
}

.fruits-pool:empty::after {
    content: '所有水果都分配完了！';
    color: #999;
    font-size: 18px;
}

.fruit-item {
    font-size: 45px;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    transition: all 0.2s;
    user-select: none;
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    filter: drop-shadow(2px 4px 3px rgba(0,0,0,0.2));
}

.fruit-item:hover {
    transform: scale(1.15);
    filter: drop-shadow(3px 6px 5px rgba(0,0,0,0.25));
}

.fruit-item:active {
    cursor: grabbing;
}

.fruit-item.dragging {
    opacity: 0.5;
    transform: scale(1.2);
}

/* 籃子區 */
.baskets-zone {
    margin-bottom: 20px;
    width: 100%;
}

.baskets-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.basket {
    background: linear-gradient(180deg, var(--basket-bg) 0%, #ffe5cc 100%);
    border: 4px solid var(--accent);
    border-radius: 20px;
    border-bottom-left-radius: 40px;
    border-bottom-right-radius: 40px;
    padding: 10px 8px 8px;
    min-width: 100px;
    height: 115px;
    transition: all 0.3s;
    position: relative;
    box-shadow: 0 8px 20px rgba(255, 154, 86, 0.25);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.basket::after {
    content: '';
    position: absolute;
    top: -15px;
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    height: 20px;
    background: linear-gradient(180deg, var(--accent-orange) 0%, var(--primary) 100%);
    border-radius: 10px;
    pointer-events: none;
}

.basket.drag-over {
    background: linear-gradient(180deg, #ffe5cc 0%, #ffd9b3 100%);
    border-color: var(--primary);
    transform: scale(1.05);
    box-shadow: 0 15px 30px rgba(255, 107, 107, 0.3);
}

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

.basket-count {
    text-align: center;
    font-size: 14px;
    color: #999;
    margin-top: 5px;
}

.basket-items {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-content: center;
    flex: 1;
    padding: 3px;
    gap: 2px;
}

/* 籃子內的水果縮小 */
.basket-items .fruit-item {
    font-size: 18px;
    width: auto;
    height: auto;
    margin: 0;
    padding: 0;
    filter: none;
    line-height: 1;
    cursor: grab;
    touch-action: none;
}

/* 控制按鈕 */
.game-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

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

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

.reset-btn:hover {
    box-shadow: 0 6px 20px rgba(255, 183, 77, 0.4);
}

.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;
}

.check-btn:hover {
    box-shadow: 0 8px 25px rgba(255, 107, 107, 0.5);
}

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

.result-content {
    background: rgba(255, 255, 255, 0.98);
    border-radius: 32px;
    padding: 40px;
    text-align: center;
    box-shadow: 0 20px 60px var(--shadow);
    border: 3px solid var(--accent);
}

.result-trophy {
    font-size: 80px;
    margin-bottom: 15px;
    animation: trophyBounce 1s ease-out;
}

@keyframes trophyBounce {
    0% { transform: scale(0) rotate(-180deg); }
    60% { transform: scale(1.2) rotate(10deg); }
    100% { transform: scale(1) rotate(0); }
}

.result-title {
    font-size: 36px;
    font-weight: 800;
    color: var(--text-dark);
    margin-bottom: 20px;
}

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

.result-mascot {
    font-size: 50px;
}

.result-name {
    font-size: 24px;
    font-weight: 700;
    color: #666;
}

.result-stats {
    display: flex;
    justify-content: center;
    gap: 25px;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.stat-card {
    background: linear-gradient(135deg, #F5F5F5 0%, #E0E0E0 100%);
    border-radius: 20px;
    padding: 25px 35px;
    min-width: 130px;
}

.stat-icon {
    font-size: 36px;
    margin-bottom: 10px;
}

.stat-value {
    font-size: 36px;
    font-weight: 800;
    color: var(--text-dark);
}

.stat-label {
    font-size: 14px;
    color: #999;
    font-weight: 600;
}

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

/* 排行榜 */
.ranking-section {
    background: linear-gradient(135deg, #fff8f0 0%, #ffe5cc 100%);
    border-radius: 20px;
    padding: 20px;
    margin-bottom: 25px;
    border: 3px solid var(--accent);
}

.ranking-title {
    font-size: 20px;
    color: var(--primary);
    margin-bottom: 15px;
    font-weight: 700;
}

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

.ranking-loading {
    text-align: center;
    color: #999;
    padding: 20px;
}

.ranking-item {
    display: flex;
    align-items: center;
    background: white;
    border-radius: 12px;
    padding: 12px 15px;
    margin-bottom: 8px;
    transition: all 0.3s;
}

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

.ranking-rank {
    font-size: 18px;
    font-weight: 800;
    min-width: 40px;
    text-align: center;
    color: #666;
}

.ranking-rank.rank-1 { color: #FFD700; }
.ranking-rank.rank-2 { color: #C0C0C0; }
.ranking-rank.rank-3 { color: #CD7F32; }

.ranking-mascot {
    font-size: 32px;
    margin: 0 12px;
}

.ranking-info {
    flex: 1;
    text-align: left;
}

.ranking-student {
    font-size: 16px;
    font-weight: 700;
    color: #333;
}

.ranking-details {
    font-size: 12px;
    color: #999;
}

.ranking-score {
    font-size: 24px;
    font-weight: 800;
    color: var(--primary);
}

/* 結果按鈕 */
.result-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

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

.primary-btn:hover {
    box-shadow: 0 8px 25px rgba(255, 107, 107, 0.5);
}

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

.secondary-btn:hover {
    box-shadow: 0 6px 20px rgba(255, 183, 77, 0.4);
}

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

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

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

.feedback-popup {
    background: white;
    border-radius: 25px;
    padding: 40px 60px;
    text-align: center;
    animation: popIn 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.3);
}

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

.feedback-icon {
    font-size: 80px;
    margin-bottom: 15px;
}

.feedback-text {
    font-size: 24px;
    font-weight: 800;
    color: #333;
}

.feedback-popup.correct {
    border: 5px solid var(--primary);
}

.feedback-popup.correct .feedback-text {
    color: var(--primary-dark);
}

.feedback-popup.incorrect {
    border: 5px solid #F44336;
}

.feedback-popup.incorrect .feedback-text {
    color: #C62828;
}

/* ==================== 大平板適配 (1024px - 1200px) ==================== */

@media (min-width: 1024px) and (max-width: 1200px) and (max-height: 900px) {
    .game-container {
        padding: 15px;
    }

    #gameScreen {
        padding: 20px;
    }

    .game-header {
        margin-bottom: 10px;
    }

    .question-box {
        padding: 10px;
        margin-bottom: 10px;
    }

    .question-fruit {
        font-size: 28px;
        margin-bottom: 4px;
    }

    .question-text {
        font-size: 16px;
    }

    .question-text .highlight {
        font-size: 18px;
        padding: 2px 8px;
    }

    .fruits-pool {
        min-height: 60px;
        padding: 8px;
        gap: 5px;
        margin-bottom: 12px;
    }

    .fruit-item {
        font-size: 30px;
        width: 40px;
        height: 40px;
    }

    .baskets-row {
        gap: 8px;
        margin-bottom: 12px;
    }

    .basket {
        min-width: 85px;
        height: 95px;
        padding: 8px 5px 6px;
    }

    .basket-items .fruit-item {
        font-size: 14px;
    }

    .game-actions {
        margin-top: 12px;
        gap: 15px;
    }

    .action-btn {
        padding: 12px 24px;
        font-size: 16px;
    }
}

/* ==================== iPad Mini 橫向適配 (768px - 1024px, 高度≤800px) ==================== */

@media (min-width: 768px) and (max-width: 1024px) and (max-height: 800px) {
    .game-container {
        padding: 10px;
    }

    #gameScreen {
        padding: 15px;
    }

    .game-header {
        margin-bottom: 8px;
        gap: 12px;
    }

    .stat-card {
        padding: 8px 12px;
    }

    .stat-value {
        font-size: 18px;
    }

    .question-box {
        padding: 8px;
        margin-bottom: 8px;
    }

    .question-fruit {
        font-size: 26px;
        margin-bottom: 3px;
    }

    .question-text {
        font-size: 15px;
    }

    .question-text .highlight {
        font-size: 17px;
        padding: 2px 8px;
    }

    .fruits-pool {
        min-height: 50px;
        padding: 6px;
        gap: 4px;
        margin-bottom: 10px;
    }

    .fruit-item {
        font-size: 28px;
        width: 36px;
        height: 36px;
    }

    .baskets-row {
        gap: 6px;
        margin-bottom: 10px;
    }

    .basket {
        min-width: 75px;
        height: 85px;
        padding: 6px 4px 5px;
    }

    .basket-items .fruit-item {
        font-size: 12px;
    }

    .game-actions {
        margin-top: 10px;
        gap: 12px;
    }

    .action-btn {
        padding: 10px 20px;
        font-size: 15px;
    }
}

/* ==================== iPad 適配 (768px - 1024px, 高度>800px) ==================== */

@media (min-width: 768px) and (max-width: 1024px) and (min-height: 801px) {
    .game-container {
        padding: 25px;
    }

    .login-card,
    #gameScreen,
    .result-content {
        padding: 35px;
        max-width: 800px;
    }

    .game-title {
        font-size: 38px;
    }

    .mascot-grid {
        grid-template-columns: repeat(6, 1fr);
        gap: 12px;
    }

    .mascot-btn {
        font-size: 34px;
        padding: 14px;
    }

    .start-btn {
        padding: 22px 50px;
        font-size: 22px;
    }

    .game-header {
        gap: 20px;
    }

    .question-box {
        padding: 12px;
        margin-bottom: 12px;
    }

    .question-fruit {
        font-size: 32px;
        margin-bottom: 5px;
    }

    .question-text {
        font-size: 18px;
    }

    .question-text .highlight {
        font-size: 20px;
        padding: 3px 10px;
    }

    .baskets-row {
        gap: 10px;
    }

    .basket {
        min-width: 95px;
        height: 110px;
        padding: 10px 6px 8px;
    }

    .basket-items {
        gap: 1px;
        padding: 2px;
    }

    .basket-items .fruit-item {
        font-size: 14px;
    }

    .fruit-item {
        font-size: 38px;
        width: 50px;
        height: 50px;
    }

    .fruits-pool {
        min-height: 70px;
        padding: 10px;
        gap: 6px;
    }

    .fruit-item {
        font-size: 32px;
        width: 42px;
        height: 42px;
    }

    .action-btn {
        padding: 16px 30px;
        font-size: 18px;
    }

    .stat-card {
        padding: 28px 40px;
    }

    .stat-value {
        font-size: 38px;
    }
}

/* ==================== 手機適配 (< 768px) ==================== */

@media (max-width: 767px) {
    .game-container {
        padding: 12px;
        align-items: flex-start;
        padding-top: 20px;
    }

    .login-card,
    #gameScreen,
    .result-content {
        padding: 25px 18px;
        border-radius: 20px;
    }

    .title-icon {
        font-size: 60px;
    }

    .food-deco {
        font-size: 30px;
    }

    .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;
    }

    .start-btn {
        padding: 18px 35px;
        font-size: 20px;
        border-radius: 16px;
        width: 100%;
    }

    .btn-icon {
        font-size: 24px;
    }

    .link-btn {
        padding: 10px 20px;
        font-size: 14px;
    }

    /* 遊戲畫面 */
    .game-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        margin-bottom: 15px;
        padding-bottom: 15px;
    }

    .player-info {
        justify-content: center;
    }

    .player-mascot {
        font-size: 32px;
    }

    .player-name {
        font-size: 16px;
    }

    .progress-badge,
    .score-badge {
        justify-content: center;
    }

    .progress-badge {
        padding: 8px 20px;
    }

    .progress-text {
        font-size: 16px;
    }

    .score-badge {
        padding: 10px 25px;
    }

    .score-icon {
        font-size: 24px;
    }

    .score-value {
        font-size: 28px;
    }

    .question-box {
        padding: 18px;
        margin-bottom: 18px;
    }

    .question-fruit {
        font-size: 40px;
    }

    .question-text {
        font-size: 18px;
    }

    .question-text .highlight {
        font-size: 20px;
        padding: 4px 10px;
    }

    .zone-label {
        font-size: 16px;
        margin-bottom: 10px;
    }

    .fruits-pool {
        padding: 18px;
        min-height: 100px;
        gap: 10px;
        border-radius: 15px;
    }

    .fruit-item {
        font-size: 36px;
        width: 48px;
        height: 48px;
    }

    .baskets-zone {
        margin-bottom: 15px;
    }

    .baskets-row {
        gap: 10px;
    }

    .basket {
        min-width: 75px;
        height: 95px;
        padding: 8px 5px 6px;
        border-radius: 15px;
        border-bottom-left-radius: 30px;
        border-bottom-right-radius: 30px;
    }

    .basket-items {
        gap: 2px;
        padding: 2px;
        min-height: 60px;
    }

    .basket-items .fruit-item {
        font-size: 14px;
    }

    .basket::after {
        top: -12px;
        height: 16px;
    }

    .basket-label {
        font-size: 14px;
    }

    .basket-count {
        font-size: 12px;
    }

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

    .action-btn {
        width: 100%;
        justify-content: center;
        padding: 16px 30px;
        font-size: 17px;
        border-radius: 12px;
    }

    /* 結果畫面 */
    .result-trophy {
        font-size: 60px;
    }

    .result-title {
        font-size: 28px;
        margin-bottom: 15px;
    }

    .result-player {
        gap: 10px;
        margin-bottom: 20px;
    }

    .result-mascot {
        font-size: 40px;
    }

    .result-name {
        font-size: 20px;
    }

    .result-stats {
        gap: 12px;
        margin-bottom: 20px;
    }

    .stat-card {
        padding: 18px 22px;
        min-width: 90px;
        border-radius: 15px;
    }

    .stat-icon {
        font-size: 30px;
        margin-bottom: 8px;
    }

    .stat-value {
        font-size: 30px;
    }

    .stat-label {
        font-size: 12px;
    }

    .result-message {
        font-size: 16px;
        padding: 12px;
        margin-bottom: 18px;
    }

    .ranking-section {
        padding: 15px;
        margin-bottom: 18px;
    }

    .ranking-title {
        font-size: 18px;
        margin-bottom: 12px;
    }

    .ranking-item {
        padding: 10px 12px;
    }

    .ranking-rank {
        font-size: 15px;
        min-width: 35px;
    }

    .ranking-mascot {
        font-size: 26px;
        margin: 0 8px;
    }

    .ranking-student {
        font-size: 14px;
    }

    .ranking-details {
        font-size: 11px;
    }

    .ranking-score {
        font-size: 20px;
    }

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

    .result-actions .action-btn {
        font-size: 16px;
    }

    /* 反饋彈窗 */
    .feedback-popup {
        padding: 30px 40px;
        border-radius: 20px;
        margin: 0 15px;
    }

    .feedback-icon {
        font-size: 60px;
    }

    .feedback-text {
        font-size: 20px;
    }
}

/* ==================== 小手機適配 (< 400px) ==================== */

@media (max-width: 400px) {
    .game-container {
        padding: 10px;
    }

    .login-card,
    #gameScreen,
    .result-content {
        padding: 20px 15px;
    }

    .game-title {
        font-size: 24px;
    }

    .mascot-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .mascot-btn {
        font-size: 26px;
        padding: 8px;
    }

    .baskets-row {
        gap: 5px;
    }

    .basket {
        min-width: 65px;
        height: 85px;
        padding: 6px 4px 5px;
    }

    .basket-items {
        gap: 1px;
        padding: 1px;
    }

    .basket-items .fruit-item {
        font-size: 12px;
    }

    .fruit-item {
        font-size: 32px;
        width: 42px;
        height: 42px;
    }

    .stat-card {
        padding: 15px 18px;
        min-width: 80px;
    }

    .stat-value {
        font-size: 26px;
    }
}

/* ==================== 觸控優化 ==================== */

@media (hover: none) and (pointer: coarse) {
    .mascot-btn:hover {
        transform: none;
    }

    .mascot-btn:active {
        transform: scale(1.1);
    }

    .fruit-item:hover {
        transform: none;
    }

    .fruit-item:active {
        transform: scale(1.15);
    }

    .start-btn:hover {
        transform: none;
    }

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

    /* 增大觸控目標 */
    .fruit-item {
        min-width: 50px;
        min-height: 50px;
    }

    .basket {
        min-height: 140px;
    }
}

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

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

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

.float-fruit {
    position: absolute;
    font-size: 35px;
    opacity: 0.35;
    animation: fruitFloat 10s ease-in-out infinite;
    pointer-events: none;
}

.ff1 { top: 8%; left: 5%; animation-delay: 0s; }
.ff2 { top: 20%; right: 6%; animation-delay: 2s; }
.ff3 { top: 45%; left: 3%; animation-delay: 4s; }
.ff4 { top: 65%; right: 4%; animation-delay: 1s; }
.ff5 { bottom: 20%; left: 8%; animation-delay: 3s; }
.ff6 { bottom: 35%; right: 10%; animation-delay: 5s; }

@keyframes fruitFloat {
    0%, 100% { transform: translateY(0) rotate(0deg) scale(1); opacity: 0.35; }
    25% { transform: translateY(-25px) rotate(15deg) scale(1.1); opacity: 0.5; }
    50% { transform: translateY(-10px) rotate(-10deg) scale(1.05); opacity: 0.4; }
    75% { transform: translateY(-35px) rotate(8deg) scale(1.15); opacity: 0.55; }
}

/* Rainbow Sun 彩虹太陽 */
.rainbow-sun {
    animation: sunPulse 4s ease-in-out infinite, rainbowRotate 8s linear infinite;
}

@keyframes rainbowRotate {
    from { filter: hue-rotate(0deg) drop-shadow(0 0 20px rgba(255, 217, 61, 0.6)); }
    to { filter: hue-rotate(360deg) drop-shadow(0 0 20px rgba(255, 217, 61, 0.6)); }
}

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

.sparkle {
    position: absolute;
    font-size: 24px;
    animation: sparkleFloat 2.5s ease-in-out infinite;
    opacity: 0;
    z-index: 10;
    pointer-events: none;
}

.s1 { top: -25px; left: -40px; animation-delay: 0s; }
.s2 { top: -15px; right: -45px; animation-delay: 0.8s; }
.s3 { bottom: -20px; left: 50%; animation-delay: 1.6s; }

@keyframes sparkleFloat {
    0%, 100% { opacity: 0; transform: scale(0.5) translateY(0) rotate(0deg); }
    50% { opacity: 1; transform: scale(1.3) translateY(-15px) rotate(180deg); }
}

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

@keyframes pulseGlow {
    0% { filter: drop-shadow(0 0 15px rgba(255, 107, 107, 0.5)); }
    100% { filter: drop-shadow(0 0 30px rgba(255, 154, 86, 0.8)) drop-shadow(0 0 50px rgba(255, 217, 61, 0.5)); }
}

/* Rainbow Ring 彩虹環 */
.rainbow-ring {
    background: linear-gradient(90deg, #ff6b6b, #ff9a56, #ffd93d, #4ecdc4, #45b7d1, #ff6b6b) !important;
    background-size: 200% 100% !important;
    border: none !important;
    -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 3.5s ease-in-out infinite;
}

.fruit-1.bounce-float { animation-delay: 0s; }
.fruit-2.bounce-float { animation-delay: 0.6s; }
.fruit-3.bounce-float { animation-delay: 1.2s; }

@keyframes bounceFloat {
    0%, 100% { transform: translateY(0) scale(1) rotate(-5deg); }
    25% { transform: translateY(-25px) scale(1.15) rotate(5deg); }
    50% { transform: translateY(-12px) scale(1.08) rotate(-3deg); }
    75% { transform: translateY(-30px) scale(1.1) rotate(8deg); }
}

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

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

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

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

@keyframes wiggle {
    0%, 100% { transform: rotate(-12deg) scale(1); }
    50% { transform: rotate(12deg) scale(1.1); }
}

/* 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.6), transparent);
    animation: shimmerSlide 2.5s ease-in-out infinite;
    pointer-events: none;
}

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

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

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

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

@keyframes glowPulse {
    0%, 100% { box-shadow: 0 5px 20px rgba(255, 217, 61, 0.4); }
    50% { box-shadow: 0 10px 40px rgba(255, 217, 61, 0.8), 0 0 25px rgba(255, 154, 86, 0.4); }
}

/* Spin Slow 慢速旋轉 */
.spin-slow {
    animation: spinSlow 5s 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.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes tickerBounce {
    0% { transform: scale(1); }
    30% { transform: scale(1.5) rotate(8deg); }
    60% { transform: scale(0.85) rotate(-5deg); }
    100% { transform: scale(1) rotate(0deg); }
}

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

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

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

@keyframes bounceIn {
    0% { transform: scale(0) rotate(-180deg); opacity: 0; }
    50% { transform: scale(1.4) rotate(15deg); opacity: 1; }
    70% { transform: scale(0.85) rotate(-8deg); }
    100% { transform: scale(1) rotate(0deg); }
}

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

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

.stars-rain {
    position: absolute;
    width: 100%;
    display: flex;
    justify-content: space-around;
    top: -25px;
    font-size: 20px;
    pointer-events: none;
}

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

.stars-rain span:nth-child(1) { animation-delay: 0s; }
.stars-rain span:nth-child(2) { animation-delay: 0.4s; }
.stars-rain span:nth-child(3) { animation-delay: 0.8s; }
.stars-rain span:nth-child(4) { animation-delay: 1.2s; }
.stars-rain span:nth-child(5) { animation-delay: 1.6s; }

@keyframes starsRain {
    0% { transform: translateY(-25px) rotate(0deg) scale(0.5); opacity: 0; }
    50% { opacity: 1; transform: translateY(5px) rotate(90deg) scale(1.2); }
    100% { transform: translateY(40px) rotate(180deg) scale(0.3); 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;
    pointer-events: none;
}

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


/* 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 {
    position: relative;
}

.start-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 動畫 */
#scoreDisplay {
    transition: transform 0.3s ease-out;
}

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


/* 閃亮文字效果增強 */
.highlight {
    position: relative;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent-orange) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    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 效果 */
.basket {
    position: relative;
}

.basket::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 20px;
    padding: 4px;
    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: basketBeam 4s linear infinite;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: -1;
    pointer-events: none;
}

.basket:hover::before {
    opacity: 0.6;
}

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