/* ===== 基础重置 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #0a0a14;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    color: #fff;
    user-select: none;
}

#game-canvas {
    display: block;
    width: 100vw;
    height: 100vh;
    outline: none;
}

.hidden { display: none !important; }
.hidden-full { visibility: hidden !important; opacity: 0 !important; pointer-events: none !important; }

/* ===== 加载屏 ===== */
.loading-screen {
    position: fixed;
    inset: 0;
    background: linear-gradient(180deg, #2a1f3d 0%, #4a3260 40%, #d49a8a 80%, #f5d4a8 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    transition: opacity 1.2s ease;
}

.loading-orb {
    position: relative;
    width: 80px;
    height: 80px;
    margin-bottom: 30px;
}

.orb-core {
    position: absolute;
    inset: 25px;
    background: radial-gradient(circle, #fff 0%, #ffe9b8 40%, transparent 70%);
    border-radius: 50%;
    animation: pulse 2s ease-in-out infinite;
    filter: blur(2px);
}

.orb-ring {
    position: absolute;
    inset: 0;
    border: 2px solid rgba(255, 220, 150, 0.6);
    border-radius: 50%;
    animation: spin 4s linear infinite;
}

.orb-ring-2 {
    inset: 10px;
    border-color: rgba(255, 240, 200, 0.4);
    animation-duration: 3s;
    animation-direction: reverse;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.3); opacity: 0.7; }
}

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

.loading-text {
    font-size: 18px;
    color: #ffe9b8;
    letter-spacing: 4px;
    margin-bottom: 20px;
    text-shadow: 0 2px 12px rgba(255, 200, 130, 0.5);
}

.loading-progress {
    width: 220px;
    height: 3px;
    background: rgba(255, 233, 184, 0.15);
    border-radius: 2px;
    overflow: hidden;
}

.loading-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #ffd89b, #ffe9b8);
    box-shadow: 0 0 12px rgba(255, 216, 155, 0.8);
    transition: width 0.3s ease;
}

.loading-detail {
    margin-top: 14px;
    font-size: 12px;
    color: rgba(255, 233, 184, 0.55);
    letter-spacing: 1px;
    height: 16px;
}

/* ===== 开始屏 ===== */
.start-screen {
    position: fixed;
    inset: 0;
    z-index: 90;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at center, rgba(20, 15, 40, 0.4) 0%, rgba(10, 10, 20, 0.7) 100%);
    backdrop-filter: blur(2px);
    transition: opacity 0.8s ease;
}

.title-card {
    text-align: center;
    padding: 40px;
    max-width: 440px;
}

.title-glyph {
    font-size: 48px;
    color: #ffe9b8;
    text-shadow: 0 0 24px rgba(255, 216, 155, 0.8), 0 0 60px rgba(255, 200, 130, 0.4);
    margin-bottom: 12px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

.game-title {
    font-size: 42px;
    font-weight: 200;
    letter-spacing: 8px;
    color: #fff;
    text-shadow: 0 2px 16px rgba(255, 216, 155, 0.6);
    margin-bottom: 8px;
}

.game-subtitle {
    font-size: 13px;
    color: rgba(255, 233, 184, 0.65);
    letter-spacing: 4px;
    margin-bottom: 24px;
}

.title-divider {
    width: 60px;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 216, 155, 0.6), transparent);
    margin: 0 auto 24px;
}

.game-desc {
    font-size: 14px;
    line-height: 1.9;
    color: rgba(255, 255, 255, 0.75);
    margin-bottom: 32px;
}

.start-btn {
    background: linear-gradient(135deg, rgba(255, 216, 155, 0.2), rgba(255, 200, 130, 0.1));
    border: 1px solid rgba(255, 216, 155, 0.5);
    color: #ffe9b8;
    padding: 14px 56px;
    font-size: 16px;
    letter-spacing: 8px;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 24px rgba(255, 200, 130, 0.2);
    margin-bottom: 32px;
}

.start-btn:hover {
    background: linear-gradient(135deg, rgba(255, 216, 155, 0.35), rgba(255, 200, 130, 0.2));
    box-shadow: 0 6px 32px rgba(255, 200, 130, 0.4);
    transform: translateY(-2px);
}

.controls-hint {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
    line-height: 2;
}

.controls-hint kbd {
    display: inline-block;
    padding: 2px 8px;
    margin: 0 3px;
    background: rgba(255, 233, 184, 0.1);
    border: 1px solid rgba(255, 233, 184, 0.25);
    border-radius: 4px;
    font-family: inherit;
    font-size: 11px;
    color: #ffe9b8;
}

/* ===== HUD ===== */
.hud {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 50;
}

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

.hud-top-right {
    position: absolute;
    top: 20px;
    right: 20px;
}

.hud-bottom-center {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    width: 260px;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.hud-bottom-center.show {
    opacity: 1;
}

/* 群系指示器 */
.biome-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: rgba(20, 22, 30, 0.55);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 233, 184, 0.15);
    border-radius: 12px;
}

.biome-swatch {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #9bbd6a;
    box-shadow: 0 0 10px currentColor, inset 0 0 4px rgba(0, 0, 0, 0.2);
    transition: background 0.6s ease, box-shadow 0.6s ease;
}

.biome-name {
    font-size: 14px;
    color: #ffe9b8;
    letter-spacing: 2px;
}

.biome-label {
    font-size: 10px;
    color: rgba(255, 233, 184, 0.5);
    letter-spacing: 1px;
    margin-top: 2px;
}

/* 调试面板 */
.debug-info {
    padding: 10px 14px;
    background: rgba(20, 22, 30, 0.55);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 233, 184, 0.15);
    border-radius: 10px;
    font-size: 11px;
    min-width: 140px;
}

.debug-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    line-height: 1.8;
}

.debug-label {
    color: rgba(255, 233, 184, 0.5);
    letter-spacing: 1px;
}

.debug-value {
    color: #ffe9b8;
    font-variant-numeric: tabular-nums;
}

/* 飞行能量条 */
.flight-bar {
    width: 100%;
    height: 4px;
    background: rgba(255, 233, 184, 0.12);
    border-radius: 2px;
    overflow: hidden;
    box-shadow: 0 0 12px rgba(255, 200, 130, 0.2);
}

.flight-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #ffd89b, #ffe9b8);
    box-shadow: 0 0 10px rgba(255, 216, 155, 0.8);
    transition: width 0.15s linear;
}

/* 中央提示 */
.hud-tip {
    position: absolute;
    top: 30%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 10px 20px;
    background: rgba(20, 22, 30, 0.7);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 233, 184, 0.2);
    border-radius: 20px;
    color: #ffe9b8;
    font-size: 14px;
    letter-spacing: 2px;
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
}

.hud-tip.show {
    opacity: 1;
}

/* ===== 触屏控件 ===== */
.touch-controls {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 60;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.touch-controls.show {
    opacity: 1;
}

.touch-pad {
    position: absolute;
    bottom: 40px;
    left: 40px;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: rgba(20, 22, 30, 0.4);
    border: 2px solid rgba(255, 233, 184, 0.2);
    backdrop-filter: blur(8px);
    pointer-events: auto;
    touch-action: none;
}

.touch-pad-knob {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 216, 155, 0.7), rgba(255, 200, 130, 0.4));
    border: 1px solid rgba(255, 233, 184, 0.5);
    transform: translate(-50%, -50%);
    transition: transform 0.05s linear;
    pointer-events: none;
}

.touch-jump, .touch-run {
    position: absolute;
    bottom: 50px;
    right: 40px;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: rgba(20, 22, 30, 0.5);
    border: 2px solid rgba(255, 233, 184, 0.3);
    backdrop-filter: blur(8px);
    color: #ffe9b8;
    font-size: 13px;
    letter-spacing: 2px;
    pointer-events: auto;
    touch-action: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.touch-jump {
    bottom: 130px;
}

.touch-jump:active, .touch-run.active {
    background: rgba(255, 216, 155, 0.3);
    border-color: rgba(255, 216, 155, 0.7);
}

@media (max-width: 640px) {
    .hud-top-right { display: none; }
    .game-title { font-size: 32px; letter-spacing: 6px; }
    .game-desc { font-size: 13px; }
}

/* ===== 氛围调节面板 ===== */
.tuning-panel {
    position: fixed;
    bottom: 44px;
    left: 12px;
    background: rgba(20, 18, 28, 0.85);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 233, 184, 0.2);
    border-radius: 12px;
    padding: 10px 14px;
    z-index: 1000;
    color: #ffe9b8;
    font-family: 'Segoe UI', sans-serif;
    font-size: 11px;
    width: 290px;
    max-height: 75vh;
    overflow-y: auto;
    display: none;
}
.tuning-panel.show { display: block; }
.tuning-panel h3 {
    margin: 0 0 6px 0;
    font-size: 12px;
    letter-spacing: 2px;
    color: #ffd89b;
    border-bottom: 1px solid rgba(255,233,184,0.15);
    padding-bottom: 3px;
}
.tuning-panel h3:not(:first-child) { margin-top: 10px; }
.tuning-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 4px 0;
    white-space: nowrap;
}
.tuning-row label {
    min-width: 110px;
    color: rgba(255,233,184,0.7);
}
.tuning-row input[type=range] {
    width: 120px;
    accent-color: #ffd89b;
}
.tuning-row input[type=number] {
    width: 56px;
    background: rgba(255,233,184,0.1);
    border: 1px solid rgba(255,233,184,0.2);
    color: #ffe9b8;
    border-radius: 4px;
    padding: 1px 4px;
    font-size: 11px;
    text-align: right;
}
.tuning-toggle {
    display: none !important;
    position: fixed;
    bottom: 12px;
    left: 12px;
    z-index: 1001;
    background: rgba(20,18,28,0.85);
    border: 1px solid rgba(255,233,184,0.2);
    color: #ffd89b;
    border-radius: 8px;
    padding: 4px 10px;
    font-size: 11px;
    cursor: pointer;
    backdrop-filter: blur(10px);
}
.tuning-toggle:hover { background: rgba(40,36,52,0.9); }
