/* 像素浮空纪元 - 全局样式 */

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

body {
    font-family: 'Courier New', monospace;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden;
    touch-action: none;
}

#game-container {
    position: relative;
    width: 360px;
    height: 640px;
    max-width: 100vw;
    max-height: 100vh;
    background: #1a1a2e;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    /* 自适应缩放：在移动端填满屏幕不留白 */
    transform-origin: center center;
}

/* 移动端自适应 */
@media (max-width: 768px) {
    #game-container {
        width: 100vw;
        height: calc(100vw * 16 / 9);  /* 基于9:16比例 */
        max-height: 100vh;
        box-shadow: none;
        border-radius: 0;
    }

    /* 如果屏幕比9:16更宽（横屏或宽屏手机），以高度为基准 */
    @media (min-aspect-ratio: 9/16) {
        #game-container {
            height: 100vh;
            width: calc(100vh * 9 / 16);
        }
    }
}

#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

#ui-layer > * {
    pointer-events: auto;
}

/* 加载屏幕 */
#loading-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, #4a90d9 0%, #2c5aa0 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    transition: opacity 0.5s ease;
}

#loading-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-content {
    text-align: center;
    color: #fff;
}

.loading-content h1 {
    font-size: 24px;
    margin-bottom: 30px;
    text-shadow: 2px 2px 0 #1a1a2e;
}

.loading-bar {
    width: 200px;
    height: 20px;
    background: rgba(26, 26, 46, 0.5);
    border: 2px solid #1a1a2e;
    border-radius: 10px;
    overflow: hidden;
    margin: 0 auto 15px;
}

.loading-progress {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #ffd700, #ffed4e);
    transition: width 0.3s ease;
}

.loading-text {
    font-size: 14px;
    opacity: 0.9;
}

/* 通用按钮样式 */
.button {
    min-width: 48px;
    min-height: 48px;
    padding: 12px 20px;
    background: #4a90d9;
    color: #fff;
    border: 2px solid #1a1a2e;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.1s ease;
    font-family: 'Courier New', monospace;
}

.button:hover {
    background: #5a9fe9;
    border-color: #ffd700;
    transform: scale(1.02);
}

.button:active {
    transform: scale(0.98);
    background: #3a80c9;
}

.button:disabled {
    background: #666;
    border-color: #444;
    opacity: 0.5;
    cursor: not-allowed;
}

/* 面板样式 */
.panel {
    position: absolute;
    background: rgba(26, 26, 46, 0.95);
    border: 2px solid #ffd700;
    border-radius: 8px;
    padding: 15px;
    color: #fff;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #ffd700;
}

.panel-title {
    font-size: 16px;
    color: #ffd700;
}

.panel-close {
    width: 24px;
    height: 24px;
    background: #ef4444;
    border: 1px solid #1a1a2e;
    border-radius: 4px;
    color: #fff;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 对话框样式 */
.dialog {
    position: absolute;
    bottom: 70px;
    left: 10px;
    right: 10px;
    background: rgba(26, 26, 46, 0.95);
    border: 2px solid #ffd700;
    border-radius: 8px;
    padding: 12px;
    color: #fff;
    font-size: 12px;
    line-height: 1.6;
}

/* HUD样式 */
.hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 36px;
    background: rgba(26, 26, 46, 0.9);
    border-bottom: 2px solid #ffd700;
    display: flex;
    align-items: center;
    padding: 0 10px;
    font-size: 12px;
    color: #fff;
}

.hud-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.hud-bars {
    margin-left: auto;
    display: flex;
    gap: 10px;
}

.bar {
    display: flex;
    align-items: center;
    gap: 4px;
}

.bar-label {
    font-size: 10px;
    color: #aaa;
}

.bar-container {
    width: 60px;
    height: 8px;
    background: #333;
    border: 1px solid #555;
    border-radius: 4px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    transition: width 0.3s linear;
}

.bar-fill.hp {
    background: linear-gradient(90deg, #ef4444, #f87171);
}

.bar-fill.mp {
    background: linear-gradient(90deg, #3b82f6, #60a5fa);
}

/* 底部导航栏 */
.navbar {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 70px;
    background: rgba(26, 26, 46, 0.95);
    border-top: 2px solid #ffd700;
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 0 10px;
}

.nav-button {
    width: 60px;
    height: 48px;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 10px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: all 0.1s ease;
}

.nav-button:hover {
    background: rgba(255, 215, 0, 0.1);
}

.nav-button:active {
    transform: scale(0.95);
}

.nav-button.active {
    color: #ffd700;
}

.nav-icon {
    font-size: 20px;
}

/* 通知消息 */
.notification {
    position: absolute;
    top: 50px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(26, 26, 46, 0.95);
    border: 2px solid #ffd700;
    border-radius: 8px;
    padding: 10px 20px;
    color: #fff;
    font-size: 12px;
    z-index: 100;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* 过渡效果 */
.transition-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 500;
}

.transition-overlay.active {
    opacity: 1;
}

/* 响应式设计 */
@media (max-width: 360px) {
    #game-container {
        width: 100vw;
        height: 100vh;
    }
}

@media (min-width: 768px) {
    #game-container {
        border-radius: 8px;
    }
}
