/* 🧺 拖拉分組遊戲 - 果園主題 */

:root {
    --primary: #4CAF50;
    --primary-dark: #388E3C;
    --primary-light: #81C784;
    --accent: #FF9800;
    --accent-dark: #F57C00;
    --sky-top: #87CEEB;
    --sky-bottom: #E0F7FA;
    --grass: #7CB342;
    --wood: #8D6E63;
    --wood-dark: #6D4C41;
    --text-dark: #2E7D32;
    --text-light: #fff;
    --shadow: rgba(0, 0, 0, 0.15);
    --basket-bg: #FFF8E1;
    --basket-border: #FFCC80;
}

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

body {
    font-family: 'Nunito', 'Microsoft JhengHei', sans-serif;
    min-height: 100vh;
    background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-bottom) 60%, var(--grass) 100%);
    overflow-x: hidden;
    position: relative;
}

/* 背景裝飾 */
.bg-decorations {
    position: fixed;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 0;
}

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

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

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

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

@keyframes sunPulse {
    0%, 100% { transform: scale(1) rotate(0deg); filter: drop-shadow(0 0 20px #FFD54F); }
    50% { transform: scale(1.1) rotate(10deg); filter: drop-shadow(0 0 40px #FFEB3B); }
}

.grass {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 120px;
    background: linear-gradient(180deg, transparent 0%, rgba(76, 175, 80, 0.3) 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-content {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 30px;
    padding: 40px;
    text-align: center;
    box-shadow: 0 20px 60px var(--shadow), 0 0 0 8px rgba(255, 255, 255, 0.5);
}

.logo-area {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 20px;
}

.fruit-bounce {
    font-size: 50px;
    animation: fruitBounce 2s ease-in-out infinite;
}

.fruit-bounce.delay-1 { animation-delay: 0.2s; }
.fruit-bounce.delay-2 { animation-delay: 0.4s; }

@keyframes fruitBounce {
    0%, 100% { transform: translateY(0) rotate(-5deg); }
    50% { transform: translateY(-20px) rotate(5deg); }
}

.game-title {
    font-size: 42px;
    font-weight: 800;
    color: var(--text-dark);
    margin-bottom: 10px;
    text-shadow: 2px 2px 0 rgba(255, 255, 255, 0.8);
}

.game-subtitle {
    font-size: 18px;
    color: #666;
    margin-bottom: 30px;
}

/* 表單區域 */
.form-section {
    margin-bottom: 25px;
    text-align: left;
}

.form-label {
    display: block;
    font-size: 16px;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 12px;
}

.form-select {
    width: 100%;
    padding: 15px 20px;
    font-size: 18px;
    font-family: inherit;
    border: 3px solid #E0E0E0;
    border-radius: 15px;
    background: white;
    color: #333;
    cursor: pointer;
    transition: all 0.3s;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 15px center;
    background-size: 20px;
}

.form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(76, 175, 80, 0.2);
}

/* 動物頭像選擇 */
.mascot-display {
    font-size: 80px;
    margin-bottom: 15px;
    animation: mascotDance 2s ease-in-out infinite;
}

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

.mascot-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 10px;
    padding: 15px;
    background: linear-gradient(135deg, #f5f7fa 0%, #e4e8eb 100%);
    border-radius: 15px;
}

.mascot-option {
    font-size: 36px;
    padding: 12px;
    background: white;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s;
    border: 3px solid transparent;
    text-align: center;
}

.mascot-option:hover {
    transform: scale(1.15);
    border-color: var(--primary);
    box-shadow: 0 8px 20px rgba(76, 175, 80, 0.3);
}

.mascot-option.selected {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-color: var(--primary-dark);
    box-shadow: 0 8px 20px rgba(76, 175, 80, 0.4);
}

/* 開始按鈕 */
.start-btn {
    display: inline-flex;
    align-items: center;
    gap: 15px;
    padding: 20px 50px;
    font-size: 24px;
    font-weight: 800;
    font-family: inherit;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 8px 30px rgba(255, 152, 0, 0.4);
    margin-top: 10px;
}

.start-btn:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 15px 40px rgba(255, 152, 0, 0.5);
}

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

.login-links {
    margin-top: 25px;
}

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

.link-btn:hover {
    background: rgba(76, 175, 80, 0.2);
    transform: translateY(-2px);
}

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

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

.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, #E3F2FD 0%, #BBDEFB 100%);
    padding: 10px 25px;
    border-radius: 50px;
    border: 2px solid #90CAF9;
}

.progress-text {
    font-size: 18px;
    font-weight: 700;
    color: #1976D2;
}

.score-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    background: linear-gradient(135deg, #FFD54F 0%, #FFCA28 100%);
    padding: 12px 30px;
    border-radius: 50px;
    box-shadow: 0 5px 20px rgba(255, 193, 7, 0.4);
}

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

.score-value {
    font-size: 32px;
    font-weight: 800;
    color: #5D4037;
}

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

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

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

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

.question-text .highlight {
    display: inline-block;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
    color: white;
    padding: 5px 15px;
    border-radius: 10px;
    margin: 0 5px;
    font-size: 28px;
}

/* 遊戲區域 */
.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, #FFF3E0 0%, #FFE0B2 100%);
    border: 3px dashed var(--accent);
    border-radius: 20px;
    padding: 25px;
    min-height: 120px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    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%, #FFE082 100%);
    border: 4px solid var(--wood);
    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(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.basket::before {
    content: '';
    position: absolute;
    top: -15px;
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    height: 20px;
    background: linear-gradient(180deg, var(--wood) 0%, var(--wood-dark) 100%);
    border-radius: 10px;
}

.basket.drag-over {
    background: linear-gradient(180deg, #C8E6C9 0%, #A5D6A7 100%);
    border-color: var(--primary);
    transform: scale(1.05);
    box-shadow: 0 15px 30px rgba(76, 175, 80, 0.3);
}

.basket-label {
    text-align: center;
    font-weight: 700;
    color: var(--wood-dark);
    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;
}

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

.action-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px 35px;
    font-size: 18px;
    font-weight: 700;
    font-family: inherit;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s;
}

.reset-btn {
    background: linear-gradient(135deg, #E0E0E0 0%, #BDBDBD 100%);
    color: #616161;
}

.reset-btn:hover {
    background: linear-gradient(135deg, #BDBDBD 0%, #9E9E9E 100%);
    transform: translateY(-3px);
}

.check-btn {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    box-shadow: 0 8px 25px rgba(76, 175, 80, 0.4);
}

.check-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 35px rgba(76, 175, 80, 0.5);
}

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

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

.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: #666;
    margin-bottom: 25px;
    padding: 15px;
    background: linear-gradient(135deg, #E8F5E9 0%, #C8E6C9 100%);
    border-radius: 15px;
}

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

.ranking-title {
    font-size: 20px;
    color: #F57C00;
    margin-bottom: 15px;
}

.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, #FFD54F 0%, #FFCA28 100%);
    border: 2px solid #FF9800;
}

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

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

.primary-btn {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
    color: white;
    box-shadow: 0 8px 25px rgba(255, 152, 0, 0.4);
}

.primary-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 35px rgba(255, 152, 0, 0.5);
}

.secondary-btn {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
}

.secondary-btn:hover {
    transform: translateY(-3px);
}

.tertiary-btn {
    background: linear-gradient(135deg, #E0E0E0 0%, #BDBDBD 100%);
    color: #616161;
}

.tertiary-btn:hover {
    background: linear-gradient(135deg, #BDBDBD 0%, #9E9E9E 100%);
    transform: translateY(-3px);
}

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

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

/* ==================== iPad 適配 (768px - 1024px) ==================== */

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

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

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

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

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

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

    .game-header {
        gap: 20px;
    }

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

    .baskets-row {
        gap: 10px;
    }

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

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

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

    .fruits-pool {
        min-height: 130px;
        padding: 25px;
    }

    .action-btn {
        padding: 18px 40px;
        font-size: 20px;
    }

    .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-content,
    #gameScreen,
    .result-content {
        padding: 25px 18px;
        border-radius: 20px;
    }

    .logo-area {
        gap: 10px;
    }

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

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

    .game-subtitle {
        font-size: 15px;
        margin-bottom: 20px;
    }

    .mascot-display {
        font-size: 60px;
        margin-bottom: 10px;
    }

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

    .mascot-option {
        font-size: 28px;
        padding: 10px;
        border-radius: 10px;
    }

    .form-label {
        font-size: 15px;
        margin-bottom: 8px;
    }

    .form-select {
        padding: 14px 16px;
        font-size: 16px;
        border-radius: 12px;
    }

    .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: 1px;
        padding: 2px;
    }

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

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

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

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

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

    .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-content,
    #gameScreen,
    .result-content {
        padding: 20px 15px;
    }

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

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

    .mascot-option {
        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-option:hover {
        transform: none;
    }

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

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

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

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

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

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

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

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

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