/* HmaScore - 古朴风格样式 */

:root {
    /* 古朴配色 - 中世纪欧洲风格 */
    --color-bg: #1a1510;
    --color-bg-secondary: #241e16;
    --color-bg-tertiary: #2d251f;
    --color-text: #e8dcc8;
    --color-text-muted: #a89f8c;
    --color-gold: #c9a959;
    --color-gold-light: #dcc075;
    --color-red: #8b2942;
    --color-red-bright: #b5385a;
    --color-blue: #294a8b;
    --color-blue-bright: #3d6bb5;
    --color-border: #4a3f2f;
    --color-success: #5a8b3d;
    --shadow-soft: 0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 30px rgba(201, 169, 89, 0.2);
}

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

body {
    font-family: Georgia, 'Times New Roman', serif;
    background: var(--color-bg);
    color: var(--color-text);
    min-height: 100vh;
    line-height: 1.6;
}

.app-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
}

/* 页面切换 */
.page {
    display: none;
    padding: 20px;
}

.page.active {
    display: block;
}

/* 计分页面分栏布局 */
/* 页面头部 */
.page-header {
    text-align: center;
    padding: 30px 0;
    border-bottom: 2px solid var(--color-gold);
    margin-bottom: 30px;
}

.logo {
    font-size: 2.5rem;
    color: var(--color-gold);
    text-shadow: var(--shadow-glow);
    letter-spacing: 3px;
}

.subtitle {
    color: var(--color-text-muted);
    font-style: italic;
    margin-top: 8px;
    font-size: 1rem;
}

/* 表单样式 */
.config-form {
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 25px;
    box-shadow: var(--shadow-soft);
}

.form-group {
    margin-bottom: 25px;
}

.form-label {
    display: block;
    font-size: 1.1rem;
    color: var(--color-gold);
    margin-bottom: 12px;
    font-weight: bold;
}

/* 单选组 */
.radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--color-bg-tertiary);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.radio-label:hover {
    border-color: var(--color-gold);
}

.radio-label input[type="radio"] {
    width: 18px;
    height: 18px;
    accent-color: var(--color-gold);
}

.radio-text {
    font-size: 0.95rem;
}

/* 滑动条 */
.range-slider {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: var(--color-bg-tertiary);
    outline: none;
    -webkit-appearance: none;
}

.range-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--color-gold);
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

.range-slider::-moz-range-thumb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--color-gold);
    cursor: pointer;
    border: none;
}

.range-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    color: var(--color-text-muted);
    font-size: 0.85rem;
}

/* 时间选择器 */
.time-selectors {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.time-select {
    padding: 10px 15px;
    font-size: 1rem;
    font-family: inherit;
    background: var(--color-bg-tertiary);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    color: var(--color-text);
    cursor: pointer;
}

.time-select:focus {
    outline: none;
    border-color: var(--color-gold);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--color-bg-tertiary);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--color-gold);
}

/* 回合输入 */
.round-input {
    display: flex;
    align-items: center;
    gap: 10px;
}

.number-input {
    width: 80px;
    padding: 10px 15px;
    font-size: 1rem;
    font-family: inherit;
    background: var(--color-bg-tertiary);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    color: var(--color-text);
    text-align: center;
}

.number-input:focus {
    outline: none;
    border-color: var(--color-gold);
}

.input-suffix {
    color: var(--color-text-muted);
}

/* 按钮 */
.btn {
    padding: 12px 24px;
    font-size: 1rem;
    font-family: inherit;
    font-weight: bold;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

.btn-primary {
    background: linear-gradient(135deg, var(--color-gold), var(--color-gold-light));
    color: var(--color-bg);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(201, 169, 89, 0.4);
}

.btn-large {
    width: 100%;
    padding: 16px;
    font-size: 1.2rem;
    margin-top: 10px;
}

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

.btn-secondary:hover:not(:disabled) {
    background: var(--color-bg-secondary);
    border-color: var(--color-gold);
}

.btn-warning {
    background: linear-gradient(135deg, #e67e22, #d35400);
    color: #fff;
}

.btn-warning:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(230, 126, 34, 0.4);
}

/* 计分页面头部 */
.score-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 15px 20px;
    margin-bottom: 20px;
}

.timer-display {
    font-size: 1.8rem;
    font-weight: bold;
    color: var(--color-gold);
    font-family: 'Courier New', monospace;
}

.round-display {
    font-size: 1.2rem;
    color: var(--color-text-muted);
}

.round-display #current-round {
    color: var(--color-gold);
    font-weight: bold;
}

.score-summary {
    font-size: 1.3rem;
    font-weight: bold;
}

.score-red-sum {
    color: var(--color-red-bright);
}

.score-blue-sum {
    color: var(--color-blue-bright);
}

.score-separator {
    color: var(--color-text-muted);
    margin: 0 8px;
}

/* 计分板 */
.scoreboard {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}

.team-side {
    flex: 1;
    background: var(--color-bg-secondary);
    border: 2px solid var(--color-border);
    border-radius: 10px;
    padding: 20px 15px;
    text-align: center;
    transition: all 0.3s ease;
}

.red-side {
    border-color: var(--color-red);
}

.blue-side {
    border-color: var(--color-blue);
}

.team-icon {
    font-size: 2rem;
    margin-bottom: 5px;
}

.team-name {
    font-size: 1.1rem;
    color: var(--color-text-muted);
    margin-bottom: 10px;
}

.team-score {
    font-size: 3.5rem;
    font-weight: bold;
    line-height: 1;
}

.red-side .team-score {
    color: var(--color-red-bright);
    text-shadow: 0 0 20px rgba(181, 56, 90, 0.5);
}

.blue-side .team-score {
    color: var(--color-blue-bright);
    text-shadow: 0 0 20px rgba(61, 107, 181, 0.5);
}

.team-stats {
    margin-top: 15px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 0.85rem;
}

.stat-item {
    background: var(--color-bg-tertiary);
    padding: 5px 10px;
    border-radius: 4px;
}

.stat-item b {
    color: var(--color-gold);
}

.vs-divider {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--color-gold);
    padding: 0 10px;
}

/* 操作面板 */
.action-panel {
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.round-status {
    text-align: center;
    padding: 15px;
    background: var(--color-bg-tertiary);
    border-radius: 6px;
    margin-bottom: 15px;
    font-size: 1.1rem;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 击中按钮 */
.hit-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 15px;
}

.btn-hit {
    flex: 1;
    max-width: 120px;
    padding: 15px 10px;
    font-size: 0.9rem;
    font-family: inherit;
    font-weight: bold;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-hit:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-hit:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.4);
}

.btn-red {
    background: linear-gradient(135deg, var(--color-red), var(--color-red-bright));
    color: #fff;
}

.btn-blue {
    background: linear-gradient(135deg, var(--color-blue), var(--color-blue-bright));
    color: #fff;
}

.btn-double {
    background: linear-gradient(135deg, var(--color-gold), var(--color-gold-light));
    color: var(--color-bg);
}

/* 计分区 */
.scoring-panel {
    background: var(--color-bg-tertiary);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: 15px;
    margin-bottom: 15px;
}

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

.scoring-label {
    min-width: 80px;
    color: var(--color-text-muted);
    font-size: 0.95rem;
}

/* v4.0: 主标签加粗醒目 */
.primary-label {
    font-weight: bold;
    min-width: 90px;
}

/* v4.0: 红方标签颜色 - 适用于任何计分标签 */
.primary-label.red,
.secondary-label.red,
.scoring-label.red {
    color: var(--color-red-bright) !important;
}

/* v4.0: 蓝方标签颜色 - 适用于任何计分标签 */
.primary-label.blue,
.secondary-label.blue,
.scoring-label.blue {
    color: var(--color-blue-bright) !important;
}

/* v4.0: 后击计分标签样式 */
.secondary-label {
    font-weight: bold;
    min-width: 90px;
}

/* v4.0: 后击计分标签样式 */
.secondary-label {
    font-weight: bold;
    min-width: 90px;
}

.score-options {
    display: flex;
    gap: 8px;
}

.btn-score-opt {
    width: 40px;
    height: 40px;
    font-size: 1rem;
    font-family: inherit;
    font-weight: bold;
    background: var(--color-bg-secondary);
    border: 2px solid var(--color-border);
    border-radius: 6px;
    color: var(--color-text);
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-score-opt:hover {
    border-color: var(--color-gold);
}

.btn-score-opt.selected {
    background: var(--color-gold);
    color: var(--color-bg);
    border-color: var(--color-gold);
}

.checkbox-inline {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 8px 12px;
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
}

.checkbox-inline input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--color-gold);
}

.btn-confirm {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--color-success), #7ab554);
    color: #fff;
    font-size: 1.1rem;
    margin-top: 10px;
}

/* 回合控制 */
.round-controls {
    display: flex;
    justify-content: center;
}

.btn-next {
    padding: 14px 40px;
    font-size: 1.1rem;
    background: linear-gradient(135deg, var(--color-blue), var(--color-blue-bright));
    color: #fff;
}

.btn-next:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(61, 107, 181, 0.4);
}

/* 历史记录 */
.history-panel {
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 15px 20px;
    margin-bottom: 20px;
}

.history-title {
    color: var(--color-gold);
    font-size: 1.1rem;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--color-border);
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--color-bg-tertiary);
    padding: 10px 15px;
    border-radius: 5px;
    font-size: 0.9rem;
}

.history-item .round-label {
    color: var(--color-gold);
    font-weight: bold;
    margin-right: 10px;
}

.history-item .result {
    flex: 1;
}

.history-item .score-change {
    font-weight: bold;
}

.history-item .red-change {
    color: var(--color-red-bright);
}

.history-item .blue-change {
    color: var(--color-blue-bright);
}

/* 比赛控制 */
.match-controls {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.match-controls .btn {
    flex: 1;
    max-width: 120px;
}

/* 弹窗 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: var(--color-bg-secondary);
    border: 2px solid var(--color-gold);
    border-radius: 12px;
    padding: 30px;
    max-width: 450px;
    width: 90%;
    text-align: center;
}

.modal-title {
    font-size: 1.8rem;
    color: var(--color-gold);
    margin-bottom: 20px;
}

.final-score {
    font-size: 2rem;
    font-weight: bold;
    margin-bottom: 10px;
}

.end-reason {
    color: var(--color-text-muted);
    margin-bottom: 25px;
    font-style: italic;
}

.summary-panel {
    background: var(--color-bg-tertiary);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
    text-align: left;
}

.summary-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.summary-stat {
    display: flex;
    justify-content: space-between;
    padding: 6px 10px;
    background: var(--color-bg-secondary);
    border-radius: 4px;
    font-size: 0.9rem;
}

.history-summary {
    text-align: left;
    margin-bottom: 20px;
    max-height: 150px;
    overflow-y: auto;
}

/* v5.0: 弹窗底部按钮组 */
.modal-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 20px;
}

.modal-buttons .btn {
    flex: 1;
    max-width: 150px;
}

/* 滚动条 */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--color-bg-tertiary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-gold);
}

/* 时间到闪红动画 */
@keyframes blink-red {
    0%, 100% {
        color: var(--color-red-bright);
        text-shadow: 0 0 20px rgba(181, 56, 90, 0.8);
    }
    50% {
        color: var(--color-text);
        text-shadow: none;
    }
}

/* 响应式 */
@media (max-width: 480px) {
    .logo {
        font-size: 2rem;
    }

    .team-score {
        font-size: 2.5rem;
    }

    .hit-buttons {
        flex-direction: column;
    }

    .btn-hit {
        max-width: none;
    }

    .score-header {
        flex-direction: column;
        gap: 10px;
    }

    .timer-display {
        font-size: 1.5rem;
    }
}

/* v5.0: 左右分栏布局 - 计分区和场记区 */

/* 计分页面占满整个屏幕 */
#score-page {
    padding: 0;
}

#score-page.active {
    max-width: none;
    height: 100vh;
    height: 100dvh;   /* 手机：100vh 含地址栏高度，会把底部按钮顶出可视区 */
    display: flex;
}

.score-page-layout {
    display: flex;
    width: 100%;
    height: 100vh;
    height: 100dvh;
}

/* 计分区（左侧 2/3） */
.score-container {
    flex: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    border-right: 2px solid var(--color-border);
    background: var(--color-bg);
}

/* 场记区（右侧 1/3） */
.control-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--color-bg-secondary);
}

/* 大型计分板（居中放大） */
.scoreboard-large {
    display: flex;
    width: 100%;
    height: 100%;
    align-items: center;
    justify-content: center;
    gap: 20px;
}

.team-side-large {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px 20px;
    background: var(--color-bg-secondary);
    border: 3px solid var(--color-border);
    border-radius: 15px;
}

.red-side {
    border-color: var(--color-red);
}

.blue-side {
    border-color: var(--color-blue);
}

.team-icon-large {
    font-size: 4rem;
    margin-bottom: 10px;
}

.team-name-large {
    font-size: 1.5rem;
    color: var(--color-text-muted);
    margin-bottom: 15px;
}

.team-score-large {
    /* 随视口高度缩放：矮屏（手机横屏）自动收小，避免撑破屏幕 */
    font-size: clamp(3rem, 38vh, 20rem);
    font-weight: bold;
    line-height: 1;
}

.red-side .team-score-large {
    color: var(--color-red-bright);
    text-shadow: 0 0 40px rgba(181, 56, 90, 0.6);
}

.blue-side .team-score-large {
    color: var(--color-blue-bright);
    text-shadow: 0 0 40px rgba(61, 107, 181, 0.6);
}

.team-stats-large {
    margin-top: 20px;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    width: 100%;
    font-size: 1.1rem;
}

.stat-item-large {
    background: var(--color-bg-tertiary);
    padding: 8px 12px;
    border-radius: 6px;
}

.stat-item-large b {
    color: var(--color-gold);
}

/* VS 分隔区（中间显示时间和回合） */
.vs-divider-large {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    gap: 15px;
}

.vs-text {
    font-size: 2rem;
    font-weight: bold;
    color: var(--color-gold);
}

.match-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.timer-inline {
    font-size: 1.8rem;
    font-weight: bold;
    color: var(--color-gold);
    font-family: 'Courier New', monospace;
}

.round-inline {
    font-size: 1.2rem;
    color: var(--color-text-muted);
}

.round-inline span:first-child {
    color: var(--color-gold);
    font-weight: bold;
}

/* 操作区（占 4/6） */
.action-area {
    flex: 4;
    display: flex;
    flex-direction: column;
    padding: 15px;
    gap: 10px;
    overflow-y: auto;
}

/* 回合记录区（固定底部 2/6） */
.history-panel-fixed {
    flex: 2;
    min-height: 80px;
    max-height: 300px;
    background: var(--color-bg-tertiary);
    border-top: 2px solid var(--color-border);
    padding: 10px 15px;
}

.history-panel-fixed .history-title {
    color: var(--color-gold);
    font-size: 0.9rem;
    margin-bottom: 8px;
}

.history-panel-fixed .history-list {
    max-height: 100px;
    overflow-y: auto;
}

/* 操作区内部样式调整 */
.action-area .round-status {
    padding: 10px;
    min-height: 40px;
    font-size: 1rem;
}

.action-area .hit-buttons {
    gap: 8px;
}

.action-area .btn-hit {
    padding: 12px 8px;
    font-size: 0.85rem;
}

.action-area .match-controls-group {
    margin-top: 8px;
    display: flex;
    justify-content: center;
    gap: 10px;
}

.action-area .match-controls-group .btn {
    flex: 1;
    max-width: 80px;
}

/* 响应式：小屏幕改为上下布局 */
@media (max-width: 768px) {
    .score-page-layout {
        flex-direction: column;
    }

    .score-container {
        padding: 15px;
        border-right: none;
        border-bottom: 2px solid var(--color-border);
    }

    .control-container {
        max-width: none;
        min-width: none;
    }

    .team-score-large {
        font-size: 5rem;
    }

    .team-icon-large {
        font-size: 2.5rem;
    }

    .vs-divider-large {
        padding: 10px;
    }
}

/*
 * 手机横屏 / 矮屏专用紧凑布局。
 * 宽度够（>768px）所以上面那条小屏规则不触发，但高度只有 ~360–430px：
 * 左右两栏塞不下，且 20rem 的比分本身就撑满整屏。这里压缩留白、缩小字号，
 * 并让右栏可滚动兜底。放在 <768px 规则之后，同权重下它优先。
 */
@media (orientation: landscape) and (max-height: 560px) {
    #score-page.active,
    .score-page-layout {
        height: 100dvh;
    }

    /*
     * 窄横屏（宽 <768px）会命中上面的纵排规则，这里强制恢复左右两栏：
     * 横向空间足够，而竖向只有 ~360px，纵排会挤成一团。
     */
    .score-page-layout {
        flex-direction: row;
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }

    .score-container {
        padding: 6px;
        border-right: 2px solid var(--color-border);
        border-bottom: none;
    }

    .scoreboard-large {
        gap: 8px;
    }

    .team-side-large {
        padding: 8px 10px;
        border-width: 2px;
        border-radius: 10px;
    }

    .team-icon-large {
        font-size: 1.6rem;
        margin-bottom: 2px;
    }

    .team-name-large {
        font-size: 0.95rem;
        margin-bottom: 4px;
    }

    .team-score-large {
        font-size: clamp(2.5rem, 34vh, 9rem);
    }

    .team-stats-large {
        margin-top: 6px;
        font-size: 0.72rem;
    }

    .stat-item-large {
        padding: 3px 6px;
    }

    .vs-divider-large {
        padding: 4px;
        gap: 4px;
    }

    .vs-text {
        font-size: 1.1rem;
    }

    .timer-inline {
        font-size: 1.1rem;
    }

    .round-inline {
        font-size: 0.85rem;
    }

    /* 右栏整体可滚动，矮屏也能摸到全部按钮 */
    .control-container {
        overflow-y: auto;
    }

    .action-area {
        padding: 6px 8px;
        gap: 6px;
    }

    .action-area .round-status {
        padding: 6px;
        min-height: 30px;
        font-size: 0.85rem;
        margin-bottom: 6px;
    }

    .action-area .hit-buttons {
        flex-direction: row;   /* 覆盖 max-width:480px 的纵排，横屏三个按钮并排 */
        margin-bottom: 6px;
        gap: 6px;
    }

    .action-area .btn-hit {
        padding: 8px 6px;
        font-size: 0.78rem;
    }

    .scoring-panel {
        padding: 8px;
        margin-bottom: 6px;
    }

    .scoring-row {
        margin-bottom: 6px;
        gap: 6px;
    }

    .scoring-label,
    .primary-label,
    .secondary-label {
        min-width: 64px;
        font-size: 0.85rem;
    }

    .btn-score-opt {
        width: 34px;
        height: 34px;
        font-size: 0.9rem;
    }

    .btn-confirm {
        padding: 8px;
        font-size: 0.95rem;
        margin-top: 6px;
    }

    .history-panel-fixed {
        min-height: 54px;
        max-height: 140px;
        padding: 6px 8px;
    }

    .history-panel-fixed .history-list {
        max-height: 60px;
    }
}

/* v5.0: 历史记录控制按钮组 */
.history-controls {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid var(--color-border);
}

.history-controls .btn {
    flex: 1;
    max-width: 120px;
}

.history-count {
    color: var(--color-text-muted);
    font-size: 0.9rem;
    margin-left: auto;
}

.history-count b {
    color: var(--color-gold);
}

/* v5.0: 配置页顶部布局 */
.config-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 30px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--color-gold);
}

.config-header .page-header {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

/* 历史记录控制（右上角） */
.history-controls-header {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}

.history-count-header {
    color: var(--color-text-muted);
    font-size: 0.85rem;
}

.history-count-header b {
    color: var(--color-gold);
}

.history-controls-header .btn {
    width: 100px;
}

/* 小按钮样式 */
.btn-small {
    padding: 8px 12px;
    font-size: 0.85rem;
}

/* 危险按钮样式 */
.btn-danger {
    background: linear-gradient(135deg, var(--color-red), var(--color-red-bright));
    color: #fff;
}

.btn-danger:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(181, 56, 90, 0.4);
}

/* ============ v5.0 娱乐比赛平台样式 ============ */

/* 入口页布局 */
.entry-header {
    text-align: center;
    margin-bottom: 32px;
}

.entry-main {
    margin: 40px 0;
}

.entry-footer {
    border-top: 1px solid var(--color-border);
    padding-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.entry-footer .stats {
    display: flex;
    justify-content: space-around;
    color: var(--color-text-muted);
    font-size: 14px;
}

.entry-footer .actions {
    display: flex;
    justify-content: center;
    gap: 12px;
}

/* 状态卡片 */
.status-card {
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 32px 24px;
    text-align: center;
}

.status-card h2 {
    color: var(--color-gold);
    margin-bottom: 16px;
}

.status-card .hint {
    color: var(--color-text-muted);
    margin-bottom: 24px;
}

.status-card.status-running {
    border-color: var(--color-gold);
    box-shadow: var(--shadow-glow);
}

.match-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
    margin: 24px 0;
    font-size: 24px;
}

.match-info .player.red {
    color: var(--color-red-bright);
    font-weight: bold;
}

.match-info .player.blue {
    color: var(--color-blue-bright);
    font-weight: bold;
}

.match-info .vs {
    color: var(--color-gold);
    font-size: 20px;
}

/* Modal 通用样式 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 32px;
    max-width: 480px;
    width: 90%;
    box-shadow: var(--shadow-soft);
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: transparent;
    border: none;
    color: var(--color-text-muted);
    font-size: 28px;
    cursor: pointer;
    line-height: 1;
}

.modal-close:hover {
    color: var(--color-text);
}

.modal-title {
    color: var(--color-gold);
    margin-bottom: 20px;
    text-align: center;
}

.modal-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 20px;
}

/* 表单行（报名 modal） */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-label {
    font-size: 13px;
    color: var(--color-text-muted);
}

.text-input,
.select-input {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    color: var(--color-text);
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
}

.text-input:focus,
.select-input:focus {
    outline: none;
    border-color: var(--color-gold);
}

.form-hint {
    color: var(--color-text-muted);
    font-size: 13px;
    text-align: center;
    margin-top: 12px;
}

/* 结果弹窗 */
.result-summary {
    background: var(--color-bg);
    border-radius: 8px;
    padding: 20px;
    margin: 16px 0;
}

.winner-row,
.loser-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
}

.winner-row .label,
.loser-row .label {
    color: var(--color-text-muted);
}

.winner-name {
    color: var(--color-gold);
    font-weight: bold;
    font-size: 18px;
}

.loser-name {
    color: var(--color-text);
    font-size: 16px;
}

.winner-score,
.loser-score {
    font-family: monospace;
    font-size: 18px;
    color: var(--color-gold-light);
}

/* 加载状态 */
.loading {
    text-align: center;
    color: var(--color-text-muted);
    padding: 40px;
}

/* ==================== v5.0 平台模式 ==================== */
/* 见 js/platform-mode.js。index.html?mode=platform 复用计分页，跳过配置页。 */

/* 配置页在平台模式下始终隐藏。选择器带 id，优先级高于 .page.active */
html.platform-mode #config-page {
    display: none;
}

/* 显式声明 v5 结算弹窗的显隐。
   .modal 在本文件里被定义过两次（display:flex 和 display:none），
   目前靠源码顺序决定，太脆弱，这里给 #end-match-modal 明确指定。 */
#end-match-modal {
    display: none;
}

#end-match-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 平台模式下隐藏关闭按钮：比赛结束后必须让用户选"立即报名/暂不报名"
   把结果回传后端，否则关掉就卡在已结束的计分页上出不来。 */
html.platform-mode #end-match-modal .modal-close {
    display: none;
}

/* ==================== v5.0 首页只读区块 ==================== */

/* 右上角悬浮按钮组（登录/退出/报名），滚动时始终可见。
   right 用 max() 让它在宽屏下对齐 .app-container 的右边缘，
   窄屏（<600px）时退回 16px 贴边。 */
.entry-fab-group {
    position: fixed;
    top: 16px;
    right: max(16px, calc((100vw - 600px) / 2));
    z-index: 100;
    display: flex;
    gap: 8px;
}

.entry-fab-group .btn {
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(4px);
}

.entry-section {
    margin-top: 20px;
}

/* 首页的区块比计分页侧栏宽松些，覆写 .history-list 的 200px */
.entry-section .history-list {
    max-height: 320px;
}

.entry-section .history-item .result {
    color: var(--color-text);
}

.match-meta {
    color: var(--color-text-muted);
    font-size: 0.85rem;
    white-space: nowrap;
    margin-left: 12px;
}

/* 报名状态三态标签 */
.reg-status {
    flex-shrink: 0;
    font-size: 0.8rem;
    padding: 2px 10px;
    border-radius: 10px;
    border: 1px solid var(--color-border);
    color: var(--color-text-muted);
}

.reg-status.waiting {
    color: var(--color-gold);
    border-color: var(--color-gold);
}

.reg-status.played {
    color: var(--color-success);
    border-color: var(--color-success);
}

.reg-status.eliminated {
    color: var(--color-red-bright);
    border-color: var(--color-red-bright);
}

/* 排行榜：名次 / 选手 / 总分 / 总失分 / 场数 */
.leaderboard-head,
.leaderboard-row {
    display: grid;
    grid-template-columns: 44px 1fr 64px 72px 52px;
    gap: 8px;
    align-items: center;
}

.leaderboard-head {
    color: var(--color-gold);
    font-size: 0.85rem;
    padding: 0 12px 8px;
    border-bottom: 1px solid var(--color-border);
}

.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 320px;
    overflow-y: auto;
    margin-top: 8px;
}

.leaderboard-row {
    background: var(--color-bg-tertiary);
    padding: 8px 12px;
    border-radius: 5px;
    font-size: 0.9rem;
}

.leaderboard-row .lb-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lb-rank {
    text-align: center;
    color: var(--color-text-muted);
}

.lb-score {
    text-align: right;
    color: var(--color-gold);
    font-weight: bold;
}

.lb-lost {
    text-align: right;
    color: var(--color-text-muted);
}

.lb-count {
    text-align: center;
    color: var(--color-text-muted);
}

.section-empty {
    color: var(--color-text-muted);
    font-style: italic;
    padding: 8px 0;
}

.section-note {
    color: var(--color-text-muted);
    font-size: 0.8rem;
    margin-top: 10px;
}

/* 窄屏收紧悬浮按钮，避免压住居中的标题 */
@media (max-width: 480px) {
    .entry-fab-group {
        top: 12px;
        right: 12px;
        gap: 6px;
    }

    .entry-fab-group .btn {
        padding: 8px 12px;
        font-size: 0.8rem;
    }

    .leaderboard-head,
    .leaderboard-row {
        grid-template-columns: 36px 1fr 52px 60px 44px;
        gap: 6px;
        font-size: 0.85rem;
    }
}

/* ==================== v5.0 对练模式 ==================== */
/* 见 js/sparring-mode.js 与 sparring.html。index.html?mode=sparring 复用计分页。 */

/* 配置页在对练模式下始终隐藏 */
html.sparring-mode #config-page {
    display: none;
}

/* 对练结算弹窗显隐（与 #end-match-modal 同理，显式声明避免受 .modal 重复定义影响） */
#sparring-end-modal {
    display: none;
}

#sparring-end-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 对练模式隐藏关闭按钮：必须点「保存并返回」把结果回传后端 */
html.sparring-mode #sparring-end-modal .modal-close {
    display: none;
}

/* 对练平局决断弹窗（平局结束 / 追加决胜剑）—— 必须二选一，无关闭按钮 */
#sparring-tie-modal {
    display: none;
}

#sparring-tie-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

#sparring-tie-modal .tie-score {
    text-align: center;
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--color-gold);
}

/* 开赛弹窗：红蓝两栏并排 */
.sparring-sides {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin: 8px 0 16px;
}

.sparring-side {
    padding: 12px;
    border-radius: 6px;
    border: 1px solid var(--color-border);
    background: var(--color-bg-tertiary);
}

.sparring-side.side-red {
    border-color: var(--color-red-bright);
}

.sparring-side.side-blue {
    border-color: var(--color-blue-bright);
}

.sparring-side-title {
    margin: 0 0 10px;
    font-size: 0.95rem;
    text-align: center;
}

.sparring-side.side-red .sparring-side-title {
    color: var(--color-red-bright);
}

.sparring-side.side-blue .sparring-side-title {
    color: var(--color-blue-bright);
}

.sparring-config {
    padding-top: 12px;
    border-top: 1px solid var(--color-border);
}

/* 状态卡里的操作按钮行（继续对练 / 取消本场） */
.status-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 8px;
}

/* 历史行里的武器小标签 */
.weapon-tag {
    display: inline-block;
    margin: 0 6px;
    padding: 1px 6px;
    font-size: 0.72rem;
    border-radius: 8px;
    border: 1px solid var(--color-border);
    color: var(--color-text-muted);
    vertical-align: middle;
}

@media (max-width: 480px) {
    .sparring-sides {
        grid-template-columns: 1fr;
        gap: 10px;
    }
}

/* 排行：武器分项切换（单手 / 双手 / 双持） */
.weapon-tabs {
    display: flex;
    gap: 8px;
    margin: 10px 0 12px;
}

.weapon-tab {
    padding: 5px 16px;
    border-radius: 6px;
    border: 1px solid var(--color-border);
    background: var(--color-bg-tertiary);
    color: var(--color-text-muted);
    cursor: pointer;
    font-size: 0.85rem;
}

.weapon-tab.active {
    color: var(--color-gold);
    border-color: var(--color-gold);
    background: var(--color-bg);
}

/* 对练排行是 7 列，覆写平台首页 5 列的 .leaderboard-* 网格（限定在 #sparring-page 内） */
#sparring-page .leaderboard-head,
#sparring-page .leaderboard-row {
    grid-template-columns: 1fr 40px 74px 56px 44px 66px 70px;
    gap: 6px;
}

#sparring-page .leaderboard-head .lb-col[data-sort] {
    cursor: pointer;
    user-select: none;
}

#sparring-page .leaderboard-row .lb-col {
    text-align: right;
}

#sparring-page .leaderboard-row .lb-name,
#sparring-page .leaderboard-head .lb-name {
    text-align: left;
}

#sparring-page .leaderboard-row .lb-points {
    color: var(--color-gold);
    font-weight: bold;
}

@media (max-width: 480px) {
    #sparring-page .leaderboard-head,
    #sparring-page .leaderboard-row {
        grid-template-columns: 1fr 34px 62px 46px 36px 56px 62px;
        gap: 4px;
        font-size: 0.8rem;
    }
}

/* 历史行右侧：类型/结果 + 详情入口 */
.history-item-right {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.btn-detail {
    flex-shrink: 0;
    margin-left: 10px;
    padding: 3px 10px;
    font-size: 0.78rem;
    border-radius: 5px;
    border: 1px solid var(--color-border);
    background: var(--color-bg);
    color: var(--color-gold);
    text-decoration: none;
    white-space: nowrap;
}

.btn-detail:hover {
    border-color: var(--color-gold);
}

/* ==================== v5.1 对练详情页 ==================== */

/* 比分卡：双方姓名/武器/比分 */
.detail-players {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin: 8px 0 4px;
    flex-wrap: wrap;
}

.detail-player {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 96px;
}

.detail-player-name {
    font-size: 1.1rem;
    font-weight: bold;
}

.detail-player.side-red .detail-player-name {
    color: var(--color-red-bright);
}

.detail-player.side-blue .detail-player-name {
    color: var(--color-blue-bright);
}

.detail-player-score {
    font-size: 2.6rem;
    font-weight: bold;
    color: var(--color-gold);
    line-height: 1.1;
}

.detail-vs {
    color: var(--color-gold);
    font-size: 1.2rem;
}

.detail-result {
    color: var(--color-text-muted);
    margin-top: 12px;
}

/* 逐剑明细 */
.detail-round-list {
    margin: 0;
    padding-left: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.detail-round-item {
    display: flex;
    align-items: baseline;
    gap: 10px;
    background: var(--color-bg-tertiary);
    padding: 8px 12px;
    border-radius: 5px;
    font-size: 0.9rem;
}

.detail-round-no {
    flex-shrink: 0;
    color: var(--color-gold);
    font-weight: bold;
    min-width: 1.6em;
}

.detail-round-desc {
    color: var(--color-text);
}

/* 本场信息列表 */
.detail-meta-list {
    margin: 0;
    padding-left: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

@media (max-width: 480px) {
    .detail-player-score {
        font-size: 2rem;
    }

    .detail-players {
        gap: 12px;
    }
}

