/* 密碼產生器遊戲樣式 */

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 1200px; /* 增大最大寬度 */
    margin: 0 auto;
    padding: 15px; /* 減少內邊距 */
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    position: fixed; /* 固定在左上角 */
    top: 20px;
    left: 20px;
    z-index: 1000;
    color: white;
    margin-bottom: 0; /* 移除下邊距 */
}

header h1 {
    font-size: 1.8em; /* 縮小字體 */
    margin-bottom: 5px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

header p {
    font-size: 0.9em; /* 縮小字體 */
    opacity: 0.9;
    margin-bottom: 10px;
}

/* 語言切換按鈕 */
.language-switcher {
    margin-top: 10px;
}

.language-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.85em;
    font-weight: 500;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.language-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.language-btn:active {
    transform: translateY(0);
}

.game-area {
    flex: 1;
    position: relative;
    margin-top: 20px; /* 添加頂部邊距，避免與固定標題重疊 */
    width: 100%;
}

.screen {
    display: none;
    animation: fadeIn 0.5s ease-in;
}

.screen.active {
    display: block;
}

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

/* 開始畫面 */
.welcome-box {
    background: white;
    border-radius: 15px;
    padding: 50px; /* 增加內邊距 */
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    max-width: 900px; /* 增加最大寬度 */
    margin: 0 auto; /* 置中 */
}

.welcome-box h2 {
    color: #667eea;
    margin-bottom: 20px;
    font-size: 1.8em;
}

.welcome-box p {
    margin-bottom: 15px;
    line-height: 1.6;
    color: #666;
}

/* 分數制度說明 */
.scoring-info {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 20px;
    margin: 20px 0;
    text-align: left;
}

.scoring-info h3 {
    color: #667eea;
    margin-bottom: 15px;
    text-align: center;
    font-size: 1.2em;
}

.scoring-info ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.scoring-info li {
    padding: 8px 0;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.scoring-info li:last-child {
    border-bottom: none;
    font-weight: bold;
    color: #28a745;
}

.scoring-info strong {
    color: #667eea;
}

.quiz-note {
    margin-top: 15px;
    padding: 10px;
    background: #e3f2fd;
    border-radius: 5px;
    font-size: 0.9em;
    color: #1976d2;
    text-align: center;
}

/* 名稱輸入區域 */
.name-input-section {
    margin: 25px 0;
    text-align: left;
}

.name-input-section label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
}

.name-input-section input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1em;
    margin-bottom: 10px;
    transition: border-color 0.3s ease;
}

.name-input-section input:focus {
    outline: none;
    border-color: #667eea;
}

/* 按鈕樣式 */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 5px;
}

.btn-primary {
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-2px);
}

.btn-warning {
    background: #ffc107;
    color: #212529;
}

.btn-warning:hover {
    background: #e0a800;
    transform: translateY(-2px);
}

.btn-disabled {
    background: #ccc !important;
    color: #666 !important;
    cursor: not-allowed !important;
    opacity: 0.6 !important;
}

.btn-disabled:hover {
    transform: none !important;
    box-shadow: none !important;
}

/* 進度條 */
.progress-bar {
    background: white;
    border-radius: 25px;
    padding: 10px;
    margin-bottom: 20px;
    position: relative;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.progress-fill {
    background: linear-gradient(45deg, #28a745, #20c997);
    height: 20px;
    border-radius: 15px;
    transition: width 0.8s ease;
    width: 10%;
}

.level-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-weight: 600;
    color: #333;
}

/* 挑戰框 */
.challenge-box, .quiz-box {
    background: white;
    border-radius: 15px;
    padding: 40px; /* 增加內邊距 */
    margin-bottom: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    max-width: 900px; /* 增加最大寬度 */
    margin: 0 auto 20px auto; /* 置中並保持下邊距 */
}

.challenge-box h3, .quiz-box h3 {
    color: #667eea;
    margin-bottom: 20px;
    font-size: 1.5em;
}

/* 要求列表 */
.requirements {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
}

/* 抽查要求樣式 */
.quiz-requirements {
    background: #e3f2fd;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
    border-left: 4px solid #2196f3;
}

.quiz-requirements h4 {
    color: #1976d2;
    margin-bottom: 15px;
    font-size: 1.1em;
}

.requirement {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    padding: 8px;
    border-radius: 5px;
    transition: all 0.3s ease;
}

.requirement:last-child {
    margin-bottom: 0;
}

.requirement.met {
    background: #d4edda;
    color: #155724;
}

.requirement.not-met {
    background: #f8d7da;
    color: #721c24;
}

/* 抽查要求項目 */
.quiz-requirement {
    background: #fff3e0;
    color: #e65100;
    border: 1px solid #ffcc02;
}

.quiz-requirement .requirement-icon {
    color: #ff9800;
}

.requirement-icon {
    margin-right: 10px;
    font-size: 1.2em;
}

/* 輸入區域 */
.input-section {
    margin-bottom: 20px;
}

.input-section label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
}

.password-container {
    position: relative;
    display: flex;
    align-items: center;
}

#password-input, #quiz-input {
    flex: 1;
    padding: 12px 50px 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1em;
    transition: border-color 0.3s ease;
}

#password-input:focus, #quiz-input:focus {
    outline: none;
    border-color: #667eea;
}

#password-input:disabled, #quiz-input:disabled {
    background-color: #f5f5f5;
    color: #999;
    cursor: not-allowed;
    opacity: 0.6;
}

.toggle-btn {
    position: absolute;
    right: 10px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2em;
    padding: 5px;
}

/* 反饋訊息 */
.feedback {
    margin-top: 10px;
    padding: 10px;
    border-radius: 5px;
    font-weight: 500;
}

.feedback.success {
    background: #d4edda;
    color: #155724;
}

.feedback.error {
    background: #f8d7da;
    color: #721c24;
}

.feedback.info {
    background: #d1ecf1;
    color: #0c5460;
}

/* 按鈕組 */
.button-group {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
}

/* 密碼歷史 */
.password-history {
    background: white;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.password-history h4 {
    color: #667eea;
    margin-bottom: 15px;
}

.password-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    margin-bottom: 8px;
    background: #f8f9fa;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.password-item:hover {
    background: #e9ecef;
}

.password-level {
    font-weight: 600;
    color: #667eea;
}

.password-hint {
    font-size: 0.9em;
    color: #666;
}

/* 分數面板 */
.score-panel {
    position: fixed;
    top: 110px; /* 向下移動，避免與標題重疊 */
    right: 20px;
    background: white;
    border-radius: 10px;
    padding: 15px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    min-width: 150px; /* 稍微增寬 */
    z-index: 999; /* 確保在正確的層級 */
}

/* 玩家信息 */
.player-info {
    margin-bottom: 15px;
    text-align: center;
}

.player-name {
    font-weight: 700;
    color: #667eea;
    background: #f8f9fa;
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 0.9em;
}

.score-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-weight: 600;
}

.score-item:last-child {
    margin-bottom: 0;
}

.score-item span:first-child {
    color: #666;
}

.score-item span:last-child {
    color: #667eea;
}

/* 連線狀態 */
.connection-info {
    margin-bottom: 15px;
    text-align: center;
}

.connection-status {
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 0.9em;
    font-weight: 600;
    text-align: center;
}

.connection-status.success,
.connection-status.connected {
    background: #d4edda;
    color: #155724;
}

.connection-status.error,
.connection-status.disconnected {
    background: #f8d7da;
    color: #721c24;
}

.connection-status.warning {
    background: #fff3cd;
    color: #856404;
}

.connection-status.connecting {
    background: #d1ecf1;
    color: #0c5460;
}

/* 全球統計 */
.global-stats {
    margin-top: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
    font-size: 0.9em;
}

.global-stats h4 {
    margin-bottom: 10px;
    color: #667eea;
    font-size: 1em;
}

/* 排行榜樣式 */
.leaderboard {
    margin-top: 10px;
    max-height: 200px;
    overflow-y: auto;
}

.leaderboard-item {
    display: flex;
    align-items: center;
    padding: 6px 8px;
    background: white;
    border-radius: 6px;
    margin-bottom: 4px;
    font-size: 0.85em;
    border: 1px solid #e9ecef;
}

.leaderboard-item .rank {
    width: 30px;
    font-weight: bold;
    color: #667eea;
}

.leaderboard-item .player-name {
    flex: 1;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.leaderboard-item .player-score {
    color: #28a745;
    font-weight: bold;
    font-size: 0.9em;
}

.no-players {
    text-align: center;
    color: #6c757d;
    font-style: italic;
    padding: 10px;
}

/* 通知系統 */
.notifications-container {
    position: fixed;
    bottom: 20px; /* 改為底部定位 */
    left: 20px;
    z-index: 2000;
    pointer-events: none;
    display: flex;
    flex-direction: column-reverse; /* 新訊息從下方出現 */
}

.notification {
    background: white;
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    border-left: 4px solid #667eea;
    max-width: 300px;
    animation: slideIn 0.3s ease;
}

.notification.success {
    border-left-color: #28a745;
}

.notification.error {
    border-left-color: #dc3545;
}

.notification.warning {
    border-left-color: #ffc107;
}

.notification.info {
    border-left-color: #17a2b8;
}

@keyframes slideIn {
    from { transform: translateY(100%); opacity: 0; } /* 改為從底部滑入 */
    to { transform: translateY(0); opacity: 1; }
}

/* 結果畫面 */
.result-box {
    background: white;
    border-radius: 15px;
    padding: 50px; /* 增加內邊距 */
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    max-width: 900px; /* 增加最大寬度 */
    margin: 0 auto; /* 置中 */
}

.result-box h2 {
    color: #28a745;
    margin-bottom: 20px;
    font-size: 2em;
}

#final-score {
    font-size: 1.5em;
    font-weight: 600;
    color: #667eea;
    margin-bottom: 20px;
}

#final-stats {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    padding: 5px 0;
    border-bottom: 1px solid #e0e0e0;
}

.stat-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

/* 排行榜樣式 */
.leaderboard {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 20px;
    margin: 20px 0;
}

.leaderboard h3 {
    color: #667eea;
    margin-bottom: 15px;
    text-align: center;
}

.leaderboard-list {
    max-height: 300px;
    overflow-y: auto;
}

.leaderboard-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    margin-bottom: 8px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: transform 0.2s ease;
}

.leaderboard-item:hover {
    transform: translateY(-2px);
}

.leaderboard-item:last-child {
    margin-bottom: 0;
}

.leaderboard-rank {
    font-weight: 700;
    color: #667eea;
    min-width: 30px;
    text-align: center;
}

.leaderboard-rank.first {
    color: #ffd700;
}

.leaderboard-rank.second {
    color: #c0c0c0;
}

.leaderboard-rank.third {
    color: #cd7f32;
}

.leaderboard-name {
    flex: 1;
    margin: 0 15px;
    font-weight: 600;
}

.leaderboard-score {
    font-weight: 700;
    color: #28a745;
}

.leaderboard-current {
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
}

.leaderboard-current .leaderboard-rank,
.leaderboard-current .leaderboard-name,
.leaderboard-current .leaderboard-score {
    color: white;
}

.no-records {
    text-align: center;
    color: #666;
    font-style: italic;
    padding: 20px;
}

/* 響應式設計 */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    header h1 {
        font-size: 2em;
    }
    
    .welcome-box, .challenge-box, .quiz-box, .result-box {
        padding: 25px; /* 在手機上稍微增加內邊距 */
        max-width: 95%; /* 確保不會太寬 */
    }
    
    header {
        position: static; /* 在手機上取消固定定位 */
        text-align: center; /* 在手機上置中 */
        margin-bottom: 20px;
        left: auto;
        top: auto;
    }
    
    header h1 {
        font-size: 2em; /* 在手機上稍微放大 */
    }
    
    header p {
        font-size: 1em;
    }
    
    .game-area {
        margin-top: 0; /* 移除頂部邊距 */
    }
    
    .score-panel {
        position: static;
        margin-bottom: 20px;
        max-width: 95%;
    }
    
    .notifications-container {
        bottom: 10px; /* 在手機上稍微向上移動 */
        left: 10px;
        right: 10px; /* 添加右邊距 */
    }
    
    .notification {
        max-width: 90%; /* 在手機上限制寬度 */
    }
    
    .button-group {
        flex-direction: column;
        align-items: center;
    }
    
    .btn {
        width: 100%;
        max-width: 200px;
    }
}

/* 動畫效果 */
.shake {
    animation: shake 0.5s ease-in-out;
}

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

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

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

/* 離線模式樣式 */
.offline-notice {
    background: linear-gradient(135deg, #ff7b7b, #ff6b6b);
    color: white;
    padding: 10px 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    text-align: center;
    font-weight: bold;
    box-shadow: 0 2px 10px rgba(255, 107, 107, 0.3);
    animation: slideInDown 0.5s ease-out;
}

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

/* 連接狀態樣式改進 */
.connection-status {
    font-size: 0.85em;
    padding: 5px 10px;
    border-radius: 15px;
    font-weight: bold;
    transition: all 0.3s ease;
}

.connection-status.connected {
    background: rgba(76, 175, 80, 0.2);
    color: #4caf50;
    border: 1px solid rgba(76, 175, 80, 0.5);
}

.connection-status.connecting {
    background: rgba(255, 152, 0, 0.2);
    color: #ff9800;
    border: 1px solid rgba(255, 152, 0, 0.5);
    animation: pulse 1.5s infinite;
}

.connection-status.disconnected {
    background: rgba(244, 67, 54, 0.2);
    color: #f44336;
    border: 1px solid rgba(244, 67, 54, 0.5);
}
