/* 开始菜单样式 */
.start-menu {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
    margin-top: 50px;
}

.menu-content {
    text-align: center;
    background-color: #fff;
    padding: 40px;
    border-radius: 15px;
    box-shadow: 0 0 30px rgba(0,0,0,0.2);
    border: 3px solid #8B4513;
}

.menu-content h2 {
    color: #8B4513;
    font-size: 28px;
    margin-bottom: 30px;
    font-weight: bold;
}

.mode-buttons {
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: center;
}

.mode-btn {
    padding: 15px 30px;
    font-size: 18px;
    font-weight: bold;
    border: 2px solid #8B4513;
    background-color: #f5f5dc;
    color: #8B4513;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 200px;
}

.mode-btn:hover {
    background-color: #8B4513;
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.mode-btn:active {
    transform: translateY(0);
}

/* 全局样式 */
body {
    font-family: 'Microsoft YaHei', sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: #f0e6d2;
    color: #333;
    margin: 0;
    padding: 10px;
    min-height: 100vh;
    box-sizing: border-box;
}

* {
    box-sizing: border-box;
}

.game-container {
    display: flex;
    gap: 30px;
    margin-top: 20px;
    width: 100%;
    max-width: 1200px;
    justify-content: center;
    align-items: flex-start;
}

/* 棋盘容器样式 */
.board-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: #f5f5dc;
    padding: 60px 20px 20px 20px;
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(0,0,0,0.3);
    position: relative;
}

.black-area, .red-area {
    width: 100%;
    display: flex;
    justify-content: center;
}

.board-with-rows {
    display: flex;
    align-items: center;
}

/* 棋盘样式 */
.board {
    width: 540px;  /* 9 * 60px */
    height: 600px; /* 10 * 60px */
    background-image: url('../images/board.svg');
    background-size: cover;
    position: relative;
    border: 2px solid #8b4513;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    max-width: 100%;
    max-height: 100%;
    min-width: 200px;
    min-height: 222px;
    z-index: 1;
}

/* 列标识样式 */
.col-labels {
    display: flex;
    width: 540px;
    margin: 10px 0;
    position: relative;
    z-index: 100;
}

.col-labels span {
    width: 60px;
    text-align: center;
    font-weight: bold;
    font-size: 16px;
    position: absolute;
    z-index: 100;
}

/* 精确定位每个列标号，使其与棋盘竖线对齐 - 使用百分比确保响应式 */
.col-labels span:nth-child(1) { left: 0%; }
.col-labels span:nth-child(2) { left: 11.111%; }
.col-labels span:nth-child(3) { left: 22.222%; }
.col-labels span:nth-child(4) { left: 33.333%; }
.col-labels span:nth-child(5) { left: 44.444%; }
.col-labels span:nth-child(6) { left: 55.556%; }
.col-labels span:nth-child(7) { left: 66.667%; }
.col-labels span:nth-child(8) { left: 77.778%; }
.col-labels span:nth-child(9) { left: 88.889%; }

.col-labels.black-top {
    margin-top: -20px;
}

.col-labels.black-top span {
    color: #000;
}

/* 人人对战模式下上方标号转向对方 */
.col-labels.black-top.pvp-mode span {
    transform: rotate(180deg);
}

/* 人人对战模式下的棋子旋转现在通过JavaScript动态设置随机角度 */

.col-labels.red-bottom span {
    color: #d32f2f;
}

/* 行标识样式 */
.row-labels {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 600px;
    padding: 30px 0;
    margin: 0 15px;
    z-index: 100;
}

.row-labels span {
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 16px;
    z-index: 100;
}

.row-labels.left span {
    color: #000;
}

.row-labels.right span {
    color: #d32f2f;
}

/* 楚河汉界间隙 */
.river-gap {
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: #666;
}

/* 棋子样式 */
.piece {
    width: 56px;
    height: 56px;
    position: absolute;
    background-size: cover;
    cursor: pointer;
    transition: all 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    border-radius: 50%;
    z-index: 10;
}

/* 移动中的棋子 */
.piece.moving {
    z-index: 20;
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.8);
}

/* 选中棋子的效果 */
.piece.selected {
    transform: scale(1.1);
    box-shadow: 0 0 15px gold;
}

/* 合法移动点的提示 */
.movable-dot {
    position: absolute;
    width: 20px;
    height: 20px;
    background-color: rgba(0, 255, 0, 0.5);
    border-radius: 50%;
    pointer-events: none; /* 让点本身不可点击 */
}

/* 移动路径线条 */
.move-path {
    position: absolute;
    background: linear-gradient(90deg, 
        rgba(255, 215, 0, 0.8) 0%, 
        rgba(255, 215, 0, 0.6) 25%, 
        rgba(255, 215, 0, 0.8) 50%, 
        rgba(255, 215, 0, 0.6) 75%, 
        rgba(255, 215, 0, 0.8) 100%);
    background-size: 20px 100%;
    pointer-events: none;
    z-index: 5;
    border-radius: 2px;
    border: 1px dashed rgba(255, 215, 0, 0.9);
    animation: pathDash 2s linear infinite;
}

/* 虚线流动动画 */
@keyframes pathDash {
    0% {
        background-position: 0px 0px;
    }
    100% {
        background-position: 20px 0px;
    }
}

/* 移动起点标记 */
.move-from {
    position: absolute;
    width: 60px;
    height: 60px;
    border: 3px dashed rgba(0, 255, 0, 0.8);
    border-radius: 50%;
    pointer-events: none;
    z-index: 8;
    animation: fromPulse 2s ease-in-out infinite;
    background-color: rgba(0, 255, 0, 0.1);
}

/* 移动终点标记 */
.move-to {
    position: absolute;
    width: 60px;
    height: 60px;
    border: 3px solid rgba(255, 0, 0, 0.8);
    border-radius: 50%;
    pointer-events: none;
    z-index: 8;
    animation: toPulse 2s ease-in-out infinite;
    background-color: rgba(255, 0, 0, 0.1);
    box-shadow: 0 0 15px rgba(255, 0, 0, 0.3);
}

/* 动画效果 */
@keyframes pathFade {
    0% {
        opacity: 1;
        transform: scale(1.2);
    }
    100% {
        opacity: 0;
        transform: scale(1);
    }
}

@keyframes fromPulse {
    0% {
        opacity: 0.8;
        transform: scale(1);
        border-color: rgba(0, 255, 0, 0.8);
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
        border-color: rgba(0, 255, 0, 1);
    }
    100% {
        opacity: 0.8;
        transform: scale(1);
        border-color: rgba(0, 255, 0, 0.8);
    }
}

@keyframes toPulse {
    0% {
        opacity: 0.9;
        transform: scale(1);
        box-shadow: 0 0 15px rgba(255, 0, 0, 0.3);
    }
    50% {
        opacity: 1;
        transform: scale(1.08);
        box-shadow: 0 0 25px rgba(255, 0, 0, 0.6);
    }
    100% {
        opacity: 0.9;
        transform: scale(1);
        box-shadow: 0 0 15px rgba(255, 0, 0, 0.3);
    }
}

/* 棋子移动轨迹粒子效果 */
.move-particle {
    position: absolute;
    width: 8px;
    height: 8px;
    background-color: rgba(255, 215, 0, 0.9);
    border-radius: 50%;
    pointer-events: none;
    z-index: 15;
    animation: particleMove 0.8s ease-out forwards;
}

@keyframes particleMove {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    100% {
        opacity: 0;
        transform: scale(0.3);
    }
}

/* 控制面板样式 */
.panel {
    width: 250px;
    padding: 20px;
    background-color: #fff8e1;
    border: 2px solid #8b4513;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0,0,0,0.2);
}

.panel h2 {
    border-bottom: 2px solid #8b4513;
    padding-bottom: 5px;
    margin-top: 0;
}

.info, .check-status {
    font-size: 1.2em;
    font-weight: bold;
    margin: 10px 0;
    min-height: 25px;
}

.check-status {
    color: #d9534f;
}

button, select {
    width: 100%;
    padding: 10px;
    margin-top: 10px;
    font-size: 1em;
    background-color: #8b4513;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}

button:hover {
    background-color: #a0522d;
}

/* 走棋记录样式 */
.move-history {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 5px;
    background-color: #f9f9f9;
}

.move-list {
    padding: 10px;
}

.move-item {
    padding: 5px;
    margin: 2px 0;
    border-radius: 3px;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.move-item:hover {
    background-color: #e0e0e0;
}

.move-item.red {
    color: #d2691e;
    font-weight: bold;
}

.move-item.black {
    color: #333;
    font-weight: bold;
}

/* 游戏结束特效 */
.game-end-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: overlayFadeIn 0.5s ease-in;
}

.game-end-message {
    background: linear-gradient(135deg, #ffd700, #ffed4e);
    color: #8b4513;
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    font-size: 2em;
    font-weight: bold;
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.8);
    border: 3px solid #8b4513;
    animation: messagePopIn 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    max-width: 450px;
}

.game-result {
    margin-bottom: 20px;
    font-size: 1.2em;
}

.game-stats {
    background: rgba(139, 69, 19, 0.1);
    border-radius: 10px;
    padding: 15px;
    margin: 20px 0;
    font-size: 0.6em;
    line-height: 1.6;
}

.game-stats div {
    margin: 5px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.game-stats div:before {
    content: '•';
    color: #8b4513;
    margin-right: 8px;
}

.game-end-buttons {
    margin-top: 20px;
    display: flex;
    gap: 15px;
    justify-content: center;
}

.game-end-buttons button {
    padding: 12px 24px;
    font-size: 1rem;
    border-radius: 8px;
    cursor: pointer;
    border: none;
    font-weight: bold;
    transition: all 0.3s ease;
    width: auto;
}

.btn-new-game {
    background: linear-gradient(135deg, #4CAF50, #45a049);
    color: white;
}

.btn-new-game:hover {
    background: linear-gradient(135deg, #45a049, #3d8b40);
    transform: translateY(-2px);
}

.btn-replay {
    background: linear-gradient(135deg, #2196F3, #1976D2);
    color: white;
}

.btn-replay:hover {
    background: linear-gradient(135deg, #1976D2, #1565C0);
    transform: translateY(-2px);
}

/* 胜利烟花特效 */
.firework {
    position: absolute;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    pointer-events: none;
    z-index: 999;
}

.firework-red {
    background-color: #ff4444;
    box-shadow: 0 0 10px #ff4444;
}

.firework-gold {
    background-color: #ffd700;
    box-shadow: 0 0 10px #ffd700;
}

.firework-blue {
    background-color: #4444ff;
    box-shadow: 0 0 10px #4444ff;
}

/* 复盘控制面板 */
.replay-controls {
    display: none;
    background-color: #fff8e1;
    border: 2px solid #8b4513;
    border-radius: 10px;
    padding: 15px;
    margin-top: 10px;
}

.replay-controls.active {
    display: block;
}

.replay-buttons {
    display: flex;
    gap: 5px;
    margin-bottom: 10px;
}

.replay-buttons button {
    flex: 1;
    padding: 8px;
    font-size: 0.9em;
    margin-top: 0;
}

.replay-progress {
    margin: 10px 0;
}

.replay-slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #ddd;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.replay-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #8b4513;
    cursor: pointer;
}

.replay-info {
    text-align: center;
    font-size: 0.9em;
    color: #666;
}

/* 动画效果 */
@keyframes overlayFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes messagePopIn {
    0% {
        opacity: 0;
        transform: scale(0.3) rotate(-10deg);
    }
    50% {
        opacity: 1;
        transform: scale(1.05) rotate(2deg);
    }
    100% {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }
}

@keyframes fireworkExplode {
    0% {
        opacity: 1;
        transform: scale(0);
    }
    50% {
        opacity: 1;
        transform: scale(1);
    }
    100% {
        opacity: 0;
        transform: scale(1.5);
    }
}

/* 响应式设计 - 媒体查询 */

/* 大屏幕桌面 (1200px+) */
@media (min-width: 1200px) {
    .game-container {
        gap: 40px;
    }
    
    .panel {
        width: 280px;
    }
}

/* 中等屏幕 (768px - 1199px) */
@media (max-width: 1199px) and (min-width: 768px) {
    .game-container {
        gap: 20px;
        padding: 0 10px;
    }
    
    .panel {
        width: 220px;
        padding: 15px;
    }
    
    .board {
        width: 450px;
        height: 500px;
    }
    
    .col-labels {
        width: 450px;
        padding: 0 25px;
    }
    
    .col-labels span {
        width: 50px;
        font-size: 14px;
    }
    
    .row-labels {
        height: 500px;
        padding: 25px 0;
    }
    
    .row-labels span {
        height: 50px;
        font-size: 14px;
    }
    
    .piece {
        width: 46px;
        height: 46px;
    }
    
    .move-from, .move-to {
        width: 50px;
        height: 50px;
    }
}

/* 小屏幕平板 (481px - 767px) */
@media (max-width: 767px) and (min-width: 481px) {
    .game-container {
        flex-direction: column;
        gap: 20px;
        align-items: center;
    }
    
    .board-container {
        padding: 15px;
    }
    
    .board {
        width: 360px;
        height: 400px;
    }
    
    .col-labels {
        width: 360px;
    }
    
    .col-labels span {
        width: 40px;
        font-size: 12px;
    }
    
    .row-labels {
        height: 400px;
        padding: 20px 0;
    }
    
    .row-labels span {
        height: 40px;
        font-size: 12px;
    }
    
    .piece {
        width: 36px;
        height: 36px;
    }
    
    .move-from, .move-to {
        width: 40px;
        height: 40px;
    }
    
    .movable-dot {
        width: 16px;
        height: 16px;
    }
    
    .panel {
        width: 100%;
        max-width: 400px;
        padding: 15px;
    }
    
    .panel h2 {
        font-size: 1.2em;
    }
    
    .info, .check-status {
        font-size: 1.1em;
    }
}

/* 手机屏幕 (最大480px) */
@media (max-width: 480px) {
    body {
        padding: 5px;
    }
    
    h1 {
        font-size: 1.5em;
        margin: 10px 0;
    }
    
    .game-container {
        flex-direction: column;
        gap: 15px;
        align-items: center;
        margin-top: 10px;
    }
    
    .board-container {
        padding: 10px;
        width: 100%;
        max-width: 320px;
    }
    
    .board {
        width: 270px;
        height: 300px;
    }
    
    .col-labels {
        width: 270px;
        margin: 5px 0;
    }
    
    .col-labels span {
        width: 30px;
        font-size: 10px;
    }
    
    .row-labels {
        height: 300px;
        padding: 15px 0;
        margin: 0 10px;
    }
    
    .row-labels span {
        height: 30px;
        font-size: 10px;
    }
    
    .piece {
        width: 26px;
        height: 26px;
    }
    
    .move-from, .move-to {
        width: 30px;
        height: 30px;
        border-width: 2px;
    }
    
    .movable-dot {
        width: 12px;
        height: 12px;
    }
    
    .move-path {
        border-width: 1px;
    }
    
    .panel {
        width: 100%;
        max-width: 320px;
        padding: 12px;
    }
    
    .panel h2 {
        font-size: 1.1em;
        margin-top: 0;
        margin-bottom: 10px;
    }
    
    .info, .check-status {
        font-size: 1em;
        margin: 8px 0;
    }
    
    button, select {
        padding: 8px;
        font-size: 0.9em;
        margin-top: 8px;
    }
    
    .move-history {
        max-height: 150px;
    }
    
    .move-item {
        font-size: 12px;
        padding: 3px;
    }
    
    .replay-buttons button {
        padding: 6px;
        font-size: 0.8em;
    }
    
    .game-end-message {
        font-size: 1.2em;
        padding: 20px;
        margin: 10px;
        max-width: 280px;
    }
    
    .game-stats {
        font-size: 0.5em;
        padding: 10px;
    }
    
    .game-end-buttons {
        flex-direction: column;
        gap: 10px;
    }
    
    .game-end-buttons button {
        width: 100%;
        padding: 10px 20px;
        font-size: 0.9rem;
    }
}

/* 超小屏幕 (最大320px) */
@media (max-width: 320px) {
    .board {
        width: 240px;
        height: 270px;
    }
    
    .col-labels {
        width: 240px;
    }
    
    .col-labels span {
        width: 26px;
        font-size: 9px;
    }
    
    .row-labels {
        height: 270px;
        padding: 12px 0;
    }
    
    .row-labels span {
        height: 27px;
        font-size: 9px;
    }
    
    .piece {
        width: 22px;
        height: 22px;
    }
    
    .move-from, .move-to {
        width: 26px;
        height: 26px;
    }
    
    .panel {
        max-width: 280px;
        padding: 10px;
    }
    
    .game-end-message {
        max-width: 250px;
        font-size: 1em;
        padding: 15px;
    }
}

/* 极小屏幕优化 (最大280px) */
@media (max-width: 280px) {
    body {
        padding: 2px;
    }
    
    h1 {
        font-size: 1.2em;
        margin: 5px 0;
    }
    
    .board-container {
        padding: 5px;
    }
    
    .board {
        width: 200px;
        height: 222px;
    }
    
    .col-labels {
        width: 200px;
        margin: 3px 0;
    }
    
    .col-labels span {
        width: 22px;
        font-size: 8px;
    }
    
    .row-labels {
        height: 222px;
        padding: 10px 0;
        margin: 0 5px;
    }
    
    .row-labels span {
        height: 22px;
        font-size: 8px;
    }
    
    .piece {
        width: 18px;
        height: 18px;
    }
    
    .panel {
        max-width: 200px;
        padding: 8px;
    }
    
    .panel h2 {
        font-size: 1em;
        margin-bottom: 8px;
    }
    
    button, select {
        padding: 6px;
        font-size: 0.8em;
        margin-top: 6px;
    }
    
    .move-history {
        max-height: 100px;
    }
    
    .move-item {
        font-size: 10px;
        padding: 2px;
    }
}

/* 全屏模式样式 */
.fullscreen-mode {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #2c1810;
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.fullscreen-mode .board-container {
    transform: none;
    margin: 0;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.fullscreen-mode .board {
    /* 尺寸由JavaScript动态设置 */
    position: relative;
}

/* 全屏模式下的样式由JavaScript动态设置 */

.fullscreen-exit-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 24px;
    cursor: pointer;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.fullscreen-exit-btn:hover {
    background: rgba(255, 255, 255, 1);
    transform: scale(1.1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

.fullscreen-restart-btn {
    position: absolute;
    top: 20px;
    right: 80px;
    background: rgba(76, 175, 80, 0.9);
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 24px;
    cursor: pointer;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    color: white;
}

.fullscreen-restart-btn:hover {
    background: rgba(76, 175, 80, 1);
    transform: scale(1.1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

/* 全屏模式下的小屏幕优化 */
@media (max-width: 768px) {
    .fullscreen-mode {
        padding: 10px;
    }
    
    .fullscreen-exit-btn {
        top: 10px;
        right: 10px;
        width: 45px;
        height: 45px;
        font-size: 20px;
    }
    
    .fullscreen-restart-btn {
        top: 10px;
        right: 65px;
        width: 45px;
        height: 45px;
        font-size: 20px;
    }
}

@media (max-width: 480px) {
    .fullscreen-mode {
        padding: 5px;
    }
    
    .fullscreen-exit-btn {
        top: 5px;
        right: 5px;
        width: 40px;
        height: 40px;
        font-size: 18px;
    }
    
    .fullscreen-restart-btn {
        top: 5px;
        right: 50px;
        width: 40px;
        height: 40px;
        font-size: 18px;
    }
}

/* 横屏模式优化 */
@media (orientation: landscape) and (max-height: 600px) {
    .fullscreen-mode .board-container {
        margin-top: -20px;
    }
    
    .fullscreen-exit-btn {
        top: 5px;
        right: 5px;
    }
}

/* 小屏幕设备优化 */
@media (max-width: 768px) {
    .fullscreen-mode .board {
        width: 90vw;
        height: 90vw;
    }
    
    .fullscreen-mode .piece {
        width: calc(90vw / 9 * 0.93);
        height: calc(90vw / 9 * 0.93);
    }
    
    .fullscreen-mode .col-labels span {
        font-size: calc(90vw / 9 * 0.15);
    }
}