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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #333;
}

.screen {
    display: none;
    width: 100%;
    padding: 20px;
}

.screen.active {
    display: block;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

h1 {
    text-align: center;
    color: #667eea;
    margin-bottom: 20px;
    font-size: 3em;
}

h2 {
    text-align: center;
    color: #667eea;
    margin-bottom: 20px;
}

h3 {
    color: #764ba2;
    margin-bottom: 15px;
}

/* 在线玩家数量 */
.online-players {
    text-align: center;
    font-size: 18px;
    color: #666;
    margin-bottom: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.online-indicator {
    width: 12px;
    height: 12px;
    background: #2ecc71;
    border-radius: 50%;
    display: inline-block;
    animation: pulse-online 2s infinite;
    box-shadow: 0 0 10px rgba(46, 204, 113, 0.5);
}

@keyframes pulse-online {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.6;
        transform: scale(1.1);
    }
}

#onlineCount {
    font-weight: bold;
    color: #2ecc71;
    font-size: 20px;
}

/* 排行榜样式 */
.leaderboard-section {
    margin-bottom: 30px;
    text-align: center;
}

.leaderboard-section h3 {
    color: #667eea;
    font-size: 1.8em;
    margin-bottom: 15px;
}

.leaderboard-toggle {
    margin-bottom: 15px;
}

.btn-small {
    padding: 8px 20px;
    font-size: 14px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    background: #f0f0f0;
    color: #333;
    transition: all 0.3s;
}

.btn-small:hover {
    background: #e0e0e0;
    transform: translateY(-1px);
}

.leaderboard-container {
    max-height: 400px;
    overflow-y: auto;
    margin: 0 auto;
    background: #f9f9f9;
    border-radius: 10px;
    padding: 15px;
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
}

.leaderboard-table thead {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.leaderboard-table th {
    padding: 12px 8px;
    text-align: center;
    font-weight: bold;
    font-size: 14px;
}

.leaderboard-table td {
    padding: 10px 8px;
    text-align: center;
    border-bottom: 1px solid #eee;
    font-size: 14px;
}

.leaderboard-table tbody tr:hover {
    background: #f5f5f5;
}

.leaderboard-table tbody tr:nth-child(1) td:first-child {
    color: #FFD700;
    font-weight: bold;
    font-size: 18px;
}

.leaderboard-table tbody tr:nth-child(2) td:first-child {
    color: #C0C0C0;
    font-weight: bold;
    font-size: 16px;
}

.leaderboard-table tbody tr:nth-child(3) td:first-child {
    color: #CD7F32;
    font-weight: bold;
    font-size: 16px;
}

.leaderboard-table .no-data {
    padding: 30px;
    color: #999;
    font-style: italic;
}

.leaderboard-table .rank {
    font-weight: bold;
    color: #667eea;
}

.leaderboard-table .player-name {
    font-weight: bold;
    color: #333;
}

.leaderboard-table .wins {
    color: #2ecc71;
    font-weight: bold;
}

.leaderboard-table .losses {
    color: #e74c3c;
    font-weight: bold;
}

.leaderboard-table .win-rate {
    color: #667eea;
    font-weight: bold;
}

/* 大厅样式 */
.lobby-content {
    text-align: center;
    margin: 40px 0;
}

#playerName {
    padding: 15px 20px;
    font-size: 18px;
    border: 2px solid #ddd;
    border-radius: 10px;
    width: 300px;
    margin-bottom: 20px;
    text-align: center;
}

.mode-selection {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-bottom: 20px;
}

.room-code-input {
    margin-top: 20px;
    display: flex;
    gap: 10px;
    justify-content: center;
    align-items: center;
}

.room-code-input input {
    padding: 12px 20px;
    font-size: 18px;
    border: 2px solid #667eea;
    border-radius: 10px;
    width: 200px;
    text-align: center;
    text-transform: uppercase;
}

.room-info {
    margin-top: 30px;
    padding: 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 15px;
    color: white;
}

.room-info h3 {
    color: white;
    font-size: 2em;
    margin-bottom: 15px;
}

.room-info p {
    font-size: 1.2em;
    margin-bottom: 20px;
}

#displayRoomCode {
    font-family: 'Courier New', monospace;
    font-size: 1.5em;
    letter-spacing: 3px;
    background: rgba(255, 255, 255, 0.2);
    padding: 5px 15px;
    border-radius: 5px;
}

.room-code-display {
    text-align: center;
    padding: 10px;
    background: #f0f0f0;
    border-radius: 10px;
    margin-bottom: 15px;
    font-size: 1.2em;
    color: #667eea;
    font-weight: bold;
}

.room-code-display span {
    font-family: 'Courier New', monospace;
    letter-spacing: 2px;
}

.btn, .btn-primary {
    padding: 15px 40px;
    font-size: 18px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
    margin: 5px;
}

.btn {
    background: #f0f0f0;
    color: #333;
}

.btn:hover {
    background: #e0e0e0;
    transform: translateY(-2px);
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-weight: bold;
}

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

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.waiting-msg {
    margin-top: 20px;
    font-size: 18px;
    color: #667eea;
    animation: pulse 1.5s infinite;
}

.hidden {
    display: none !important;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.rules {
    margin-top: 40px;
    padding: 20px;
    background: #f9f9f9;
    border-radius: 10px;
}

.rules ul {
    list-style-position: inside;
    line-height: 1.8;
}

/* 棋盘样式 */
.board-container {
    display: flex;
    justify-content: center;
    margin: 30px 0;
}

.board {
    display: grid;
    grid-template-columns: repeat(10, 40px);
    grid-template-rows: repeat(10, 40px);
    gap: 2px;
    background: #ddd;
    padding: 2px;
    border-radius: 5px;
}

.cell {
    width: 40px;
    height: 40px;
    background: white;
    border: 1px solid #ccc;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.cell:hover {
    background: #f0f0f0;
}

.cell.plane {
    background: #667eea;
}

.cell.plane-head {
    background: #e74c3c;
    font-weight: bold;
}

.cell.preview {
    background: rgba(102, 126, 234, 0.3);
}

.cell.preview-invalid {
    background: rgba(231, 76, 60, 0.3);
}

.cell.hit {
    background: #e74c3c;
}

.cell.miss {
    background: #95a5a6;
}

.cell.sink {
    background: #c0392b;
    animation: sink 0.5s;
}

@keyframes sink {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

/* 摆放界面 */
.placement-controls {
    text-align: center;
    margin-bottom: 20px;
}

.hint {
    text-align: center;
    color: #666;
    margin-top: 20px;
}

/* 对战界面 */
.battle-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.battle-header h2 {
    display: flex;
    align-items: center;
    gap: 10px;
}

.opponent-name-display {
    font-size: 0.7em;
    color: #764ba2;
    font-weight: normal;
}

.turn-indicator {
    padding: 10px 20px;
    border-radius: 10px;
    font-weight: bold;
    font-size: 18px;
}

.turn-indicator.your-turn {
    background: #2ecc71;
    color: white;
}

.turn-indicator.opponent-turn {
    background: #e74c3c;
    color: white;
}

/* 移动端回合提示 */
.turn-indicator-mobile {
    display: none;
    padding: 12px 20px;
    border-radius: 10px;
    font-weight: bold;
    font-size: 16px;
    text-align: center;
    margin-bottom: 15px;
    animation: pulse-glow 2s infinite;
}

.turn-indicator-mobile.your-turn {
    background: #2ecc71;
    color: white;
    box-shadow: 0 0 20px rgba(46, 204, 113, 0.5);
}

.turn-indicator-mobile.opponent-turn {
    background: #e74c3c;
    color: white;
    box-shadow: 0 0 20px rgba(231, 76, 60, 0.5);
}

@keyframes pulse-glow {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 20px rgba(46, 204, 113, 0.5);
    }
    50% {
        transform: scale(1.02);
        box-shadow: 0 0 30px rgba(46, 204, 113, 0.8);
    }
}

.battle-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
}

.board-section {
    text-align: center;
}

.board-section h3 {
    margin-bottom: 15px;
}

/* 游戏结束 */
.game-over-content {
    text-align: center;
    padding: 60px 0;
}

.game-over-content h1 {
    font-size: 4em;
    margin-bottom: 40px;
}

/* 对手飞机展示 */
.opponent-planes-reveal {
    margin: 40px auto;
    max-width: 600px;
}

.opponent-planes-reveal h3 {
    color: #667eea;
    font-size: 1.5em;
    margin-bottom: 20px;
    text-align: center;
}

.reveal-board-container {
    display: flex;
    justify-content: center;
    margin: 20px 0;
}

.reveal-legend {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #666;
}

.legend-color {
    width: 30px;
    height: 30px;
    border-radius: 4px;
    border: 1px solid #ccc;
}

.legend-color.plane-body {
    background: #667eea;
}

.legend-color.plane-head {
    background: #e74c3c;
}

.legend-color.hit-mark {
    background: #f39c12;
    position: relative;
}

.legend-color.hit-mark::after {
    content: 'X';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-weight: bold;
    font-size: 18px;
}

/* 揭示棋盘特殊样式 */
#opponentRevealBoard .cell.opponent-plane {
    background: #667eea;
}

#opponentRevealBoard .cell.opponent-plane-head {
    background: #e74c3c;
}

#opponentRevealBoard .cell.opponent-plane-head::before {
    content: '✈';
    color: white;
    font-size: 20px;
}

#opponentRevealBoard .cell.my-attack {
    position: relative;
}

#opponentRevealBoard .cell.my-attack::after {
    content: 'X';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #f39c12;
    font-weight: bold;
    font-size: 24px;
    text-shadow: 0 0 3px rgba(0,0,0,0.5);
}

#opponentRevealBoard .cell.my-attack-hit {
    background: rgba(243, 156, 18, 0.3);
}

#opponentRevealBoard .cell.my-attack-sink {
    background: rgba(231, 76, 60, 0.5);
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 20px;
    }

    h1 {
        font-size: 2em;
        margin-bottom: 15px;
    }

    /* 在线玩家数量 */
    .online-players {
        font-size: 16px;
        margin-bottom: 20px;
    }

    #onlineCount {
        font-size: 18px;
    }

    /* 移动端隐藏顶部回合提示 */
    .battle-header {
        flex-direction: column;
        gap: 10px;
    }

    .battle-header h2 {
        font-size: 1.5em;
        flex-direction: column;
        gap: 5px;
    }

    .opponent-name-display {
        font-size: 0.8em;
    }

    .turn-indicator {
        display: none;
    }

    /* 移动端显示攻击棋盘上方的回合提示 */
    .turn-indicator-mobile {
        display: block;
    }

    .battle-layout {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .board {
        grid-template-columns: repeat(10, 30px);
        grid-template-rows: repeat(10, 30px);
    }

    .cell {
        width: 30px;
        height: 30px;
        font-size: 16px;
    }

    /* 游戏结束页面 */
    .game-over-content h1 {
        font-size: 2.5em;
    }

    .opponent-planes-reveal {
        margin: 20px auto;
    }

    .reveal-legend {
        gap: 10px;
        font-size: 12px;
    }

    .legend-color {
        width: 25px;
        height: 25px;
    }

    .legend-color.hit-mark::after {
        font-size: 14px;
    }

    #opponentRevealBoard .cell.my-attack::after {
        font-size: 18px;
    }

    /* 优化排行榜在移动端的显示 */
    .leaderboard-table {
        font-size: 12px;
    }

    .leaderboard-table th,
    .leaderboard-table td {
        padding: 8px 4px;
    }

    /* 优化按钮在移动端的显示 */
    .mode-selection {
        flex-direction: column;
        gap: 10px;
    }

    .btn, .btn-primary {
        width: 100%;
        padding: 12px 20px;
    }
}
