* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    touch-action: manipulation;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: "Microsoft YaHei", Arial, Helvetica, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: #333;
    background: #fff;
}

/* 头部 */
.header {
    background: #f5f7fa;
    border-bottom: 1px solid #e4e7ed;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    color: #303133;
    font-size: 18px;
    font-weight: bold;
}

.nav {
    display: flex;
    gap: 20px;
}

.nav-link {
    color: #606266;
    text-decoration: none;
    font-size: 14px;
}

.nav-link:hover,
.nav-link.active {
    color: #409eff;
}

/* 主体 */
.main {
    max-width: 1200px;
    margin: 20px auto;
    padding: 0 20px;
}

/* 搜索区域 */
.search-box {
    background: #fff;
    border: 1px solid #e4e7ed;
    padding: 20px;
    margin-bottom: 20px;
}

.search-row {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

.search-label {
    font-size: 14px;
    color: #606266;
    white-space: nowrap;
}

.search-input {
    padding: 8px 12px;
    font-size: 14px;
    border: 1px solid #dcdfe6;
    border-radius: 4px;
    min-width: 200px;
}

.search-input:focus {
    outline: none;
    border-color: #409eff;
}

.btn {
    padding: 8px 20px;
    font-size: 14px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    touch-action: manipulation;
}

.btn-blue {
    background: #409eff;
    color: #fff;
}

.btn-blue:hover {
    background: #66b1ff;
}

.btn-green {
    background: #67c23a;
    color: #fff;
}

.btn-green:hover {
    background: #85ce61;
}

.btn-gray {
    background: #909399;
    color: #fff;
}

.btn-gray:hover {
    background: #a6a9ad;
}

.btn-milky {
    background: #fafafa;
    color: #606266;
    border: 1px solid #ebeef5;
}

.btn-milky:hover {
    background: #f5f5f5;
    border-color: #e4e7ed;
}

/* 分页导航 */
.pagination {
    background: #f5f7fa;
    padding: 15px;
    text-align: center;
    border-top: 1px solid #e4e7ed;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.pagination-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.jump-input-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 20px;
    font-size: 14px;
    color: #606266;
}

.jump-input {
    width: 60px;
    padding: 6px 8px;
    font-size: 14px;
    border: 1px solid #dcdfe6;
    border-radius: 4px;
    text-align: center;
}

.jump-input:focus {
    outline: none;
    border-color: #409eff;
}

.page-indicator {
    padding: 6px 15px;
    background: #fff;
    color: #303133;
    border: 1px solid #dcdfe6;
    border-radius: 4px;
    font-weight: 500;
}

.btn-page {
    padding: 6px 15px;
    font-size: 14px;
    background: #fff;
    color: #409eff;
    border: 1px solid #dcdfe6;
    cursor: pointer;
}

.btn-page:hover:not(:disabled) {
    background: #409eff;
    color: #fff;
}

.btn-page:disabled {
    background: #f5f7fa;
    color: #c0c4cc;
    border-color: #e4e7ed;
    cursor: not-allowed;
}

.search-info {
    padding: 10px 0;
    font-size: 14px;
    color: #606266;
}

/* 搜索按钮行 */
.search-btn-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

/* 棋手1+棋手2 同行 */
.search-row-players {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.search-field {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 0;
}

.search-field .search-label {
    width: 42px;
    flex-shrink: 0;
}

.search-field .search-input {
    width: 0;
    min-width: 0;
    flex: 1;
}

/* 比赛名行标签宽度与棋手标签对齐 */
.search-row .search-label {
    width: 42px;
    flex-shrink: 0;
}

.page-size-selector {
    display: flex;
    align-items: center;
    gap: 8px;
}

.page-size-selector label {
    font-size: 14px;
    color: #606266;
}

#pageSizeSelect {
    padding: 6px 10px;
    font-size: 14px;
    border: 1px solid #dcdfe6;
    border-radius: 4px;
    cursor: pointer;
}

#pageSizeSelect:focus {
    outline: none;
    border-color: #409eff;
}

/* 内容区域 */
.content-area {
    background: #fff;
    border: 1px solid #e4e7ed;
    min-height: 400px;
}

/* 棋谱表格 */
.game-table {
    width: 100%;
    border-collapse: collapse;
}

.game-table th,
.game-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #ebeef5;
}

.game-table th {
    background: #f5f7fa;
    font-weight: 600;
    color: #909399;
    font-size: 14px;
}

.game-table tbody tr:hover {
    background: #f5f7fa;
    cursor: pointer;
}

.game-table .col-num {
    width: 50px;
    text-align: center;
}

.game-table .col-player {
    width: 120px;
}

.game-table .col-result {
    width: 120px;
}

.game-table .col-date {
    width: 140px;
}

.game-table .col-tournament {
    width: auto;
}

.game-table .col-action {
    width: 80px;
    text-align: center;
}

.view-link {
    color: #409eff;
    text-decoration: none;
    cursor: pointer;
}

.view-link:hover {
    text-decoration: underline;
}

/* 棋盘区域 */
.board-main {
    display: flex;
    justify-content: flex-start;
    align-items: flex-start;
    padding: 20px;
    gap: 30px;
    flex-wrap: wrap;
    margin-left: 50px;
}

.game-info-panel {
    flex: 0 0 280px;
}

.game-info {
    background: #f5f7fa;
    border: 1px solid #e4e7ed;
    padding: 20px;
}

.game-info h3 {
    color: #303133;
    margin-bottom: 15px;
    font-size: 16px;
}

.game-info p {
    margin-bottom: 8px;
    font-size: 14px;
    color: #606266;
}

.game-info strong {
    color: #303133;
}

.board-container {
    flex: 0 0 auto;
    position: relative;
    touch-action: none;
}

#boardCanvas {
    border: 2px solid #dcdfe6;
    background: #d4b896;
    display: block;
    touch-action: none;
}

/* 棋盘上的标签和按钮 - 相对于board-area定位 */
.board-area {
    position: relative;
}

.board-label {
    position: absolute;
    background: rgba(255, 255, 255, 0.95);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: bold;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    border: 1px solid #e4e7ed;
    z-index: 100;
}

.board-label-move {
    top: 70px;
    right: 20px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
}

.board-btn {
    position: absolute;
    right: 20px;
    width: auto;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: bold;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    transition: transform 0.2s;
    z-index: 100;
}

.board-btn:hover {
    transform: scale(1.05);
    background: rgba(0, 0, 0, 0.9);
}

.board-btn-download {
    top: 120px;
}

.board-btn-back {
    top: 170px;
}

/* 背景选择器 */
.bg-selector {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: flex;
    gap: 6px;
    z-index: 100;
}

/* 右侧工具面板 */
.right-tools-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 15px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 8px;
    align-self: flex-start;
}

.tool-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.tool-label {
    font-size: 12px;
    color: #606266;
    font-weight: 500;
}

.tool-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid #dcdfe6;
    background: white;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
}

.tool-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.bg-selector-vertical {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.bg-selector-vertical .bg-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid #dcdfe6;
    cursor: pointer;
    transition: transform 0.2s;
}

.bg-selector-vertical .bg-btn:hover {
    transform: scale(1.1);
}

.bg-selector-vertical .bg-btn.active {
    border-color: #409eff;
    box-shadow: 0 0 0 2px rgba(64, 158, 255, 0.3);
}

.bg-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid #dcdfe6;
    cursor: pointer;
    transition: transform 0.2s;
}

.bg-btn:hover {
    transform: scale(1.1);
}

.bg-btn.active {
    border-color: #409eff;
    box-shadow: 0 0 0 2px rgba(64, 158, 255, 0.3);
}

/* 控制面板 */
.control-panel {
    background: #f5f7fa;
    padding: 8px 15px;
    text-align: center;
    border-top: 1px solid #e4e7ed;
    width: 100%;
    display: flex;
    justify-content: center;
}

/* 桌面端：显示底部控制面板 */
.control-panel-desktop {
    display: flex;
    margin-left: 50px;
}

/* 移动端：控制面板在board-main内部 */
.control-panel-inline {
    display: none;
}

@media (max-width: 768px) {
    /* 移动端：隐藏底部控制面板 */
    .control-panel-desktop {
        display: none;
    }
    
    /* 移动端：显示内部控制面板 */
    .control-panel-inline {
        display: flex;
        padding: 8px 15px 4px 15px;
        border-top: none;
        background: transparent;
        width: 100%;
        justify-content: center;
    }
}

.move-indicator {
    display: inline-block;
    padding: 6px 15px;
    background: #409eff;
    color: #fff;
    margin: 0 10px;
    font-weight: 500;
    border-radius: 4px;
}

/* 走棋按钮 */
.move-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.btn-amber {
    background: linear-gradient(to right, #d97706, #b45309);
    color: white;
}

.btn-amber:hover {
    background: linear-gradient(to right, #b45309, #92400e);
}

.btn-amber-light {
    background: linear-gradient(to right, #f59e0b, #d97706);
    color: white;
}

.btn-amber-light:hover {
    background: linear-gradient(to right, #d97706, #b45309);
}

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

/* 加载和错误 */
.loading {
    text-align: center;
    padding: 60px;
    color: #909399;
}

.error {
    color: #f56c6c;
    padding: 40px;
    text-align: center;
}

/* 底部 */
.footer {
    text-align: center;
    padding: 20px;
    color: #909399;
    font-size: 12px;
    margin-top: 30px;
}

/* 响应式 */
@media (max-width: 900px) {
    .game-table .col-tournament {
        display: none;
    }
    
    .search-row {
        flex-direction: row;
        align-items: center;
        flex-wrap: nowrap;
        gap: 6px;
    }
    
    .search-label {
        flex-shrink: 0;
        font-size: 13px;
    }
    
    .search-field {
        gap: 4px;
    }
    
    .search-field .search-input {
        min-width: 60px;
    }
    
    .search-input {
        flex: 1;
        min-width: 0;
    }
    
    .search-btn-row {
        flex-wrap: nowrap;
    }
    
    .search-btn-row .btn {
        flex: 1;
    }
}

/* 939-1050px区间：图标组移到棋盘右侧 */
@media (max-width: 1050px) and (min-width: 939px) {
    .board-label-move {
        top: 70px;
        right: -80px;
    }
    
    .board-btn {
        right: -80px;
    }
    
    .board-btn-download {
        top: 100px;
    }
    
    .board-btn-back {
        top: 128px;
    }
}

/* 平板端（768px-1024px）走子图标放大 */
@media (max-width: 1024px) and (min-width: 768px) {
    .move-buttons .btn {
        padding: 24px 36px;
        font-size: 32px;
    }
    
    .control-panel {
        padding: 12px 20px;
    }
}

@media (max-width: 768px) {
    .board-main {
        flex-direction: column;
        align-items: center;
        margin-left: 0;
        padding: 10px;
    }
    
    #boardCanvas {
        max-width: 100%;
        height: auto;
    }
    
    .board-container {
        width: 100%;
        display: flex;
        justify-content: center;
        touch-action: none; /* 防止iOS Safari缩放 */
    }
    
    .pagination {
        flex-direction: column;
        gap: 10px;
    }
    
    .pagination-right {
        justify-content: center;
    }
    
    .control-panel {
        padding: 8px 15px 4px 15px;
        border-top: none;
        background: transparent;
    }
    
    .move-buttons {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 6px;
        justify-content: center;
    }
    
    .move-buttons .btn {
        width: auto;
        max-width: none;
        padding: 6px 10px;
        font-size: 14px;
    }
    
    .game-info-panel {
        flex: 0 0 auto;
        width: 100%;
    }
    
    .board-label {
        font-size: 11px;
        padding: 5px 8px;
    }
    
    /* 移动端棋盘overlay按钮紧凑排列 */
    .board-label-move {
        top: 140px;
        right: 20px;
        font-size: 11px;
        padding: 3px 8px;
    }
    
    .board-btn {
        right: 20px;
        font-size: 11px;
        padding: 4px 8px;
    }
    
    .board-btn-download {
        top: 170px;
    }
    
    .board-btn-back {
        top: 198px;
    }
    
    /* 移动端显示右侧工具面板 */
    .right-tools-panel {
        display: flex;
        flex-direction: row;
        justify-content: center;
        gap: 8px;
        margin-top: 8px;
        position: relative;
        left: 50%;
        transform: translateX(-50%);
    }

    .tool-group {
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .tool-btn {
        width: 28px;
        height: 28px;
        font-size: 14px;
    }

    .bg-selector-vertical {
        display: flex;
        flex-direction: row;
        gap: 4px;
    }

    .bg-btn {
        width: 28px;
        height: 28px;
    }
}

@media (max-width: 600px) {
    .game-table .col-date {
        display: none;
    }
    
    .game-table .col-result {
        width: 80px;
    }
    
    .board-label-move {
        top: 140px;
        right: 20px;
        font-size: 10px;
        padding: 2px 6px;
    }
    
    .board-btn {
        right: 20px;
        font-size: 10px;
        padding: 3px 6px;
        width: auto;
        height: auto;
    }
    
    .board-btn-download {
        top: 165px;
    }
    
    .board-btn-back {
        top: 190px;
    }
    
    .control-panel {
        padding: 6px 15px 2px 15px;
        border-top: none;
        background: transparent;
    }
    
    .move-buttons {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 5px;
        justify-content: center;
    }
    
    .move-buttons .btn {
        width: auto;
        max-width: none;
        padding: 5px 8px;
        font-size: 13px;
    }
    
    /* 移动端显示右侧工具面板 */
    .right-tools-panel {
        display: flex;
        flex-direction: row;
        justify-content: center;
        gap: 8px;
        margin-top: 8px;
        position: relative;
        left: 50%;
        transform: translateX(-50%);
    }
    
    .tool-group {
        display: flex;
        flex-direction: column;
        align-items: center;
    }
    
    .tool-btn {
        width: 24px;
        height: 24px;
        font-size: 12px;
    }
    
    .bg-selector-vertical {
        display: flex;
        flex-direction: row;
        gap: 3px;
    }
    
    .bg-btn {
        width: 24px;
        height: 24px;
    }
}




/* 搜索容器基础样式 - 移动端优先 */
.search-all-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.search-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.search-item .search-label {
    width: 55px;
    flex-shrink: 0;
}

.search-item .search-input {
    flex: 1;
    min-width: 0;
}

/* 按钮行样式 */
.search-buttons-row {
    display: flex;
    gap: 10px;
}

.search-buttons-row .btn {
    flex: 1;
}

/* 经典版电脑端（>1024px）搜索区域单行布局 */
@media (min-width: 1025px) {
    .search-all-container {
        flex-direction: row;
        align-items: center;
        gap: 12px;
        flex-wrap: wrap;
    }
    
    .search-item {
        margin-bottom: 0;
    }
    
    .search-item .search-label {
        width: auto;
    }
    
    .search-item .search-input {
        width: 170px;
        min-width: 170px;
        flex: none;
    }
    
    /* 赛事名输入框增加一个汉字宽度 */
    .search-all-container > .search-item:nth-of-type(3) .search-input {
        width: 194px;
        min-width: 194px;
    }
    
    /* 电脑端按钮行变成contents，让按钮直接参与flex布局 */
    .search-buttons-row {
        display: contents;
    }
    
    .search-buttons-row .btn {
        flex: none;
    }
    
    .search-all-container .btn {
        align-self: center;
    }
}

/* 平板端（768px-1024px）优化 */
@media (max-width: 1024px) and (min-width: 768px) {
    .search-item .search-label {
        width: 60px;
    }
    
    .search-buttons-row .btn {
        flex: none;
        padding: 10px 24px;
    }
}

/* 小屏幕手机端（<600px）优化 */
@media (max-width: 600px) {
    .search-item .search-label {
        width: 48px;
        font-size: 13px;
    }
    
    .search-buttons-row {
        flex-direction: column;
    }
    
    .search-buttons-row .btn {
        width: 100%;
    }
}



/* 清空状态样式 */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

.empty-stones {
    font-size: 48px;
    margin-bottom: 16px;
}

.empty-text {
    font-size: 18px;
    color: #606266;
}

