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

body {
    overflow: hidden;
    background: #0a1628;
    font-family: 'Segoe UI', Arial, sans-serif;
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
}

#game-container.playing {
    cursor: none;
}

/* 计分板 */
#scoreboard {
    position: absolute;
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
    display: none; /* 默认隐藏，游戏开始时显示 */
    align-items: center;
    gap: 30px;
    background: rgba(0, 10, 30, 0.85);
    border: 1px solid rgba(100, 180, 255, 0.4);
    border-radius: 12px;
    padding: 12px 30px;
    z-index: 20;
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.team-score {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: bold;
}

.player-team {
    color: #44aaff;
}

.enemy-team {
    color: #ff6666;
}

.team-name {
    font-size: 16px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.team-points {
    font-size: 32px;
    min-width: 60px;
    text-align: center;
    text-shadow: 0 0 10px currentColor;
}

.team-caps {
    font-size: 14px;
    background: rgba(255, 255, 255, 0.15);
    padding: 4px 8px;
    border-radius: 4px;
    color: #fff;
}

.timer-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.game-timer {
    font-size: 24px;
    font-weight: bold;
    color: #ffd700;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
    font-family: 'Courier New', monospace;
}

.points-to-win {
    font-size: 11px;
    color: #7ab0e0;
}

#three-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

#three-container canvas {
    display: block;
}

#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
    pointer-events: none;
}

/* HUD */
#hud {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 24px;
    background: linear-gradient(180deg, rgba(0, 15, 40, 0.85) 0%, rgba(0, 10, 30, 0.92) 100%);
    border: 1px solid rgba(100, 180, 255, 0.35);
    border-radius: 12px;
    padding: 12px 28px;
    color: #c0deff;
    font-size: 14px;
    pointer-events: none;
    z-index: 10;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(100, 180, 255, 0.1);
}

#hp-bar-container {
    position: relative;
    width: 220px;
    height: 24px;
    background: rgba(255, 0, 0, 0.15);
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid rgba(255, 80, 80, 0.4);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

#hp-bar {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #2ecc40, #4cff72);
    transition: width 0.3s;
    border-radius: 6px;
    box-shadow: 0 0 8px rgba(46, 204, 64, 0.3);
}

#hp-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 12px;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 0 4px rgba(0,0,0,0.8);
}

#weapon-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

#weapon-name {
    font-weight: bold;
    color: #ffd700;
}

#reload-status {
    font-size: 12px;
    color: #4cff72;
}

#speed-info, #score-info {
    white-space: nowrap;
}

/* Minimap */
#minimap-container {
    position: absolute;
    bottom: 20px;
    right: 15px;
    width: 200px;
    height: 200px;
    border: 2px solid rgba(100, 180, 255, 0.4);
    border-radius: 10px;
    background: rgba(0, 15, 40, 0.85);
    z-index: 25;
    pointer-events: none;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(100, 180, 255, 0.1);
    backdrop-filter: blur(6px);
}

#minimapCanvas {
    border-radius: 8px;
    width: 100%;
    height: 100%;
}

/* Crosshair */
#crosshair {
    position: absolute;
    width: 40px;
    height: 40px;
    pointer-events: none;
    z-index: 20;
    transform: translate(-50%, -50%);
    display: none;
}

/* CSS准心已由Canvas动态准心替代 */

/* Start screen */
#start-screen {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, #050d1a 0%, #0a1e3a 40%, #132e4f 70%, #0d2240 100%);
    z-index: 100;
    color: #c0deff;
    pointer-events: auto;
}

#start-screen::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 50% 80%, rgba(20, 60, 120, 0.3) 0%, transparent 70%);
    pointer-events: none;
}

#start-screen h1 {
    font-size: 56px;
    color: #fff;
    text-shadow: 0 0 30px rgba(100, 180, 255, 0.6), 0 0 60px rgba(50, 120, 200, 0.3);
    margin-bottom: 10px;
    letter-spacing: 4px;
    position: relative;
}

#start-screen > p {
    font-size: 18px;
    margin-bottom: 30px;
    color: #7ab0e0;
}

.selection-container {
    display: flex;
    gap: 40px;
    margin-bottom: 30px;
    flex-wrap: wrap;
    justify-content: center;
}

.ship-select, .map-select {
    text-align: center;
}

.ship-select h3, .map-select h3 {
    margin-bottom: 12px;
    font-size: 16px;
    color: #7ab0e0;
}

.btn-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.map-btn {
    padding: 10px 20px;
    margin: 0 4px;
    border: 2px solid rgba(100, 180, 255, 0.3);
    background: rgba(20, 50, 90, 0.6);
    color: #c0deff;
    font-size: 14px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.map-btn:hover {
    background: rgba(30, 70, 130, 0.8);
    border-color: rgba(100, 180, 255, 0.6);
}

.map-btn.selected {
    background: rgba(40, 100, 180, 0.7);
    border-color: #4cacff;
    color: #fff;
    box-shadow: 0 0 12px rgba(76, 172, 255, 0.3);
}

.map-desc {
    margin-top: 12px;
    font-size: 13px;
    color: #7ab0e0;
    font-style: italic;
    min-height: 20px;
}

.ship-btn {
    padding: 10px 24px;
    margin: 0 8px;
    border: 2px solid rgba(100, 180, 255, 0.3);
    background: rgba(20, 50, 90, 0.6);
    color: #c0deff;
    font-size: 15px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.ship-btn:hover {
    background: rgba(30, 70, 130, 0.8);
    border-color: rgba(100, 180, 255, 0.6);
}

.ship-btn.selected {
    background: rgba(40, 100, 180, 0.7);
    border-color: #4cacff;
    color: #fff;
    box-shadow: 0 0 12px rgba(76, 172, 255, 0.3);
}

#start-btn, #restart-btn {
    padding: 16px 56px;
    font-size: 20px;
    font-weight: bold;
    color: #fff;
    background: linear-gradient(135deg, #1a6dd4, #2589f5);
    border: 2px solid rgba(100, 180, 255, 0.3);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
    letter-spacing: 2px;
    position: relative;
    box-shadow: 0 4px 15px rgba(25, 100, 200, 0.3);
}

#start-btn:hover, #restart-btn:hover {
    background: linear-gradient(135deg, #2589f5, #4ca4ff);
    transform: scale(1.05) translateY(-2px);
    box-shadow: 0 8px 30px rgba(37, 137, 245, 0.5);
    border-color: rgba(100, 180, 255, 0.6);
}

.controls-hint {
    margin-top: 24px;
    text-align: center;
    color: #5a8cb8;
    font-size: 13px;
    line-height: 1.8;
}

/* End screen */
#end-screen {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(5, 10, 25, 0.92);
    z-index: 100;
    color: #c0deff;
    backdrop-filter: blur(12px);
}

#end-screen h1 {
    font-size: 48px;
    margin-bottom: 20px;
    text-shadow: 0 0 30px rgba(100, 180, 255, 0.6);
    letter-spacing: 3px;
}

#end-stats {
    font-size: 18px;
    margin-bottom: 30px;
    line-height: 1.8;
    text-align: center;
}

.hidden {
    display: none !important;
}

/* 舰队状态面板 */
.fleet-panel {
    position: absolute;
    top: 80px;
    width: 155px;
    max-height: calc(100vh - 120px);
    height: auto;
    background: rgba(0, 10, 30, 0.6);
    border: 1px solid rgba(100, 180, 255, 0.2);
    border-radius: 8px;
    padding: 6px;
    z-index: 15;
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.ally-panel {
    left: 10px;
    border-color: rgba(68, 170, 255, 0.3);
}

.enemy-panel {
    right: 10px;
    border-color: rgba(255, 68, 68, 0.3);
}

.panel-header {
    font-size: 14px;
    font-weight: bold;
    text-align: center;
    padding-bottom: 8px;
    margin-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.ally-panel .panel-header {
    color: #44aaff;
}

.enemy-panel .panel-header {
    color: #ff6666;
}

.ships-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
    flex: 1;
}

/* 自定义滚动条 */
.ships-list::-webkit-scrollbar {
    width: 4px;
}

.ships-list::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}

.ships-list::-webkit-scrollbar-thumb {
    background: rgba(100, 180, 255, 0.3);
    border-radius: 2px;
}

.ship-item {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 3px 5px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    font-size: 10px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
    flex-shrink: 0;
}

.ship-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.ally-panel .ship-item.active {
    border-color: #44aaff;
    background: rgba(68, 170, 255, 0.15);
}

.enemy-panel .ship-item {
    cursor: default;
}

.ship-icon {
    width: 18px;
    height: 18px;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: bold;
    flex-shrink: 0;
}

.ally-panel .ship-icon {
    background: rgba(68, 170, 255, 0.2);
    color: #44aaff;
}

.enemy-panel .ship-icon {
    background: rgba(255, 68, 68, 0.2);
    color: #ff6666;
}

.ship-info {
    flex: 1;
    min-width: 0;
}

.ship-name {
    font-weight: bold;
    font-size: 10px;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

.ship-dmg {
    font-size: 9px;
    color: #ffcc44;
    line-height: 1.1;
}

.ship-status {
    font-size: 9px;
    color: #7ab0e0;
}

.ship-hp-bar {
    width: 100%;
    height: 3px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 2px;
    margin-top: 2px;
    overflow: hidden;
}

.ship-hp-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.3s, background 0.3s;
}

.ally-panel .ship-hp-fill {
    background: linear-gradient(90deg, #2ecc40, #4cff72);
}

.ally-panel .ship-hp-fill.low {
    background: linear-gradient(90deg, #ffaa00, #ffcc44);
}

.ally-panel .ship-hp-fill.critical {
    background: linear-gradient(90deg, #ff3333, #ff6644);
}

.enemy-panel .ship-hp-fill {
    background: linear-gradient(90deg, #ff6666, #ff8888);
}

.ship-item.destroyed {
    opacity: 0.45;
    background: rgba(60, 60, 60, 0.15);
}

.ship-item.destroyed .ship-icon {
    background: rgba(100, 100, 100, 0.2);
    color: #666;
}

.ship-item.destroyed .ship-name {
    color: #666;
    text-decoration: line-through;
}

.ship-item.destroyed .ship-dmg {
    color: #888;
}

.ship-item.destroyed .ship-hp-fill {
    background: rgba(100, 100, 100, 0.3) !important;
}

/* Damage flash */
.damage-flash {
    position: absolute;
    inset: 0;
    background: rgba(255, 0, 0, 0.15);
    pointer-events: none;
    z-index: 15;
    animation: flashOut 0.3s ease-out forwards;
}

@keyframes flashOut {
    to { opacity: 0; }
}
