:root {
    --brown:   #d4a373;
    --brown-dk:#ab8361;
    --cream:   #FAFAFA;
    --green:   #2a9a5a;
    --danger:  #f77b6e;
}
body { background: var(--cream); margin: 0; padding: 0; font-family: sans-serif; }

/* ── header ── */
.game-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 16px;
    background: white; border-bottom: 1px solid #f0e8df;
    position: sticky; top: 0; z-index: 10;
}
.game-title { font-size: 1.1rem; font-weight: 700; color: var(--brown-dk); }
.game-stat  { display: flex; align-items: center; gap: 5px; font-weight: 800; font-size: 1.1rem; }
.stat-timer { color: #888; font-variant-numeric: tabular-nums; }
.stat-pairs { color: var(--brown-dk); }

.icon-clock {
    align-self: flex-end;  /* 或 flex-start 試試看 */
    margin-bottom: 3px;    /* 微調 */
}

/* ── 左右兩欄 ── */
.match-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 16px;
    max-width: 500px;
    margin: 0 auto;
    margin-top: 16px;
}

.match-col {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ── 牌 ── */
.card {
    aspect-ratio: 7/3;
    border-radius: 16px;
    border: 1.5px solid #e8ded3;
    background: white;
    display: flex; align-items: center; justify-content: center;
    text-align: center;
    padding: 7px 12px;
    cursor: pointer;
    font-weight: 700;
    color: #8f735a;
    line-height: 30px;
    word-break: break-word;
    box-shadow: 0 3px 12px rgba(212,163,115,0.08);
    transition: border-color 0.15s ease, background 0.15s ease,
                opacity 0.2s ease, transform 0.2s ease;
    user-select: none;
    -webkit-user-select: none;
}

.card.selected {
    border-color: #76b491;
    background: #f2faf6;
    color: #459467;
}

.ch-text {
    font-size: 1.25rem !important;
}

.card.matched {
    opacity: 0;
    transform: scale(0.85);
    pointer-events: none;
    border-color: transparent;
}

.card.wrong {
    border-color: #e99992;
    background: #fff8fc;
    color: #8f735a;
}
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25%       { transform: translateX(-6px); }
    75%       { transform: translateX(6px); }
}
.card.shake { animation: shake 0.3s ease; }

/* ── 完成畫面 ── */
.finish-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    align-items: center; justify-content: center;
    z-index: 999;
}
.finish-box {
    background: white; border-radius: 24px;
    padding: 36px 28px; text-align: center;
    width: 85%; max-width: 320px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    animation: popUp 0.3s ease-out;
}
@keyframes popUp {
    0%   { transform: scale(0.8); opacity: 0; }
    100% { transform: scale(1);   opacity: 1; }
}
.finish-emoji  { font-size: 3rem; margin-bottom: 12px; }
.finish-title  { font-size: 1.5rem; font-weight: 900; color: var(--brown-dk); margin-bottom: 16px; }
.finish-time   { font-size: 2rem; font-weight: 800; color: var(--brown); line-height: 1; padding-bottom: 6px; }
.finish-label  { font-size: 0.9rem; color: #aaa; margin-bottom: 24px; }
.finish-btn {
    width: 100%; padding: 16px; border-radius: 14px; border: none;
    background: var(--brown); color: white;
    font-size: 1.1rem; font-weight: 800; cursor: pointer; margin-bottom: 10px;
}
.finish-btn-outline {
    width: 100%; padding: 14px; border-radius: 14px;
    border: 2px solid #eee; background: white;
    color: #888; font-size: 1rem; font-weight: 700; cursor: pointer;
}

/* ── 底部按鈕 ── */
.fixed-buttons {
    position: fixed; bottom: 0; left: 0; right: 0;
    display: flex; gap: 10px; padding: 12px 12px;
    background: white; border-top: 1px solid #f0e8df; z-index: 10;
}
.fixed-buttons button {
    padding: 12px; border-radius: 36px; border: none;
    font-size: 1rem; font-weight: 600; cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease;
}
.btn-back   { background: #dae0f4; color:#666; flex: 1; transition: border: 1px solid #afb4c4}
.btn-replay { background: var(--brown); color: white; flex: 1;}
.btn-back.is-active   { background: #bac7ef; transform: scale(0.99); }
.btn-replay.is-active { background: #b8864f; transform: scale(0.99); }

/* 9對：三欄格子 */
.match-grid-9 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 12px 10px;
    max-width: 500px;
    margin: 0 auto;
    margin-top: 4px;
}
.match-grid-9 .card { height: 72px; }
.ch-text-9 { font-weight: 600; }

.match-grid-9 .card { height: 72px; aspect-ratio: unset; padding: 6px 5px; }

/* 輕鬆5對按鈕 */
.btn-five { background:#d6efb6; color:#666; flex: 1; border: 1px solid #afb4c4}
.btn-five.is-active { background: #afda7a; transform: scale(0.99); }




