* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
}
body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: #2c1810;
    font-family: 'Microsoft YaHei', 'PingFang SC', sans-serif;
    padding: 12px;
}

/* 弹窗 */
.modal {
    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;
}
.modal-content {
    background: #6b4c3b;
    padding: 32px 40px;
    border-radius: 24px;
    max-width: 420px;
    width: 90%;
    text-align: center;
    border: 2px solid #8b6b4b;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.9);
}
.modal-content h2 {
    color: #f7e8c8;
    margin-bottom: 4px;
}
.room-input-group {
    display: flex;
    gap: 10px;
    margin-top: 8px;
}
.room-input-group input {
    flex: 1;
    padding: 10px 14px;
    border-radius: 12px;
    border: 1px solid #8b6b4b;
    background: #3d2b1f;
    color: #f0d5b0;
    font-size: 16px;
    outline: none;
    text-align: center;
    letter-spacing: 2px;
}
.room-input-group input::placeholder {
    color: #7a5f4a;
}
.room-input-group input:focus {
    border-color: #d4a76a;
}
.btn {
    padding: 8px 18px;
    border: none;
    border-radius: 20px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    background: rgba(255, 215, 140, 0.12);
    color: #f0d5b0;
    border: 1px solid rgba(255, 215, 140, 0.2);
    white-space: nowrap;
}
.btn:hover {
    background: rgba(255, 215, 140, 0.25);
    transform: scale(1.03);
}
.btn:active {
    transform: scale(0.95);
}
.btn-primary {
    background: #8b5a3b;
    border-color: #a87a5a;
    color: #f7e8c8;
}
.btn-primary:hover {
    background: #a87a5a;
}
.btn-primary:active {
    background: #7a4d32;
}

/* 游戏容器 */
.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: #6b4c3b;
    padding: 20px 28px 24px 28px;
    border-radius: 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8), inset 0 1px 4px rgba(255, 215, 140, 0.3);
    border: 2px solid #8b6b4b;
    max-width: 700px;
    width: 100%;
}
.header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-bottom: 10px;
    gap: 6px;
}
.header .title {
    font-size: 26px;
    font-weight: bold;
    letter-spacing: 4px;
    background: linear-gradient(180deg, #f7e8c8, #d4a76a);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: none;
    white-space: nowrap;
}
.status-area {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.status-area .turn-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 14px;
    border-radius: 30px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 215, 140, 0.2);
    font-size: 15px;
    color: #f0d5b0;
}
.turn-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.3);
    transition: background 0.3s;
    flex-shrink: 0;
}
.turn-dot.red {
    background: #d43d3d;
    box-shadow: 0 0 12px rgba(212, 61, 61, 0.6);
}
.turn-dot.black {
    background: #2a2a2a;
    box-shadow: 0 0 12px rgba(50, 50, 50, 0.6);
}
.status-text {
    font-weight: bold;
    min-width: 44px;
    text-align: center;
    font-size: 15px;
}
.status-text.red {
    color: #ff6b6b;
}
.status-text.black {
    color: #aaa;
}
.btn-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.mode-label {
    color: #c4a88a;
    font-size: 14px;
    font-weight: bold;
    letter-spacing: 1px;
    padding: 4px 16px;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 30px;
    border: 1px solid rgba(255, 215, 140, 0.08);
    margin-bottom: 12px;
    width: 100%;
    text-align: center;
}
.board-wrapper {
    position: relative;
    border-radius: 12px;
    box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.6), 0 10px 40px rgba(0, 0, 0, 0.7);
    border: 6px solid #5a3d2b;
    background: #d4a76a;
    width: 100%;
    max-width: 600px;
}
canvas {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 9 / 10;
    background: #d4a76a;
    border-radius: 6px;
    cursor: pointer;
    touch-action: none;
}
.info-bar {
    display: flex;
    justify-content: space-between;
    width: 100%;
    margin-top: 12px;
    color: #c4a88a;
    font-size: 14px;
    padding: 0 4px;
    flex-wrap: wrap;
    gap: 4px;
}
.info-bar .move-log {
    color: #e8d5b8;
    font-size: 13px;
    max-width: 380px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 120px;
}
.info-bar .move-log span {
    color: #ffb37b;
}
.check-notify {
    color: #ff4444;
    font-weight: bold;
    animation: pulse 0.7s ease-in-out infinite alternate;
    font-size: 15px;
}
@keyframes pulse {
    0% {
        opacity: 0.5;
        transform: scale(0.95);
    }
    100% {
        opacity: 1;
        transform: scale(1.05);
    }
}

@media (max-width: 640px) {
    .game-container {
        padding: 12px 12px 16px 12px;
    }
    .header .title {
        font-size: 20px;
        letter-spacing: 2px;
    }
    .status-area {
        gap: 6px;
    }
    .status-area .turn-indicator {
        font-size: 13px;
        padding: 3px 10px;
    }
    .status-text {
        font-size: 13px;
        min-width: 34px;
    }
    .btn {
        font-size: 12px;
        padding: 3px 10px;
    }
    .mode-label {
        font-size: 12px;
        padding: 2px 12px;
    }
    .info-bar {
        font-size: 12px;
    }
    .info-bar .move-log {
        font-size: 12px;
        max-width: 200px;
    }
    .check-notify {
        font-size: 13px;
    }
    .modal-content {
        padding: 24px 20px;
    }
    .modal-content h2 {
        font-size: 20px;
    }
    .room-input-group {
        flex-direction: column;
    }
}
@media (max-width: 480px) {
    .header .title {
        font-size: 17px;
        letter-spacing: 1px;
    }
    .status-area .turn-indicator {
        font-size: 11px;
        padding: 2px 8px;
    }
    .status-text {
        font-size: 11px;
        min-width: 28px;
    }
    .btn {
        font-size: 11px;
        padding: 2px 8px;
    }
    .mode-label {
        font-size: 11px;
        padding: 2px 8px;
    }
    .info-bar .move-log {
        font-size: 11px;
        max-width: 140px;
    }
}
/* ===== 新增样式 ===== */
.input-field {
    padding: 10px 14px;
    border-radius: 12px;
    border: 1px solid #8b6b4b;
    background: #3d2b1f;
    color: #f0d5b0;
    font-size: 15px;
    outline: none;
    width: 100%;
    margin: 4px 0;
}
.input-field:focus {
    border-color: #d4a76a;
}
#chatMessages {
    scrollbar-width: thin;
    scrollbar-color: #5a3d2b transparent;
}
#chatMessages::-webkit-scrollbar {
    width: 4px;
}
#chatMessages::-webkit-scrollbar-thumb {
    background: #5a3d2b;
    border-radius: 4px;
}
.modal-content .input-field {
    width: 100%;
    margin: 6px 0;
}
.modal-content .btn {
    min-width: 80px;
}
#replayControls .btn {
    padding: 2px 10px;
    font-size: 13px;
}