/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

/* 游戏容器 */
.game-container {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 600px;
    width: 100%;
    padding: 30px;
}

/* 标题区 */
.header {
    text-align: center;
    margin-bottom: 30px;
}

.header h1 {
    color: #333;
    font-size: 2em;
    margin-bottom: 10px;
}

.subtitle {
    color: #666;
    font-size: 1em;
}

/* 状态栏 */
.status-bar {
    display: flex;
    justify-content: space-around;
    background: #f8f9fa;
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 20px;
}

.status-item {
    text-align: center;
}

.status-item .label {
    color: #666;
    font-size: 0.9em;
    display: block;
    margin-bottom: 5px;
}

.status-item .value {
    color: #667eea;
    font-size: 1.5em;
    font-weight: bold;
}

/* 游戏区 */
.game-area {
    margin-bottom: 30px;
}

/* 输入区 */
.input-section {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

#guessInput {
    flex: 1;
    padding: 12px 15px;
    font-size: 1em;
    border: 2px solid #ddd;
    border-radius: 8px;
    outline: none;
    transition: border-color 0.3s;
}

#guessInput:focus {
    border-color: #667eea;
}

#guessInput:disabled {
    background: #f0f0f0;
    cursor: not-allowed;
}

/* 按钮样式 */
.btn {
    padding: 12px 24px;
    font-size: 1em;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: bold;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #28a745;
    color: white;
}

.btn-secondary:hover {
    background: #218838;
    transform: translateY(-2px);
}

.btn-outline {
    background: transparent;
    border: 2px solid #667eea;
    color: #667eea;
}

.btn-outline:hover {
    background: #667eea;
    color: white;
}

/* 提示框 */
.message-box {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.message-box p {
    font-size: 1.1em;
    text-align: center;
}

.hint {
    color: #666;
}

.success {
    color: #28a745;
    font-weight: bold;
    animation: pulse 1s ease-in-out;
}

.error {
    color: #dc3545;
    font-weight: bold;
    animation: shake 0.5s ease-in-out;
}

.warning {
    color: #ffc107;
    font-weight: bold;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

/* 进度条 */
.progress-bar {
    height: 10px;
    background: #e9ecef;
    border-radius: 5px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    transition: width 0.3s ease;
    width: 100%;
}

/* 历史记录区 */
.history-section {
    margin-bottom: 20px;
}

.history-section h3 {
    color: #333;
    margin-bottom: 15px;
    font-size: 1.2em;
}

.history-list {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 10px;
    max-height: 200px;
    overflow-y: auto;
}

.empty-hint {
    color: #999;
    text-align: center;
    font-style: italic;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    margin-bottom: 8px;
    background: white;
    border-radius: 5px;
    border-left: 4px solid #667eea;
}

.history-item.too-high {
    border-left-color: #dc3545;
}

.history-item.too-low {
    border-left-color: #007bff;
}

.history-item.correct {
    border-left-color: #28a745;
    background: #d4edda;
}

.guess-number {
    font-weight: bold;
    font-size: 1.2em;
    color: #333;
}

.guess-result {
    font-size: 0.9em;
    color: #666;
}

/* 控制按钮 */
.controls {
    display: flex;
    gap: 10px;
    justify-content: center;
}

/* 响应式设计 */
@media (max-width: 600px) {
    .game-container {
        padding: 20px;
    }

    .header h1 {
        font-size: 1.5em;
    }

    .status-bar {
        flex-direction: column;
        gap: 10px;
    }

    .input-section {
        flex-direction: column;
    }

    .controls {
        flex-direction: column;
    }
}

/* 提交分数表单 */
.submit-score-container {
    margin-top: 20px;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.submit-score-form {
    display: flex;
    gap: 10px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
}

#playerNameInput {
    padding: 10px 15px;
    font-size: 1em;
    border: 2px solid #ddd;
    border-radius: 8px;
    outline: none;
    min-width: 200px;
}

#playerNameInput:focus {
    border-color: #667eea;
}

/* 排行榜遮罩层 */
.ranking-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* 排行榜弹窗 */
.ranking-modal {
    background: white;
    border-radius: 15px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: scaleIn 0.3s ease;
}

@keyframes scaleIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.ranking-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ranking-header h2 {
    margin: 0;
    font-size: 1.5em;
}

.close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 2em;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.3s;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* 排行榜列表 */
.ranking-list {
    padding: 20px;
    max-height: calc(80vh - 80px);
    overflow-y: auto;
}

.ranking-item {
    display: grid;
    grid-template-columns: 50px 1fr 80px 80px 100px;
    gap: 10px;
    align-items: center;
    padding: 12px;
    margin-bottom: 8px;
    background: #f8f9fa;
    border-radius: 8px;
    transition: transform 0.2s;
}

.ranking-item:hover {
    transform: translateX(5px);
    background: #e9ecef;
}

.ranking-item.top-three {
    background: linear-gradient(135deg, #fff9e6 0%, #fff3cd 100%);
    border-left: 4px solid #ffc107;
}

.rank {
    font-weight: bold;
    font-size: 1.2em;
    text-align: center;
}

.name {
    font-weight: 600;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.score {
    color: #667eea;
    font-weight: bold;
    text-align: center;
}

.attempts {
    color: #666;
    text-align: center;
    font-size: 0.9em;
}

.date {
    color: #999;
    font-size: 0.85em;
    text-align: right;
}

.empty-ranking {
    text-align: center;
    color: #999;
    padding: 40px;
    font-style: italic;
}
