/* ============================================
   计分页面共用样式 (scorebook.php, scorepage.php, scoreboard.php)
   ============================================ */

/* --- 基础重置与全局样式 --- */
* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", sans-serif;
    background: #f5f1e8; /* 奶茶色背景 */
    color: #4a3b32;
}

body {
    display: flex;
}

/* --- 页面布局 --- */
.page {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-height: 100vh;
}

/* --- 头部样式 (共用) --- */
header,
.app-bar {
    background: #c9b59a; /* 奶茶色 */
    color: #fff;
    padding: 10px 16px;
}

.header-title,
.app-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0 0 4px;
}

.header-sub {
    font-size: 1.4rem;
    opacity: 1;
    font-weight: 600;
}

.app-link {
    font-size: .85rem;
    color: #fff;
    text-decoration: none;
}

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

.info-row {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
    font-size: .85rem;
}

.info-item {
    display: flex;
    gap: 4px;
}

.info-label {
    opacity: 0.8;
}

.info-value {
    font-weight: 600;
}

/* --- 容器 --- */
.container,
.main {
    flex: 1;
    padding: 12px 10px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.container {
    width: 100%;
    max-width: 960px;
    margin: 0 auto;
}

/* --- 卡片样式 (共用) --- */
.card {
    background: #fffaf0;
    border-radius: 12px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.06);
    padding: 10px 10px 12px;
}

.card-title {
    font-size: 1rem;
    margin: 0 0 8px;
    font-weight: 600;
    color: #5f4633;
}

/* --- 返回链接按钮 (共用) --- */
.back-link {
    margin-top: 4px;
    margin-bottom: 4px;
}

.back-link a {
    display: block;
    width: 100%;
    padding: 10px 12px;
    border-radius: 999px;
    background: #e7d5ba;
    color: #5c4633;
    text-align: center;
    font-size: 1.3rem;
    font-weight: 600;
    text-decoration: none;
    box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}

.back-link a:hover {
    background: #ddc5a5;
}

/* --- 按钮样式 (共用) --- */
.btn-primary {
    border: none;
    border-radius: 999px;
    padding: 8px 14px;
    font-size: .85rem;
    font-weight: 600;
    cursor: pointer;
    background: #b58963;
    color: #fff;
}

.btn-primary:hover {
    background: #a3764e;
}

.btn-secondary {
    background: #e0d4c4;
    color: #5c4633;
    border: none;
    border-radius: 999px;
    padding: 8px 14px;
    font-size: .85rem;
    font-weight: 600;
    cursor: pointer;
}

.btn-secondary:hover {
    background: #d3c1aa;
}

.btn-text {
    background: transparent;
    border: none;
    color: #7d6a57;
    font-size: .8rem;
    cursor: pointer;
    text-decoration: underline;
    padding: 0;
}

/* --- 表格样式 (共用) --- */
.score-table-wrapper {
    margin-top: 8px;
    overflow-x: auto;
}

table.score-table {
    border-collapse: collapse;
    width: 100%;
    background: #fff;
    border-radius: 10px;
    overflow: hidden;
    table-layout: fixed;
}

table.score-table th,
table.score-table td {
    border: 1px solid #e3d6c5;
    text-align: center;
    padding: 4px 2px;
    font-size: .8rem;
}

thead th {
    background: #f1e0c8;
    font-weight: 600;
    font-size: 0.8rem;
    color: #5f4633;
}

tbody td {
    font-size: 1.1rem;
    height: 40px;
}

/* 单元格链接 */
.cell-link {
    display: block;
    width: 100%;
    height: 100%;
    padding: 4px 2px;
    box-sizing: border-box;
    color: inherit;
    text-decoration: none;
}

.cell-link:hover {
    background: rgba(0,0,0,0.04);
}

/* --- 箭的颜色类 (共用) --- */
.arrow-cell {
    font-weight: 700;
}

.arrow-yellow {
    background: #FBE251;
}

.arrow-red {
    background: #E16B8C;
}

.arrow-blue {
    background: #7DB9DE;
}

.arrow-gray {
    background: #707C74;
}

.arrow-white {
    background: #FFFFFF;
}

/* --- 表格特殊单元格 --- */
.round-label {
    font-weight: 700;
    background: #f8efe2;
}

.score-table td.subtotal-cell {
    font-size: 1.3rem;
    background: #f7f2e7;
    font-weight: 700;
}

.score-table td.total-cell {
    font-size: 1.3rem;
    background: #fbe7b4;
    font-weight: 700;
    color: #b86a1f;
}

.score-table td.count-cell {
    font-size: 1.3rem;
    background: #e0d6c7;
    font-weight: 700;
    color: #5a6a73;
}

.score-table td.arrow-cell {
    font-size: 1.5rem;
}

/* --- 摘要行 --- */
.summary-row td {
    background: #fdf3dd;
    font-weight: 700;
}

.summary-total {
    color: #b86a1f;
    font-size: 1.3rem;
}

.summary-tenx,
.summary-x {
    color: #5a6a73;
    font-size: 1.2rem;
}

/* --- 提示信息 --- */
.hint {
    margin-top: 6px;
    font-size: .8rem;
    color: #9c8a75;
    text-align: center;
}

.no-score-msg {
    margin-top: 10px;
    font-size: .9rem;
    color: #9a8b7c;
    text-align: center;
}

.empty-tip {
    margin-top: 8px;
    font-size: .85rem;
    color: #9a8b7c;
}

/* ============================================
   scorebook.php 专用样式
   ============================================ */

/* 周导航 */
.week-header {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 6px;
}

.week-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: nowrap;
}

.week-title {
    font-size: .95rem;
    font-weight: 600;
    white-space: nowrap;
}

.week-range {
    padding: 4px 10px;
    border-radius: 999px;
    background: #f7f0e4;
}

.week-nav-btn {
    border: none;
    background: #e7d5ba;
    color: #5c4633;
    border-radius: 999px;
    padding: 4px 8px;
    font-size: .8rem;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}

.week-nav-btn:hover {
    background: #ddc5a5;
}

/* 新增练习按钮 */
.new-session-main-btn-wrap {
    margin-top: 4px;
}

.new-session-main-btn {
    display: block;
    width: 100%;
    border: none;
    border-radius: 999px;
    padding: 10px 12px;
    font-size: 1.3rem;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
    background: #b58963;
    color: #fff;
    text-decoration: none;
}

.new-session-main-btn:hover {
    background: #a3764e;
}

/* 周日期 */
.week-days {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 4px;
    margin-top: 10px;
}

.day-pill {
    border-radius: 8px;
    text-align: center;
    font-size: .75rem;
}

.day-pill form {
    margin: 0;
}

.day-pill-btn {
    display: block;
    width: 100%;
    border-radius: 8px;
    border: none;
    background: transparent;
    padding: 0;
    cursor: pointer;
}

.day-pill-inner {
    border-radius: 10px;
    padding: 4px 0;
    background: #f7f0e4;
    color: #5c4633;
}

.day-pill-inner.today {
    border: 1px solid #b58963;
    background: #fbe7c0;
    color: #b58963;
}

.day-pill-inner .dow {
    font-size: .7rem;
    color: #9a8b7c;
}

.day-pill-inner.today .dow {
    color: #b58963;
}

.day-pill-inner .date {
    font-weight: 600;
}

/* 会话列表 */
.sessions-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
}

.session-card {
    border-radius: 12px;
    padding: 10px 12px;
    background: #fdf6ea;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    display: flex;
    flex-direction: column;
    gap: 4px;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
}

.session-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    font-size: .8rem;
    color: #7d6a57;
}

.session-distance {
    font-size: .8rem;
    font-weight: 600;
}

.session-date {
    font-size: .8rem;
    font-weight: 500;
}

.session-body {
    margin-top: 6px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.session-location-v2 {
    flex: 1 1 auto;
    font-size: 1.6rem;
    font-weight: 700;
    color: #4a3b32;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.session-score-v2 {
    font-size: 1.6rem;
    font-weight: 800;
    color: #b86a1f;
    text-align: right;
    min-width: 70px;
    white-space: nowrap;
}

.session-chart-vertical {
    flex: 0 0 60%;
    max-width: 100%;
    display: flex;
    align-items: flex-end;
    justify-content: space-around;
    height: 120px;
    padding: 6px 8px;
    border-radius: 10px;
    background: linear-gradient(to top, #f5e5cf, #fff8ec);
    box-shadow: inset 0 1px 3px rgba(255,255,255,0.8),
                0 1px 3px rgba(0,0,0,0.06);
}

.vbar-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.vbar {
    width: 10px;
    border-radius: 6px 6px 2px 2px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.25);
    display: block;
}

.vbar-label {
    font-size: .6rem;
    text-align: center;
    color: #7d6a57;
}

/* 新增练习表单 */
.new-session-card {
    margin-top: 10px;
    border: 1px dashed #d3c1aa;
    background: #fffdf7;
}

.new-session-title {
    font-size: .95rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: #5c4633;
}

.new-session-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 6px;
    font-size: .85rem;
}

.new-session-row label {
    display: block;
    font-size: .8rem;
    color: #7d6a57;
    margin-bottom: 2px;
}

.new-session-row input[type="text"],
.new-session-row input[type="number"],
.new-session-row input[type="date"] {
    padding: 4px 6px;
    border-radius: 8px;
    border: 1px solid #d3c1aa;
    font-size: .9rem;
    width: 100%;
    background: #fffbf5;
    color: #4a3b32;
}

.new-session-row input:focus {
    outline: none;
    border-color: #b58963;
    box-shadow: 0 0 0 1px rgba(181,137,99,0.2);
}

.new-session-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 6px;
}

/* ============================================
   scoreboard.php 专用样式
   ============================================ */

.round-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: .8rem;
    background: #e7d5ba;
    color: #5c4838;
    margin-left: 6px;
}

.scoreboard .card {
    width: 100%;
    max-width: 620px;
    margin: 0 auto;
    border-radius: 16px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.12);
    padding: 12px 12px 14px;
}

.scoreboard table.score-table {
    min-width: 420px;
}

.scoreboard tbody td {
    font-size: 2rem;
    height: 44px;
}

.score-cell {
    cursor: default;
}

.score-cell.total {
    background: #f7f2e7;
    font-weight: 700;
}

.score-cell.overall-total {
    background: #fbe7b4;
    font-weight: 700;
    color: #b86a1f;
}

.score-cell.tenx-count,
.score-cell.x-count {
    background: #e0d6c7;
    font-weight: 700;
    color: #5a6a73;
}

.group {
    border: 2px solid #b89b7a;
}

.group-top-left {
    border-top-width: 2px;
    border-left-width: 2px;
}

.group-top-right {
    border-top-width: 2px;
    border-right-width: 2px;
}

.group-bottom-left {
    border-bottom-width: 2px;
    border-left-width: 2px;
}

.group-bottom-right {
    border-bottom-width: 2px;
    border-right-width: 2px;
}

.summary {
    margin-top: 10px;
    padding: 10px;
    background: #f7f0e4;
    border-radius: 12px;
    font-size: .9rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    grid-gap: 4px 12px;
}

.summary-item label {
    font-size: .8rem;
    color: #8a7461;
}

.summary-item span {
    font-weight: 700;
    font-size: 1.1rem;
}

.sum-total {
    color: #b86a1f;
}

.sum-tenx,
.sum-x {
    color: #5a6a73;
}

.btn-row {
    margin-top: 12px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.btn {
    flex: 1 1 120px;
    padding: 10px;
    border-radius: 999px;
    border: none;
    font-size: .95rem;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
}

/* 键盘样式 */
.keyboard {
    width: 100%;
    max-width: 620px;
    margin: 0 auto;
    margin-top: 8px;
    margin-bottom: 6px;
    background: #d2bda0;
    color: #fff;
    padding: 8px 10px 10px;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.08);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.keyboard-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}

.key-btn {
    border: none;
    border-radius: 999px;
    font-size: 1.4rem;
    padding: 8px 4px;
    background: #f7efe3;
    color: #5b4433;
    width: 100%;
    box-shadow: 0 1px 2px rgba(0,0,0,0.12);
    touch-action: manipulation;
}

.key-btn:active {
    transform: scale(0.97);
    box-shadow: none;
}

.key-btn.function {
    font-size: 1rem;
    background: #c0a487;
    color: #fff;
}

.key-btn.danger {
    background: #c46a5a;
}

.key-btn.primary {
    background: #b58963;
}

.key-yellow {
    background: #fbe9a7;
    color: #5b4433;
}

.key-red {
    background: #f3b0b2;
    color: #5b4433;
}

.key-blue {
    background: #bed5f2;
    color: #334355;
}

.key-gray {
    background: #d2d2d2;
    color: #424242;
}

.key-white {
    background: #ffffff;
    color: #5b4433;
}

/* ============================================
   响应式设计
   ============================================ */

@media (max-width: 600px) {
    .week-nav {
        gap: 4px;
    }
    
    .week-title {
        font-size: .9rem;
    }
    
    .week-range {
        padding: 4px 6px;
    }
    
    .week-days {
        gap: 2px;
    }
    
    .session-card {
        padding: 8px 10px;
    }
    
    .session-body {
        flex-direction: column;
        align-items: stretch;
    }
    
    .session-chart-vertical {
        max-width: 100%;
        height: 120px;
        margin-top: 4px;
    }
    
    .session-score-v2 {
        text-align: left;
    }
}

@media (max-width: 480px) {
    .main {
        padding: 10px 8px 14px;
    }
    
    .scoreboard tbody td {
        height: 40px;
    }
}

@media (min-width: 768px) {
    header,
    .app-bar {
        padding: 12px 24px;
    }
    
    .main,
    .container {
        padding: 16px 24px 24px;
    }
    
    .card {
        padding: 16px 16px 18px;
    }
    
    tbody td {
        font-size: 1.2rem;
        height: 48px;
    }
    
    .score-table td.arrow-cell {
        font-size: 1.8rem;
    }
    
    .scoreboard tbody td {
        font-size: 1.6rem;
        height: 52px;
    }
    
    .scoreboard .arrow-cell {
        font-size: 1.7rem;
    }
}

@media (min-width: 901px) {
    .sessions-list {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }
    
    .session-card {
        height: 100%;
    }
}