/* ========== UI 组件样式 ========== */

/* ===== 按钮样式 ===== */
.ui-button {
    position: absolute;
    padding: 15px 30px;
    font-size: 16px;
    font-weight: bold;
    text-transform: uppercase;
    border: 4px solid #000;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Courier New', monospace;
    text-align: center;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.ui-button:hover {
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
}

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

.ui-button.primary {
    background: linear-gradient(180deg, #4CAF50 0%, #2E7D32 100%);
    color: white;
    text-shadow: 2px 2px 0 #000;
}

.ui-button.secondary {
    background: linear-gradient(180deg, #2196F3 0%, #1565C0 100%);
    color: white;
    text-shadow: 2px 2px 0 #000;
}

.ui-button.danger {
    background: linear-gradient(180deg, #f44336 0%, #c62828 100%);
    color: white;
    text-shadow: 2px 2px 0 #000;
}

.ui-button.warning {
    background: linear-gradient(180deg, #ff9800 0%, #e65100 100%);
    color: white;
    text-shadow: 2px 2px 0 #000;
}

/* ===== 面板样式 ===== */
.ui-panel {
    position: absolute;
    background: rgba(0, 0, 0, 0.9);
    border: 4px solid #fff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.8);
}

.ui-panel.title {
    background: linear-gradient(180deg, rgba(30, 30, 60, 0.95) 0%, rgba(20, 20, 40, 0.95) 100%);
    border-color: #ffd700;
}

/* ===== 菜单场景 ===== */
#menu-scene {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: linear-gradient(180deg, #1a1a3e 0%, #0f0f23 50%, #1a0f2e 100%);
}

#menu-scene::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(circle at 30% 20%, rgba(255, 0, 100, 0.1) 0%, transparent 40%),
        radial-gradient(circle at 70% 80%, rgba(0, 100, 255, 0.1) 0%, transparent 40%);
    pointer-events: none;
}

.game-title {
    font-size: clamp(24px, 6vw, 64px);
    color: #ffd700;
    margin-bottom: 50px;
    text-align: center;
    animation: slideIn 0.8s ease-out;
}

.game-title .pixel {
    display: inline-block;
    animation: pulse 2s ease-in-out infinite;
}

.game-title .pixel:nth-child(1) { animation-delay: 0s; }
.game-title .pixel:nth-child(2) { animation-delay: 0.1s; }
.game-title .pixel:nth-child(3) { animation-delay: 0.2s; }
.game-title .pixel:nth-child(4) { animation-delay: 0.3s; }

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 20px;
    animation: fadeIn 1s ease-out 0.3s both;
}

.menu-buttons .ui-button {
    position: relative;
    min-width: 200px;
}

/* ===== 关卡选择场景 ===== */
#level-select-scene {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, #1a1a3e 0%, #0f0f23 100%);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.level-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
    margin: 30px 0;
    max-width: 800px;
    width: 90%;
}

.level-card {
    background: linear-gradient(180deg, #2a2a4a 0%, #1a1a3a 100%);
    border: 4px solid #444;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
}

.level-card:hover:not(.locked) {
    transform: translateY(-5px);
    border-color: #ffd700;
    box-shadow: 0 10px 30px rgba(255, 215, 0, 0.3);
}

.level-card.locked {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(50%);
}

.level-card.locked::after {
    content: '🔒';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 48px;
}

.level-name {
    color: #fff;
    font-size: 18px;
    margin-bottom: 10px;
}

.level-info {
    color: #888;
    font-size: 12px;
}

.level-stars {
    color: #ffd700;
    font-size: 24px;
    margin-top: 10px;
}

/* ===== HUD ===== */
#hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 15px;
    display: none;
    pointer-events: none;
}

.hud-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.hud-left, .hud-right {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.stat-bar {
    width: 200px;
    height: 24px;
    background: rgba(0, 0, 0, 0.7);
    border: 3px solid #fff;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
}

.stat-bar-fill {
    height: 100%;
    transition: width 0.3s;
    position: relative;
}

.stat-bar-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(180deg, rgba(255,255,255,0.3) 0%, transparent 100%);
}

.stat-bar-fill.health {
    background: linear-gradient(180deg, #ff4444 0%, #cc0000 100%);
}

.stat-bar-fill.mana {
    background: linear-gradient(180deg, #4444ff 0%, #0000cc 100%);
}

.stat-bar-fill.exp {
    background: linear-gradient(180deg, #44ff44 0%, #00cc00 100%);
}

.stat-bar-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-size: 12px;
    font-weight: bold;
    text-shadow: 1px 1px 2px #000;
    white-space: nowrap;
}

.stat-bar-label {
    color: #fff;
    font-size: 12px;
    margin-bottom: 5px;
    text-shadow: 2px 2px 0 #000;
}

.hud-stats {
    color: #ffd700;
    font-size: 14px;
    text-shadow: 2px 2px 0 #000;
}

.hud-stats div {
    margin-bottom: 5px;
}

/* ===== 虚拟控制器 ===== */
#virtual-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 200px;
    display: none;
    pointer-events: none;
}

#virtual-controls.active {
    display: block;
}

#virtual-controls > * {
    pointer-events: auto;
}

#joystick-zone {
    position: absolute;
    bottom: 20px;
    left: 20px;
    width: 150px;
    height: 150px;
}

#joystick-base {
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.2);
    border: 3px solid rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    position: relative;
}

#joystick-stick {
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.6);
    border: 3px solid rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: none;
}

#action-buttons {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: grid;
    grid-template-columns: repeat(2, 70px);
    grid-template-rows: repeat(2, 70px);
    gap: 10px;
}

.action-btn {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    border: 4px solid rgba(255, 255, 255, 0.8);
    font-size: 24px;
    font-weight: bold;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition: all 0.1s;
}

.action-btn:active {
    transform: scale(0.9);
}

.action-btn.attack {
    background: rgba(255, 68, 68, 0.7);
    grid-column: 2;
    grid-row: 2;
}

.action-btn.jump {
    background: rgba(68, 255, 68, 0.7);
    grid-column: 1;
    grid-row: 1;
}

.action-btn.skill {
    background: rgba(68, 68, 255, 0.7);
    grid-column: 1;
    grid-row: 2;
}

.action-btn.dash {
    background: rgba(255, 255, 68, 0.7);
    grid-column: 2;
    grid-row: 1;
}

.action-btn-label {
    color: #fff;
    font-size: 10px;
    text-shadow: 1px 1px 2px #000;
    margin-top: 5px;
    text-align: center;
}

#pause-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.2);
    border: 3px solid rgba(255, 255, 255, 0.5);
    border-radius: 8px;
    color: #fff;
    font-size: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

#pause-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ===== 暂停菜单 ===== */
#pause-menu {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.95);
    border: 4px solid #ffd700;
    border-radius: 12px;
    padding: 40px;
    text-align: center;
    display: none;
    animation: scaleIn 0.3s ease-out;
}

.pause-title {
    color: #ffd700;
    font-size: 32px;
    margin-bottom: 30px;
}

.pause-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.pause-buttons .ui-button {
    position: relative;
    min-width: 200px;
}

/* ===== 对话框 ===== */
#dialog-box {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 600px;
    background: rgba(0, 0, 0, 0.9);
    border: 4px solid #fff;
    border-radius: 12px;
    padding: 20px;
    display: none;
}

.dialog-speaker {
    color: #ffd700;
    font-size: 16px;
    margin-bottom: 10px;
}

.dialog-text {
    color: #fff;
    font-size: 14px;
    line-height: 1.6;
}

.dialog-continue {
    position: absolute;
    bottom: 10px;
    right: 15px;
    color: #ffd700;
    font-size: 12px;
    animation: blink 1s step-end infinite;
}

/* ===== 通知消息 ===== */
#notification {
    position: absolute;
    top: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    border: 3px solid #ffd700;
    border-radius: 8px;
    padding: 15px 30px;
    color: #fff;
    font-size: 16px;
    display: none;
    animation: slideIn 0.3s ease-out;
    z-index: 1000;
}

#notification.success {
    border-color: #4CAF50;
}

#notification.error {
    border-color: #f44336;
}

#notification.warning {
    border-color: #ff9800;
}

/* ===== 游戏结束画面 ===== */
#game-over {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.5s ease-out;
}

.game-over-title {
    font-size: 48px;
    margin-bottom: 20px;
}

.game-over-title.victory {
    color: #ffd700;
}

.game-over-title.defeat {
    color: #ff4444;
}

.game-over-stats {
    color: #fff;
    font-size: 18px;
    margin-bottom: 30px;
    text-align: center;
}

.game-over-stats div {
    margin-bottom: 10px;
}

/* ===== 商店界面 ===== */
#shop-panel {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 700px;
    max-height: 80vh;
    background: rgba(0, 0, 0, 0.95);
    border: 4px solid #ffd700;
    border-radius: 12px;
    padding: 20px;
    display: none;
    overflow-y: auto;
}

.shop-title {
    color: #ffd700;
    font-size: 24px;
    text-align: center;
    margin-bottom: 20px;
}

.shop-items {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.shop-item {
    background: rgba(255, 255, 255, 0.1);
    border: 3px solid #666;
    border-radius: 8px;
    padding: 15px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.shop-item:hover {
    border-color: #ffd700;
    transform: scale(1.05);
}

.shop-item.purchased {
    opacity: 0.5;
    cursor: not-allowed;
}

.item-name {
    color: #fff;
    font-size: 14px;
    margin-bottom: 10px;
}

.item-price {
    color: #ffd700;
    font-size: 12px;
    margin-bottom: 5px;
}

.item-stats {
    color: #888;
    font-size: 10px;
}

/* ===== 响应式调整 ===== */
@media (max-width: 768px) {
    .stat-bar {
        width: 150px;
        height: 20px;
    }

    .stat-bar-text {
        font-size: 10px;
    }

    .hud-stats {
        font-size: 12px;
    }

    #joystick-zone {
        width: 120px;
        height: 120px;
    }

    #joystick-stick {
        width: 50px;
        height: 50px;
    }

    #action-buttons {
        grid-template-columns: repeat(2, 60px);
        grid-template-rows: repeat(2, 60px);
    }

    .action-btn {
        width: 60px;
        height: 60px;
        font-size: 20px;
    }

    .level-grid {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        gap: 15px;
    }

    .menu-buttons .ui-button {
        min-width: 180px;
        padding: 12px 24px;
        font-size: 14px;
    }
}
