/* 全局样式 */
:root {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-card: #0f3460;
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0b0;
    --accent-black: #1a1a1a;
    --accent-white: #f0f0f0;
    --board-bg: #dcb35c;
    --board-line: #8b6914;
    --highlight-win: #4caf50;
    --highlight-hint: #ff9800;
    --border-color: #2a2a4a;
    --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-success: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
    --gradient-danger: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

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

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    background-image: 
        radial-gradient(circle at 20% 50%, rgba(102, 126, 234, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(240, 147, 251, 0.1) 0%, transparent 50%);
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem;
}

/* 页头样式 */
header {
    text-align: center;
    padding: 2rem 1rem;
    background: var(--bg-secondary);
    border-radius: 20px;
    margin-bottom: 1.5rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

header h1 {
    font-size: 2.5rem;
    color: #ffd700;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* 游戏区域布局 */
.game-area {
    display: grid;
    grid-template-columns: 280px 1fr 280px;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

/* 左侧面板 */
.left-panel, .right-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.game-info, .controls, .action-buttons, .move-history,
.player-profiles, .achievements, .sound-controls {
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 1.2rem;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
}

/* 游戏信息 */
.current-player {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 0.8rem;
}

.game-status {
    font-size: 1.2rem;
    color: #ffd700;
    text-align: center;
    margin-bottom: 1rem;
    padding: 0.5rem;
    background: rgba(255, 215, 0, 0.1);
    border-radius: 8px;
    font-weight: bold;
}

.score-board {
    display: flex;
    justify-content: space-around;
}

.score-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.player-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.player-icon.black {
    background: radial-gradient(circle at 35% 35%, #555, #111);
}

.player-icon.white {
    background: radial-gradient(circle at 35% 35%, #fff, #ccc);
}

/* 控制区域 */
.control-group {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.8rem;
}

.control-group label {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.control-group select,
.control-group input {
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 0.9rem;
}

.control-group select {
    cursor: pointer;
}

.control-group input[type="checkbox"] {
    width: 40px;
    height: 20px;
    accent-color: var(--highlight-win);
}

/* 按钮样式 */
.action-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.7rem 1rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.btn:active {
    transform: translateY(1px);
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    grid-column: span 2;
}

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

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: #1a4a7a;
    border-color: #4a7aaa;
    transform: translateY(-2px);
}

/* 落子记录 */
.move-history {
    max-height: 250px;
    overflow: hidden;
}

.move-history h3 {
    margin-bottom: 0.8rem;
}

#move-list {
    max-height: 180px;
    overflow-y: auto;
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    padding-right: 0.3rem;
}

#move-list::-webkit-scrollbar {
    width: 4px;
}

#move-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 2px;
}

#move-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}

.move-item {
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    background: var(--bg-card);
}

.move-item.black-move {
    border-left: 2px solid #333;
}

.move-item.white-move {
    border-left: 2px solid #fff;
}

/* 棋盘区域 */
.game-board-container {
    background: var(--bg-secondary);
    border-radius: 20px;
    padding: 1.5rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.board-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.board-info {
    display: flex;
    gap: 1.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.board-wrapper {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 1rem;
}

#gomoku-board {
    border-radius: 12px;
    box-shadow: 
        0 15px 40px rgba(0, 0, 0, 0.4),
        inset 0 2px 4px rgba(255, 255, 255, 0.1);
    cursor: pointer;
    transition: box-shadow 0.3s ease;
}

#gomoku-board:hover {
    box-shadow: 
        0 15px 50px rgba(102, 126, 234, 0.2),
        inset 0 2px 4px rgba(255, 255, 255, 0.1);
}

.winning-line {
    position: absolute;
    pointer-events: none;
    display: none;
}

.particle-container {
    position: absolute;
    pointer-events: none;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
}

/* 粒子特效 */
.particle {
    position: absolute;
    pointer-events: none;
    animation: particle-fly 0.8s ease-out forwards;
}

@keyframes particle-fly {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(var(--dx), var(--dy)) scale(0);
        opacity: 0;
    }
}

/* 胜利闪烁动画 */
@keyframes win-flash {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.win-flash {
    animation: win-flash 0.5s ease-in-out 3;
}

/* 棋盘页脚 */
.board-footer {
    width: 100%;
}

.instructions {
    background: rgba(255, 215, 0, 0.05);
    border-radius: 12px;
    padding: 1rem;
}

.instructions h4 {
    margin-bottom: 0.5rem;
    color: #ffd700;
}

.instructions ul {
    list-style: none;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.3rem 1rem;
}

.instructions li {
    font-size: 0.8rem;
    color: var(--text-secondary);
    padding: 0.2rem 0;
}

.instructions li::before {
    content: '•';
    color: #ffd700;
    margin-right: 0.4rem;
}

/* 玩家信息栏 */
.player-profile {
    margin-bottom: 1rem;
    padding: 1rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
}

.player-profile.black-player {
    border-left: 3px solid #555;
}

.player-profile.white-player {
    border-left: 3px solid #eee;
}

.player-header {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 0.8rem;
}

.player-details p {
    font-size: 0.85rem;
    margin-bottom: 0.3rem;
    color: var(--text-secondary);
}

.player-details i {
    width: 20px;
    color: #ffd700;
}

/* 成就系统 */
.achievement-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.achievement {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.03);
    font-size: 0.8rem;
    opacity: 0.4;
    transition: all 0.3s ease;
}

.achievement[data-achieved="true"] {
    opacity: 1;
    background: rgba(255, 215, 0, 0.1);
}

.achievement i {
    color: #ffd700;
}

/* 音效控制按钮 */
.sound-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.sound-btn {
    padding: 0.5rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.sound-btn:hover {
    background: #1a4a7a;
    border-color: #4a7aaa;
    transform: scale(1.05);
}

.sound-btn.muted {
    opacity: 0.5;
    background: rgba(255, 0, 0, 0.1);
    border-color: rgba(255, 0, 0, 0.3);
}

/* 页脚 */
footer {
    text-align: center;
    padding: 1.5rem;
    background: var(--bg-secondary);
    border-radius: 16px;
}

footer p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.footer-links {
    margin-top: 0.5rem;
}

.footer-links a {
    color: var(--text-secondary);
    text-decoration: none;
    margin: 0 0.8rem;
}

.footer-links a:hover {
    color: #ffd700;
}

/* 胜利弹窗 */
.win-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fade-in 0.3s ease;
}

@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.win-dialog {
    background: var(--bg-secondary);
    border-radius: 20px;
    padding: 2rem;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    animation: slide-up 0.5s ease;
}

@keyframes slide-up {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.win-dialog h2 {
    font-size: 2rem;
    color: #ffd700;
    margin-bottom: 1rem;
}

.win-dialog .win-icon {
    font-size: 4rem;
    color: #ffd700;
    margin-bottom: 1rem;
    animation: win-bounce 0.5s ease infinite alternate;
}

@keyframes win-bounce {
    from { transform: translateY(0); }
    to { transform: translateY(-10px); }
}

.win-dialog .btns {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 1rem;
}

.win-dialog .btn {
    min-width: 120px;
}

/* 响应式设计 */
@media (max-width: 1200px) {
    .game-area {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .left-panel, .right-panel {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
        gap: 1rem;
    }
}

@media (max-width: 768px) {
    header h1 {
        font-size: 1.5rem;
    }

    .board-header h2 {
        font-size: 1rem;
    }

    .instructions ul {
        grid-template-columns: 1fr;
    }
}

/* 棋盘光晕特效 */
@keyframes glow-pulse {
    0%, 100% { filter: drop-shadow(0 0 5px rgba(255, 215, 0, 0.3)); }
    50% { filter: drop-shadow(0 0 15px rgba(255, 215, 0, 0.6)); }
}

.glow-active {
    animation: glow-pulse 2s ease-in-out infinite;
}

/* 棋子放置动画 */
@keyframes piece-drop {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes ripple {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 215, 0, 0.6);
    }
    100% {
        box-shadow: 0 0 0 20px rgba(255, 215, 0, 0);
    }
}

/* 自定义滚动条 */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}