/* assets/css/target_page.css */
/* ====== 奶茶色主題共用樣式：靶位看板 / 個人總表 / 單回合計分 ====== */

:root {
    --milk-bg:       #f6eee6;
    --milk-bg-deep:  #e8ddcf;
    --milk-card:     #fdf9f3;
    --milk-card-alt: #f4e7d8;
    --milk-border:   #dbcab6;
    --milk-text:     #4b3a2c;
    --milk-muted:    #8b7460;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", sans-serif;
    background: radial-gradient(circle at top left, #fdf5ec 0, var(--milk-bg) 40%, #f2e3d3 100%);
    color: var(--milk-text);
}

body {
    display: flex;
}

/* ========= 通用 page / header / main 框架 ========= */

.page {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-height: 100vh;
    padding: 8px 10px 12px;
}

header {
    padding: 10px 12px;
    border-radius: 12px;
    background: linear-gradient(135deg, #fbeee2, #f0dec9);
    color: var(--milk-text);
    box-shadow: 0 3px 8px rgba(155, 117, 82, 0.18);
    border: 1px solid rgba(219,202,182,.8);
}

/* 比賽名稱 / 子標題用 */
.header-title {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 4px;
}
.header-sub {
    font-size: .9rem;
    color: var(--milk-muted);
}

/* header 內 info chip / summary chip 共用 */

.summary-row,
.header-info-row {
    margin-top: 8px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    font-size: .85rem;
}

.summary-chip,
.info-chip {
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(255,255,255,.85);
    border: 1px solid rgba(199,168,133,.9);
    font-size: .85rem;
    display: inline-flex;
    align-items: baseline;
    gap: 4px;
}

.summary-chip-label,
.info-label {
    opacity: .8;
    font-size: .8rem;
}

.summary-chip-value {
    font-weight: 700;
    font-size: 2rem;
}

.summary-total { color: #c27925; }
.summary-tenx  { color: #b65c76; }
.summary-x     { color: #6e7aa4; }

.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 10px 0 4px;
    overflow: auto;
}

/* 返回連結 */

.back-link {
    margin: 10px 0 12px;
}

.back-link a {
    display: block;
    width: 100%;
    padding: 12px 0;
    border-radius: 999px;            /* 超大圓角 */
    background: #e1cfb4;             /* 奶茶色 */
    box-shadow: 0 4px 0 rgba(153, 120, 80, .45);
    text-align: center;
    font-size: 1.05rem;
    font-weight: 700;
    color: #5b3a2c;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
    transition: transform .08s ease, box-shadow .08s ease, filter .08s ease;
}

/* 按下去的效果 */
.back-link a:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 rgba(153, 120, 80, .35);
    filter: brightness(.97);
}

/* ========= 卡片共用樣式 ========= */

.card {
    background: var(--milk-card);
    border-radius: 14px;
    padding: 10px 10px 12px;
    box-shadow: 0 3px 8px rgba(162, 124, 88, 0.16);
    border: 1px solid var(--milk-border);
}

.card-title {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 6px;
}

.card-title-main {
    font-size: 1.05rem;
    font-weight: 600;
}
.card-title-sub {
    font-size: .8rem;
    color: var(--milk-muted);
}

/* ========= 靶位看板（target_scorepage.php）專用 ========= */

.header-top {
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
}

.competition-name {
    font-size: 1.8rem;
    font-weight: 700;
}
.game-name {
    font-size: .95rem;
    opacity: .9;
}

/* 局數 / 回合 / 靶位 同一行，三元件圓角框，整體 80% */
.header-chips-row {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 8px;
    transform: scale(0.8);
    transform-origin: left center;
    white-space: nowrap;
}
.header-chip {
    display: inline-flex;
    align-items: center;
    padding: 6px 14px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 1rem;
    border: 2px solid rgba(139, 115, 85, 0.6);
    box-shadow: 0 2px 4px rgba(0,0,0,0.12);
}
/* 僅數字放大 200%，文字（第、局、回合、靶位）維持 1rem */
.header-chip-num {
    font-size: 200%;
    font-weight: 800;
}
.header-chip-set {
    background: #f8b4c4;
    color: #000;
    border-color: rgba(200, 100, 120, 0.6);
}
.header-chip-round {
    background: #fff9c4;
    color: #000;
    border-color: rgba(200, 180, 80, 0.6);
}
.header-chip-target {
    background: #c8e6c9;
    color: #000;
    border-color: rgba(100, 160, 110, 0.6);
}

.target-badge {
    padding: 6px 16px;
    border-radius: 999px;
    background: #f9d1a7;
    color: #5b3a12;
    font-weight: 700;
    font-size: 1.6rem;
    box-shadow: 0 2px 4px rgba(167, 117, 70, 0.3);
}

.round-indicator {
    padding: 6px 16px;
    border-radius: 999px;
    background: #f6e08a;
    color: #6a4a09;
    font-weight: 700;
    font-size: 1.6rem;
    box-shadow: 0 2px 4px rgba(171, 140, 57, 0.3);
}

/* 雙局時：第N局 獨立圓角 tag + 第M回合（不換行），回合數字放大一倍 */
.round-indicator-multi {
    display: flex;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}
.round-indicator-multi .round-set-tag {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 999px;
    background: rgba(139, 115, 85, 0.25);
    color: #5b3a12;
    font-weight: 700;
    font-size: 0.85em;
}
.round-indicator-multi .round-round-line { font-size: inherit; }
.round-num-large {
    font-size: 2em;
    font-weight: 800;
    line-height: 1;
}

.cards {
    display: block;
    margin-top: 8px;
}

.cards .card {
    min-height: 90px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: transform .12s, box-shadow .12s, background .12s;
}

.cards .card:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 12px rgba(158, 118, 82, 0.26);
    background: #fff7ee;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 6px;
    gap: 6px;
}

.player-name {
    font-size: 1.4rem;
    font-weight: 700;
    word-break: break-all;
}

.player-id-badge {
    font-size: 1rem;
    padding: 4px 10px;
    border-radius: 999px;
    background: #f0d2aa;
    color: #5b3a12;
    white-space: nowrap;
    text-align: right;
}

.pos-badge {
    font-size: .75rem;
    padding: 1px 6px;
    border-radius: 999px;
    background: #f9c37b;
    color: #5b3a12;
    margin-right: 4px;
}

.card-body {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    font-size: .8rem;
    margin-top: 6px;
}

.stat-item {
    padding: 4px 5px;
    border-radius: 8px;
    background: #f7ecde;
    border: 1px solid rgba(215,188,151,.8);
}
.stat-label {
    opacity: .8;
    font-size: .75rem;
}
.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    margin-top: 1px;
}
.stat-total .stat-value { color: #c27925; }
.stat-tenx .stat-value  { color: #b65c76; }
.stat-x .stat-value     { color: #6e7aa4; }

.round-scores {
    margin-top: 4px;
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 4px;
    font-size: .85rem;
}

.round-chip {
    padding: 3px 0;
    border-radius: 6px;
    text-align: center;
    background: #f3e4d3;
    border: 1px solid rgba(205,177,140,.9);
    font-weight: 600;
    color: var(--milk-text);
}

.empty-msg,
.no-score-msg {
    margin-top: 12px;
    text-align: center;
    font-size: .9rem;
    color: var(--milk-muted);
}

/* ========= 個人總表 / 單回合計分 共用 table 樣式 ========= */

.score-table-wrapper {
    margin-top: 4px;
    overflow-x: auto;
}

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

table.score-table th,
table.score-table td {
    border: 1px solid rgba(197, 172, 142, .6);
    text-align: center;
    padding: 4px 2px;
    font-size: .8rem;
    color: var(--milk-text);
}
.score-table td.arrow-cell {
    font-size: 1.8rem !important;
    font-weight: 700;
    line-height: 1.1;
}

thead th {
    background: #f3e4d3;
    font-weight: 600;
    font-size: .8rem;
}

tbody td {
    font-size: 1rem;
    height: 36px;
}

/* 個人總表用 */

.round-label {
    font-weight: 700;
    background: #f1e0cd;
    width: 28px;
}

.subtotal-cell {
    font-size: 1.2rem;
    font-weight: 700;
    background: #f3ebdd;
}

.total-cell {
    font-size: 1.8rem;
    font-weight: 700;
    background: #f7e2bf;
}

.count-cell {
    font-size: 1.8rem;
    font-weight: 700;
    background: #f7efe4;
}

/* 箭底色：保留靶色，但搭配奶茶背景 */

.arrow-cell {
    font-weight: 700;
    font-size: 1.8rem;
}

.arrow-yellow { background: #FBE251; color:#5b3a00; }
.arrow-red    { background: #E16B8C; color:#4a101f; }
.arrow-blue   { background: #7DB9DE; color:#123047; }
.arrow-gray   { background: #707C74; color:#f7f7f7; }
.arrow-white  { background: #FFFFFF; color:#4b3a2c; }

/* ========= 單回合計分（target_scoreboard.php）專用 ========= */

.round-badge {
    display: inline-block;
    margin-left: 4px;
    padding: 2px 10px;
    border-radius: 999px;
    background: #f9d1a7;
    color: #5b3a12;
    font-size: .85rem;
}

/* 單回合表格用 cell 樣式 */
.score-cell {
    min-width: 40px;
    height: 44px;
}

/* 六格分組邊框圓角（外觀用，可選） */
.group {
}
.group-top-left    { border-top-left-radius: 8px; }
.group-top-right   { border-top-right-radius: 8px; }
.group-bottom-left { border-bottom-left-radius: 8px; }
.group-bottom-right{ border-bottom-right-radius: 8px; }

.hint {
    margin-top: 8px;
    font-size: .85rem;
    color: var(--milk-muted);
}

/* ========= 螢幕鍵盤 ========= */

.keyboard {
    margin-top: 12px;
    padding-bottom: 4px;
}

.keyboard-row {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-bottom: 6px;
}

.key-btn {
    min-width: 70px;
    padding: 10px 8px;
    border-radius: 999px;
    border: 1px solid rgba(177,143,105,.8);
    background: #fdf9f3;
    font-size: 1rem;
    font-weight: 600;
    color: var(--milk-text);
    box-shadow: 0 2px 4px rgba(160,123,88,.3);
    outline: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.key-btn:active {
    transform: translateY(1px);
    box-shadow: 0 1px 2px rgba(160,123,88,.3);
}

/* 分數色系鍵 */
.key-yellow { background: #FBE251; }
.key-red    { background: #E16B8C; color:#fff; }
.key-blue   { background: #7DB9DE; color:#fff; }
.key-gray   { background: #707C74; color:#fff; }
.key-white  { background: #FFFFFF; }

/* 功能鍵 */
/* 功能鍵：返回 / 清除 / 儲存 */
.key-btn.function {
    font-size: 1.5rem;
    background: #c5aa87;
    color: #4b3a2c;
}

.key-btn.function.danger {
    background: #c96f5c;       /* 清除：紅色 */
    color: #ffffff;
}

.key-btn.function.primary {
    font-size: 1.5rem;         /* ← 跟清除、返回一樣大 */
    background: #b98c59;       /* 送出：咖啡色 */
    color: #ffffff;
    line-height: 1.3;
    padding-top: 10px;
    padding-bottom: 10px;
}

/* ===== 射箭計分鍵盤樣式（奶茶色大圓角按鈕）===== */

.keyboard {
    margin-top: 18px;
    padding: 18px 16px 22px;
    border-radius: 26px;
    background: #d8c3a3;               /* 整塊淡咖啡底 */
    box-shadow: 0 6px 10px rgba(147, 117, 80, .25);
}

.keyboard-row {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.keyboard-row:last-child {
    margin-bottom: 0;
}

.key-btn {
    flex: 1 1 0;
    border: none;
    border-radius: 999px;              /* 超大圓角 */
    padding: 16px 2px;
    font-size: 1.7rem;
    font-weight: 600;
    font-family: inherit;
    color: #5b3a2c;
    background: #f3ebe0;
    box-shadow: 0 4px 0 rgba(140, 108, 74, .35);
    outline: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: transform .08s ease, box-shadow .08s ease, filter .08s ease;
}

/* 按下去的視覺效果 */
.key-btn:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 rgba(140, 108, 74, .25);
    filter: brightness(.97);
}

/* 數字／X／M 顏色 */
.key-yellow {           /* 9、X、10 用的淡黃 */
    background: #f7e59f;
}

.key-red {              /* 8、7 用的粉紅 */
    background: #e9a6a3;
}

.key-blue {             /* 6、5 用的淡藍 */
    background: #c4d6f2;
}

.key-gray {             /* 4、3 用的灰色 */
    background: #d8d6d3;
}

.key-white {            /* 2、1、M 白色 */
    background: #ffffff;
}

/* 功能鍵：返回 / 清除 / 儲存 */
.key-btn.function {
    font-size: 1.5rem;
    background: #c5aa87;       /* 左上「<」與其他功能鍵的基底色 */
    color: #4b3a2c;
}

.key-btn.function.danger {
    font-size: 1.5rem;
    background: #c96f5c;       /* 清除：紅色 */
    color: #ffffff;
}

.key-btn.function.primary {
    background: #b98c59;       /* 填入表單並儲存：咖啡色 */
    color: #ffffff;
    line-height: 1.3;
    padding-top: 10px;
    padding-bottom: 10px;
}

/* 小尺寸螢幕微調 */
@media (max-width: 480px) {
    .key-btn {
        padding: 14px 6px;
        font-size: 1.5rem;
    }

}
/* ========= RWD ========= */

@media (min-width: 768px) {
    .competition-name { font-size: 1.8rem; }
    .player-name      { font-size: 1.8rem; }
    .stat-value       { font-size: 1.8rem; }
    .target-badge,
    .round-indicator  { font-size: 1.6rem; }

    tbody td {
        font-size: 1.05rem;
        height: 42px;
    }
    .arrow-cell {
        font-size: 2rem;
    }
    .subtotal-cell {
        font-size: 1.5rem;
    }
    .total-cell {
        font-size: 2rem;
    }
}

/* 個人總表：最下面「總計」那一列，放大數字 */
.grand-total-score{
    font-size: 1.6rem !important;
    font-weight: 800;
}
.grand-total-tenx,
.grand-total-x {
    font-size: 1.2rem !important;
    font-weight: 800;
}