/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Noto Sans TC', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    min-height: 100vh;
    padding: 15px;
    color: #333;
    overflow-x: hidden;
    position: relative;
}

/* 背景裝飾 */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 20% 50%, rgba(255, 255, 255, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(255, 255, 255, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 40% 80%, rgba(255, 255, 255, 0.1) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 25px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    backdrop-filter: blur(10px);
    position: relative;
    z-index: 10;
}

/* 头部样式 */
.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    padding: 25px;
    text-align: center;
    color: #fff;
    position: relative;
}

/* 返回首頁按鈕 */
.back-home-btn {
    position: absolute;
    top: 15px;
    left: 15px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    padding: 8px 15px;
    border-radius: 20px;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.back-home-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 12px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    letter-spacing: 1px;
}

.header p {
    font-size: 1.2rem;
    opacity: 0.95;
    font-weight: 500;
}

/* 游戏区域 */
.game-area {
    padding: 25px;
}

/* 計分板样式 */
.score-board {
    display: flex;
    justify-content: center;
    gap: 25px;
    margin-bottom: 35px;
    flex-wrap: wrap;
}

.score {
    padding: 18px 25px;
    border-radius: 20px;
    font-size: 1.3rem;
    font-weight: 700;
    color: white;
    text-align: center;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
    min-width: 120px;
}

.correct-score {
    background: linear-gradient(135deg, #32CD32 0%, #228B22 100%);
}

.wrong-score {
    background: linear-gradient(135deg, #FF6347 0%, #DC143C 100%);
}

.total-score {
    background: linear-gradient(135deg, #4169E1 0%, #1E90FF 100%);
}

.score-label {
    display: block;
    font-size: 1rem;
    margin-bottom: 5px;
    opacity: 0.9;
}

.score-unit {
    font-size: 1rem;
    margin-left: 5px;
    opacity: 0.9;
}

/* 游戏说明 */
.instruction {
    text-align: center;
    font-size: 1.4rem;
    color: #555;
    margin-bottom: 30px;
    padding: 25px;
    background: linear-gradient(135deg, #F0F8FF 0%, #E6E6FA 100%);
    border-radius: 20px;
    border-left: 6px solid #4169E1;
    font-weight: 600;
}

/* 难度选择器 */
.difficulty-selector {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-bottom: 30px;
    padding: 25px;
    background: linear-gradient(135deg, #FFF8DC 0%, #F0E68C 100%);
    border-radius: 20px;
    border: 3px solid #DAA520;
}

.difficulty-label {
    font-size: 1.3rem;
    font-weight: 700;
    color: #B8860B;
}

.difficulty-select {
    font-size: 1.2rem;
    font-weight: 600;
    padding: 12px 20px;
    border-radius: 15px;
    border: 3px solid #DAA520;
    background: white;
    color: #B8860B;
    outline: none;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 150px;
}

.difficulty-select:hover {
    border-color: #B8860B;
    box-shadow: 0 5px 15px rgba(218, 165, 32, 0.3);
}

.difficulty-select:focus {
    border-color: #B8860B;
    box-shadow: 0 0 0 3px rgba(218, 165, 32, 0.2);
}

/* 题目区域 */
.question-area {
    margin-bottom: 30px;
}

.question {
    text-align: center;
    font-size: 2.2rem;
    font-weight: 700;
    color: #333;
    padding: 30px;
    background: linear-gradient(135deg, #FFE4B5 0%, #FFDAB9 100%);
    border-radius: 25px;
    box-shadow: 0 10px 25px rgba(255, 165, 0, 0.3);
    border: 3px solid #FFA500;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 答案输入区域 */
.answer-area {
    margin-bottom: 30px;
}

.answer-input {
    width: 100%;
    font-size: 2rem;
    font-weight: 600;
    text-align: center;
    padding: 20px;
    border-radius: 20px;
    border: 3px solid #4ECDC4;
    background: white;
    color: #333;
    outline: none;
    transition: all 0.3s ease;
    box-shadow: 0 5px 15px rgba(78, 205, 196, 0.2);
}

/* 確保沒有數字輸入框的上下箭頭（防止某些瀏覽器顯示） */
.answer-input::-webkit-outer-spin-button,
.answer-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.answer-input[type=number] {
    -moz-appearance: textfield;
}

.answer-input:focus {
    border-color: #26A69A;
    box-shadow: 0 0 0 3px rgba(78, 205, 196, 0.3);
    transform: scale(1.02);
}

.answer-input::placeholder {
    color: #999;
    font-weight: 400;
}

.answer-error {
    color: #F44336;
    font-size: 1.2rem;
    font-weight: 600;
    text-align: center;
    margin-top: 10px;
    padding: 10px;
    background: rgba(244, 67, 54, 0.1);
    border-radius: 10px;
    border: 2px solid rgba(244, 67, 54, 0.3);
    display: none;
}

/* 控制按鈕 */
.controls {
    display: flex;
    justify-content: center;
    gap: 25px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.btn {
    padding: 18px 35px;
    border: none;
    border-radius: 30px;
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
    min-width: 140px;
}

.btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.3);
}

.btn:disabled {
    background: #ccc !important;
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.btn-primary {
    background: linear-gradient(135deg, #FF6B6B 0%, #FF8E53 100%);
    color: white;
}

.btn-secondary {
    background: linear-gradient(135deg, #4ECDC4 0%, #44A08D 100%);
    color: white;
}

.btn-info {
    background: linear-gradient(135deg, #FFE66D 0%, #FF6B6B 100%);
    color: white;
}

/* 反饋訊息 */
.feedback {
    text-align: center;
    font-size: 1.4rem;
    font-weight: 700;
    padding: 25px;
    border-radius: 20px;
    margin-bottom: 25px;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.5s ease;
    border: 3px solid transparent;
}

.feedback.show {
    opacity: 1;
    transform: translateY(0);
}

.feedback.correct {
    background: linear-gradient(135deg, #E8F5E8 0%, #D4F4D4 100%);
    color: #2D5016;
    border-color: #32CD32;
}

.feedback.wrong {
    background: linear-gradient(135deg, #FFE8E8 0%, #FFD4D4 100%);
    color: #8B0000;
    border-color: #FF6347;
}

.feedback.encouraging {
    background: linear-gradient(135deg, #E6F3FF 0%, #CCE7FF 100%);
    color: #003D82;
    border-color: #4169E1;
}

/* 慶祝區域 */
.celebration-area {
    text-align: center;
    font-size: 3rem;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.celebration-balloons {
    animation: balloonPop 0.6s ease-out;
    display: inline-block;
}

/* 動畫效果 */
@keyframes balloonPop {
    0% { 
        transform: scale(0.5);
        opacity: 0;
    }
    50% { 
        transform: scale(1.3);
        opacity: 1;
    }
    100% { 
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes correctPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

@keyframes wrongShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

.correct-animation {
    animation: correctPulse 0.6s ease-in-out;
}

.wrong-animation {
    animation: wrongShake 0.6s ease-in-out;
}

/* 響應式設計 */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .container {
        margin: 5px;
        border-radius: 20px;
    }
    
    .header {
        padding: 20px 15px;
    }
    
    .back-home-btn {
        top: 10px;
        left: 10px;
        font-size: 0.8rem;
        padding: 6px 12px;
    }
    
    .header h1 {
        font-size: 2rem;
    }
    
    .header p {
        font-size: 1.1rem;
    }
    
    .game-area {
        padding: 20px 15px;
    }
    
    .score-board {
        gap: 15px;
        margin-bottom: 20px;
    }
    
    .score {
        padding: 12px 18px;
        font-size: 1.1rem;
        min-width: 100px;
    }
    
    .instruction {
        font-size: 1.2rem;
        padding: 20px;
        margin-bottom: 20px;
    }
    
    .difficulty-selector {
        padding: 20px;
        margin-bottom: 20px;
        gap: 15px;
    }
    
    .difficulty-label {
        font-size: 1.2rem;
    }
    
    .difficulty-select {
        font-size: 1.1rem;
        padding: 10px 15px;
        min-width: 130px;
    }
    
    .question {
        font-size: 1.8rem;
        padding: 25px 20px;
        margin-bottom: 20px;
    }
    
    .answer-input {
        font-size: 1.6rem;
        padding: 15px;
    }
    
    .answer-error {
        font-size: 1.1rem;
        padding: 8px;
        margin-top: 8px;
    }
    
    .controls {
        gap: 15px;
        margin-bottom: 20px;
    }
    
    .btn {
        padding: 15px 25px;
        font-size: 1.1rem;
        min-width: 120px;
    }
    
    .feedback {
        font-size: 1.2rem;
        padding: 20px;
        margin-bottom: 15px;
    }
    
    .celebration-area {
        font-size: 2.5rem;
        min-height: 60px;
    }
}

/* iPhone 專用優化 (320px - 414px) */
@media (max-width: 414px) {
    body {
        padding: 8px;
        min-height: 100vh;
        display: flex;
        align-items: center;
    }
    
    .container {
        margin: 0;
        width: 100%;
        max-height: 100vh;
        overflow-y: auto;
    }
    
    .header {
        padding: 15px 12px;
    }
    
    .back-home-btn {
        top: 8px;
        left: 8px;
        font-size: 0.75rem;
        padding: 5px 10px;
    }
    
    .header h1 {
        font-size: 1.8rem;
        margin-bottom: 8px;
    }
    
    .header p {
        font-size: 1rem;
    }
    
    .game-area {
        padding: 15px 12px;
    }
    
    .score-board {
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
        margin-bottom: 12px;
    }
    
    .score {
        padding: 8px 12px;
        font-size: 0.9rem;
        min-width: 80px;
    }
    
    .instruction {
        font-size: 1rem;
        padding: 12px;
        margin-bottom: 12px;
    }
    
    .difficulty-selector {
        padding: 15px 12px;
        margin-bottom: 12px;
        gap: 10px;
    }
    
    .difficulty-label {
        font-size: 1rem;
    }
    
    .difficulty-select {
        font-size: 1rem;
        padding: 8px 12px;
        min-width: 120px;
    }
    
    .question {
        font-size: 1.5rem;
        padding: 20px 15px;
        margin-bottom: 12px;
        min-height: 80px;
    }
    
    .answer-area {
        margin-bottom: 12px;
    }
    
    .answer-input {
        font-size: 1.4rem;
        padding: 12px;
    }
    
    .answer-error {
        font-size: 1rem;
        padding: 6px;
        margin-top: 6px;
    }
    
    .controls {
        gap: 10px;
        margin-bottom: 12px;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .btn {
        padding: 12px 18px;
        font-size: 1rem;
        min-width: 100px;
    }
    
    .feedback {
        font-size: 1rem;
        padding: 12px;
        margin-bottom: 8px;
    }
    
    .celebration-area {
        font-size: 2rem;
        min-height: 40px;
    }
}

/* iPad 專用優化 (768px - 1024px) */
@media (min-width: 415px) and (max-width: 1024px) {
    body {
        padding: 15px;
        min-height: 100vh;
        display: flex;
        align-items: center;
    }
    
    .container {
        margin: 0 auto;
        width: 100%;
        max-width: 900px;
        max-height: 100vh;
        overflow-y: auto;
    }
    
    .header {
        padding: 25px 20px;
    }
    
    .header h1 {
        font-size: 2.2rem;
    }
    
    .game-area {
        padding: 25px 20px;
    }
    
    .score-board {
        gap: 20px;
        margin-bottom: 25px;
    }
    
    .difficulty-selector {
        padding: 25px 20px;
        margin-bottom: 25px;
    }
    
    .question {
        font-size: 2rem;
        padding: 30px 25px;
        margin-bottom: 25px;
        min-height: 100px;
    }
    
    .answer-input {
        font-size: 1.8rem;
        padding: 18px;
    }
    
    .controls {
        gap: 20px;
        margin-bottom: 25px;
    }
    
    .btn {
        padding: 16px 30px;
        font-size: 1.2rem;
        min-width: 130px;
    }
    
    .celebration-area {
        font-size: 2.8rem;
        min-height: 70px;
    }
}

/* 特殊效果 */
.floating-numbers {
    position: absolute;
    pointer-events: none;
    font-size: 2rem;
    opacity: 0.6;
    animation: floatUp 3s ease-out forwards;
}

@keyframes floatUp {
    0% {
        transform: translateY(0px) rotate(0deg);
        opacity: 0.8;
    }
    100% {
        transform: translateY(-100px) rotate(360deg);
        opacity: 0;
    }
}

/* 成功慶祝效果 */
.success-celebration {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 4rem;
    z-index: 1000;
    animation: celebrationBurst 2s ease-out;
    pointer-events: none;
}

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