@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700&display=swap');

body {
    margin: 0;
    overflow: hidden;
    background-color: #050010; /* 深紫色背景 */
    color: #fff;
    font-family: 'Orbitron', sans-serif; /* 赛博朋克字体 */
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
}

/* 新增：等级预览按钮样式 */
.level-btn {
    flex: 1;
    background: #222;
    border: 1px solid #444;
    color: #888;
    padding: 5px;
    cursor: pointer;
    border-radius: 4px;
    font-size: 12px;
}

.level-btn.active {
    background: #00d2ff;
    color: #000;
    border-color: #00d2ff;
    font-weight: bold;
}

.level-btn.owned {
    background: rgba(0, 210, 255, 0.2);
    border-color: #00d2ff;
    color: #fff;
}

.level-btn:hover {
    background: #444;
}

.level-btn.active:hover {
    background: #00b0e0;
}

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 800px; /* 稍微放宽一点适应宽屏 */
    max-height: 800px; /* 防止在超高屏幕上变形 */
    aspect-ratio: 3/4; /* 保持纵向比例 */
    box-shadow: 0 0 30px #d500f9, 0 0 10px #00e5ff; /* 霓虹光晕 */
    border: 2px solid #d500f9;
    background-color: #000; /* 确保有底色 */
    overflow: hidden; /* 防止内容溢出 */
}

canvas {
    background-color: #000;
    display: block;
    width: 100%;
    height: 100%;
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    padding: 20px;
    box-sizing: border-box;
}

/* 关键修复：让 ui-layer 内部的按钮和交互元素能够接收点击 */
#ui-layer button, 
#ui-layer .switch, 
#ui-layer input {
    pointer-events: auto;
}

#score-board {
    font-size: 24px;
    font-weight: bold;
    color: #00e5ff;
    text-shadow: 0 0 10px #00e5ff;
}

.player-status {
    position: absolute;
    bottom: 20px;
    font-size: 18px;
    text-shadow: 0 0 5px #fff;
}

#p1-status {
    left: 20px;
    color: #00e5ff; /* Cyan */
}

#p2-status {
    right: 20px;
    color: #ff00ff; /* Magenta */
    text-align: right;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(5, 0, 16, 0.95); /* 加深背景不透明度，防止透视 */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 50; /* 提高层级 */
    backdrop-filter: blur(10px); /* 增强模糊 */
    pointer-events: auto; /* 确保能接收点击事件 */
}

.screen h1 {
    font-size: 80px;
    margin-bottom: 30px;
    font-family: "Arial Black", "Orbitron", sans-serif;
    font-weight: 900;
    letter-spacing: 8px;
    text-transform: uppercase;
    
    /* 渐变填充 */
    background: linear-gradient(180deg, #ffffff 0%, #00e5ff 45%, #d500f9 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
    
    /* 霓虹发光与投影 */
    filter: drop-shadow(0 0 10px rgba(0, 229, 255, 0.5))
            drop-shadow(0 0 20px rgba(213, 0, 249, 0.3));
    
    transform: skew(-10deg);
    
    /* 呼吸动画 */
    animation: titlePulse 2s ease-in-out infinite alternate;
}

@keyframes titlePulse {
    from {
        filter: drop-shadow(0 0 10px rgba(0, 229, 255, 0.5))
                drop-shadow(0 0 20px rgba(213, 0, 249, 0.3));
        transform: skew(-10deg) scale(1);
    }
    to {
        filter: drop-shadow(0 0 20px rgba(0, 229, 255, 0.8))
                drop-shadow(0 0 40px rgba(213, 0, 249, 0.6));
        transform: skew(-10deg) scale(1.05);
    }
}

button {
    padding: 15px 40px;
    font-size: 20px;
    font-family: 'Orbitron', sans-serif;
    cursor: pointer;
    background: linear-gradient(45deg, #d500f9, #651fff);
    border: none;
    color: #fff;
    border-radius: 5px;
    box-shadow: 0 0 15px rgba(213, 0, 249, 0.6);
    transition: all 0.3s;
    text-transform: uppercase;
    letter-spacing: 2px;
    position: relative;
    overflow: hidden;
}

button:hover {
    transform: scale(1.05);
    box-shadow: 0 0 25px rgba(213, 0, 249, 0.9);
}

button:active {
    transform: scale(0.95);
}

.hidden {
    display: none !important;
}

/* 进度条霓虹化 */
#stage-info {
    text-shadow: 0 0 10px #ffd700, 0 0 20px #ff6d00;
}
#stage-progress {
    background: #00e5ff !important;
    box-shadow: 0 0 10px #00e5ff;
}

/* 登录界面光束特效 */
.login-bg-rays {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 200%;
    height: 200%;
    background: repeating-conic-gradient(
        from 0deg,
        rgba(0, 210, 255, 0.05) 0deg,
        rgba(0, 210, 255, 0) 10deg,
        rgba(0, 210, 255, 0.05) 20deg
    );
    animation: rotateRays 60s linear infinite;
    z-index: 0;
    pointer-events: none;
}

@keyframes rotateRays {
    from { transform: translate(-50%, -50%) rotate(0deg); }
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* 按钮样式微调 */
#start-btn { margin-top: 20px; }
#surrender-btn {
    pointer-events: auto;
    background: rgba(255, 0, 0, 0.3);
    border: 1px solid #ff0000;
    padding: 5px 10px;
    font-size: 14px;
    margin-top: 5px;
    color: #ff4d4d;
    box-shadow: none;
}
#surrender-btn:hover {
    background: rgba(255, 0, 0, 0.6);
    box-shadow: 0 0 10px #ff0000;
}

/* 开关按钮样式 */
.switch {
    position: relative;
    display: inline-block;
    width: 80px;
    height: 34px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #0f2a4a;
    transition: .4s;
    border: 1px solid #00d2ff;
    box-shadow: inset 0 0 10px #000;
}

.slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 3px;
    background-color: #555;
    transition: .4s;
    box-shadow: 0 0 5px #000;
}

input:checked + .slider {
    background-color: #0077ff;
}

input:checked + .slider:before {
    transform: translateX(46px);
    background-color: #fff;
    box-shadow: 0 0 10px #fff;
}

/* 圆形滑块 */
.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

/* 文字标签 */
.on-text, .off-text {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 14px;
    font-weight: bold;
    color: #fff;
}

.on-text {
    left: 10px;
    opacity: 0;
    transition: opacity 0.4s;
}

.off-text {
    right: 10px;
    opacity: 1;
    transition: opacity 0.4s;
}

input:checked + .slider .on-text {
    opacity: 1;
}

input:checked + .slider .off-text {
    opacity: 0;
}

/* 勋章面板 */
#achievement-panel {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%; /* 宽度占满 */
    max-width: 100%; /* 移除最大宽度限制 */
    height: 100%; /* 占满高度 */
    max-height: 100%; /* 防止高度溢出 */
    background: rgba(10, 10, 20, 0.95);
    border: 2px solid #ffd700;
    border-left: none; /* 移除左右边框，增强贴合感 */
    border-right: none;
    border-radius: 0; /* 移除圆角 */
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.8);
    z-index: 100; /* 确保在最上层 */
    pointer-events: auto; /* 关键修复：允许面板交互 */
    overflow: hidden; /* 防止整体溢出 */
    box-sizing: border-box; /* 确保 padding 不会撑破宽度 */
}

#badge-list {
    display: block; /* 彻底放弃 Flex，改用 Block 布局 */
    width: 100%;
    margin-bottom: 20px;
    flex: 1; /* 占据剩余空间 */
    min-height: 0; 
    overflow-y: auto; /* 允许滚动 */
    padding: 10px;
    box-sizing: border-box;
}

/* 勋章列表样式重构 */
.badge {
    position: relative;
    display: flex;
    flex-direction: row; 
    align-items: center;
    justify-content: flex-start; /* 左对齐 */
    width: 100%;
    max-width: 600px;
    height: auto;
    min-height: 80px;
    margin: 0 auto 15px auto; /* 居中并添加底部间距 */
    padding: 15px 20px;
    border-radius: 12px;
    
    /* 修改边框颜色为黄色，与用户需求一致 */
    border: 2px solid #ffd700; 
    
    background-color: rgba(30, 30, 40, 0.6); 
    background-image: none !important;
    cursor: default;
    transition: all 0.3s ease;
    overflow: visible !important;
    box-sizing: border-box;
}

.badge:last-child {
    margin-bottom: 0; /* 最后一个不需要底部间距 */
}

/* 已解锁状态 - 保持黄色边框，增加发光 */
.badge.unlocked {
    background-color: rgba(0, 50, 80, 0.6);
    border-color: #ffd700; /* 保持黄色 */
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
}

.badge:hover {
    transform: translateX(5px) scale(1.02); /* 增强悬停效果 */
    border-color: #ffd700; /* 悬停也保持黄色 */
    background-color: rgba(40, 40, 60, 0.9);
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.5); /* 黄色光晕 */
    z-index: 10;
}

/* 勋章图标 */
.badge-icon {
    font-size: 32px;
    margin-right: 20px;
    width: 50px; /* 固定宽度 */
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.3);
    border-radius: 50%;
    flex-shrink: 0; /* 防止图标被压缩 */
}

/* 勋章名称 */
.badge-name {
    display: none; 
}

/* 详情内容块 */
.badge-tooltip {
    visibility: visible !important;
    opacity: 1 !important;
    position: static !important;
    width: auto !important;
    flex: 1; /* 占据剩余空间 */
    background: none !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    transform: none !important;
    pointer-events: auto !important;
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-align: left;
    min-width: 0; /* 允许文本截断 */
}

.tooltip-title {
    font-size: 18px;
    font-weight: bold;
    color: #fff; /* 默认白色 */
    margin-bottom: 4px;
    border-bottom: none;
    padding-bottom: 0;
    white-space: nowrap; /* 标题不换行 */
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 解锁后的标题颜色 */
.badge.unlocked .tooltip-title {
    color: #00d2ff;
    text-shadow: 0 0 10px rgba(0, 210, 255, 0.5);
}

.tooltip-desc {
    font-size: 14px;
    color: #aaa;
    margin-bottom: 4px;
    line-height: 1.4;
}

.tooltip-status {
    text-align: left;
    font-size: 12px;
    margin-top: -2px; /* 向上移动一点 */
    font-weight: normal;
    opacity: 0.8;
}

.status-unlocked {
    color: #00ff00;
}

.status-locked {
    color: #ff0000;
}
