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

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #0f2027 0%, #203a43 50%, #2c5364 100%);
    color: #e0f7fa;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    background-attachment: fixed;
}

/* 游戏容器 */
.game-container {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    padding: 30px;
    max-width: 800px;
    width: 100%;
    text-align: center;
    transition: all 0.3s ease;
    position: relative;
}

.game-container:hover {
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

h1 {
    color: #81d4fa;
    margin-bottom: 20px;
    font-size: 2.5em;
    text-shadow: 0 0 10px rgba(129, 212, 250, 0.5);
    background: linear-gradient(45deg, #81d4fa, #4fc3f7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* 游戏信息显示 */
.game-info-container {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
    gap: 20px;
    padding-right: 150px; /* 为计时器预留空间 */
}

.game-info {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
    background: rgba(129, 212, 250, 0.1);
    padding: 15px;
    border-radius: 15px;
    border: 1px solid rgba(129, 212, 250, 0.2);
    backdrop-filter: blur(5px);
    flex: 1;
}

/* 计时器样式 */
.timer-container {
    display: flex;
    justify-content: center;
    align-items: center;
    position: absolute;
    top: 20px;
    right: 20px;
    cursor: move;
    user-select: none;
    z-index: 10;
    width: auto;
    height: auto;
}

.timer-box {
    background: rgba(129, 212, 250, 0.15);
    border: 1px solid rgba(129, 212, 250, 0.3);
    border-radius: 10px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 15px rgba(129, 212, 250, 0.2);
    min-width: 120px;
}

.timer {
    font-size: 1.2em;
    font-weight: bold;
    color: #81d4fa;
    text-shadow: 0 0 6px rgba(129, 212, 250, 0.5);
    font-family: 'Courier New', monospace;
}

.timer-controls {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.timer-btn {
    padding: 8px 12px;
    border: 2px solid rgba(129, 212, 250, 0.3);
    border-radius: 12px;
    font-size: 0.9em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    background: rgba(129, 212, 250, 0.1);
    color: #81d4fa;
    backdrop-filter: blur(5px);
    text-shadow: 0 0 5px rgba(129, 212, 250, 0.3);
    box-shadow: 0 4px 15px rgba(129, 212, 250, 0.2);
    width: auto;
    height: auto;
    min-width: 40px;
}

.timer-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    box-shadow: none;
}

.timer-btn.start-pause:hover:not(:disabled) {
    background: rgba(76, 175, 80, 0.2);
    border-color: rgba(76, 175, 80, 0.5);
    color: #4caf50;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.3);
    text-shadow: 0 0 8px rgba(76, 175, 80, 0.5);
}

.timer-btn.reset:hover:not(:disabled) {
    background: rgba(233, 30, 99, 0.2);
    border-color: rgba(233, 30, 99, 0.5);
    color: #e91e63;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(233, 30, 99, 0.3);
    text-shadow: 0 0 8px rgba(233, 30, 99, 0.5);
}

.timer-btn:active {
    transform: translateY(0);
    animation: pulse 0.2s ease;
}

.timer-btn.start {
    order: 1;
}

.timer-btn.pause {
    order: 2;
}

.timer-btn.reset {
    order: 3;
}

.info-item {
    margin: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.info-item .label {
    font-size: 0.9em;
    color: #b3e5fc;
    margin-bottom: 5px;
    text-shadow: 0 0 5px rgba(179, 229, 252, 0.3);
}

.info-item span:not(.label) {
    font-size: 1.3em;
    font-weight: bold;
    color: #81d4fa;
    text-shadow: 0 0 8px rgba(129, 212, 250, 0.5);
}

/* 画布容器 */
.canvas-container {
    position: relative;
    margin: 20px auto;
    width: 600px;
    height: 600px;
    border: 2px solid rgba(129, 212, 250, 0.3);
    border-radius: 15px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(5px);
    box-shadow: inset 0 0 20px rgba(129, 212, 250, 0.1);
}

#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(15, 32, 39, 0.8) 0%, rgba(32, 58, 67, 0.8) 100%);
}

/* 控制面板 */
.control-panel {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin: 25px 0;
    flex-wrap: wrap;
}

.control-btn {
    padding: 12px 25px;
    border: 2px solid rgba(129, 212, 250, 0.3);
    border-radius: 12px;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 120px;
    background: rgba(129, 212, 250, 0.1);
    color: #81d4fa;
    backdrop-filter: blur(5px);
    text-shadow: 0 0 5px rgba(129, 212, 250, 0.3);
    box-shadow: 0 4px 15px rgba(129, 212, 250, 0.2);
}

.control-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    box-shadow: none;
}

.control-btn.start:hover:not(:disabled) {
    background: rgba(76, 175, 80, 0.2);
    border-color: rgba(76, 175, 80, 0.5);
    color: #4caf50;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.3);
    text-shadow: 0 0 8px rgba(76, 175, 80, 0.5);
}

.control-btn.pause:hover:not(:disabled) {
    background: rgba(255, 152, 0, 0.2);
    border-color: rgba(255, 152, 0, 0.5);
    color: #ff9800;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 152, 0, 0.3);
    text-shadow: 0 0 8px rgba(255, 152, 0, 0.5);
}

.control-btn.restart:hover:not(:disabled) {
    background: rgba(233, 30, 99, 0.2);
    border-color: rgba(233, 30, 99, 0.5);
    color: #e91e63;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(233, 30, 99, 0.3);
    text-shadow: 0 0 8px rgba(233, 30, 99, 0.5);
}

.control-btn.settings:hover:not(:disabled) {
    background: rgba(156, 39, 176, 0.2);
    border-color: rgba(156, 39, 176, 0.5);
    color: #9c27b0;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(156, 39, 176, 0.3);
    text-shadow: 0 0 8px rgba(156, 39, 176, 0.5);
}

/* 按键提示 */
.key-hints {
    display: flex;
    justify-content: center;
    gap: 25px;
    margin: 20px 0;
    flex-wrap: wrap;
}

.hint-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.key {
    display: inline-block;
    width: 55px;
    height: 55px;
    background: rgba(129, 212, 250, 0.15);
    border: 2px solid rgba(129, 212, 250, 0.4);
    border-radius: 10px;
    font-size: 1.3em;
    font-weight: bold;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 8px;
    box-shadow: 0 4px 12px rgba(129, 212, 250, 0.25);
    color: #81d4fa;
    text-shadow: 0 0 8px rgba(129, 212, 250, 0.5);
    backdrop-filter: blur(5px);
    transition: all 0.3s ease;
}

.key:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(129, 212, 250, 0.4);
    border-color: rgba(129, 212, 250, 0.6);
}

.hint {
    font-size: 0.9em;
    color: #b3e5fc;
    text-shadow: 0 0 5px rgba(179, 229, 252, 0.3);
}

/* 游戏结束统计 */
.game-stats {
    background: rgba(129, 212, 250, 0.1);
    padding: 25px;
    border-radius: 15px;
    margin-top: 20px;
    transition: all 0.3s ease;
    border: 1px solid rgba(129, 212, 250, 0.2);
    backdrop-filter: blur(5px);
    box-shadow: 0 8px 25px rgba(129, 212, 250, 0.15);
}

.game-stats h2 {
    color: #81d4fa;
    margin-bottom: 20px;
    text-shadow: 0 0 8px rgba(129, 212, 250, 0.5);
    background: linear-gradient(45deg, #81d4fa, #4fc3f7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
    min-height: 250px;
    align-content: start;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-label {
    font-size: 0.9em;
    color: #b3e5fc;
    margin-bottom: 5px;
    text-shadow: 0 0 5px rgba(179, 229, 252, 0.3);
}

.stat-item span:not(.stat-label) {
    font-size: 1.5em;
    font-weight: bold;
    color: #81d4fa;
    text-shadow: 0 0 8px rgba(129, 212, 250, 0.5);
}

/* 成绩参考值样式 */
.score-reference {
    background: rgba(129, 212, 250, 0.08);
    border: 1px solid rgba(129, 212, 250, 0.3);
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 20px;
    text-align: center;
}

.reference-title {
    font-size: 1em;
    color: #81d4fa;
    margin-bottom: 10px;
    font-weight: bold;
    text-shadow: 0 0 5px rgba(129, 212, 250, 0.5);
}

.reference-content {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    font-size: 0.85em;
    color: #e1f5fe;
    max-width: 350px;
    margin: 0 auto;
}

.reference-item {
    background: rgba(129, 212, 250, 0.12);
    padding: 8px 12px;
    border-radius: 15px;
    border: 1px solid rgba(129, 212, 250, 0.25);
    text-shadow: 0 0 5px rgba(129, 212, 250, 0.4);
    box-shadow: 0 2px 5px rgba(129, 212, 250, 0.15);
    text-align: center;
}

/* 移除遮罩层，解决滚动和点击问题 */
.overlay {
    display: none;
}

/* 设置面板和历史记录面板通用样式 - 彻底优化 */
.settings-panel,
.history-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    /* 使用纯色背景，彻底解决模糊问题 */
    background: #0f2027;
    /* 移除所有模糊效果 */
    border: 2px solid #81d4fa;
    border-radius: 15px;
    box-shadow: 0 15px 50px rgba(129, 212, 250, 0.3);
    padding: 0;
    width: 90%;
    max-width: 600px;
    z-index: 100;
    transition: all 0.3s ease;
    /* 固定高度，确保内部滚动正常工作 */
    height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    /* 确保面板可以接收点击事件 */
    pointer-events: auto;
}

.settings-header {
    background: rgba(129, 212, 250, 0.2);
    color: #81d4fa;
    padding: 15px 20px;
    border-radius: 15px 15px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(129, 212, 250, 0.2);
}

.settings-header h2 {
    margin: 0;
    font-size: 1.3em;
    text-shadow: 0 0 8px rgba(129, 212, 250, 0.5);
    background: linear-gradient(45deg, #81d4fa, #4fc3f7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.close-btn {
    background: none;
    border: none;
    color: #81d4fa;
    font-size: 1.5em;
    cursor: pointer;
    font-weight: bold;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 50%;
    transition: all 0.3s ease;
    text-shadow: 0 0 8px rgba(129, 212, 250, 0.5);
}

.close-btn:hover {
    background-color: rgba(129, 212, 250, 0.2);
    transform: rotate(90deg);
}

/* 历史记录面板样式 */
.history-header {
    background: rgba(129, 212, 250, 0.2);
    color: #81d4fa;
    padding: 15px 20px;
    border-radius: 15px 15px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(129, 212, 250, 0.2);
    /* 固定头部，确保滚动时始终可见 */
    flex-shrink: 0;
}

.history-header h2 {
    margin: 0;
    font-size: 1.3em;
    text-shadow: 0 0 8px rgba(129, 212, 250, 0.5);
    background: linear-gradient(45deg, #81d4fa, #4fc3f7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.history-content {
    padding: 20px;
    overflow-y: auto;
    /* 允许内部内容滚动 */
    flex: 1;
    /* 确保内容区域可以滚动 */
    overflow-y: auto;
    /* 自定义滚动条 */
    scrollbar-width: thin;
    scrollbar-color: rgba(129, 212, 250, 0.5) rgba(0, 0, 0, 0.2);
}

/* 自定义滚动条样式 */
.history-content::-webkit-scrollbar {
    width: 8px;
}

.history-content::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

.history-content::-webkit-scrollbar-thumb {
    background: rgba(129, 212, 250, 0.5);
    border-radius: 4px;
}

.history-content::-webkit-scrollbar-thumb:hover {
    background: rgba(129, 212, 250, 0.7);
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.history-item {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(129, 212, 250, 0.2);
    border-radius: 10px;
    padding: 15px;
    backdrop-filter: blur(5px);
    transition: all 0.3s ease;
}

.history-item:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(129, 212, 250, 0.4);
    box-shadow: 0 4px 15px rgba(129, 212, 250, 0.15);
}

.history-date {
    font-size: 1.1em;
    font-weight: bold;
    color: #81d4fa;
    margin-bottom: 10px;
    text-shadow: 0 0 5px rgba(129, 212, 250, 0.3);
}

.history-session {
    margin-left: 20px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    margin-bottom: 8px;
    border-left: 3px solid rgba(129, 212, 250, 0.5);
}

.history-session:last-child {
    margin-bottom: 0;
}

.history-session-info {
    font-size: 0.95em;
    color: #b3e5fc;
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

.history-session-info span {
    text-shadow: 0 0 3px rgba(179, 229, 252, 0.3);
}

.history-session-label {
    font-weight: bold;
    color: #81d4fa;
}

/* 查看历史记录按钮样式 */
.control-btn.history {
    background: rgba(156, 39, 176, 0.2);
    border-color: rgba(156, 39, 176, 0.3);
    color: #9c27b0;
    box-shadow: 0 4px 15px rgba(156, 39, 176, 0.2);
}

.control-btn.history:hover:not(:disabled) {
    background: rgba(156, 39, 176, 0.3);
    border-color: rgba(156, 39, 176, 0.5);
    color: #ba68c8;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(156, 39, 176, 0.3);
    text-shadow: 0 0 8px rgba(156, 39, 176, 0.5);
}

.settings-content {
    padding: 25px;
    overflow-y: auto;
    flex: 1;
    /* 自定义滚动条 */
    scrollbar-width: thin;
    scrollbar-color: rgba(129, 212, 250, 0.5) rgba(0, 0, 0, 0.2);
}

/* 为设置面板添加滚动条样式 */
.settings-content::-webkit-scrollbar {
    width: 8px;
}

.settings-content::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

.settings-content::-webkit-scrollbar-thumb {
    background: rgba(129, 212, 250, 0.5);
    border-radius: 4px;
}

.settings-content::-webkit-scrollbar-thumb:hover {
    background: rgba(129, 212, 250, 0.7);
}

.setting-group {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.setting-group label {
    margin-bottom: 8px;
    font-weight: bold;
    color: #81d4fa;
    text-shadow: 0 0 5px rgba(129, 212, 250, 0.3);
}

.setting-group select,
.setting-group input {
    width: 100%;
    padding: 10px;
    border: 1px solid rgba(129, 212, 250, 0.3);
    border-radius: 8px;
    font-size: 1em;
    background: rgba(255, 255, 255, 0.05);
    color: #81d4fa;
    backdrop-filter: blur(5px);
    transition: all 0.3s ease;
}

.setting-group select:focus,
.setting-group input:focus {
    outline: none;
    border-color: rgba(129, 212, 250, 0.6);
    box-shadow: 0 0 10px rgba(129, 212, 250, 0.3);
    background: rgba(255, 255, 255, 0.1);
}

.setting-group input[type="number"] {
    -moz-appearance: textfield;
}

.setting-group input[type="number"]::-webkit-outer-spin-button,
.setting-group input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* 隐藏类 */
.hidden {
    display: none !important;
}

/* 遮罩层 */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 99;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .game-container {
        padding: 20px;
        margin: 10px;
    }
    
    h1 {
        font-size: 2em;
    }
    
    .canvas-container {
        width: 100%;
        height: auto;
        aspect-ratio: 1;
    }
    
    #gameCanvas {
        width: 100%;
        height: 100%;
    }
    
    .control-panel {
        flex-direction: column;
        align-items: center;
    }
    
    .control-btn {
        width: 200px;
    }
    
    .key-hints {
        gap: 15px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .game-info {
        flex-direction: column;
        gap: 10px;
    }
    
    .info-item {
        flex-direction: row;
        justify-content: space-between;
        width: 100%;
    }
}

/* 动画效果 */
@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

.control-btn:not(:disabled):active {
    transform: translateY(0);
    animation: pulse 0.2s ease;
}