/* ============================================
   3D 游戏 - 移动端适配样式
   SciTW.cn 游戏平台
   ============================================ */

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: #000;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

/* ---------- 加载界面 ---------- */
#loading-screen {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

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

.loading-spinner {
    width: 60px; height: 60px;
    margin: 0 auto 20px;
    border: 4px solid rgba(255,255,255,0.2);
    border-top-color: #00d4ff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    font-size: 16px;
    margin-bottom: 16px;
    opacity: 0.9;
}

.loading-bar {
    width: 200px;
    height: 6px;
    background: rgba(255,255,255,0.15);
    border-radius: 3px;
    margin: 0 auto;
    overflow: hidden;
}

.loading-progress {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #00d4ff, #7b2ff7);
    border-radius: 3px;
    transition: width 0.3s ease;
}

/* ---------- 登录界面 ---------- */
#login-screen {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
}

.login-container {
    text-align: center;
    color: #fff;
    padding: 40px 30px;
}

.login-container h1 {
    font-size: 32px;
    margin-bottom: 8px;
}

.subtitle {
    font-size: 14px;
    opacity: 0.7;
    margin-bottom: 40px;
}

.welcome-msg {
    font-size: 18px;
    margin-bottom: 30px;
    color: #00d4ff;
}

.btn-primary {
    display: inline-block;
    padding: 14px 40px;
    background: linear-gradient(135deg, #00d4ff, #7b2ff7);
    color: #fff;
    border: none;
    border-radius: 30px;
    font-size: 16px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 20px rgba(0, 212, 255, 0.3);
}

.btn-primary:active {
    transform: scale(0.95);
}

.btn-secondary {
    display: inline-block;
    padding: 10px 24px;
    background: rgba(255,255,255,0.1);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 20px;
    font-size: 14px;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-secondary:active {
    background: rgba(255,255,255,0.2);
}

#guest-msg p {
    margin-bottom: 20px;
    opacity: 0.8;
}

/* ---------- 游戏画布 ---------- */
#render-canvas {
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
    outline: none;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1;
    background: #0a0a1a;
}

/* ---------- 游戏 HUD ---------- */
#game-hud {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 100;
}

.hud-top {
    position: absolute;
    top: 10px;
    left: 0; right: 0;
    display: flex;
    justify-content: space-between;
    padding: 0 15px;
}

.hud-item {
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 8px 16px;
    color: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 70px;
}

.hud-label {
    font-size: 10px;
    opacity: 0.7;
    text-transform: uppercase;
}

.hud-value {
    font-size: 20px;
    font-weight: 700;
    color: #00d4ff;
}

.hud-bottom {
    position: absolute;
    bottom: 20px;
    left: 15px;
}

.energy-bar {
    width: 120px;
    height: 8px;
    background: rgba(255,255,255,0.15);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 4px;
}

.energy-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #ff6b6b, #ffd93d, #6bcb77);
    border-radius: 4px;
    transition: width 0.3s ease;
}

/* ---------- 虚拟摇杆 ---------- */
.joystick-zone {
    position: absolute;
    bottom: 30px;
    right: 30px;
    width: 140px;
    height: 140px;
    pointer-events: auto;
}

.joystick-base {
    width: 120px;
    height: 120px;
    background: rgba(255,255,255,0.1);
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    position: relative;
    margin: 10px;
}

.joystick-thumb {
    width: 50px;
    height: 50px;
    background: rgba(0, 212, 255, 0.6);
    border-radius: 50%;
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    transition: none;
}

/* ---------- 攻击按钮 ---------- */
.attack-btn {
    position: absolute;
    bottom: 40px;
    right: 180px;
    width: 70px;
    height: 70px;
    background: rgba(255, 50, 50, 0.6);
    border: 2px solid rgba(255, 100, 100, 0.8);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    pointer-events: auto;
    cursor: pointer;
    transition: transform 0.1s;
    user-select: none;
    -webkit-user-select: none;
}

.attack-btn:active {
    transform: scale(0.9);
    background: rgba(255, 50, 50, 0.8);
}

/* ---------- 横屏适配 ---------- */
@media (orientation: landscape) {
    .hud-top {
        top: 5px;
    }
    .hud-item {
        padding: 6px 12px;
        min-width: 60px;
    }
    .hud-value {
        font-size: 16px;
    }
    .joystick-zone {
        bottom: 20px;
        right: 20px;
        width: 120px;
        height: 120px;
    }
    .joystick-base {
        width: 100px;
        height: 100px;
    }
    .joystick-thumb {
        width: 40px;
        height: 40px;
    }
}

/* ---------- 小屏手机适配 ---------- */
@media (max-width: 360px) {
    .hud-item {
        padding: 6px 10px;
        min-width: 55px;
        border-radius: 8px;
    }
    .hud-value {
        font-size: 16px;
    }
    .hud-label {
        font-size: 9px;
    }
}
