body {
    font-family: 'Microsoft YaHei', Arial, sans-serif;
    background-color: #f4f4f9;
    margin: 0;
    padding: 0;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    background-color: #fff;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.1);
    border-radius: 10px;
}

h1 {
    color: #333;
    text-align: center;
    margin-bottom: 30px;
}

h2 {
    color: #444;
    margin-top: 30px;
}

.game-form {
    margin: 20px 0;
}

.game-form table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

.game-form th,
.game-form td {
    padding: 10px;
    text-align: center;
    border: 1px solid #ddd;
}

.game-form input[type="number"],
.game-form select {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.save-btn {
    padding: 10px 20px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}

.save-btn:hover {
    background-color: #45a049;
}

.history {
    margin-top: 40px;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

.history-table th,
.history-table td {
    padding: 10px;
    text-align: center;
    border: 1px solid #ddd;
}

.error {
    color: #dc3545;
    text-align: center;
    margin: 10px 0;
    display: none;
}

/* 新增样式 */
.nav-buttons {
    margin: 20px 0;
}

.nav-btn {
    display: inline-block;
    padding: 10px 20px;
    background-color: #4CAF50;
    color: white;
    text-decoration: none;
    border-radius: 5px;
}

.nav-btn:hover {
    background-color: #45a049;
}

/* 排名页面样式 */
.rankings {
    margin-top: 20px;
}

.sort-controls {
    margin-bottom: 20px;
}

.sort-controls select {
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

#rankingsTable {
    width: 100%;
    border-collapse: collapse;
}

#rankingsTable th,
#rankingsTable td {
    padding: 10px;
    text-align: center;
    border: 1px solid #ddd;
}

.inactive-player {
    color: #6c757d;
    background-color: #f8f9fa !important;
}

/* 新玩家表单样式 */
.player-form {
    margin: 20px 0;
    display: flex;
    gap: 10px;
}

.player-form input[type="text"] {
    flex: 1;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.add-btn {
    padding: 8px 20px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.add-btn:hover {
    background-color: #45a049;
}

.rankings-table {
    width: 100%;
    margin-top: 20px;
    border-collapse: collapse;
}

.rankings-table th,
.rankings-table td {
    padding: 12px;
    text-align: center;
    border: 1px solid #ddd;
}

.rankings-table th {
    background-color: #f8f9fa;
    font-weight: bold;
    cursor: pointer;
}

.rankings-table tr:nth-child(even) {
    background-color: #f8f9fa;
}

.rankings-table tr:hover {
    background-color: #f2f2f2;
}

/* 无比赛记录的玩家样式 */
.rankings-table tr.inactive-player {
    color: #999;
    background-color: #f8f8f8;
}

.rankings-table tr.inactive-player:hover {
    background-color: #f2f2f2;
}

/* 新增样式 */
.add-player-form {
    margin: 20px 0;
    text-align: center;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 5px;
}

.add-player-form input {
    width: 200px;
    margin-right: 10px;
}

.sort-options {
    margin: 20px 0;
    text-align: center;
}

.sort-options select {
    padding: 8px;
    border-radius: 4px;
    border: 1px solid #ddd;
    font-size: 14px;
    margin-left: 10px;
}

/* 表格样式 */
.table {
    margin-bottom: 0;
}

.table th {
    white-space: nowrap;
    background-color: #f8f9fa;
}

.table td {
    vertical-align: middle;
}

/* 卡片样式 */
.card {
    border: none;
    border-radius: 10px;
}

.card-body {
    padding: 1.5rem;
}

/* 表单样式 */
.form-control:focus {
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.btn-primary {
    background-color: #0d6efd;
    border-color: #0d6efd;
}

.btn-primary:hover {
    background-color: #0b5ed7;
    border-color: #0a58ca;
}

/* 导航栏样式 */
.navbar {
    box-shadow: 0 2px 4px rgba(0, 0, 0, .1);
    padding: 0.75rem 1rem;
}

.navbar-brand {
    font-size: 1.25rem;
    padding: 0.5rem 1rem;
    margin-right: 2rem;
}

.navbar-nav {
    margin-left: 1rem;
}

.navbar-nav .nav-link {
    color: rgba(255, 255, 255, 0.85) !important;
    padding: 0.5rem 1.5rem;
    margin: 0 0.25rem;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.navbar-nav .nav-link:hover {
    color: #fff !important;
    background-color: rgba(255, 255, 255, 0.1);
}

.navbar-nav .nav-link.active {
    color: #fff !important;
    background-color: rgba(255, 255, 255, 0.15);
}

.navbar-toggler {
    padding: 0.5rem;
    border: none;
}

.navbar-toggler:focus {
    box-shadow: none;
}

@media (max-width: 768px) {
    .navbar-nav .nav-link {
        padding: 0.75rem 1rem;
        margin: 0.25rem 0;
    }
}

/* 响应式布局 */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    .card-body {
        padding: 1rem;
    }

    .table-responsive {
        margin: 0 -1rem;
    }

    .table td,
    .table th {
        padding: 0.5rem;
    }
}

/* 动画效果 */
.btn {
    transition: all 0.2s;
}

.btn:active {
    transform: scale(0.95);
}

/* 输入框组样式 */
.input-group {
    max-width: 500px;
}

/* 模态框样式 */
.modal-content {
    border: none;
    border-radius: 10px;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.modal-header {
    border-bottom: 1px solid #dee2e6;
    background-color: #f8f9fa;
    border-radius: 10px 10px 0 0;
}

.modal-footer {
    border-top: 1px solid #dee2e6;
    background-color: #f8f9fa;
    border-radius: 0 0 10px 10px;
}

/* 表格固定列样式 */
.table-responsive {
    position: relative;
}

.table {
    margin-bottom: 0;
}

/* 固定第一列 */
.table th:first-child,
.table td:first-child {
    position: sticky;
    left: 0;
    z-index: 1;
}

/* 确保固定列的背景色正确且不透明 */
.table-striped>tbody>tr:nth-of-type(odd)>td:first-child {
    background-color: #f2f2f2;
}

.table-striped>tbody>tr:nth-of-type(even)>td:first-child {
    background-color: #ffffff;
}

.table>thead>tr>th:first-child {
    background-color: #cfe2ff;
    border-right: 1px solid #dee2e6;
    z-index: 2;
}

/* 添加阴影效果 */
.table th:first-child::after,
.table td:first-child::after {
    content: '';
    position: absolute;
    top: 0;
    right: -5px;
    bottom: 0;
    width: 5px;
    pointer-events: none;
    background: linear-gradient(to right, rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0));
}

/* 处理悬停效果 */
.table-hover>tbody:not(.tr-hover-first-child-exempt)>tr:hover>td:first-child {
    background-color: #ebebeb !important;
}

/* 处理不活跃玩家的样式 */
.table-striped>tbody>tr.inactive-player>td:first-child {
    background-color: #f8f8f8;
}

.table thead {
    border-top: none !important;
}

/* 可排序表头样式 */
.sortable {
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s;
}

.sortable:hover {
    background-color: #e9ecef !important;
}

/* 排序按钮样式 */
.sort-btn {
    padding: 0 4px;
    margin-left: 4px;
    border: none;
    background: none;
    color: #666;
    transition: color 0.2s;
}

.sort-btn:hover {
    color: #000;
}

.sort-btn i {
    font-size: 0.8rem;
}

/* 表头样式优化 */
.table th {
    white-space: nowrap;
    position: relative;
}

/* 激活状态的排序按钮 */
.sort-btn i.fa-sort-up,
.sort-btn i.fa-sort-down {
    color: #0d6efd;
}

/* 激活状态的表头 */
.sortable[data-sort].active {
    background-color: #e9ecef;
}

/* 玩家历史对局气泡框样式 */
#playerHistoryPopover {
    position: fixed;
    z-index: 1060;
    display: none;
    max-width: 600px;
    background-color: #fff;
    border: 1px solid rgba(0, 0, 0, .2);
    border-radius: 0.5rem;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

#playerHistoryPopover .popover-header {
    padding: 0.75rem 1rem;
    background-color: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    border-top-left-radius: calc(0.5rem - 1px);
    border-top-right-radius: calc(0.5rem - 1px);
    font-weight: 500;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#playerHistoryPopover .popover-body {
    padding: 0;
    max-height: 80vh;
    overflow-y: auto;
}

#playerHistoryPopover .table {
    margin-bottom: 0;
}

#playerHistoryPopover .table th {
    position: sticky;
    top: 0;
    background-color: #fff;
    z-index: 1;
    font-weight: 500;
    border-top: none;
    padding: 0.75rem;
}

#playerHistoryPopover .table td {
    vertical-align: middle;
    padding: 0.75rem;
}

/* 对局历史中的玩家得分样式 */
.game-players {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.game-row {
    display: flex;
    justify-content: space-between;
    gap: 1.5rem;
}

.player-score {
    white-space: nowrap;
    flex: 1;
    text-align: left;
    padding: 0.25rem 0;
}

/* 移动端适配 */
@media (max-width: 768px) {
    #playerHistoryPopover {
        position: fixed;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%);
        width: calc(100% - 32px) !important;
        max-width: none;
        margin: 0;
        max-height: 90vh;
    }

    #playerHistoryPopover .popover-body {
        max-height: calc(90vh - 50px);
    }

    #playerHistoryPopover .table th,
    #playerHistoryPopover .table td {
        padding: 0.625rem;
    }

    .game-row {
        flex-direction: column;
        gap: 0.25rem;
    }

    .player-score {
        font-size: 0.875rem;
        padding: 0.125rem 0;
    }

    #playerHistoryPopover .table td:first-child {
        width: 100px;
    }
}

/* 气泡框动画 */
#playerHistoryPopover.fade {
    transition: opacity 0.15s linear;
}

#playerHistoryPopover.fade:not(.show) {
    opacity: 0;
}

/* 玩家名称链接样式 */
.player-name-link {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s;
}

.player-name-link:hover {
    color: #0d6efd;
}

/* 分页控件样式 */
#historyPagination {
    gap: 0.25rem;
}

#historyPagination .btn {
    min-width: 40px;
    padding: 0.375rem;
    font-size: 0.875rem;
}

#historyPagination .btn.active {
    background-color: #0d6efd;
    color: white;
}

#historyPagination .btn:not(.active):hover {
    background-color: #e9ecef;
}

#historyPagination .btn.disabled {
    pointer-events: none;
    opacity: 0.65;
}

#pageInfo {
    font-size: 0.875rem;
}

@media (max-width: 768px) {
    #historyPagination {
        flex-wrap: wrap;
        justify-content: center;
    }

    #historyPagination .btn {
        min-width: 35px;
        padding: 0.25rem;
        font-size: 0.8rem;
    }

    .d-flex.justify-content-between.align-items-center.mt-3 {
        flex-direction: column;
        gap: 1rem;
    }
}

/* Game Recorder Styles */
.game-recorder-wrapper {
    max-width: 600px;
    margin: 0 auto;
}

@media (min-width: 768px) {
    .game-recorder-wrapper {
        padding: 20px;
    }
}

.round-history {
    max-height: 400px;
    overflow-y: auto;
}

.round-item {
    background-color: #f8f9fa;
    transition: background-color 0.2s;
}

.round-item:hover {
    background-color: #e9ecef;
}

.btn-group .btn-check:checked+.btn-outline-primary {
    background-color: #0d6efd;
    color: white;
}

.btn-group .btn-check:checked+.btn-outline-secondary {
    background-color: #6c757d;
    color: white;
}

/* Mobile optimizations for game recorder */
@media (max-width: 576px) {
    .game-recorder-wrapper {
        padding: 0;
    }

    .card-body {
        padding: 1rem;
    }

    .btn-group label {
        font-size: 0.875rem;
        padding: 0.375rem 0.5rem;
    }

    .round-item {
        font-size: 0.875rem;
    }
}

/* Score table in game recorder */
#scoreTableBody td {
    padding: 0.5rem;
}

#scoreTableBody .fw-bold {
    font-size: 1.1rem;
}

/* Tenpai checkbox layout - 2 per row */
.tenpai-checkbox-item {
    flex: 0 0 calc(50% - 0.5rem);
    min-width: calc(50% - 0.5rem);
}

/* Player state buttons layout - 2 per row */
.player-state-item {
    flex: 0 0 calc(50% - 0.5rem);
    min-width: calc(50% - 0.5rem);
}

/* Fixed height for result details section to prevent UI jumping */
.result-details-container {
    min-height: 95px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.result-details-container>div {
    width: 100%;
}

.result-details-container>div:not(#noResultPlaceholder) {
    align-self: flex-start;
}