/* 代码狗生存战 - 主样式 */

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

body {
    background: linear-gradient(135deg, #0f0f1a 0%, #1a1a2e 50%, #16213e 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    font-family: 'Microsoft YaHei', 'Segoe UI', sans-serif;
    overflow: hidden;
    color: #fff;
}

/* 游戏容器 */
#gameContainer {
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    border-radius: 16px;
}

/* 游戏画布 */
#gameCanvas {
    border-radius: 16px;
    background: #0a0a15;
    cursor: crosshair;
}

/* UI 面板 */
.ui-panel {
    position: absolute;
    background: rgba(20, 25, 40, 0.9);
    border: 1px solid rgba(100, 150, 255, 0.3);
    border-radius: 12px;
    padding: 12px 16px;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

/* 左上角状态面板 */
#statsPanel {
    top: 16px;
    left: 16px;
    min-width: 220px;
}

/* 血条 */
.stat-row {
    margin-bottom: 8px;
}

.stat-label {
    font-size: 12px;
    color: #8899aa;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.bar-container {
    height: 12px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 6px;
    overflow: hidden;
    position: relative;
}

.hp-bar {
    height: 100%;
    background: linear-gradient(90deg, #ff4444 0%, #ff6666 50%, #ff8888 100%);
    border-radius: 6px;
    transition: width 0.3s ease;
    position: relative;
}

.hp-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 40%;
    background: linear-gradient(180deg, rgba(255,255,255,0.3) 0%, transparent 100%);
    border-radius: 6px 6px 0 0;
}

.xp-bar {
    height: 100%;
    background: linear-gradient(90deg, #44ff88 0%, #66ffaa 50%, #88ffcc 100%);
    border-radius: 6px;
    transition: width 0.3s ease;
    position: relative;
}

.xp-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 40%;
    background: linear-gradient(180deg, rgba(255,255,255,0.3) 0%, transparent 100%);
    border-radius: 6px 6px 0 0;
}

/* 属性面板 */
#attrPanel {
    top: 16px;
    right: 16px;
    min-width: 140px;
}

.attr-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.attr-item {
    text-align: center;
    padding: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
}

.attr-icon {
    font-size: 18px;
    margin-bottom: 2px;
}

.attr-value {
    font-size: 16px;
    font-weight: bold;
    color: #ffdd44;
}

.attr-name {
    font-size: 10px;
    color: #667788;
}

/* 波次信息 */
#wavePanel {
    top: 50%;
    right: 16px;
    transform: translateY(-50%);
    text-align: center;
}

.wave-number {
    font-size: 32px;
    font-weight: bold;
    color: #ff6666;
    text-shadow: 0 0 20px rgba(255, 102, 102, 0.5);
}

.wave-label {
    font-size: 12px;
    color: #8899aa;
}

.enemy-count {
    margin-top: 12px;
    font-size: 14px;
    color: #ff8888;
}

/* 技能栏 */
#skillBar {
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    padding: 12px;
}

.skill-slot {
    width: 48px;
    height: 48px;
    background: rgba(0, 0, 0, 0.4);
    border: 2px solid rgba(100, 150, 255, 0.3);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    position: relative;
    transition: all 0.3s;
}

.skill-slot.active {
    border-color: #ffdd44;
    background: rgba(255, 221, 68, 0.1);
    box-shadow: 0 0 15px rgba(255, 221, 68, 0.3);
}

.skill-level {
    position: absolute;
    bottom: -4px;
    right: -4px;
    background: #ff4444;
    color: #fff;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: bold;
}

/* 屏幕遮罩 */
.screen-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 15, 30, 0.95);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-radius: 16px;
    backdrop-filter: blur(5px);
}

.screen-overlay.hidden {
    display: none;
}

/* 开始屏幕 */
#startScreen {
    background: linear-gradient(135deg, rgba(15, 20, 40, 0.98) 0%, rgba(25, 30, 60, 0.98) 100%);
}

.game-title {
    font-size: 56px;
    font-weight: bold;
    margin-bottom: 8px;
    background: linear-gradient(135deg, #ffdd44 0%, #ffaa22 50%, #ff6644 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 40px rgba(255, 221, 68, 0.3);
}

.game-subtitle {
    font-size: 18px;
    color: #8899aa;
    margin-bottom: 48px;
    letter-spacing: 2px;
}

/* 按钮样式 */
.btn {
    padding: 18px 48px;
    font-size: 20px;
    font-weight: bold;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-primary {
    background: linear-gradient(135deg, #ffdd44 0%, #ffaa22 100%);
    color: #1a1a2e;
    box-shadow: 0 8px 30px rgba(255, 221, 68, 0.4);
}

.btn-primary:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 12px 40px rgba(255, 221, 68, 0.5);
}

.btn-secondary {
    background: linear-gradient(135deg, #4488ff 0%, #2266dd 100%);
    color: #fff;
    box-shadow: 0 8px 30px rgba(68, 136, 255, 0.4);
}

.btn-secondary:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 12px 40px rgba(68, 136, 255, 0.5);
}

/* 控制说明 */
.controls-section {
    margin-top: 48px;
    display: flex;
    gap: 32px;
}

.control-item {
    text-align: center;
    padding: 16px 24px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.control-key {
    font-size: 14px;
    color: #ffdd44;
    font-weight: bold;
    margin-bottom: 4px;
}

.control-desc {
    font-size: 12px;
    color: #667788;
}

/* 升级屏幕 */
#levelUpScreen {
    background: rgba(10, 15, 30, 0.98);
}

.level-up-title {
    font-size: 36px;
    color: #ffdd44;
    margin-bottom: 8px;
    text-shadow: 0 0 30px rgba(255, 221, 68, 0.5);
}

.level-up-subtitle {
    font-size: 16px;
    color: #8899aa;
    margin-bottom: 40px;
}

.skills-container {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
    justify-content: center;
    max-width: 900px;
    padding: 0 40px;
}

.skill-card {
    width: 260px;
    padding: 24px;
    background: linear-gradient(135deg, rgba(40, 50, 80, 0.8) 0%, rgba(30, 40, 70, 0.8) 100%);
    border: 2px solid rgba(100, 150, 255, 0.3);
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.skill-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #ffdd44, #ff6644, #ffdd44);
    opacity: 0;
    transition: opacity 0.3s;
}

.skill-card:hover {
    transform: translateY(-8px) scale(1.02);
    border-color: #ffdd44;
    box-shadow: 0 20px 50px rgba(255, 221, 68, 0.2);
}

.skill-card:hover::before {
    opacity: 1;
}

.skill-card-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.skill-card-name {
    font-size: 18px;
    font-weight: bold;
    color: #fff;
    margin-bottom: 8px;
}

.skill-card-desc {
    font-size: 13px;
    color: #8899aa;
    margin-bottom: 12px;
    line-height: 1.5;
}

.skill-card-level {
    font-size: 12px;
    color: #44ff88;
    font-weight: bold;
}

/* 游戏结束屏幕 */
#gameOverScreen {
    background: rgba(20, 10, 15, 0.98);
}

.game-over-title {
    font-size: 52px;
    color: #ff4444;
    margin-bottom: 8px;
    text-shadow: 0 0 40px rgba(255, 68, 68, 0.5);
}

.game-over-subtitle {
    font-size: 16px;
    color: #ff8888;
    margin-bottom: 40px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 40px;
}

.stat-box {
    padding: 20px 32px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.stat-box-value {
    font-size: 32px;
    font-weight: bold;
    color: #ffdd44;
}

.stat-box-label {
    font-size: 12px;
    color: #667788;
    margin-top: 4px;
}

/* 浮动文字动画 */
@keyframes floatUp {
    0% {
        opacity: 1;
        transform: translateY(0);
    }
    100% {
        opacity: 0;
        transform: translateY(-40px);
    }
}

/* 粒子发光效果 */
@keyframes glow {
    0%, 100% {
        filter: brightness(1);
    }
    50% {
        filter: brightness(1.3);
    }
}

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

/* 暂停菜单 */
.pause-menu {
    display: flex;
    flex-direction: column;
    gap: 16px;
    align-items: center;
}

/* 设置面板 */
.settings-panel {
    background: rgba(30, 35, 50, 0.9);
    border-radius: 16px;
    padding: 24px 32px;
    min-width: 300px;
    border: 1px solid rgba(100, 150, 255, 0.2);
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.setting-item:last-child {
    border-bottom: none;
}

.setting-item span {
    font-size: 16px;
    color: #fff;
}

.toggle-btn {
    padding: 8px 20px;
    background: linear-gradient(135deg, #44ff88, #22cc66);
    border: none;
    border-radius: 20px;
    color: #fff;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    min-width: 80px;
}

.toggle-btn.off {
    background: linear-gradient(135deg, #ff4444, #cc3333);
}

.toggle-btn:hover {
    transform: scale(1.05);
}

/* 成就面板 */
.achievements-progress {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    width: 100%;
    max-width: 400px;
}

.progress-bar {
    flex: 1;
    height: 20px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 10px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #ffdd44, #ffaa22);
    border-radius: 10px;
    transition: width 0.5s ease;
}

.achievements-progress span {
    color: #ffdd44;
    font-weight: bold;
    font-size: 18px;
}

.achievements-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    max-width: 800px;
    max-height: 400px;
    overflow-y: auto;
    padding: 16px;
}

.achievement-item {
    background: rgba(40, 50, 70, 0.6);
    border: 2px solid rgba(100, 150, 255, 0.2);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.3s;
}

.achievement-item.unlocked {
    border-color: #ffdd44;
    background: rgba(255, 221, 68, 0.1);
}

.achievement-item.locked {
    opacity: 0.5;
    filter: grayscale(0.5);
}

.achievement-item .icon {
    font-size: 32px;
}

.achievement-item .info {
    flex: 1;
}

.achievement-item .name {
    font-weight: bold;
    color: #fff;
    margin-bottom: 4px;
}

.achievement-item .desc {
    font-size: 12px;
    color: #8899aa;
}

/* 成就通知 */
.achievement-notification {
    font-family: 'Microsoft YaHei', sans-serif;
}

.achievement-notification .achievement-icon {
    font-size: 48px;
}

.achievement-notification .achievement-title {
    font-size: 14px;
    color: #884400;
    font-weight: bold;
}

.achievement-notification .achievement-name {
    font-size: 20px;
    font-weight: bold;
    margin: 4px 0;
}

.achievement-notification .achievement-desc {
    font-size: 12px;
    color: #666;
}

/* 选择区域 */
.selection-section {
    margin: 20px 0;
    text-align: center;
}

.selection-section h3 {
    color: #ffdd44;
    margin-bottom: 15px;
    font-size: 18px;
}

.character-grid, .map-grid {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.character-card, .map-card {
    width: 120px;
    padding: 15px;
    background: rgba(40, 50, 80, 0.6);
    border: 2px solid rgba(100, 150, 255, 0.3);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
}

.character-card:hover, .map-card:hover {
    transform: scale(1.05);
    border-color: #ffdd44;
}

.character-card.selected, .map-card.selected {
    border-color: #ffdd44;
    background: rgba(255, 221, 68, 0.2);
    box-shadow: 0 0 20px rgba(255, 221, 68, 0.3);
}

.character-card .emoji, .map-card .emoji {
    font-size: 40px;
    margin-bottom: 8px;
}

.character-card .name, .map-card .name {
    font-size: 14px;
    font-weight: bold;
    color: #fff;
    margin-bottom: 4px;
}

.character-card .desc, .map-card .desc {
    font-size: 11px;
    color: #8899aa;
}

/* 排行榜 */
.leaderboard-list {
    background: rgba(30, 35, 50, 0.9);
    border-radius: 12px;
    padding: 20px;
    min-width: 400px;
    max-height: 400px;
    overflow-y: auto;
}

.leaderboard-entry {
    display: flex;
    align-items: center;
    padding: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    gap: 15px;
}

.leaderboard-entry:last-child {
    border-bottom: none;
}

.leaderboard-rank {
    font-size: 24px;
    font-weight: bold;
    color: #ffdd44;
    width: 40px;
}

.leaderboard-rank.top3 {
    color: #ff4444;
}

.leaderboard-info {
    flex: 1;
}

.leaderboard-name {
    font-size: 16px;
    font-weight: bold;
    color: #fff;
}

.leaderboard-stats {
    font-size: 12px;
    color: #8899aa;
    margin-top: 4px;
}

.leaderboard-date {
    font-size: 11px;
    color: #667788;
}

/* 闪烁动画 */
@keyframes flash {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* 技能选择倒计时 */
.skill-timer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: #ff4444;
    transform-origin: left;
    animation: timer 10s linear forwards;
}

@keyframes timer {
    from {
        transform: scaleX(1);
    }
    to {
        transform: scaleX(0);
    }
}

/* 响应式 - 平板 */
@media (max-width: 1024px) {
    #gameCanvas {
        width: 100vw;
        height: 100vh;
    }
    
    #gameContainer {
        width: 100vw;
        height: 100vh;
        border-radius: 0;
    }
    
    .game-title {
        font-size: 42px;
    }
    
    .skills-container {
        flex-direction: column;
        align-items: center;
        max-height: 70vh;
        overflow-y: auto;
    }
}

/* 响应式 - 手机 */
@media (max-width: 768px) {
    body {
        overflow: hidden;
        touch-action: none;
    }
    
    #gameCanvas {
        width: 100vw !important;
        height: 100vh !important;
        border-radius: 0;
    }
    
    #gameContainer {
        width: 100vw;
        height: 100vh;
        border-radius: 0;
        box-shadow: none;
    }
    
    .ui-panel {
        font-size: 11px;
        padding: 8px 10px;
        border-radius: 8px;
    }
    
    #statsPanel {
        top: 8px;
        left: 8px;
        min-width: 120px;
    }
    
    .bar-container {
        height: 8px;
    }
    
    #attrPanel {
        top: 8px;
        right: 8px;
        min-width: 80px;
    }
    
    .attr-grid {
        gap: 4px;
    }
    
    .attr-item {
        padding: 4px;
    }
    
    .attr-icon {
        font-size: 14px;
    }
    
    .attr-value {
        font-size: 12px;
    }
    
    #wavePanel {
        top: auto;
        bottom: 180px;
        right: 8px;
        transform: none;
    }
    
    .wave-number {
        font-size: 24px;
    }
    
    #skillBar {
        bottom: 180px;
        left: 8px;
        right: auto;
        transform: none;
        gap: 4px;
        padding: 6px;
    }
    
    .skill-slot {
        width: 32px;
        height: 32px;
        font-size: 16px;
        border-radius: 6px;
    }
    
    .skill-level {
        font-size: 8px;
        padding: 1px 3px;
    }
    
    .game-title {
        font-size: 28px;
    }
    
    .game-subtitle {
        font-size: 14px;
    }
    
    .controls-section {
        flex-direction: column;
        gap: 12px;
        margin-top: 24px;
    }
    
    .control-item {
        padding: 12px 16px;
    }
    
    .btn {
        padding: 14px 32px;
        font-size: 16px;
    }
    
    .skills-container {
        flex-direction: column;
        gap: 12px;
        padding: 0 20px;
        max-height: 60vh;
        overflow-y: auto;
    }
    
    .skill-card {
        width: 100%;
        max-width: 300px;
        padding: 16px;
    }
    
    .skill-card-icon {
        font-size: 36px;
    }
    
    .skill-card-name {
        font-size: 16px;
    }
    
    .stat-box {
        padding: 12px 20px;
    }
    
    .stat-box-value {
        font-size: 24px;
    }
    
    .game-over-title {
        font-size: 36px;
    }
    
    .stats-grid {
        gap: 12px;
    }
}

/* 横屏模式 */
@media (max-width: 768px) and (orientation: landscape) {
    #statsPanel {
        top: 8px;
        left: 8px;
    }
    
    #attrPanel {
        display: none;
    }
    
    #wavePanel {
        top: 8px;
        right: 8px;
        bottom: auto;
    }
    
    #skillBar {
        bottom: 20px;
        left: 50%;
        transform: translateX(-50%);
    }
}

/* 防止触摸高亮 */
* {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    user-select: none;
}

/* 禁用文本选择 */
body {
    user-select: none;
    -webkit-user-select: none;
}
