@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    height: 100%;
    overflow: hidden;
    position: fixed;
    width: 100%;
}

body {
    font-family: 'Press Start 2P', cursive;
    background: #1a1a1a;
    color: #fff;
    height: 100%;
    width: 100%;
    overflow: hidden;
    position: fixed;
    top: 0;
    left: 0;
}

/* 顶部栏：Logo和信息合并 */
.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: rgba(0, 0, 0, 0.95);
    border-bottom: 4px solid #fff;
    box-shadow: 
        0 0 0 4px #000,
        0 6px 0 rgba(0, 0, 0, 0.5);
    image-rendering: pixelated;
    min-height: 50px;
}

.logo h1 {
    font-size: clamp(14px, 2.2vw, 20px);
    letter-spacing: 3px;
    color: #fff;
    text-shadow: 
        2px 2px 0px #000,
        4px 4px 0px rgba(0, 0, 0, 0.5);
    margin: 0;
    padding: 5px 0;
}

.info-panel {
    display: flex;
    gap: 24px;
    align-items: center;
}

.info-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.info-label {
    font-size: 9px;
    color: #aaa;
    text-transform: uppercase;
}

.info-value {
    font-size: 14px;
    color: #fff;
    text-shadow: 
        1px 1px 0px #000,
        2px 2px 0px rgba(0, 0, 0, 0.5);
}

/* 游戏主区域 */
.game-main {
    width: 100vw;
    height: 100vh;
    height: 100dvh; /* 动态视口高度，考虑移动端地址栏 */
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    position: relative;
    overflow: hidden;
}

.game-container {
    position: relative;
    display: inline-block;
    margin: 0 auto;
}

#gameCanvas {
    display: block;
    background: #fff;
    border: 2px solid #000;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

/* 像素风格摇杆 */
.joystick-container {
    position: fixed;
    z-index: 1000;
    display: none !important;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.1s;
}

.joystick-container.active {
    display: block !important;
    opacity: 1;
}

.joystick-base {
    width: 120px;
    height: 120px;
    background: rgba(0, 0, 0, 0.8);
    border: 4px solid #fff;
    position: relative;
    box-shadow: 
        0 0 0 4px #000,
        inset 0 0 0 2px #000;
    image-rendering: pixelated;
    pointer-events: auto;
}

.joystick-base::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        linear-gradient(to right, #fff 0%, #fff 4px, transparent 4px),
        linear-gradient(to bottom, #fff 0%, #fff 4px, transparent 4px),
        linear-gradient(to left, #fff 0%, #fff 4px, transparent 4px),
        linear-gradient(to top, #fff 0%, #fff 4px, transparent 4px);
    pointer-events: none;
}

.joystick-stick {
    width: 48px;
    height: 48px;
    background: #fff;
    border: 3px solid #000;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: transform 0.05s;
    box-shadow: 
        0 0 0 3px #000,
        inset 2px 2px 0px rgba(255, 255, 255, 0.5),
        inset -2px -2px 0px rgba(0, 0, 0, 0.3);
    image-rendering: pixelated;
}

.joystick-stick.active {
    box-shadow: 
        0 0 0 3px #000,
        inset 1px 1px 0px rgba(255, 255, 255, 0.5),
        inset -1px -1px 0px rgba(0, 0, 0, 0.3);
}

/* 响应式设计 */
@media (max-width: 768px) {
    .top-bar {
        padding: 12px 15px;
        min-height: 45px;
    }
    
    .logo h1 {
        font-size: 11px;
        letter-spacing: 2px;
    }
    
    .info-panel {
        gap: 16px;
    }
    
    .info-item {
        gap: 6px;
    }
    
    .info-label {
        font-size: 7px;
    }
    
    .info-value {
        font-size: 11px;
    }
    
    .game-main {
        padding: 0;
    }
    
    .game-container {
        padding: 6px;
        border-width: 3px;
    }
    
    /* 摇杆在移动端可用，但默认隐藏，只在触摸时显示 */
    
    .joystick-base {
        width: 100px;
        height: 100px;
    }
    
    .joystick-stick {
        width: 40px;
        height: 40px;
    }
}

@media (max-width: 480px) {
    .top-bar {
        padding: 10px 12px;
        min-height: 40px;
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .logo h1 {
        font-size: 10px;
        letter-spacing: 1px;
    }
    
    .info-panel {
        gap: 10px;
        flex-wrap: wrap;
    }
    
    .info-item {
        gap: 5px;
    }
    
    .info-label {
        font-size: 6px;
    }
    
    .info-value {
        font-size: 9px;
    }
    
    .game-main {
        padding: 0;
    }
    
    .game-container {
        padding: 4px;
        border-width: 2px;
    }
    
    .joystick-base {
        width: 90px;
        height: 90px;
    }
    
    .joystick-stick {
        width: 36px;
        height: 36px;
    }
}

/* 桌面端隐藏摇杆 */
@media (min-width: 769px) {
    .joystick-container {
        display: none !important;
    }
}

/* 横屏适配 */
@media (orientation: landscape) and (max-height: 600px) {
    .top-bar {
        padding: 8px 12px;
        min-height: 35px;
    }
    
    .logo h1 {
        font-size: 10px;
    }
    
    .info-panel {
        gap: 12px;
    }
    
    .game-main {
        padding-top: 45px;
        padding-left: 5px;
        padding-right: 5px;
        padding-bottom: 5px;
    }
}
