* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    overflow: hidden;
    background: #1a1a1a;
    font-family: 'Segoe UI', system-ui, sans-serif;
    color: #e0e0e0;
    user-select: none;
}

#canvas {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: default;
}

#canvas:active {
    cursor: none;
}

/* 破坏统计 */
#destroyStats {
    position: fixed;
    bottom: 12px;
    left: 12px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 13px;
    z-index: 100;
    pointer-events: none;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.stat-row {
    margin: 4px 0;
    color: #e0e0e0;
}

.stat-row span {
    font-weight: bold;
    color: #ff6b6b;
}

@media (max-width: 768px) {
    #destroyStats {
        bottom: auto;
        top: 50%;
        left: 8px;
        transform: translateY(-50%);
        font-size: 11px;
        padding: 8px 10px;
    }
}

/* 加载界面 */
#loading {
    position: fixed;
    inset: 0;
    background: #111;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: opacity 0.5s;
}

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

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

.loading-bar {
    width: 300px;
    height: 4px;
    background: #333;
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 16px;
}

.loading-fill {
    height: 100%;
    width: 0%;
    background: #d4a017;
    transition: width 0.3s;
}

#loadingText {
    font-size: 14px;
    color: #888;
}

/* HUD */
#hud {
    position: fixed;
    top: 12px;
    left: 12px;
    display: flex;
    gap: 16px;
    font-size: 13px;
    font-family: 'Consolas', monospace;
    z-index: 10;
}

#hud > div {
    padding: 4px 10px;
    background: rgba(0,0,0,0.4);
    border-radius: 3px;
    line-height: 1;
}

#fps {
    color: #4CAF50;
}

/* 控制模式显示 */
#controlMode {
    font-weight: bold;
    min-width: 70px;
    text-align: center;
}

.mode-work {
    color: #4CAF50;
}

.mode-drive {
    color: #2196F3;
}

/* 右上角信息区 */
#topRight {
    position: fixed;
    top: 12px;
    right: 12px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    z-index: 20;
}

/* 视角指南针 */
#compass {
    cursor: pointer;
    user-select: none;
}

.compass-ring {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.3);
    background: rgba(0,0,0,0.4);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.compass-needle {
    width: 2px;
    height: 20px;
    background: linear-gradient(to bottom, #ff4444 50%, #ffffff 50%);
    position: absolute;
    top: 5px;
    left: 50%;
    transform-origin: bottom center;
    transform: translateX(-50%);
    transition: transform 0.1s ease-out;
}

.compass-label {
    position: absolute;
    font-size: 8px;
    color: rgba(255,255,255,0.6);
    font-weight: bold;
    font-family: 'Consolas', monospace;
}

.compass-n { top: 2px; left: 50%; transform: translateX(-50%); color: #ff4444; }
.compass-s { bottom: 2px; left: 50%; transform: translateX(-50%); }
.compass-e { right: 3px; top: 50%; transform: translateY(-50%); }
.compass-w { left: 3px; top: 50%; transform: translateY(-50%); }

/* 控制面板 */
#controlPanel {
    position: fixed;
    bottom: 12px;
    right: 12px;
    width: 220px;
    background: rgba(20,20,20,0.6);
    border: 1px solid #333;
    border-radius: 4px;
    z-index: 10;
    font-size: 12px;
    backdrop-filter: blur(4px);
}

.panel-section {
    padding: 10px 12px;
    border-bottom: 1px solid #2a2a2a;
}

.panel-section:last-child {
    border-bottom: none;
}

.panel-section h3 {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #888;
    margin-bottom: 8px;
}

.status-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.status-row span {
    width: 50px;
    font-size: 11px;
    color: #aaa;
}

.status-bar {
    flex: 1;
    height: 6px;
    background: #2a2a2a;
    border-radius: 3px;
    overflow: hidden;
}

.status-fill {
    height: 100%;
    width: 50%;
    background: #d4a017;
    border-radius: 3px;
    transition: width 0.1s;
}

.help-row {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 4px;
    color: #999;
    font-size: 11px;
}

kbd {
    display: inline-block;
    min-width: 22px;
    padding: 1px 5px;
    font-size: 10px;
    font-family: 'Consolas', monospace;
    text-align: center;
    background: #2a2a2a;
    border: 1px solid #444;
    border-radius: 3px;
    color: #ccc;
}

/* 移动端控制 */
#mobileControls {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: auto;
    z-index: 10;
    padding: 10px 20px 20px;
}

.joystick-zone {
    position: absolute;
    bottom: 20px;
    width: 120px;
    height: 120px;
}

#leftJoystick {
    left: 30px;
}

#rightJoystick {
    right: 30px;
}

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

.joystick-stick {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    background: rgba(255,255,255,0.15);
    border-radius: 50%;
    transition: none;
}

#buttonGroup {
    display: none;
}

.ctrl-btn {
    display: none;
}

/* 踏板区域 */
#pedalArea {
    position: absolute;
    bottom: 140px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    padding: 0 10px;
}

#leftPedal,
#rightPedal {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.pedal {
    width: 70px;
    height: 100px;
    background: rgba(255,255,255,0.05);
    border: 2px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    touch-action: manipulation;
    cursor: pointer;
}

.pedal:active {
    background: rgba(212,160,23,0.2);
}

.pedal-btn {
    width: 70px;
    height: 40px;
    padding: 4px 10px;
    font-size: 11px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 5px;
    color: #ddd;
    cursor: pointer;
    touch-action: manipulation;
    margin-bottom: 8px;
}

.pedal-btn:active {
    background: rgba(212,160,23,0.3);
}

@media (max-width: 768px) {
    #mobileControls { display: block; }
    #controlPanel { display: none; }
}

@media (pointer: coarse) {
    #mobileControls { display: block; }
}

/* 仪表盘 */
#dashboard {
    background: rgba(10, 12, 18, 0.6);
    border: 1px solid rgba(212, 160, 23, 0.3);
    border-radius: 6px;
    padding: 6px 8px 4px;
    backdrop-filter: blur(6px);
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    user-select: none;
    display: flex;
    flex-direction: column;
    gap: 2px;
    opacity: 0.8;
}

.gauge-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.gauge-canvas {
    display: block;
    width: 60px;
    height: 40px;
}

.gauge-row-inner {
    display: flex;
    justify-content: space-between;
    width: 80px;
    margin-top: -2px;
}

.gauge-label {
    font-size: 8px;
    letter-spacing: 1px;
    color: #666;
    font-family: 'Consolas', monospace;
}

.gauge-value {
    font-size: 11px;
    font-weight: bold;
    color: #d4a017;
    font-family: 'Consolas', monospace;
    text-shadow: 0 0 4px rgba(212, 160, 23, 0.3);
}

/* 音效开关按钮 */
.sound-btn {
    position: fixed;
    bottom: 20px;
    left: 20px;
    width: 44px;
    height: 44px;
    font-size: 20px;
    line-height: 44px;
    text-align: center;
    background: rgba(30,30,30,0.7);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 8px;
    color: #e0e0e0;
    cursor: pointer;
    z-index: 100;
    transition: background 0.2s;
}

.sound-btn:hover {
    background: rgba(50,50,50,0.8);
}

.sound-btn.muted {
    opacity: 0.5;
}

/* 右上角声音按钮 */
.sound-btn-inline {
    width: 36px;
    height: 36px;
    font-size: 18px;
    line-height: 36px;
    text-align: center;
    background: rgba(30,30,30,0.5);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 6px;
    color: #e0e0e0;
    cursor: pointer;
    transition: background 0.2s;
}

.sound-btn-inline:hover {
    background: rgba(50,50,50,0.6);
}

@media (max-width: 768px) {
    #mobileControls { display: block; }
    #controlPanel { display: none; }
    
    #dashboard {
        padding: 6px 8px 4px;
    }
    .gauge-canvas { width: 64px; height: 42px; }
    .gauge-row-inner { width: 64px; }
    .gauge-value { font-size: 9px; }
}
