/* ===== Reset & Base ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #0a0a0a;
    color: #fff;
    -webkit-tap-highlight-color: transparent;
    touch-action: none;
}

/* ===== Loading Screen ===== */
.loading {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0a0a1a 0%, #1a1a2e 100%);
    z-index: 1000;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.loading.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    display: flex; /* 覆盖 .hidden 的 display:none，保证淡出过渡生效 */
}

.loading-content {
    text-align: center;
}

/* 有背景图时：底部居中 + 直线进度条 */
.loading.has-bg {
    align-items: flex-end;
    justify-content: center;
    padding: 24px 20px 30px;
}

.loading.has-bg::before {
    content: '';
    position: absolute;
    inset: 0;
    /* 整体暗层 + 底部加深，增强与背景图区分 */
    background:
        linear-gradient(to top, rgba(0, 0, 0, 0.58) 0%, rgba(0, 0, 0, 0.35) 28%, rgba(0, 0, 0, 0.2) 55%, rgba(0, 0, 0, 0.12) 100%),
        rgba(0, 0, 0, 0.18);
    pointer-events: none;
}

.loading.has-bg .loading-content {
    position: relative;
    z-index: 1;
    min-width: 260px;
    text-align: center;
    padding: 12px 16px;
    border-radius: 14px;
    background: rgba(8, 10, 20, 0.46);
    border: 1px solid rgba(255, 255, 255, 0.22);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

/* Progress Ring */
.progress-ring-container {
    position: relative;
    width: 120px;
    height: 120px;
    margin: 0 auto 24px;
}

.progress-line {
    display: none;
}

.loading.has-bg .progress-ring {
    display: none;
}

.loading.has-bg .progress-ring-container {
    width: auto;
    height: auto;
    margin: 0 0 8px;
}

.loading.has-bg .progress-text {
    position: static;
    display: inline-block;
    font-size: 16px;
    letter-spacing: 0;
}

.loading.has-bg .progress-line {
    display: block;
    width: min(68vw, 320px);
    height: 5px;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.28);
    border-radius: 999px;
    overflow: hidden;
}

.progress-line-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #6366f1 0%, #a78bfa 100%);
    border-radius: 999px;
    transition: width 0.15s ease;
}

.loading.has-bg .loading-text {
    margin-top: 7px;
    font-size: 11px;
    letter-spacing: 2px;
    color: rgba(255, 255, 255, 0.8);
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.55);
}


.progress-ring {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.progress-ring-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.08);
    stroke-width: 4;
}

.progress-ring-circle {
    fill: none;
    stroke: url(#progress-gradient);
    stroke-width: 4;
    stroke-linecap: round;
    stroke-dasharray: 339.292;  /* 2 × π × r(54) */
    stroke-dashoffset: 339.292;
}

.progress-text {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    letter-spacing: -0.5px;
}

.loading-text {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.45);
    letter-spacing: 3px;
    text-transform: uppercase;
}

/* ===== Container ===== */
#container {
    width: 100%;
    height: 100%;
    cursor: grab;
}

#container:active {
    cursor: grabbing;
}

/* ===== Controls ===== */
.controls {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    pointer-events: none;
    z-index: 100;
    transition: opacity 0.3s ease;
}

.controls.hidden {
    opacity: 0;
    pointer-events: none;
}

.controls-left,
.controls-right {
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: auto;
}

/* ===== Control Button ===== */
.control-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    color: rgba(255, 255, 255, 0.9);
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 60px;
}

.control-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

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

.control-btn.active {
    background: rgba(99, 102, 241, 0.4);
    border-color: rgba(99, 102, 241, 0.6);
    color: #fff;
}

.control-btn.disabled {
    opacity: 0.4;
    pointer-events: none;
}

.control-btn svg {
    width: 24px;
    height: 24px;
}

.btn-label {
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* ===== Compass ===== */
.compass {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 50px;
    height: 50px;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 100;
}

.compass-arrow {
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 20px solid #ef4444;
    position: relative;
    transition: transform 0.1s ease-out;
}

.compass-arrow::after {
    content: '';
    position: absolute;
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 20px solid rgba(255, 255, 255, 0.6);
    left: -6px;
    top: 8px;
}

.compass-label {
    position: absolute;
    top: -8px;
    font-size: 10px;
    font-weight: 700;
    color: #ef4444;
}

/* ===== Toast ===== */
.toast {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    padding: 12px 24px;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 30px;
    font-size: 14px;
    color: #fff;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 200;
    white-space: nowrap;
}

.toast.show {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* ===== Gyro Prompt ===== */
.gyro-prompt {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    z-index: 300;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.gyro-prompt.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.gyro-prompt-content {
    background: linear-gradient(145deg, #1e1e2e 0%, #2a2a3e 100%);
    padding: 32px;
    border-radius: 24px;
    text-align: center;
    max-width: 320px;
    margin: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.gyro-prompt-content h3 {
    font-size: 20px;
    margin-bottom: 12px;
    color: #fff;
}

.gyro-prompt-content p {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
    line-height: 1.5;
    margin-bottom: 24px;
}

.gyro-prompt-buttons {
    display: flex;
    gap: 12px;
}

.prompt-btn {
    flex: 1;
    padding: 14px 20px;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.8);
}

.prompt-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

.prompt-btn.primary {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: #fff;
}

.prompt-btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px -5px rgba(99, 102, 241, 0.4);
}

/* ===== VR Mode ===== */
body.vr-mode #controls {
    display: none;
}

body.vr-mode .compass {
    display: none;
}

/* VR Divider Line */
.vr-divider {
    position: fixed;
    top: 0;
    left: 50%;
    width: 2px;
    height: 100%;
    background: rgba(255, 255, 255, 0.2);
    transform: translateX(-50%);
    z-index: 50;
    display: none;
}

body.vr-mode .vr-divider {
    display: block;
}

/* VR Exit Button */
.vr-exit {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    padding: 15px 40px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 30px;
    color: #fff;
    font-size: 14px;
    cursor: pointer;
    z-index: 100;
    display: none;
}

body.vr-mode .vr-exit {
    display: block;
}

/* ===== Responsive ===== */
@media (max-width: 480px) {
    .progress-ring-container {
        width: 104px;
        height: 104px;
        margin: 0 auto 18px;
    }

    .progress-text {
        font-size: 22px;
    }

    .loading-text {
        font-size: 12px;
        letter-spacing: 2px;
    }

    .loading.has-bg {
        padding: 14px 12px calc(16px + env(safe-area-inset-bottom));
    }

    .loading.has-bg .loading-content {
        width: min(92vw, 360px);
        min-width: 0;
        padding: 10px 12px;
        border-radius: 12px;
    }

    .loading.has-bg .progress-text {
        font-size: 15px;
    }

    .loading.has-bg .progress-line {
        width: 100%;
        height: 4px;
    }

    .loading.has-bg .loading-text {
        margin-top: 6px;
        font-size: 10px;
        letter-spacing: 1.5px;
    }

    .controls {
        padding: 15px;
    }
    
    .control-btn {
        padding: 10px;
        min-width: 52px;
        border-radius: 14px;
    }
    
    .control-btn svg {
        width: 20px;
        height: 20px;
    }
    
    .btn-label {
        font-size: 9px;
    }
    
    .compass {
        width: 44px;
        height: 44px;
    }
}

/* ===== Landscape Optimization ===== */
@media (max-height: 500px) and (orientation: landscape) {
    .loading.has-bg {
        padding-bottom: calc(10px + env(safe-area-inset-bottom));
    }

    .loading.has-bg .loading-content {
        padding: 8px 12px;
    }

    .loading.has-bg .loading-text {
        margin-top: 4px;
    }

    .controls-left,
    .controls-right {
        flex-direction: row;
    }
    
    .controls {
        padding: 10px 20px;
    }
}

.hidden{
    display: none;
}