/* ============================================================
   Darkness Sheet — "Parchment" (light) / "Stone" (dark) theme
   ============================================================ */

/* Non-themed constants — same in every theme */
:root {
    --touch-min: 48px;
    --radius: 8px;
    --font-display: 'Cinzel Decorative', serif;
    --font-heading: 'Cinzel', serif;
}

/* Dark theme "Stone" (default — applies when no data-theme attribute is set yet, and explicitly via [data-theme="dark"]) */
:root,
[data-theme="dark"] {
    --ds-bg: #0e0e12;
    --ds-surface: #00000060;
    --ds-surface2: #23232e55;
    --ds-surface-opaque: #1a1a22;
    --ds-border: #3a3a4a;
    --ds-accent: #e3ad44;
    --ds-accent-dim: #6e532044;
    --ds-accent-hover: #f0c468;
    --ds-red: #c0392b;
    --ds-red-dim: #7d1f1544;
    --ds-green: #27ae60;
    --ds-text: #d2d8e0;
    --ds-text-dim: #9097a1;
    --ds-unconscious: #4a2020;
    --ds-dead: #2a1515;
    --ds-petrified-bg: #26262e;

    /* Consolidated status palette (HP thresholds, alive/KO badges, chip-variant colors) */
    --ds-status-good: #7ca33a;
    --ds-status-good-glow: rgba(124,163,58,.6);
    --ds-status-caution: #d98e34;
    --ds-status-caution-glow: rgba(217,142,52,.6);
    --ds-status-danger: #d6492f;
    --ds-status-danger-glow: rgba(214,73,47,.65);
    --ds-violet: #9772cc;
    --ds-violet-text: #b89ae6;
    --ds-moss: #84a440;
    --ds-moss-text: #b8d56c;
    --ds-petrified: #6a6a8a;
    --ds-petrified-glow: rgba(120,120,190,.4);
    --ds-lantern-glow: rgba(235,186,86,.72);
    --ds-crit: #e6b450;
    --ds-crit-glow: rgba(230,180,80,.9);
    --ds-die-bg: linear-gradient(160deg,#2a2d33,#15171c);
    --ds-die-text-shadow: 0 1px 2px rgba(0,0,0,.9);

    /* Flagship "engraved stone" cell look (used by the Play/Sheet views) */
    --ds-cell-bg: rgba(6,8,12,.5);
    --ds-cell-border: #0b0d11;
    --ds-cell-bevel: inset 1px 1px 2px rgba(0,0,0,.5), inset -1px -1px 0 rgba(150,158,170,.14);
    --ds-chip-bg: rgba(10,12,16,.66);
    --ds-ink: #eef1f5;
    --ds-ink-dim: #d2d8e0;
    --ds-heading-shadow: 0 2px 8px rgba(0,0,0,.9);

    /* Page background */
    --ds-page-bg-image: linear-gradient(rgba(8,9,12,.4),rgba(8,9,12,.4)), radial-gradient(130% 115% at 50% 0%, rgba(40,44,52,.04) 0%, rgba(6,7,9,.3) 62%, rgba(2,2,4,.56) 100%), url('/img/textures/stone-bg.png');
    --ds-page-bg-size: cover, cover, cover;
    --ds-page-bg-repeat: no-repeat;
}

/* Light theme "Parchment" */
[data-theme="light"] {
    --ds-bg: #f7f5f0;
    --ds-surface: #ffffff;
    --ds-surface2: #ece7da;
    --ds-surface-opaque: #ffffff;
    --ds-border: #d6cfc0;
    --ds-accent: #8a5a14;
    --ds-accent-dim: #ecdcb8;
    --ds-accent-hover: #6e4710;
    --ds-red: #b3392b;
    --ds-red-dim: #f5d6d1;
    --ds-green: #1e8449;
    --ds-text: #4a3a1e;
    --ds-text-dim: #6b5733;
    --ds-unconscious: #f3dada;
    --ds-dead: #e8c9c9;
    --ds-petrified-bg: #d8d8dc;

    --ds-status-good: #6f8a2c;
    --ds-status-good-glow: rgba(111,138,44,.5);
    --ds-status-caution: #c47a1e;
    --ds-status-caution-glow: rgba(196,122,30,.5);
    --ds-status-danger: #bf471d;
    --ds-status-danger-glow: rgba(191,71,29,.5);
    --ds-violet: #9c4063;
    --ds-violet-text: #6f2a47;
    --ds-moss: #7d8a2c;
    --ds-moss-text: #525e16;
    --ds-petrified: #6a6080;
    --ds-petrified-glow: rgba(106,96,128,.3);
    --ds-lantern-glow: rgba(228,170,70,.78);
    --ds-crit: #9a6a1c;
    --ds-crit-glow: rgba(154,106,28,.7);
    --ds-die-bg: radial-gradient(circle at 38% 32%,#f3e7c8,#d8c49b);
    --ds-die-text-shadow: 0 1px 0 rgba(255,248,228,.6);

    --ds-cell-bg: rgba(120,92,46,.1);
    --ds-cell-border: rgba(74,52,22,.4);
    --ds-cell-bevel: none;
    --ds-chip-bg: rgba(120,92,46,.1);
    --ds-ink: #2a1808;
    --ds-ink-dim: #6b5733;
    --ds-heading-shadow: 0 1px 4px rgba(0,0,0,.7);

    --ds-page-bg-image: radial-gradient(135% 110% at 50% 0%, rgba(0,0,0,0) 0%, rgba(20,8,2,.16) 70%, rgba(12,4,1,.34) 100%), url('/img/textures/table-tile.png');
    --ds-page-bg-size: cover, 860px auto;
    --ds-page-bg-repeat: no-repeat, repeat;
}

/* Per-game accent override: the base accent above is Four Against Darkness' gold (the
   primary/original game); Nimble swaps it to teal/cyan in both themes. Every existing
   rule already keyed off --ds-accent/-dim/-hover picks this up with no further changes. */
html[data-theme="dark"] body[data-game="Nimble"] { --ds-accent: #5cc4d4; --ds-accent-dim: #1f5258; --ds-accent-hover: #8adce8; }
html[data-theme="light"] body[data-game="Nimble"] { --ds-accent: #0f6f6a; --ds-accent-dim: #cfe9e6; --ds-accent-hover: #0a514c; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
    background-color: var(--ds-bg);
    background-image: var(--ds-page-bg-image);
    background-size: var(--ds-page-bg-size);
    background-repeat: var(--ds-page-bg-repeat);
    background-position: center;
    background-attachment: fixed;
    color: var(--ds-text);
    font-family: 'Segoe UI', system-ui, sans-serif;
    font-size: 16px;
    min-height: 100vh;
    margin: 0;
}

/* ---- Typography ---- */
h1, h2, h3, h4 {
    color: var(--ds-accent);
    font-family: var(--font-heading);
    letter-spacing: 0.04em;
    text-shadow: var(--ds-heading-shadow);
}
a { color: var(--ds-accent); text-decoration: none; }
a:hover { color: var(--ds-accent-hover); text-decoration: underline; }

/* ---- Layout ---- */
.ds-container { max-width: 1400px; margin: 0 auto; padding: 0 1rem; }
.ds-page { padding: 1rem 0 2rem; }

/* ---- Navbar ---- */
.ds-nav {
    background: var(--ds-surface);
    border-bottom: 2px solid var(--ds-accent-dim);
    padding: 0 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 56px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.ds-nav-brand {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--ds-accent) !important;
    text-decoration: none !important;
    text-shadow: var(--ds-heading-shadow);
    flex: 1;
}

.ds-nav-link {
    font-family: var(--font-heading);
    color: var(--ds-text) !important;
    padding: 0.5rem 0.9rem;
    border-radius: var(--radius);
    min-height: var(--touch-min);
    display: flex;
    align-items: center;
    font-size: 0.92rem;
    letter-spacing: 0.02em;
    transition: background 0.15s;
}
.ds-nav-link:hover { background: var(--ds-surface2); text-decoration: none !important; }
.ds-nav-link.active { background: var(--ds-accent-dim); color: var(--ds-accent) !important; }

/* ---- Buttons ---- */
.btn-ds {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-height: var(--touch-min);
    min-width: var(--touch-min);
    padding: 0.5rem 1.1rem;
    border-radius: var(--radius);
    border: none;
    font-size: 1rem;
    cursor: pointer;
    transition: filter 0.15s, transform 0.1s;
    font-weight: 500;
    touch-action: manipulation;
    user-select: none;
}
.btn-ds:active { transform: scale(0.96); }
.btn-ds-primary { background: var(--ds-accent-dim); color: var(--ds-accent); border: 1px solid var(--ds-accent); }
.btn-ds-primary:hover { filter: brightness(1.2); }
.btn-ds-danger { background: var(--ds-red-dim); color: var(--ds-red); border: 1px solid var(--ds-red); }
.btn-ds-danger:hover { filter: brightness(1.2); }
.btn-ds-ghost { background: transparent; color: var(--ds-text-dim); border: 1px solid var(--ds-border); }
.btn-ds-ghost:hover { background: var(--ds-surface2); color: var(--ds-text); }
.btn-ds-success { background: rgba(39,174,96,0.15); color: var(--ds-green); border: 1px solid var(--ds-green); }
.btn-ds-success:hover { filter: brightness(1.2); }

/* ---- Cards ---- */
.ds-card {
    background: var(--ds-surface);
    border: 1px solid var(--ds-border);
    border-radius: 12px;
    padding: 1.2rem;
}
[data-theme="light"] .ds-card {
    background-color: var(--ds-surface);
    background-image: url('/img/textures/parchment.png');
    background-size: auto;
    background-repeat: repeat;
}

/* ---- Forms ---- */
.ds-form-group { margin-bottom: 1.1rem; }
.ds-label {
    display: block;
    font-family: var(--font-heading);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ds-text-dim);
    margin-bottom: 0.35rem;
}
.ds-input, .ds-select, .ds-textarea {
    width: 100%;
    background: var(--ds-surface2);
    border: 1px solid var(--ds-border);
    color: var(--ds-text);
    border-radius: var(--radius);
    padding: 0.65rem 0.85rem;
    font-size: 1rem;
    min-height: var(--touch-min);
    transition: border-color 0.15s;
    appearance: none;
}
.ds-input:focus, .ds-select:focus, .ds-textarea:focus {
    outline: none;
    border-color: var(--ds-accent);
    box-shadow: 0 0 0 2px rgba(227,173,68,0.25);
}
.ds-select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%239097a1' d='M6 8L0 0h12z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 1rem center; padding-right: 2.5rem; }
/* Dark mode: native option popup inherits OS colors unless told otherwise.
   color-scheme:dark makes browsers render the popup in dark mode; the explicit
   background/color make the <select> element itself consistently opaque. */
[data-theme="dark"] select,
[data-theme="dark"] .ds-select,
[data-theme="dark"] .spell-slot-select {
    color-scheme: dark;
    background-color: var(--ds-surface-opaque);
    color: var(--ds-text);
}
[data-theme="dark"] select option,
[data-theme="dark"] .ds-select option,
[data-theme="dark"] .spell-slot-select option {
    background: var(--ds-surface-opaque);
    color: var(--ds-text);
}
.ds-textarea { resize: vertical; min-height: 80px; }
.field-validation-error { color: var(--ds-red); font-size: 0.82rem; }
.validation-summary-valid { display: none; }
.validation-summary-errors {
    display: block;
    background: var(--ds-red-dim);
    border: 1px solid var(--ds-red);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    color: var(--ds-red);
    font-size: 0.85rem;
}
.validation-summary-errors ul { margin: 0; padding-left: 1.1rem; }
.validation-summary-errors li { margin: 0.15rem 0; }

/* ---- Character List ---- */
.char-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }

.char-card {
    background: var(--ds-surface);
    border: 1px solid var(--ds-border);
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}
.char-card-name { font-family: var(--font-heading); font-size: 1.15rem; font-weight: 700; color: var(--ds-accent); }
.char-card-class { font-size: 0.85rem; color: var(--ds-text-dim); text-transform: uppercase; letter-spacing: 0.06em; }
.char-card-stats { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.char-stat-pill {
    background: var(--ds-surface2);
    border: 1px solid var(--ds-border);
    border-radius: 20px;
    padding: 0.2rem 0.65rem;
    font-size: 0.8rem;
    white-space: nowrap;
}
.char-card-actions { display: flex; gap: 0.5rem; margin-top: auto; padding-top: 0.5rem; }

/* ---- Party List ---- */
.party-list { display: flex; flex-direction: column; gap: 1rem; }
.party-card {
    background: var(--ds-surface);
    border: 1px solid var(--ds-border);
    border-radius: 12px;
    padding: 1rem 1.2rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}
.party-name { font-family: var(--font-heading); font-size: 1.2rem; font-weight: 700; color: var(--ds-accent); flex: 1; }
.party-members { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.party-member-tag {
    background: var(--ds-surface2);
    border: 1px solid var(--ds-border);
    border-radius: 20px;
    padding: 0.2rem 0.7rem;
    font-size: 0.82rem;
}
.party-actions { display: flex; gap: 0.5rem; }

/* ================================================================
   PLAY VIEW — 2×2 grid of character sheets
   ================================================================ */
.play-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
    gap: 0.8rem;
    padding: 0.5rem;
}

@media (max-width: 800px) {
    .play-grid { grid-template-columns: 1fr; }
}

.play-sheet {
    background: var(--ds-surface);
    border: 2px solid var(--ds-border);
    border-radius: 12px;
    padding: 0.9rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    position: relative;
    transition: filter 0.2s, border-color 0.2s, background 0.2s;
}
[data-theme="light"] .play-sheet {
    background-image: url('/img/textures/parchment.png');
    background-size: 300px 300px;
}
.play-sheet.unconscious { border-color: var(--ds-status-danger); background: var(--ds-unconscious); }
.play-sheet.dead { border-color: var(--ds-status-danger); background: var(--ds-dead); filter: grayscale(0.4) brightness(0.85); }
.play-sheet.petrified { border-color: var(--ds-petrified); background: var(--ds-petrified-bg); filter: saturate(0.6); }
.play-sheet.lantern-glow .play-char-name { text-shadow: 0 0 12px var(--ds-lantern-glow), 0 0 4px var(--ds-lantern-glow); }

.play-sheet-header {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}
.psh-name-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}
.psh-meta-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}
.play-char-name { font-family: var(--font-heading); font-size: 1.05rem; font-weight: 700; color: var(--ds-ink); letter-spacing: 0.02em; line-height: 1.2; }
.play-char-meta {
    font-size: 0.73rem;
    color: var(--ds-ink-dim);
    letter-spacing: 0.02em;
}
.psh-btn-row {
    display: flex;
    gap: 0.25rem;
    align-items: center;
    flex-shrink: 0;
}

.play-status-badge {
    font-family: var(--font-heading);
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 0.2rem 0.6rem;
    border-radius: 2px;
    font-weight: 600;
    white-space: nowrap;
}
.badge-alive { background: var(--ds-chip-bg); color: var(--ds-moss-text); border: 1px solid var(--ds-moss); }
.badge-unconscious { background: var(--ds-chip-bg); color: var(--ds-status-danger); border: 1px solid var(--ds-status-danger); animation: pulse-red 1.5s infinite; }
.badge-dead { background: var(--ds-chip-bg); color: var(--ds-text-dim); border: 1px solid var(--ds-border); }
.badge-petrified { background: var(--ds-chip-bg); color: var(--ds-petrified); border: 1px solid var(--ds-petrified); }

.play-sheet-btn {
    font-size: 0.68rem;
    padding: 0.2rem 0.5rem;
    border-radius: 2px;
    border: 1px solid var(--ds-cell-border);
    background: var(--ds-cell-bg);
    box-shadow: var(--ds-cell-bevel);
    color: var(--ds-ink-dim);
    cursor: pointer;
    touch-action: manipulation;
    white-space: nowrap;
}

@keyframes pulse-red {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.55; }
}

/* HP hit/heal feedback on the current-HP figure (.php-current / #nimble-hp) */
@keyframes hpHit {
    0%, 100% { transform: translate(0,0); }
    15% { transform: translate(-3px,1px); }
    30% { transform: translate(3px,-1px); }
    45% { transform: translate(-2px,0); }
    60% { transform: translate(2px,1px); }
    80% { transform: translate(-1px,0); }
}
@keyframes hpPop {
    0% { transform: scale(1); }
    40% { transform: scale(1.2); }
    100% { transform: scale(1); }
}
@keyframes hpHitGlow {
    0%, 100% { text-shadow: none; }
    30% { text-shadow: 0 0 16px var(--ds-status-danger-glow); }
}
@keyframes hpHealGlow {
    0%, 100% { text-shadow: none; }
    30% { text-shadow: 0 0 16px var(--ds-status-good-glow); }
}
.hp-flash-hit { animation: hpHit 0.42s ease, hpHitGlow 0.5s ease; }
.hp-flash-heal { animation: hpPop 0.4s ease, hpHealGlow 0.5s ease; }

/* ---- HP Row ---- */
.play-hp-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--ds-surface2);
    border-radius: 10px;
    padding: 0.5rem 0.75rem;
}
.play-hp-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ds-text-dim);
    width: 22px;
}
.play-hp-display {
    font-size: 1.4rem;
    font-weight: 700;
    min-width: 50px;
    text-align: center;
    line-height: 1;
}
.play-hp-max { font-size: 0.8rem; color: var(--ds-text-dim); }
.hp-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    font-size: 1.4rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
    user-select: none;
    transition: transform 0.1s, filter 0.1s;
    flex-shrink: 0;
}
.hp-btn:active { transform: scale(0.9); }
.hp-btn-minus { background: var(--ds-status-danger); color: #f6e7d6; border: 1px solid rgba(0,0,0,.35); }
.hp-btn-minus:hover { filter: brightness(1.15); }
.hp-btn-plus { background: var(--ds-status-good); color: #f3efd9; border: 1px solid rgba(0,0,0,.35); }
.hp-btn-plus:hover { filter: brightness(1.15); }

.hp-bar-track {
    flex: 1;
    height: 8px;
    background: var(--ds-cell-border);
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid var(--ds-cell-border);
}
.hp-bar-fill {
    height: 100%;
    background: var(--ds-status-good);
    box-shadow: 0 0 8px var(--ds-status-good-glow);
    border-radius: 4px;
    transition: width 0.3s ease, background 0.3s ease, box-shadow 0.3s ease;
}
.hp-bar-fill.low { background: var(--ds-status-caution); box-shadow: 0 0 8px var(--ds-status-caution-glow); }
.hp-bar-fill.critical { background: var(--ds-status-danger); box-shadow: 0 0 8px var(--ds-status-danger-glow); }
.hp-bar-fill.zero { background: var(--ds-status-danger); box-shadow: none; width: 0 !important; }

/* ---- Vitals: HP panel + combat stats side by side ---- */
.play-vitals {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.55rem;
    align-items: start;
}

/* ---- Nimble: Armor/Speed/Hit Dice/Initiative 2x2 grid beside the HP panel ---- */
.nimble-vitals-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem;
}

/* ---- Nimble: Wounds death-track ---- */
.wound-track {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    background: var(--ds-chip-bg);
    border: 1px solid var(--ds-status-danger);
    border-radius: 2px;
    padding: 0.6rem 0.85rem;
    margin-top: 0.75rem;
}
.wound-track-label {
    font-family: var(--font-heading);
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--ds-status-danger);
    white-space: nowrap;
}
.wound-pips-row { display: flex; align-items: center; gap: 0.5rem; flex: 1; }
.wound-pips { display: flex; gap: 0.5rem; }
.wound-pip {
    width: 19px;
    height: 19px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--ds-cell-bg);
    border: 1px solid var(--ds-border);
    touch-action: manipulation;
}
.wound-pip.filled { border-color: #5a1f12; box-shadow: 0 0 8px var(--ds-status-danger-glow); }
[data-theme="dark"] .wound-pip.filled { background: radial-gradient(circle at 40% 35%, #e2674a, #8a2a18); }
[data-theme="light"] .wound-pip.filled { background: var(--ds-status-danger); border-color: #933015; }
.wound-track-hint {
    font-size: 0.65rem;
    color: var(--ds-ink-dim);
    letter-spacing: 0.03em;
    white-space: nowrap;
}

/* ---- Nimble: Actions-this-turn track ---- */
.action-track {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    background: var(--ds-chip-bg);
    border: 1px solid var(--ds-accent);
    border-radius: 2px;
    padding: 0.5rem 0.85rem;
}
.action-track-label {
    font-family: var(--font-heading);
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--ds-accent);
    white-space: nowrap;
}
.action-pips { display: flex; gap: 0.5rem; flex: 1; }
.action-pip {
    width: 19px;
    height: 19px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--ds-cell-bg);
    border: 1px solid var(--ds-border);
    touch-action: manipulation;
}
.action-pip.filled { background: var(--ds-accent); border-color: var(--ds-accent-hover); box-shadow: 0 0 8px var(--ds-accent); }
.action-reset-btn { font-size: 0.7rem; padding: 0.3rem 0.6rem; flex-shrink: 0; }

/* ---- Section label hint text (e.g. "tap to roll d20") ---- */
.play-section-hint {
    font-family: 'Segoe UI', system-ui, sans-serif;
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    font-size: 0.66rem;
    color: var(--ds-text-dim);
    margin-left: 0.4rem;
}

/* ---- Nimble skill chip (clickable, rolls d20) ---- */
.play-chip-skill {
    border-color: var(--ds-accent);
    color: var(--ds-accent);
    background: var(--ds-chip-bg);
    box-shadow: none;
    cursor: pointer;
}
.play-chip-skill:hover { filter: brightness(1.15); }

/* ---- HP Panel ---- */
.play-hp-panel {
    background: var(--ds-cell-bg);
    border: 1px solid var(--ds-cell-border);
    box-shadow: var(--ds-cell-bevel);
    border-radius: 2px;
    padding: 0.5rem 0.65rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    min-width: 88px;
}
.php-label {
    font-family: var(--font-heading);
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--ds-ink-dim);
    font-weight: 600;
}
.php-nums {
    display: flex;
    align-items: baseline;
    gap: 0.1rem;
    line-height: 1;
}
.php-current {
    font-size: 2rem;
    font-weight: 800;
    color: var(--ds-ink);
    line-height: 1;
}
.php-sep {
    font-size: 1rem;
    color: var(--ds-ink-dim);
}
.php-max {
    font-size: 1rem;
    color: var(--ds-ink-dim);
}
.php-bar { width: 100%; margin: 0.1rem 0; }
.php-btns { display: flex; gap: 0.4rem; }
.php-btns .hp-btn { width: 36px; height: 36px; font-size: 1.05rem; }

/* ---- Combat stats panel ---- */
.play-combat-stats {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}
.pcs-top-row { display: flex; gap: 0.3rem; }
.pcs-box {
    flex: 1;
    background: var(--ds-cell-bg);
    border: 1px solid var(--ds-cell-border);
    box-shadow: var(--ds-cell-bevel);
    border-radius: 2px;
    padding: 0.28rem 0.4rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.pcs-val {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--ds-accent);
    line-height: 1.1;
}
.pcs-lbl {
    font-family: var(--font-heading);
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--ds-ink-dim);
    margin-top: 0.1rem;
}
.pcs-adj-row {
    display: flex;
    align-items: center;
    gap: 0.2rem;
}
.pcs-adj-btn {
    width: 18px;
    height: 18px;
    border-radius: 2px;
    border: 1px solid var(--ds-cell-border);
    background: var(--ds-cell-bg);
    color: var(--ds-ink-dim);
    font-size: 0.75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
    padding: 0;
    line-height: 1;
    flex-shrink: 0;
}
.pcs-adj-btn:active { transform: scale(0.85); }
.pcs-adj-btn:hover { filter: brightness(1.3); }

.pcs-weapon-box {
    background: var(--ds-cell-bg);
    border: 1px solid var(--ds-cell-border);
    box-shadow: var(--ds-cell-bevel);
    border-radius: 2px;
    padding: 0.25rem 0.5rem;
    display: flex;
    flex-direction: column;
    flex: 1;
}
.pcs-weapon-val {
    font-size: 0.82rem;
    color: var(--ds-ink);
    line-height: 1.2;
}
.pcs-gear-row { display: flex; gap: 0.3rem; }

/* ---- Resource inputs inside pcs-box (XP/GP/Clue/Mad) ---- */
.pcs-res-input {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--ds-accent);
    line-height: 1.1;
    background: none;
    border: none;
    outline: none;
    text-align: center;
    width: 2.5rem;
    font-family: inherit;
}
.pcs-res-input:focus { color: var(--ds-ink); }
.pcs-res-input::-webkit-outer-spin-button,
.pcs-res-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.pcs-res-input[type=number] { -moz-appearance: textfield; }

/* ---- Stats Row ---- */
.play-stats-row {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}
.play-stat-block {
    flex: 1;
    min-width: 70px;
    background: var(--ds-surface2);
    border: 1px solid var(--ds-border);
    border-radius: 8px;
    padding: 0.4rem 0.5rem;
    text-align: center;
}
.play-stat-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--ds-accent);
    line-height: 1.1;
}
.play-stat-label {
    font-size: 0.66rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--ds-text-dim);
    margin-top: 0.15rem;
}

/* ---- XP & Gold inline adjusters ---- */
.play-adjuster-row {
    display: flex;
    gap: 0.5rem;
}
.play-adjuster {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    background: var(--ds-surface2);
    border-radius: 8px;
    padding: 0.35rem 0.5rem;
}
.adj-label {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--ds-text-dim);
    width: 22px;
    flex-shrink: 0;
}
.adj-value {
    flex: 1;
    font-size: 1rem;
    font-weight: 600;
    text-align: center;
    color: var(--ds-text);
    background: none;
    border: none;
    outline: none;
    width: 50px;
    min-width: 0;
}
.adj-value:focus { color: var(--ds-accent); }
.adj-btn {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    border: 1px solid var(--ds-border);
    background: var(--ds-surface);
    color: var(--ds-text);
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
    flex-shrink: 0;
}
.adj-btn:active { transform: scale(0.9); }
.adj-btn:hover { background: var(--ds-border); }

/* ---- Talents / Spells / Equipment chips ---- */
.play-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.play-chips .play-chip[data-name] { cursor: grab; touch-action: none; }
.play-chips .play-chip[data-name]:active { cursor: grabbing; }
.play-chip {
    background: var(--ds-cell-bg);
    border: 1px solid var(--ds-cell-border);
    box-shadow: var(--ds-cell-bevel);
    border-radius: 2px;
    padding: 0.22rem 0.6rem;
    font-size: 0.74rem;
    color: var(--ds-ink-dim);
}
.play-chip-spell { border-color: var(--ds-violet); color: var(--ds-violet-text); background: var(--ds-chip-bg); box-shadow: none; gap: 0.3rem; }
.play-chip-spell:hover { background: color-mix(in srgb, var(--ds-violet) 12%, var(--ds-chip-bg)); }
.play-chip-trait { border-color: var(--ds-moss); color: var(--ds-moss-text); background: var(--ds-chip-bg); box-shadow: none; }

/* ---- Spell mana cost badge ---- */
.spell-mana-cost {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--ds-violet);
    color: #fff;
    border-radius: 999px;
    font-size: 0.65rem;
    font-weight: 700;
    min-width: 1.2em;
    height: 1.2em;
    padding: 0 0.28em;
    line-height: 1;
}

/* ---- Spell tier grouping ---- */
.nimble-spells-section { margin-top: 0.5rem; }
.spell-tier-group { margin-top: 0.5rem; }
.spell-tier-label {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ds-violet);
    opacity: 0.8;
    margin-bottom: 0.35rem;
}

/* ---- Spell chip blocked (not enough mana or actions) ---- */
.chip-spell-blocked {
    opacity: 0.4;
    cursor: not-allowed !important;
    pointer-events: auto;
    filter: grayscale(0.5);
}
.chip-spell-blocked:hover { background: var(--ds-chip-bg) !important; }

/* ---- Spell cast flash animation ---- */
@keyframes spellCastFlash {
    0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ds-violet) 70%, transparent); }
    40%  { box-shadow: 0 0 0 6px color-mix(in srgb, var(--ds-violet) 40%, transparent); background: color-mix(in srgb, var(--ds-violet) 25%, var(--ds-chip-bg)); }
    100% { box-shadow: 0 0 0 0 transparent; background: var(--ds-chip-bg); }
}
.spell-cast-flash { animation: spellCastFlash 0.5s ease-out forwards; }

/* ---- Saves-as tag in character meta ---- */
.saves-as-tag {
    font-size: 0.65rem;
    color: var(--ds-ink-dim);
    background: var(--ds-cell-bg);
    border: 1px solid var(--ds-cell-border);
    border-radius: 2px;
    padding: 0.05rem 0.4rem;
    margin-left: 0.3rem;
    white-space: nowrap;
}

/* ---- Equipment label row with toggle button ---- */
.equip-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.25rem;
}
.equip-toggle-btn {
    width: 19px;
    height: 19px;
    border-radius: 2px;
    border: 1px solid var(--ds-cell-border);
    background: var(--ds-cell-bg);
    color: var(--ds-ink-dim);
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
    padding: 0;
    line-height: 1;
    flex-shrink: 0;
}
.equip-toggle-btn:hover { filter: brightness(1.3); }

/* ---- Equipment chip with remove button ---- */
.play-chip-equip {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
}
.equip-remove-btn {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--ds-ink-dim);
    font-size: 0.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
    flex-shrink: 0;
    touch-action: manipulation;
}
.equip-remove-btn:hover { color: var(--ds-status-danger); }

/* ---- Equipment add row ---- */
.equip-add-row {
    display: flex;
    gap: 0.3rem;
    margin-top: 0.3rem;
}
.equip-add-input {
    flex: 1;
    min-width: 0;
    background: var(--ds-cell-bg);
    border: 1px solid var(--ds-cell-border);
    border-radius: 2px;
    padding: 0.25rem 0.45rem;
    font-size: 0.75rem;
    color: var(--ds-ink-dim);
    outline: none;
    font-family: inherit;
}
.equip-add-input:focus { border-color: var(--ds-accent); color: var(--ds-ink); }
.equip-add-btn {
    width: 26px;
    height: 26px;
    border-radius: 2px;
    border: 1px solid var(--ds-cell-border);
    background: var(--ds-cell-bg);
    color: var(--ds-ink-dim);
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
    padding: 0;
    flex-shrink: 0;
}
.equip-add-btn:hover { filter: brightness(1.3); }

/* ---- Feature usage — checkboxes inline inside chip ---- */
.play-chip.has-usage {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}
.feature-use-boxes {
    display: inline-flex;
    gap: 0.25rem;
    align-items: center;
}
.feature-use-cb {
    width: 0.95rem;
    height: 0.95rem;
    min-width: 0.95rem;
    cursor: pointer;
    accent-color: var(--ds-accent);
    touch-action: manipulation;
    margin: 0;
    vertical-align: middle;
}

/* ---- Spell slots ---- */
.play-slots-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.3rem;
}
.play-spell-slot {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}
.spell-slot-used-cb {
    width: 1.3rem;
    height: 1.3rem;
    min-width: 1.3rem;
    cursor: pointer;
    accent-color: var(--ds-violet);
    touch-action: manipulation;
    flex-shrink: 0;
}
.spell-slot-select {
    flex: 1;
    min-width: 0;
    background: var(--ds-chip-bg);
    border: 1px solid var(--ds-violet);
    border-radius: 2px;
    color: var(--ds-violet-text);
    font-size: 0.78rem;
    padding: 0.3rem 0.45rem;
    font-family: inherit;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}
.spell-slot-select:focus { border-color: var(--ds-violet); filter: brightness(1.15); }
.spell-slot-select.assigned { border-color: var(--ds-violet); color: var(--ds-violet-text); background: var(--ds-chip-bg); }
.play-spell-slot.slot-used .spell-slot-select {
    text-decoration: line-through;
    opacity: 0.5;
}

/* ---- Status checkboxes (Lantern, Bandaged) ---- */
.play-checks-row {
    display: flex;
    gap: 0.9rem;
    align-items: center;
}
.play-check-item {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    cursor: pointer;
    user-select: none;
    touch-action: manipulation;
}
.play-check-item span {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--ds-ink-dim);
}
.play-check-cb {
    width: 1rem;
    height: 1rem;
    accent-color: var(--ds-accent);
    cursor: pointer;
    touch-action: manipulation;
    margin: 0;
}

/* psh-btn-row separator between checkboxes and action buttons */
.psh-btn-sep { color: var(--ds-cell-border); margin: 0 0.1rem; font-size: 0.8rem; }

/* ---- Quest input ---- */
.play-quest-input {
    width: 100%;
    background: var(--ds-cell-bg);
    border: 1px solid var(--ds-cell-border);
    box-shadow: var(--ds-cell-bevel);
    border-radius: 2px;
    padding: 0.4rem 0.6rem;
    font-size: 0.8rem;
    font-style: italic;
    color: var(--ds-ink-dim);
    outline: none;
    font-family: inherit;
}
.play-quest-input:focus {
    border-color: var(--ds-accent);
    color: var(--ds-ink);
}

/* ---- Notes ---- */
.play-notes {
    background: var(--ds-cell-bg);
    border: 1px solid var(--ds-cell-border);
    box-shadow: var(--ds-cell-bevel);
    border-radius: 2px;
    padding: 0.45rem 0.65rem;
    font-size: 0.82rem;
    color: var(--ds-ink-dim);
    resize: none;
    min-height: 50px;
    width: 100%;
    outline: none;
    font-family: inherit;
    scrollbar-width: thin;
    scrollbar-color: var(--ds-cell-border) transparent;
}
.play-notes::placeholder { font-style: italic; }
.play-notes:focus { border-color: var(--ds-accent); color: var(--ds-ink); }
.play-notes::-webkit-scrollbar { width: 7px; }
.play-notes::-webkit-scrollbar-track { background: transparent; }
.play-notes::-webkit-scrollbar-thumb { background: var(--ds-cell-border); border-radius: 4px; }
.play-notes::-webkit-scrollbar-thumb:hover { background: var(--ds-ink-dim); }

/* ---- Section labels ---- */
.play-section-label {
    font-family: var(--font-heading);
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--ds-ink-dim);
    margin-bottom: 0.25rem;
}

/* ---- Passive abilities collapsible ---- */
.passive-section {
    margin-top: 0.4rem;
}
.passive-section > summary {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    cursor: pointer;
    font-family: var(--font-heading);
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--ds-text-dim);
    list-style: none;
    user-select: none;
    padding: 0.15rem 0;
    margin-bottom: 0.2rem;
}
.passive-section > summary::-webkit-details-marker { display: none; }
.passive-section > summary::before {
    content: '▶';
    font-size: 0.55em;
    transition: transform 0.15s;
    display: inline-block;
}
.passive-section[open] > summary::before { transform: rotate(90deg); }
.passive-section > summary:hover { color: var(--ds-text); }

/* ---- Saved toast ---- */
.ds-toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    background: #1a4a2e;
    color: #6ee89e;
    border: 1px solid var(--ds-green);
    border-radius: 8px;
    padding: 0.6rem 1.2rem;
    font-size: 0.9rem;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.25s, transform 0.25s;
    pointer-events: none;
    z-index: 500;
}
.ds-toast.show { opacity: 1; transform: translateY(0); }

/* ---- Class selection grid ---- */
.class-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.75rem;
}
.class-card {
    background: var(--ds-surface2);
    border: 2px solid var(--ds-border);
    border-radius: 10px;
    padding: 0.85rem;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    min-height: var(--touch-min);
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}
.class-card:hover { border-color: var(--ds-accent-dim); background: var(--ds-surface2); }
.class-card.selected { border-color: var(--ds-accent); background: var(--ds-accent-dim); }
.class-card-name { font-family: var(--font-heading); font-weight: 700; color: var(--ds-accent); font-size: 1rem; }
.class-card-desc { font-size: 0.75rem; color: var(--ds-text-dim); }
.class-card-stats { display: flex; gap: 0.4rem; margin-top: auto; padding-top: 0.4rem; }
.class-stat { font-size: 0.72rem; background: var(--ds-surface); border: 1px solid var(--ds-border); border-radius: 12px; padding: 0.15rem 0.45rem; color: var(--ds-text-dim); }

/* ---- Character selection in party builder ---- */
.char-select-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.6rem;
}
.char-select-card {
    background: var(--ds-surface2);
    border: 2px solid var(--ds-border);
    border-radius: 10px;
    padding: 0.75rem;
    cursor: pointer;
    transition: border-color 0.15s;
    display: flex;
    align-items: center;
    gap: 0.7rem;
    min-height: var(--touch-min);
}
.char-select-card:hover { border-color: var(--ds-accent-dim); }
.char-select-card.selected { border-color: var(--ds-accent); background: var(--ds-accent-dim); }
.char-select-card.disabled { opacity: 0.4; pointer-events: none; }
.char-select-check {
    width: 22px;
    height: 22px;
    border: 2px solid var(--ds-border);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.9rem;
}
.char-select-card.selected .char-select-check { background: var(--ds-accent-dim); border-color: var(--ds-accent); color: var(--ds-accent); }
.char-select-info { flex: 1; min-width: 0; }
.char-select-name { font-weight: 600; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.char-select-sub { font-size: 0.75rem; color: var(--ds-text-dim); }

/* ---- Utility ---- */
.ds-divider { border: none; border-top: 1px solid var(--ds-border); margin: 1rem 0; }
.text-dim { color: var(--ds-text-dim); }
.text-accent { color: var(--ds-accent); }
.text-sm { font-size: 0.85rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.gap-1 { gap: 0.5rem; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }
.play-header-bar {
    background: var(--ds-surface);
    border: 1px solid var(--ds-border);
    border-bottom: 2px solid var(--ds-accent-dim);
    border-radius: 12px;
    padding: 0.7rem 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}
[data-theme="light"] .play-header-bar {
    background-image: url('/img/textures/parchment.png');
    background-size: 300px 300px;
}
.play-party-name { font-family: var(--font-heading); font-size: 1.2rem; font-weight: 700; color: var(--ds-ink); flex: 1; }

/* ── Admin dropdown ────────────────────────────── */
.ds-nav-dropdown {
    position: relative;
}
.ds-nav-dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 160px;
    background: var(--ds-surface-opaque);
    border: 1px solid var(--ds-border);
    border-radius: var(--radius);
    z-index: 200;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
    overflow: hidden;
}
.ds-nav-dropdown.open .ds-nav-dropdown-menu {
    display: flex;
    flex-direction: column;
}
.ds-nav-dropdown-item {
    display: block;
    padding: 0.7rem 1rem;
    color: var(--ds-text);
    text-decoration: none;
    font-size: 0.9rem;
    min-height: 44px;
    display: flex;
    align-items: center;
    touch-action: manipulation;
}
.ds-nav-dropdown-item:hover {
    background: var(--ds-surface2);
    color: var(--ds-accent);
}

/* ── Source badge ──────────────────────────────── */
.source-badge {
    font-size: 0.72rem;
    padding: 0.1rem 0.45rem;
    border-radius: 4px;
    background: var(--ds-accent-dim);
    border: 1px solid var(--ds-accent);
    color: var(--ds-accent);
    font-weight: 500;
    white-space: nowrap;
}

/* ── Chip-check (checkbox chip for edit forms) ── */
.chip-check {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background: var(--ds-surface2);
    border: 1px solid var(--ds-border);
    border-radius: 6px;
    padding: 0.35rem 0.65rem;
    cursor: pointer;
    touch-action: manipulation;
    min-height: 44px;
    transition: border-color 0.12s, background 0.12s;
}
.chip-check span { font-family: var(--font-heading); font-size: 0.9rem; }
.chip-check-active-feature { border-color: var(--ds-accent); background: var(--ds-accent-dim); }
.chip-check-active-feature span { color: var(--ds-accent); }
.chip-check-active-talent  { border-color: var(--ds-moss); background: rgba(132,164,64,0.14); }
.chip-check-active-talent  span { color: var(--ds-moss-text); }
.chip-check-active-spell   { border-color: var(--ds-violet); background: rgba(151,114,204,0.14); }
.chip-check-active-spell   span { color: var(--ds-violet-text); }
.chip-check-active-exclude { border-color: var(--ds-status-danger); background: rgba(214,73,47,0.14); }
.chip-check-active-exclude span { color: var(--ds-status-danger); }
.chip-check:has(input:checked) { border-color: var(--ds-accent); background: var(--ds-accent-dim); }
.chip-check:has(input:checked) span { color: var(--ds-accent); }

/* ── Modal overlay (e.g. subclass choice on level-up) ──── */
.ds-modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}
.ds-modal {
    background: var(--ds-surface-opaque);
    border: 1px solid var(--ds-border);
    border-radius: 12px;
    padding: 1.5rem;
    max-width: 420px;
    width: 100%;
}

/* ── Play chip: Features ─────────────────────── */
.play-chip-feature {
    border-color: var(--ds-accent);
    color: var(--ds-accent);
    background: var(--ds-chip-bg);
    box-shadow: none;
}

/* ── Feature use pips ────────────────────────── */
.play-chip-has-use {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}
.play-chip-has-use.chip-use-spent {
    opacity: 0.45;
    text-decoration: line-through;
}
.feature-use-pips {
    display: inline-flex;
    gap: 3px;
    align-items: center;
    flex-shrink: 0;
}
.feature-use-pip {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    border: 1.5px solid var(--ds-accent);
    cursor: pointer;
    flex-shrink: 0;
    transition: background .12s, opacity .12s;
}
.feature-use-pip.pip-used {
    background: var(--ds-accent);
}
.feature-use-pip:hover {
    opacity: 0.7;
}

/* ── Play chip tooltips ──────────────────────── */
.play-chip[data-tip] { position: relative; }
.play-chip[data-tip]:not([data-tip=""]) { cursor: help; }
.play-chip[data-tip]:not([data-tip=""])::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 7px);
    left: 50%;
    transform: translateX(-50%);
    background: #18182a;
    border: 1px solid #34373d;
    color: #e8e4d8;
    padding: 0.45rem 0.65rem;
    border-radius: 7px;
    font-size: 0.78rem;
    line-height: 1.45;
    white-space: normal;
    width: max-content;
    max-width: 210px;
    z-index: 300;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}
.play-chip[data-tip]:not([data-tip=""]):hover::after,
.play-chip[data-tip]:not([data-tip=""]).tip-active::after {
    opacity: 1;
}

/* =====================================================================
   Shop page
   ===================================================================== */
.shop-items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.6rem;
}
.shop-item-card {
    background: var(--ds-surface2);
    border: 1px solid var(--ds-border);
    border-radius: 10px;
    padding: 0.65rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}
.shop-item-unavailable { pointer-events: none; }
.shop-item-name {
    font-weight: 600;
    font-size: 0.92rem;
    color: var(--ds-text);
}
.shop-item-desc {
    flex: 1;
    font-size: 0.78rem;
    line-height: 1.4;
}
.shop-item-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.4rem;
    margin-top: 0.3rem;
    padding-top: 0.3rem;
    border-top: 1px solid var(--ds-border);
}
.shop-item-price {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--ds-accent);
}
.shop-buy-btn {
    font-size: 0.8rem;
    padding: 0.3rem 0.75rem;
}
.shop-buy-btn:disabled { opacity: 0.35; cursor: not-allowed; }

/* Character buyer cards */
.shop-party-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.6rem;
}
@media (max-width: 600px) {
    .shop-party-row { grid-template-columns: repeat(2, 1fr); }
}
.shop-char-card {
    background: var(--ds-surface2);
    border: 2px solid var(--ds-border);
    border-radius: 10px;
    padding: 0.75rem;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    text-align: center;
    transition: border-color 0.15s;
    user-select: none;
}
.shop-char-card:hover { border-color: var(--ds-accent); }
.shop-char-card.shop-char-active {
    border-color: var(--ds-accent);
    background: var(--ds-accent-dim);
}
.shop-char-card.dead { opacity: 0.4; cursor: not-allowed; }
.shop-char-name { font-weight: 700; font-size: 0.95rem; }
.shop-char-gold {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--ds-accent);
    line-height: 1.1;
    margin-top: 0.25rem;
}
.shop-char-inv {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    justify-content: center;
    margin-top: 0.35rem;
    width: 100%;
}
.shop-inv-chip {
    font-size: 0.7rem;
    background: var(--ds-surface);
    border: 1px solid var(--ds-border);
    border-radius: 4px;
    padding: 0.1rem 0.35rem;
    color: var(--ds-text-dim);
    line-height: 1.4;
}
@keyframes chipAppear {
    from { opacity: 0; transform: scale(0.8); }
    to   { opacity: 1; transform: scale(1); }
}
.shop-inv-chip-new {
    border-color: var(--ds-accent);
    color: var(--ds-text);
    animation: chipAppear 0.25s ease-out;
}
.shop-char-error {
    font-size: 0.75rem;
    color: var(--ds-red);
    min-height: 1rem;
}
@keyframes shopGoldFlash {
    0%   { color: var(--ds-green); }
    100% { color: var(--ds-accent); }
}
.shop-gold-flash { animation: shopGoldFlash 0.5s ease-out; }
@keyframes shopErrFlash {
    0%,100% { opacity: 1; }
    50%      { opacity: 0.5; }
}
.shop-err-flash { animation: shopErrFlash 0.3s ease-in-out 2; }
