/* 紙本藏書與朱砂印記：介面共用的表面、文字與狀態色。 */
:root {
    --surface: #fcfaf5;
    --surface-raised: #fffdf9;
    --surface-muted: #ebe7de;
    --ink: #303d37;
    --ink-muted: #73786c;
    --accent: #963d42;
    --accent-wash: #f6eae7;
    --jade: #526e61;
    --line: #d9cbb5;
    --soft-shadow: 0 4px 14px rgb(48 61 55 / 5%);
}
.dark {
    --surface: #28322e;
    --surface-raised: #303c36;
    --surface-muted: #222b27;
    --ink: #ece5d8;
    --ink-muted: #b5b9aa;
    --accent: #dfaaa3;
    --accent-wash: #443532;
    --jade: #a5bfae;
    --line: #526052;
    --soft-shadow: 0 4px 14px rgb(0 0 0 / 12%);
}
body {
    color: var(--ink);
    background-image: radial-gradient(ellipse at 50% 0%, rgb(170 133 81 / 8%), transparent 65%);
}
button, select, textarea { font-family: inherit; }
button { touch-action: manipulation; }
#app { gap: 20px; padding-bottom: 80px; }
.app-header { padding: 22px 0 6px; margin-bottom: 0; }
.header-eyebrow, .section-caption {
    color: var(--ink-muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .22em;
    margin-bottom: 14px;
}
.app-header h1 { color: var(--ink); letter-spacing: .1em; }
.app-header h1 i { color: var(--accent); font-size: .65em; }
.app-header > p:last-child { color: var(--ink-muted); line-height: 1.8; }
.decorative-line { width: 64px; height: 1px; background: var(--line); margin: 16px auto; }
.dark .decorative-line { background: var(--line); }
#game-setup { padding: clamp(18px, 3vw, 32px); }
.library-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding-bottom: 20px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--line);
}
.library-filters { display: flex; flex-direction: column; gap: 12px; min-width: 0; flex: 1 1 480px; }
.library-label { font-size: 16px; color: var(--ink); }
.dark .library-label { color: var(--ink); }
#deck-filter-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.filter-pill {
    padding: 7px 12px;
    border-radius: 8px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--ink-muted);
    font-size: 12px;
    line-height: 1.5;
    transition: background .2s, color .2s;
}
.filter-pill:hover { background: var(--surface-muted); color: var(--ink); }
.filter-pill.is-active { background: var(--accent-wash); color: var(--accent); border-color: var(--accent); font-weight: 700; }
#open-custom-dialog { background: var(--surface-muted); color: var(--ink); border: 1px solid var(--line); padding: 10px 14px; box-shadow: none; }
/* 捲動區內保留完整的邊框與陰影空間；選中樣式不再放大卡片。 */
.deck-library {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    max-height: 310px;
    overflow-y: auto;
    padding: 6px 10px 12px 6px;
    margin: 0 -6px 22px;
    scrollbar-gutter: stable;
    scrollbar-width: thin;
    scrollbar-color: var(--line) transparent;
}
.deck-card {
    position: relative;
    min-width: 0;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
    cursor: pointer;
    text-align: left;
    box-shadow: var(--soft-shadow);
    transition: border-color .2s, background .2s;
}
.deck-card:hover { border-color: var(--accent); background: var(--surface-raised); }
.deck-card.is-selected { border-color: var(--accent); background: var(--accent-wash); box-shadow: inset 0 0 0 1px var(--accent); }
.deck-badge { display: inline-block; padding: 3px 7px; border-radius: 4px; background: var(--surface-muted); color: var(--ink-muted); font-size: 10px; white-space: nowrap; }
.is-selected .deck-badge { background: var(--accent); color: var(--surface); }
.deck-title { color: var(--ink); margin-top: 12px; font-size: 16px; line-height: 1.6; overflow-wrap: anywhere; }
.dark .deck-title { color: var(--ink); }
.is-selected .deck-title { color: var(--accent); }
.deck-subtitle { line-height: 1.8; color: var(--ink-muted); }
.deck-card > div:first-child { flex-wrap: wrap; }
.deck-detail { padding: 22px; margin-bottom: 24px; background: var(--surface-raised); border: 1px solid var(--line); border-radius: 16px; }
.deck-detail .section-caption { margin-bottom: 10px; }
.deck-detail h2 { color: var(--ink); line-height: 1.6; }
.dark .deck-detail h2 { color: var(--ink); }
.deck-quotation { border-left: 2px solid var(--secondary); padding: 10px 14px; margin: 16px 0; background: var(--surface); font-size: 13px; line-height: 1.9; }
#selected-deck-badge { background: var(--accent-wash); color: var(--accent); white-space: nowrap; }
#selected-deck-title { min-width: 0; }
.deck-detail > div:first-of-type > div:first-child { flex-wrap: wrap; }
/* 難度以完整底色區分，文字顏色由元件統一管理，避免 CDN 工具類別覆蓋。 */
#game-setup .difficulty-btn {
    --difficulty-color: #3f6854;
    background: var(--difficulty-color);
    color: #fffdf9;
    border: 1px solid var(--difficulty-color);
    box-shadow: var(--soft-shadow);
    padding: 18px 12px;
}
#game-setup .difficulty-btn[data-difficulty="medium"] { --difficulty-color: #8b642d; }
#game-setup .difficulty-btn[data-difficulty="hard"] { --difficulty-color: #963d42; }
#game-setup .difficulty-btn:hover { filter: brightness(1.08); box-shadow: var(--soft-shadow); }
#game-setup .difficulty-btn i,
#game-setup .difficulty-btn > span { color: inherit; }
#game-setup .difficulty-btn > span:last-child { margin-top: 6px; }

.stats-item { background: var(--surface-raised); border-color: var(--line); box-shadow: none; }
.game-complete, .dark .game-complete { background: var(--surface); border: 1px solid var(--line); box-shadow: var(--soft-shadow); }
.btn-secondary, .dark .btn-secondary { background: var(--surface-muted); color: var(--ink); border-color: var(--line); }
#match-toast { background: var(--accent-wash); color: var(--ink); border-color: var(--line); }
dialog { color: var(--ink); }
#preview-dialog, #custom-dialog { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; }
dialog input, dialog textarea, dialog select { background: var(--surface-raised); color: var(--ink); border-color: var(--line); line-height: 1.7; }
.sound-toggle { width: 42px; height: 42px; border: 1px solid var(--line); font-size: 18px; box-shadow: var(--soft-shadow); }
@media (max-width: 767px) {
    .deck-library { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 480px) {
    #app { padding: 12px 12px 72px; gap: 16px; }
    .app-header { padding-top: 16px; }
    .app-header h1 { font-size: 28px; }
    #game-setup { padding: 16px; border-radius: 18px; }
    .library-toolbar { gap: 12px; padding-bottom: 16px; }
    .library-filters { flex-basis: 100%; }
    .deck-library { grid-template-columns: minmax(0, 1fr); max-height: 330px; }
    .deck-card { padding: 14px; }
    .deck-detail { padding: 16px; }
}
