/* style.css (完整响应式版) */

/* ------------------- 0. 全局与基础设置 ------------------- */
:root {
    /* 定义颜色变量，方便统一修改 */
    --bg-color: #fdfaf3;
    --primary-text: #2d2d2d;
    --secondary-text: #666;
    --border-color: #2d2d2d;
    --container-bg: white;
    --accent-color: #007BFF;
    --correct-color: #4CAF50;
    --incorrect-color: #f44336;
}

/* Mobile-First: 默认字体大小，适合小屏幕 */
html {
    font-size: 14px;
    box-sizing: border-box;
}

/* 继承box-sizing，是现代CSS的最佳实践 */
*, *::before, *::after {
    box-sizing: inherit;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    padding: 1.5rem 0; /* 在垂直方向增加一些边距 */
    background-color: var(--bg-color);
    color: var(--primary-text);
}


/* ------------------- 1. 容器样式 (Mobile) ------------------- */
#start-screen, #game-container, #end-screen {
    background-color: var(--container-bg);
    padding: 1.5rem;
    border: 3px solid var(--border-color);
    border-radius: 25px;
    text-align: center;
    width: 90%;
    max-width: 500px;
    box-shadow: 5px 5px 0px #c7c1b5;
}

h1, h2, h3 {
    margin-top: 0;
    margin-bottom: 1.5rem;
}

.hidden {
    display: none !important;
}


/* ------------------- 2. 各界面样式 (Mobile) ------------------- */

/* --- 开始界面 --- */
.mode-selection {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}
.mode-btn {
    padding: 1.1rem;
    font-size: 1.2rem;
    font-weight: bold;
    background-color: #ffc857;
    border: 3px solid var(--border-color);
    border-radius: 15px;
    cursor: pointer;
    transition: transform 0.2s, background-color 0.2s;
}
.mode-description {
    color: var(--secondary-text);
    line-height: 1.6;
}

/* --- 游戏界面 --- */
#info-bar {
    display: flex;
    justify-content: space-between;
    align-items: center; /* 垂直居中 */
    margin-bottom: 1.5rem;
    font-weight: bold;
}
#info-bar span {
    /*background-color: var(--container-bg);*/
    border: 2px solid var(--border-color);
    border: 2px solid var(--border-color);
    padding: 0.6rem 1rem;
    border-radius: 12px;
}
#lives-display {
    color: #e5383b;
    font-size: 1.5rem;
    letter-spacing: 0.2rem;
}

/* 猜图模式 */
#image-container {
    padding: 1rem;
    background-color: #ffffff;
    border: 3px solid var(--border-color);
    border-radius: 15px;
    margin-bottom: 1rem;
}
#question-image {
    max-width: 100%;
    max-height: 200px; /* 移动端图片高度限制 */
    display: block; /* 解决图片底部空隙问题 */
    margin: 0 auto;
}
.prompt-text {
    color: var(--secondary-text);
    font-weight: normal;
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
}

/* 识图模式 */
#name-prompt {
    font-size: 2.5rem;
    color: var(--accent-color);
    margin: 1.5rem 0;
    word-break: break-word; /* 防止长名字溢出 */
}

/* 选项容器 (Mobile: 单列布局) */
#options-container {
    display: grid;
    grid-template-columns: 1fr; /* 移动端默认为单列 */
    gap: 1rem;
}

/* 选项按钮通用样式 */
.option-btn-text, .option-btn-image {
    cursor: pointer;
    border: 3px solid var(--border-color);
    transition: all 0.2s ease;
}
/* 增加点击反馈，对移动端更友好 */
.mode-btn:active, .option-btn-text:active, .option-btn-image:active, #main-menu-btn:active {
    transform: translateY(2px);
}

/* 文字选项按钮 */
.option-btn-text {
    padding: 1.1rem;
    font-size: 1.1rem;
    font-weight: bold;
    background-color: var(--container-bg);
    color: var(--primary-text);
    border-radius: 50px;
}

/* 图片选项按钮 */
.option-btn-image {
    padding: 0.5rem;
    background-color: var(--container-bg);
    border-radius: 15px;
    height: 120px; /* 移动端图片选项高度 */
}
.option-btn-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 10px;
}

/* 按钮反馈样式 */
.correct {
    border-color: var(--correct-color) !important;
    background-color: #dff0d8 !important;
}
.incorrect {
    border-color: var(--incorrect-color) !important;
    background-color: #f2dede !important;
}
:disabled {
    cursor: not-allowed;
    opacity: 0.8;
}

/* --- 结束画面 --- */
#final-title {
    font-size: 2rem;
    margin-bottom: 0.75rem;
}
#final-score {
    font-size: 1.2rem;
    color: var(--secondary-text);
    font-weight: bold;
}
#main-menu-btn {
    padding: 1rem 2rem;
    margin-top: 1.5rem;
    font-size: 1.1rem;
    color: #fff;
    background-color: var(--accent-color);
    border: 2px solid var(--border-color);
    border-radius: 50px;
    cursor: pointer;
}

/* --- 动画 --- */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}
.shake-animation {
    animation: shake 0.5s ease-in-out;
}


/* ------------------- 3. PC端样式 (通过媒体查询覆盖) ------------------- */

/* 当屏幕宽度大于等于 768px (平板和PC) 时，应用以下样式 */
@media (min-width: 768px) {
    html {
        font-size: 16px; /* 恢复PC端标准字体大小 */
    }

    #start-screen, #game-container, #end-screen {
        max-width: 550px; /* 在PC上可以适当加宽 */
        padding: 2rem;
    }

    /* 选项容器 (PC: 恢复2x2网格布局) */
    #options-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.25rem;
    }

    /* 增高图片和图片选项的高度 */
    #question-image {
        max-height: 250px;
    }
    .option-btn-image {
        height: 160px;
    }

    /* 调整PC端字体大小 */
    #name-prompt {
        font-size: 2.8rem;
    }
    #final-title {
        font-size: 2.5rem;
    }
}

/* 倒计时器样式 */
#timer-display {
    width: 3rem; /* 固定宽高 */
    height: 3rem;
    background-color: var(--accent-color);
    color: white;
    border-radius: 50%; /* 形成圆形 */
    display: flex; /* 使用flex布局使数字垂直水平居中 */
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    font-weight: bold;
    border: 3px solid var(--border-color);
    transition: background-color 0.3s, transform 0.3s;
}

/* 时间紧急时的警告动画 */
.timer-warning {
    background-color: #e5383b !important; /* 变为红色 */
    animation: pulse 1s infinite;
}

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

/* 确保信息栏能容纳三个元素 */
@media (max-width: 400px) {
    #info-bar span {
        padding: 0.5rem; /* 在非常窄的屏幕上减小内边距 */
        font-size: 0.9rem;
    }
    #lives-display {
        font-size: 1.2rem;
    }
}

/* ------------------- 4. 排行榜样式 ------------------- */
#leaderboard-display {
    margin-top: 2rem;
    padding: 1rem;
    border: 3px dashed var(--border-color);
    border-radius: 15px;
    background-color: #fffbeb;
}

#leaderboard-display h4 {
    margin-bottom: 1rem;
    font-size: 1.3rem;
}

#leaderboard-list {
    list-style: none;
    padding-left: 0;
    margin: 0;
}

#leaderboard-list li {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0.2rem;
    font-size: 1.1rem;
    border-bottom: 1px solid #ddd;
}

#leaderboard-list li:last-child {
    border-bottom: none;
}

/* 为前三名添加奖牌 */
#leaderboard-list li:nth-child(1)::before { content: '🥇 '; }
#leaderboard-list li:nth-child(2)::before { content: '🥈 '; }
#leaderboard-list li:nth-child(3)::before { content: '🥉 '; }

.leaderboard-score {
    font-weight: bold;
    color: var(--accent-color);
}

/* ------------------- 5. 分数提交表单样式 ------------------- */
#save-score-form {
    margin-top: 1.5rem;
    padding: 1rem;
    background-color: #e9f5ff;
    border-radius: 10px;
}
#save-score-form p {
    margin-top: 0;
    margin-bottom: 0.8rem;
    font-weight: bold;
}
#player-name {
    width: 70%;
    padding: 0.7rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    text-align: center;
}
#save-score-btn {
    display: block;
    width: 100%;
    margin-top: 1rem;
    padding: 0.8rem;
    font-size: 1rem;
    color: white;
    background-color: var(--correct-color);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
}
#save-score-btn:disabled {
    background-color: var(--secondary-text);
}