/* 21 點訓練器 - 配色沿用輪盤模擬器：深色賭場風、金色強調、綠色牌桌 */
:root {
    font-family: 'Inter', system-ui, Avenir, Helvetica, Arial, sans-serif;
    line-height: 1.5;
    font-weight: 400;
    color-scheme: dark;
    color: rgba(255, 255, 255, 0.87);
    background-color: #0a0a0a;
    --gold: #d4af37;
    --gold-hover: #f1c40f;
    --casino-green: #1a472a;
    --casino-red: #8b0000;
    --card-bg: #1e1e1e;
    --border-color: #333;
    --accent-glow: rgba(212, 175, 55, 0.2);
    --site-purple: #BB91FF;
    --site-blue: #497BFF;
    --site-orange: #FFBD80;
    --good: #4caf50;
    --bad: #f44336;
}

body {
    margin: 0;
    display: flex;
    justify-content: center;
    min-height: 100vh;
    background: radial-gradient(circle at center, #1a1a1a 0%, #0a0a0a 100%);
}

.container {
    width: 100%;
    max-width: 960px;
    padding: 2rem;
}

header {
    text-align: center;
    margin-bottom: 2rem;
}

h1 {
    font-size: 2.5rem;
    color: var(--gold);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 0.5rem;
    text-shadow: 0 0 10px var(--accent-glow);
}

.subtitle {
    color: #aaa;
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    margin-bottom: 1.5rem;
}

.card h2 {
    color: var(--gold);
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

label {
    display: block;
    font-size: 0.9rem;
    color: #aaa;
    margin-bottom: 0.25rem;
}

select,
input[type="number"] {
    background: #2a2a2a;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.5rem;
    color: white;
    width: 100%;
    box-sizing: border-box;
}

button {
    background-color: var(--gold);
    color: #000;
    border: none;
    border-radius: 8px;
    padding: 0.8rem 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s;
}

button:hover:not(:disabled) {
    background-color: var(--gold-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--accent-glow);
}

button:disabled {
    background-color: #444;
    color: #999;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

button.secondary {
    background-color: #2a2a2a;
    color: #fff;
    border: 1px solid var(--border-color);
}

button.secondary:hover:not(:disabled) {
    background-color: #3a3a3a;
    border-color: var(--gold);
    box-shadow: none;
}

/* 重新洗牌按鈕：與副牌數下拉選單同高同寬，金色描邊呼應主題
   （不動全域 .secondary，頁內其他次要按鈕維持原樣；
   下拉與按鈕的內建行高不同，明確寫死同高才會完全對齊） */
.settings-row select,
#reshuffle-btn {
    height: 40px;
}

#reshuffle-btn {
    width: 100%;
    box-sizing: border-box;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    background: transparent;
    border: 1px solid var(--gold);
    color: var(--gold);
}

#reshuffle-btn:hover:not(:disabled) {
    background: var(--accent-glow);
    transform: none;
    box-shadow: none;
}

/* 模式切換 */
.mode-tabs {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.mode-tabs button {
    flex: 1;
    font-size: 1.05rem;
}

.mode-tabs button.active {
    background-color: var(--gold);
    color: #000;
}

.mode-tabs button:not(.active) {
    background-color: #2a2a2a;
    color: #ddd;
    border: 1px solid var(--border-color);
}

/* 設定列 */
.settings-row {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

.settings-row > div {
    flex: 1;
    min-width: 140px;
}

.rules-note {
    font-size: 0.85rem;
    color: #aaa;
    margin-top: 1rem;
    line-height: 1.7;
}

/* 牌桌 */
.felt {
    background: var(--casino-green);
    border-radius: 12px;
    border: 1px solid #2d6a44;
    padding: 1.5rem;
    margin-bottom: 1rem;
    box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.4);
}

.hand-row {
    margin-bottom: 1.25rem;
}

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

.hand-label {
    font-size: 0.9rem;
    color: #cfe8d8;
    margin-bottom: 0.5rem;
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
}

.hand-total {
    background: rgba(0, 0, 0, 0.35);
    border-radius: 999px;
    padding: 0.1rem 0.7rem;
    font-weight: 700;
    color: #fff;
}

.hand-total.bust {
    background: var(--casino-red);
}

.hand-total.blackjack {
    background: var(--gold);
    color: #000;
}

.hand-result {
    font-weight: 700;
}

.hand-result.win {
    color: #7ee787;
}

.hand-result.lose {
    color: #ff7b72;
}

.hand-result.push {
    color: #ddd;
}

.hand-cards {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    min-height: 88px;
}

.playing-card {
    width: 62px;
    height: 88px;
    background: #fff;
    color: #111;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 6px 7px;
    font-weight: 700;
    position: relative;
    box-sizing: border-box;
}

.playing-card .rank {
    font-size: 1.15rem;
    line-height: 1;
}

.playing-card .suit {
    font-size: 1.5rem;
    text-align: center;
    line-height: 1;
}

.playing-card .rank-bottom {
    font-size: 1.15rem;
    line-height: 1;
    transform: rotate(180deg);
}

.playing-card.red {
    color: #c62828;
}

.playing-card.mini {
    width: 40px;
    height: 56px;
    padding: 3px 4px;
}

.playing-card.mini .rank,
.playing-card.mini .rank-bottom {
    font-size: 0.8rem;
}

.playing-card.mini .suit {
    font-size: 1rem;
}

.playing-card.face-down {
    background: repeating-linear-gradient(45deg, #8a6d1b 0 6px, #d4af37 6px 12px);
    color: transparent;
}

.playing-card.face-down .rank,
.playing-card.face-down .suit,
.playing-card.face-down .rank-bottom {
    visibility: hidden;
}

.active-hand {
    outline: 2px solid var(--gold);
    outline-offset: 4px;
    border-radius: 8px;
}

/* 動作按鈕 */
.action-btns {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.action-btns button {
    font-size: 1rem;
    padding: 0.9rem 0.5rem;
}

/* 回饋 */
.feedback {
    border-radius: 8px;
    padding: 1rem 1.25rem;
    font-size: 1.05rem;
    line-height: 1.7;
    display: none;
}

.feedback.show {
    display: block;
}

.feedback.correct {
    background: rgba(76, 175, 80, 0.15);
    border: 1px solid var(--good);
}

.feedback.wrong {
    background: rgba(244, 67, 54, 0.15);
    border: 1px solid var(--bad);
}

.feedback.info {
    background: rgba(212, 175, 55, 0.12);
    border: 1px solid var(--gold);
}

.feedback .answer {
    font-weight: 700;
    font-size: 1.15rem;
}

.feedback .reason {
    color: #ddd;
    font-size: 0.95rem;
}

/* 統計 */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 1rem;
}

.stat-card {
    background: #2a2a2a;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.9rem;
    text-align: center;
}

.stat-card .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gold);
}

.stat-card .stat-label {
    font-size: 0.85rem;
    color: #aaa;
}

/* Hi-Lo */
.count-strip {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    min-height: 56px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    padding: 0.75rem;
    margin-bottom: 1rem;
}

.count-strip .empty-note {
    color: #888;
    font-size: 0.9rem;
    align-self: center;
}

.hilo-value {
    font-size: 0.7rem;
    text-align: center;
    color: #aaa;
}

.hilo-value .plus {
    color: #7ee787;
}

.hilo-value .minus {
    color: #ff7b72;
}

.check-row {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: flex-end;
}

.check-row > div {
    flex: 1;
    min-width: 120px;
}

.hilo-reference {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 1rem;
    font-size: 0.9rem;
}

.hilo-reference span {
    background: #2a2a2a;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    padding: 0.25rem 0.8rem;
}

.hint-line {
    font-size: 0.9rem;
    color: #aaa;
    margin-top: 0.75rem;
}

/* 策略表 */
.strategy-tables {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    overflow-x: auto;
}

.strategy-tables h3 {
    font-size: 1rem;
    color: #ddd;
    margin-bottom: 0.5rem;
}

table.strategy {
    border-collapse: collapse;
    font-size: 0.85rem;
    width: 100%;
    min-width: 560px;
}

table.strategy th,
table.strategy td {
    border: 1px solid #444;
    text-align: center;
    padding: 0.3rem 0.2rem;
}

table.strategy th {
    background: #2a2a2a;
    color: var(--gold);
}

table.strategy td.row-label {
    background: #2a2a2a;
    color: #fff;
    font-weight: 600;
    white-space: nowrap;
}

table.strategy td.cell-H {
    background: rgba(73, 123, 255, 0.25);
}

table.strategy td.cell-S {
    background: rgba(76, 175, 80, 0.25);
}

table.strategy td.cell-D {
    background: rgba(212, 175, 55, 0.3);
    font-weight: 700;
}

table.strategy td.cell-P {
    background: rgba(255, 189, 128, 0.3);
    font-weight: 700;
}

.strategy-legend {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    font-size: 0.9rem;
    color: #ccc;
    margin-top: 1rem;
}

details summary {
    cursor: pointer;
    color: var(--gold);
    font-weight: 600;
    font-size: 1.05rem;
}

footer {
    text-align: center;
    padding: 1rem 0;
    color: #888;
}

footer a {
    color: var(--gold);
}

@media (max-width: 768px) {
    .container {
        padding: 1rem;
        /* width: 100% 搭配 content-box 時，padding 會讓容器比畫面寬、
           策略表打開後整頁可左右拖動；改 border-box 把 padding 算進寬度內 */
        box-sizing: border-box;
    }

    /* 策略表：手機版整張塞進畫面、不再左右捲動，表頭列捲動時固定在畫面上方 */
    .strategy-tables {
        overflow: visible;
    }

    table.strategy {
        min-width: 0;
        width: 100%;
        table-layout: fixed;
        font-size: 0.8rem;
    }

    table.strategy th,
    table.strategy td {
        padding: 0.3rem 0.1rem;
    }

    table.strategy th:first-child,
    table.strategy td.row-label {
        width: 15%;
    }

    table.strategy thead th {
        position: sticky;
        top: 0;
        z-index: 2;
    }

    h1 {
        font-size: 1.8rem;
    }

    .action-btns {
        grid-template-columns: repeat(2, 1fr);
    }

    .playing-card {
        width: 52px;
        height: 74px;
    }

    .playing-card .rank,
    .playing-card .rank-bottom {
        font-size: 1rem;
    }

    .playing-card .suit {
        font-size: 1.25rem;
    }
}

/* 加到主畫面提示：手機限定的底部卡片，預設隱藏；
   顯示時 ui.js 會同步在 body 補 padding-bottom，卡片才不會蓋住發牌按鈕 */
.install-prompt[hidden] {
    display: none;
}

.install-prompt {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    margin: 0 auto;
    max-width: 560px;
    box-sizing: border-box;
    background: #1e1e1e;
    border-top: 2px solid var(--gold);
    border-left: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    border-radius: 16px 16px 0 0;
    padding: 1rem 1.25rem calc(1rem + env(safe-area-inset-bottom));
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.6);
    animation: install-prompt-up 0.3s ease-out;
}

@keyframes install-prompt-up {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.install-prompt-body {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
}

.install-prompt-icon {
    flex: none;
    width: 40px;
    height: 40px;
    line-height: 40px;
    text-align: center;
    font-size: 1.5rem;
    color: var(--gold);
    background: var(--casino-green);
    border-radius: 10px;
}

.install-prompt-text {
    flex: 1;
    min-width: 0;
}

.install-prompt-title {
    font-weight: 700;
    font-size: 1.05rem;
    color: #fff;
}

.install-prompt-sub {
    margin: 0.25rem 0 0;
    font-size: 0.9rem;
    color: #aaa;
}

.install-variant-note {
    margin: 0.5rem 0 0;
    font-size: 0.9rem;
    color: #ddd;
}

.install-steps {
    margin: 0.5rem 0 0;
    padding-left: 1.25rem;
    font-size: 0.9rem;
    color: #ddd;
    line-height: 1.8;
}

.install-steps li {
    padding-left: 0.25rem;
}

.install-step-icon {
    display: inline-block;
    vertical-align: -2px;
    margin-right: 0.25rem;
    color: var(--gold);
}

.install-note {
    color: #aaa;
    font-size: 0.85rem;
}

.install-prompt-close {
    flex: none;
    width: 32px;
    height: 32px;
    padding: 0;
    line-height: 1;
    font-size: 1.25rem;
    background: transparent;
    color: #aaa;
    border: none;
    border-radius: 6px;
}

.install-prompt-close:hover:not(:disabled) {
    background: #2a2a2a;
    color: #fff;
    transform: none;
    box-shadow: none;
}

.install-prompt-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.9rem;
}

.install-prompt-actions button {
    flex: 1;
    padding: 0.7rem 0.5rem;
}

.install-prompt-actions button.secondary {
    background: transparent;
    border: 1px solid var(--border-color);
}
