:root {
    --bg: #1a1325;
    --bg-elev: #251a36;
    --bg-elev-2: #322449;
    --fg: #ece6f7;
    --fg-dim: #a89bc4;
    --accent: #f7c948;
    --danger: #e05a5a;
    --good: #5ed18f;
    --shield: #6fb8e8;
    --ruby: #e74c5e;
    --sapphire: #4f7df0;
    --emerald: #5ed18f;
    --topaz: #f7c948;
    --diamond: #e8e8f5;
    --amethyst: #a87fe8;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--fg);
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    min-height: 100vh;
}

header {
    padding: 0.75rem 1.5rem;
    border-bottom: 1px solid var(--bg-elev-2);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    background: var(--bg-elev);
}

header h1 {
    font-size: 1.4rem;
    margin: 0;
    letter-spacing: 0.15em;
    color: var(--accent);
}

.hud {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.hud-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.timer {
    color: var(--accent);
    font-weight: bold;
    min-width: 2.5em;
    display: inline-block;
    text-align: right;
}
.timer.warn { color: var(--danger); }

button {
    background: var(--bg-elev-2);
    color: var(--fg);
    border: 1px solid var(--accent);
    padding: 0.5rem 1rem;
    font: inherit;
    cursor: pointer;
    border-radius: 4px;
}
button:hover:not(:disabled) { background: var(--accent); color: var(--bg); }
button:disabled { opacity: 0.4; cursor: not-allowed; }
button.primary {
    background: var(--accent);
    color: var(--bg);
    font-weight: bold;
}
button.primary:hover:not(:disabled) { filter: brightness(1.1); }

.banner {
    font-size: 1.5rem;
    font-weight: bold;
    letter-spacing: 0.2em;
    min-width: 6em;
    text-align: center;
}
.banner.victory { color: var(--good); }
.banner.defeat { color: var(--danger); }
.banner.cleared { color: var(--accent); }

main {
    display: grid;
    /* Party flanks the board on the left, enemies on the right, board
       fills the middle. Each side column is fixed-width so the board
       stays roughly centered as the viewport flexes. */
    grid-template-columns: 320px 1fr 320px;
    gap: 1rem;
    padding: 1rem;
    /* Leave room for the bottom spell bar so combat cards never slip
       under it. Keep in sync with `.spell-tray` height below. */
    padding-bottom: 120px;
    align-items: start;
}

.center-stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    min-height: 600px;
}

.hidden { display: none !important; }

.map {
    position: relative;
    background: var(--bg-elev);
    border-radius: 8px;
    border: 1px solid var(--bg-elev-2);
    margin: 1rem auto;
    /* No padding — SVG and node positions share the same origin (padding box edge). */
}
.map-edges {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: visible;
}
.map-edge {
    stroke: var(--bg-elev-2);
    stroke-width: 2;
}
.map-edge.reachable {
    stroke: var(--accent);
    stroke-width: 3;
    stroke-dasharray: 6 4;
    animation: edge-flow 1.4s linear infinite;
}
@keyframes edge-flow {
    to { stroke-dashoffset: -20; }
}

.map-node {
    position: absolute;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--bg-elev-2);
    border: 2px solid var(--bg-elev-2);
    color: var(--fg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    cursor: not-allowed;
    padding: 0;
    transition: transform 120ms ease-out, box-shadow 120ms;
}
.map-node.reachable {
    cursor: pointer;
    border-color: var(--accent);
    box-shadow: 0 0 12px rgba(247, 201, 72, 0.4);
    animation: node-glow 1.6s ease-in-out infinite;
}
.map-node.reachable:hover {
    transform: scale(1.15);
    box-shadow: 0 0 20px rgba(247, 201, 72, 0.7);
}
.map-node.cleared {
    border-color: var(--good);
    background: var(--bg-elev);
    opacity: 0.85;
}
.map-node.locked { opacity: 0.45; }
.map-node.type-elite {
    background: rgba(224, 90, 90, 0.18);
    border-color: var(--danger);
}
.map-node.type-elite.reachable { box-shadow: 0 0 14px rgba(224, 90, 90, 0.5); }
.map-node.type-camp {
    background: rgba(94, 209, 143, 0.12);
}
.map-node.type-event {
    background: rgba(168, 127, 232, 0.15);
}
.map-node.type-boss {
    background: rgba(247, 201, 72, 0.2);
    border-color: var(--accent);
    width: 60px;
    height: 60px;
    font-size: 1.8rem;
}

@keyframes node-glow {
    0%, 100% { box-shadow: 0 0 8px rgba(247, 201, 72, 0.35); }
    50%      { box-shadow: 0 0 18px rgba(247, 201, 72, 0.7); }
}

.map-node .map-node-quest-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent);
    color: var(--bg);
    font-size: 0.75rem;
    line-height: 18px;
    text-align: center;
    font-weight: bold;
    box-shadow: 0 0 6px rgba(247, 201, 72, 0.75);
    pointer-events: none;
}
.map-node.has-quest-marker {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
.map-node.has-quest-marker.cleared .map-node-quest-badge { display: none; }

/* ----- floating numbers ----- */

.float-layer {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 2000;
    overflow: hidden;
}

.float {
    position: fixed;
    transform: translate(-50%, 0);
    font: bold 1.3rem ui-monospace, "SF Mono", Menlo, monospace;
    text-shadow:
        0 0 4px #000,
        0 1px 2px #000,
        -1px 0 0 #000, 1px 0 0 #000, 0 -1px 0 #000, 0 1px 0 #000;
    will-change: transform, opacity;
    animation: float-up 1100ms ease-out forwards;
    pointer-events: none;
    white-space: nowrap;
}
@keyframes float-up {
    0%   { transform: translate(-50%, 0)     scale(0.6); opacity: 0; }
    18%  { transform: translate(-50%, -8px)  scale(1.25); opacity: 1; }
    100% { transform: translate(-50%, -64px) scale(1);   opacity: 0; }
}

.float-damage      { color: var(--ruby); }
.float-damage.crit { color: var(--accent); font-size: 1.8rem; }
.float-damage.weak { color: var(--good);   font-size: 1.5rem; }
.float-damage.resist { color: var(--fg-dim); font-size: 1rem; opacity: 0.85; }
.float-damage.true { color: var(--amethyst); font-size: 1.6rem; }
.float-damage.big  { color: var(--danger); font-size: 1.7rem; }

.float-heal   { color: var(--good); }
.float-shield { color: var(--shield); }
.float-shield.small { font-size: 0.85rem; }

.float-miss { color: var(--fg-dim); font-style: italic; font-size: 1rem; }

.float-summon { color: var(--amethyst); font-size: 1rem; }

.float-meter { color: var(--amethyst); }
.float-meter.small { font-size: 0.9rem; }

.float-ult {
    color: var(--amethyst);
    font-size: 2.4rem;
    letter-spacing: 0.15em;
    text-shadow:
        0 0 12px var(--amethyst),
        0 0 4px #000,
        0 2px 4px #000;
    animation: float-up-big 1400ms ease-out forwards;
}
@keyframes float-up-big {
    0%   { transform: translate(-50%, 0)     scale(0.4); opacity: 0; }
    20%  { transform: translate(-50%, -12px) scale(1.4); opacity: 1; }
    100% { transform: translate(-50%, -80px) scale(1.1); opacity: 0; }
}

/* ----- screen shake ----- */

@keyframes shake-sm {
    0%, 100% { transform: translate(0, 0); }
    20% { transform: translate(-2px,  1px); }
    40% { transform: translate( 2px, -1px); }
    60% { transform: translate(-1px,  2px); }
    80% { transform: translate( 1px, -2px); }
}
@keyframes shake-md {
    0%, 100% { transform: translate(0, 0); }
    15% { transform: translate(-4px,  2px); }
    30% { transform: translate( 4px, -2px); }
    45% { transform: translate(-3px, -3px); }
    60% { transform: translate( 3px,  3px); }
    75% { transform: translate(-2px,  4px); }
    90% { transform: translate( 2px, -4px); }
}
@keyframes shake-lg {
    0%, 100% { transform: translate(0, 0); }
    10% { transform: translate(-7px,  3px); }
    20% { transform: translate( 6px, -4px); }
    30% { transform: translate(-5px,  5px); }
    40% { transform: translate( 5px,  4px); }
    50% { transform: translate(-6px, -5px); }
    60% { transform: translate( 7px,  3px); }
    70% { transform: translate(-4px,  4px); }
    80% { transform: translate( 4px, -3px); }
    90% { transform: translate(-2px,  2px); }
}
.shake-sm { animation: shake-sm 280ms ease-in-out; }
.shake-md { animation: shake-md 380ms ease-in-out; }
.shake-lg { animation: shake-lg 520ms ease-in-out; }

.party {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    max-height: calc(100vh - 220px);
    overflow-y: auto;
}
.party-side {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.hero-card {
    background: var(--bg-elev);
    border: 1px solid var(--bg-elev-2);
    border-radius: 6px;
    padding: 0.6rem;
}
.hero-card.rank-front { border-left: 4px solid var(--ruby); }
.hero-card.rank-rear  { border-left: 4px solid var(--sapphire); }
.hero-card.dead { opacity: 0.4; filter: grayscale(80%); }

.hero-header {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.4rem;
}
.hero-glyph { font-size: 1.2rem; }
.hero-name { font-weight: bold; flex: 1; }
.hero-rank {
    font-size: 0.75rem;
    color: var(--fg-dim);
    border: 1px solid var(--fg-dim);
    border-radius: 3px;
    padding: 0 0.3em;
}
.hero-stats { display: flex; flex-direction: column; gap: 0.2rem; }
.shield { font-size: 0.85rem; color: var(--shield); }

.hero-loaded {
    margin-top: 0.25rem;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-size: 0.85rem;
    background: var(--bg-elev-2);
    border-left: 3px solid var(--bg-elev-2);
    display: flex;
    align-items: center;
    gap: 0.35rem;
}
.hero-loaded.empty { opacity: 0.55; font-style: italic; }
.hero-loaded .loaded-score { font-weight: bold; }
.hero-loaded .dim { color: var(--fg-dim); }
.hero-loaded.color-ruby     { border-left-color: var(--ruby); }
.hero-loaded.color-sapphire { border-left-color: var(--sapphire); }
.hero-loaded.color-emerald  { border-left-color: var(--emerald); }
.hero-loaded.color-topaz    { border-left-color: var(--topaz); }
.hero-loaded.color-diamond  { border-left-color: var(--diamond); }
.hero-loaded.color-amethyst { border-left-color: var(--amethyst); }

.hero-card.clickable { cursor: pointer; }
.hero-card.clickable:hover {
    background: var(--bg-elev-2);
    transform: translateY(-1px);
}

.hero-card.just-received {
    animation: hero-receive-pulse 550ms ease-out;
}
.hero-card.just-received .hero-loaded {
    animation: loaded-flash 550ms ease-out;
}
@keyframes hero-receive-pulse {
    0%   { box-shadow: 0 0 0 0 var(--accent); }
    35%  { box-shadow: 0 0 14px 3px var(--accent); background: var(--bg-elev-2); }
    100% { box-shadow: 0 0 0 0 transparent; }
}
@keyframes loaded-flash {
    0%   { filter: brightness(1); }
    35%  { filter: brightness(1.6); }
    100% { filter: brightness(1); }
}

.hero-level {
    font-size: 0.7rem;
    color: var(--accent);
    font-weight: bold;
    border: 1px solid var(--accent);
    border-radius: 3px;
    padding: 0 0.3em;
}

/* Prepared spell-slot chips (Phase 2; replaces the MP bar). */
.slot-chips {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
    margin-top: 0.2rem;
}
.slot-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    padding: 0.05rem 0.35rem;
    border-radius: 10px;
    background: rgba(84, 96, 255, 0.18);
    border: 1px solid rgba(84, 96, 255, 0.45);
    font-size: 0.65rem;
    line-height: 1.1;
    color: var(--fg);
}
.slot-chip.empty {
    opacity: 0.35;
}
.slot-chip-lvl {
    font-weight: 600;
    color: var(--sapphire);
}
.slot-chip-count {
    color: var(--fg-dim);
}

/* WoW-style action bar docked to the bottom of the viewport. Each caster
 * gets a labeled cluster of square icon buttons; each button shows the
 * spell glyph, a cost chip, and a tooltip on hover. Non-combat phases
 * hide the bar entirely (see `.spell-tray.empty`). */
.spell-tray {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    height: 110px;
    background: linear-gradient(to top, rgba(10, 12, 20, 0.96), rgba(18, 22, 32, 0.88));
    border-top: 1px solid var(--bg-elev-2);
    padding: 0.5rem 1rem;
    display: flex;
    gap: 1.25rem;
    align-items: center;
    justify-content: center;
    overflow-x: auto;
    box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.45);
}
.spell-tray.empty { display: none; }
.spell-tray.hidden { display: none; }
.spell-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    min-width: 0;
}
.spell-group-header {
    font-size: 0.65rem;
    color: var(--fg-dim);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    white-space: nowrap;
}
.spell-list {
    display: flex;
    flex-direction: row;
    gap: 0.4rem;
}

/* Each spell/feature is a compact square tile. The glyph dominates; the
 * cost sits under it as a small line. Hovering reveals the tooltip (the
 * native `title` attribute). Disabled tiles desaturate. */
.spell-btn {
    background: radial-gradient(circle at 30% 30%, var(--bg-elev), var(--bg));
    border: 2px solid var(--bg-elev-2);
    color: var(--fg);
    width: 62px;
    height: 62px;
    padding: 0.25rem 0.15rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.1rem;
    border-radius: 8px;
    cursor: pointer;
    position: relative;
    transition: transform 80ms ease-out, border-color 80ms, box-shadow 80ms;
}
.spell-btn:not(:disabled):hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(247, 201, 72, 0.28);
}
.spell-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    filter: grayscale(60%);
}
.spell-btn .spell-name {
    font-size: 1.35rem;
    line-height: 1;
}
.spell-btn .spell-label {
    font-size: 0.55rem;
    color: var(--fg-dim);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 56px;
}
.spell-btn .spell-cost {
    position: absolute;
    bottom: 2px;
    right: 3px;
    font-size: 0.55rem;
    padding: 0.05rem 0.25rem;
    background: rgba(10, 12, 20, 0.82);
    border-radius: 4px;
    color: var(--sapphire);
    font-weight: bold;
    line-height: 1.1;
}
.spell-btn.feature-btn {
    border-color: rgba(247, 201, 72, 0.35);
}
.spell-btn.feature-btn .spell-cost {
    color: var(--accent);
}

/* Character sheet: compact two-column layout so the whole sheet fits on
 * one viewport on typical laptop screens. Outer panel is a vertical flex
 * container with a scrollable body between a fixed header and footer; if
 * the window is shorter than the content, the body scrolls and the Close
 * button stays on-screen. */
/* Two-class selector (.rest-panel.character-sheet) has higher specificity
 * than the plain .rest-panel block defined further down, so these values
 * win the cascade without resorting to !important. */
.rest-panel.character-sheet {
    text-align: left;
    max-width: 1280px;
    width: min(96vw, 1280px);
    max-height: 90vh;
    padding: 1.5rem 2rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.char-sheet-header {
    flex: 0 0 auto;
}
.char-sheet-header h2 {
    margin: 0 0 0.15rem;
    font-size: 1.3rem;
    letter-spacing: 0.04em;
    color: var(--accent);
}
.char-sheet-tagline {
    color: var(--fg-dim);
    font-size: 0.8rem;
    text-transform: capitalize;
    letter-spacing: 0.04em;
    margin-bottom: 0.4rem;
}
.char-sheet-stat-strip {
    font-size: 0.85rem;
    color: var(--fg-dim);
    padding: 0.4rem 0.6rem;
    background: var(--bg-elev-2);
    border-radius: 4px;
}
.char-sheet-stat-strip strong {
    color: var(--fg);
    font-weight: 700;
}
.char-sheet-tabs {
    display: flex;
    gap: 0.25rem;
    margin-top: 0.6rem;
    border-bottom: 1px solid var(--bg-elev-2);
}
.char-sheet-tab-btn {
    background: transparent;
    border: 1px solid transparent;
    border-bottom: none;
    border-top-left-radius: 6px;
    border-top-right-radius: 6px;
    color: var(--fg-dim);
    padding: 0.3rem 0.9rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    cursor: pointer;
    margin-bottom: -1px;               /* overlap the 1px bottom border of the tab bar */
}
.char-sheet-tab-btn:hover {
    color: var(--fg);
}
.char-sheet-tab-btn.active {
    color: var(--accent);
    background: var(--bg-elev);
    border-color: var(--bg-elev-2);
    border-bottom-color: var(--bg-elev);
}
.char-sheet-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
}
.char-sheet-tab {
    display: none;
}
.char-sheet-tab.active {
    display: block;
}
.char-sheet-footer {
    flex: 0 0 auto;
    display: flex;
    justify-content: flex-end;
    border-top: 1px solid var(--bg-elev-2);
    padding-top: 0.6rem;
}
.char-sheet-section {
    margin: 0.6rem 0 0.2rem;
    color: var(--fg-dim);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    border-bottom: 1px solid var(--bg-elev-2);
    padding-bottom: 0.15rem;
}
.char-sheet-tab > .char-sheet-section:first-child {
    margin-top: 0.25rem;
}
.char-sheet-spells {
    list-style: none;
    padding: 0;
    margin: 0.35rem 0 0;
}
.char-sheet-spells li {
    padding: 0.2rem 0;
    color: var(--fg-dim);
    font-size: 0.78rem;
    line-height: 1.35;
}
.char-sheet-spells strong { color: var(--accent); }

.ability-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.4rem;
    margin: 0.35rem 0 0.25rem;
}
.ability-cell {
    padding: 0.5rem 0.35rem;
    background: var(--bg-elev-2);
    border: 1px solid var(--bg-elev-2);
    border-radius: 4px;
    text-align: center;
}
.ability-cell.prime {
    border-color: var(--accent);
}
.ability-label {
    font-size: 0.65rem;
    color: var(--fg-dim);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}
.ability-score {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--fg);
    margin: 0.15rem 0;
}
.ability-hint {
    font-size: 0.64rem;
    color: var(--fg-dim);
    line-height: 1.2;
}
.ability-bonus {
    margin-top: 0.3rem;
    font-size: 0.78rem;
    color: var(--accent);
}

.save-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.3rem;
    margin: 0.25rem 0 0.15rem;
}
.save-cell {
    padding: 0.25rem 0.2rem;
    background: var(--bg-elev-2);
    border: 1px solid var(--bg-elev-2);
    border-radius: 4px;
    text-align: center;
}
.save-label {
    font-size: 0.55rem;
    color: var(--fg-dim);
    letter-spacing: 0.08em;
}
.save-target {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--fg);
}
.float-save      { color: var(--good);   font-style: italic; font-size: 0.95rem; }
.float-save-fail { color: var(--danger); font-style: italic; font-size: 0.95rem; }

.equip-slots {
    display: grid;
    gap: 0.2rem;
    margin: 0.3rem 0 0;
}
.equip-slot {
    display: grid;
    grid-template-columns: 70px 1fr auto;
    gap: 0.4rem;
    align-items: center;
    background: var(--bg-elev-2);
    padding: 0.25rem 0.45rem;
    border-radius: 4px;
    font-size: 0.75rem;
}
.equip-slot.empty { opacity: 0.55; font-style: italic; }
.equip-slot-name {
    text-transform: uppercase;
    font-size: 0.6rem;
    letter-spacing: 0.12em;
    color: var(--fg-dim);
}
.equip-slot-item { color: var(--fg); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.equip-slot .dim { color: var(--fg-dim); font-size: 0.7rem; }

.char-sheet-inventory {
    list-style: none;
    padding: 0;
    margin: 0.3rem 0 0;
    display: grid;
    gap: 0.18rem;
}
.char-sheet-inventory li {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.2rem 0.35rem;
    background: var(--bg-elev-2);
    border-radius: 4px;
    font-size: 0.75rem;
}
.char-sheet-inventory strong { color: var(--accent); }
.char-sheet-inventory .dim { color: var(--fg-dim); flex: 1; font-size: 0.7rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.char-sheet-inventory button { font-size: 0.7rem; padding: 0.18rem 0.5rem; }

.equip-action {
    background: var(--bg-elev);
    border: 1px solid var(--accent);
    color: var(--accent);
    padding: 0.2rem 0.5rem;
    font-size: 0.75rem;
    border-radius: 3px;
}
.equip-action:not(:disabled):hover {
    background: var(--accent);
    color: var(--bg);
}
.equip-action:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.loot-offer {
    background: var(--bg-elev-2);
    border: 1px solid var(--accent);
    border-radius: 6px;
    padding: 0.75rem;
    margin: 0.5rem 0 0.75rem;
}
.loot-name { font-weight: bold; color: var(--accent); }
.loot-name .dim { font-weight: normal; color: var(--fg-dim); }
.loot-desc { color: var(--fg-dim); font-size: 0.85rem; margin: 0.25rem 0 0.5rem; }
.loot-takers { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.loot-taker {
    background: var(--bg-elev);
    border: 1px solid var(--accent);
    color: var(--fg);
    padding: 0.3rem 0.6rem;
    font-size: 0.85rem;
}
.loot-taker:hover { background: var(--accent); color: var(--bg); }

.event-choices {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-top: 1rem;
}
.event-choice {
    background: var(--bg-elev-2);
    border: 1px solid var(--bg-elev-2);
    color: var(--fg);
    padding: 0.55rem 0.75rem;
    text-align: left;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    border-radius: 4px;
    font-size: 0.9rem;
}
.event-choice:not(:disabled):hover {
    border-color: var(--accent);
    background: var(--bg-elev-2);
}
.event-choice:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.event-choice-label { flex: 1; }
.event-gate {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--fg-dim);
    border: 1px solid var(--fg-dim);
    border-radius: 999px;
    padding: 0.1rem 0.45rem;
}

.recruit-panel { text-align: left; max-width: 520px; }
.recruit-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem 1.5rem;
    margin: 1rem 0;
    font-size: 0.9rem;
    color: var(--fg-dim);
}
.recruit-stats strong { color: var(--fg); }
.recruit-replace-list {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    margin-bottom: 0.75rem;
}
.recruit-replace, .recruit-accept {
    background: var(--bg-elev-2);
    border: 1px solid var(--accent);
    color: var(--fg);
    padding: 0.5rem 0.75rem;
    text-align: left;
    font-size: 0.9rem;
    border-radius: 4px;
}
.recruit-replace .dim { color: var(--fg-dim); }
.recruit-replace:hover, .recruit-accept:hover { background: var(--accent); color: var(--bg); }

.factions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.faction-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.85rem;
    border: 1px solid var(--bg-elev-2);
    background: var(--bg-elev-2);
    color: var(--fg-dim);
}
.faction-chip.rel-allied {
    border-color: var(--good);
    color: var(--good);
}
.faction-chip.rel-hostile {
    border-color: var(--danger);
    color: var(--danger);
}
.faction-chip.rel-neutral {
    border-color: var(--fg-dim);
    color: var(--fg-dim);
}
.faction-glyph { font-size: 1rem; }
.faction-name { font-size: 0.8rem; }

.quest-log {
    text-align: left;
    max-width: min(1100px, 92vw);
    width: min(1100px, 92vw);
    max-height: 90vh;
    overflow-y: auto;
}
.quest-log-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    align-items: start;
    margin: 0.5rem 0 1rem;
}
.quest-col h3 { margin-top: 0; }
@media (max-width: 820px) {
    .quest-log-layout { grid-template-columns: 1fr; }
}
.quest-list {
    list-style: none;
    padding: 0;
    margin: 0.5rem 0;
    display: grid;
    gap: 0.5rem;
}
.quest-item {
    background: var(--bg-elev-2);
    border-radius: 5px;
    padding: 0.6rem 0.75rem;
    border-left: 3px solid var(--accent);
}
.quest-item.state-completed {
    border-left-color: var(--good);
    opacity: 0.85;
}
.quest-item.state-failed {
    border-left-color: var(--danger);
    opacity: 0.7;
}
.quest-title { font-weight: bold; color: var(--accent); }
.quest-item.state-completed .quest-title { color: var(--good); }
.quest-item.state-failed .quest-title {
    color: var(--danger);
    text-decoration: line-through;
}
.quest-desc { color: var(--fg-dim); font-size: 0.85rem; margin: 0.25rem 0 0.4rem; }
.quest-steps {
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 0.85rem;
}
.quest-steps li { padding: 0.15rem 0; color: var(--fg-dim); }
.quest-steps li.done { color: var(--good); text-decoration: line-through; }

.quest-generated-section { margin-bottom: 1.25rem; }
.generated-quest .quest-plantings {
    margin: 0.25rem 0; color: var(--fg-dim); font-size: 0.8rem;
}
.generated-quest .quest-next {
    margin-top: 0.4rem; color: var(--accent); font-size: 0.85rem;
}
.generated-quest .quest-interferences {
    margin-top: 0.25rem; color: var(--danger); font-size: 0.75rem; font-style: italic;
}
.generated-quest .quest-reward {
    margin-top: 0.25rem; color: var(--good); font-size: 0.8rem;
}
.quest-status-badge {
    margin-left: 0.5rem; padding: 0.05rem 0.4rem;
    border-radius: 0.25rem; background: var(--bg-dim);
    color: var(--fg-dim); font-size: 0.7rem; font-weight: normal;
}
.quest-item.state-completed .quest-status-badge { color: var(--good); }
.quest-item.state-failed .quest-status-badge { color: var(--danger); }
.char-sheet-none {
    color: var(--fg-dim);
    font-style: italic;
    font-size: 0.85rem;
    padding: 0.25rem 0;
}

.float-spell { color: var(--sapphire); font-size: 1rem; }
.float-xp { color: var(--accent); font-size: 0.95rem; }
.float-levelup {
    color: var(--good);
    font-size: 1.6rem;
    text-shadow: 0 0 12px var(--good), 0 0 4px #000;
    animation: float-up-big 1400ms ease-out forwards;
}

/* ----- status effects ----- */

.status-row {
    display: flex;
    gap: 0.2rem;
    margin-top: 0.25rem;
    flex-wrap: wrap;
}

.status-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.15rem;
    font-size: 0.85rem;
    line-height: 1;
    padding: 0.1rem 0.3rem;
    border-radius: 999px;
    border: 1px solid;
    background: rgba(0, 0, 0, 0.25);
}
.status-chip .status-duration {
    font-size: 0.65rem;
    opacity: 0.85;
}
.status-poison { color: var(--emerald); border-color: var(--emerald); }
.status-stun   { color: var(--accent);  border-color: var(--accent); }
.status-curse  { color: var(--amethyst); border-color: var(--amethyst); }
.status-bless  { color: var(--shield);  border-color: var(--shield); }

.float-status {
    font-size: 1.05rem;
    letter-spacing: 0.1em;
    font-weight: bold;
    text-shadow: 0 0 4px #000, 0 1px 2px #000;
}
.float-status.status-poison { color: var(--emerald); }
.float-status.status-stun   { color: var(--accent); }
.float-status.status-curse  { color: var(--amethyst); }
.float-status.status-bless  { color: var(--shield); }

.float-status-tick {
    font-size: 0.95rem;
    font-style: italic;
}
.float-status-tick.status-poison { color: var(--emerald); }

.float-cleanse {
    color: var(--good);
    font-size: 1rem;
    letter-spacing: 0.15em;
}

.hp-bar {
    background: #00000040;
    border-radius: 3px;
    height: 1.1rem;
    position: relative;
    overflow: hidden;
}
.hp-bar-fill {
    background: var(--good);
    height: 100%;
    transition: width 200ms ease-out;
}
.hp-bar-text {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: bold;
    text-shadow: 0 0 2px #000;
}

.play-area {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    align-items: stretch;
    width: 100%;
}

.encounter-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    width: 100%;
    max-width: 460px;
    padding: 0.5rem 0.75rem;
    background: var(--bg-elev);
    border-radius: 6px;
    border-left: 4px solid var(--accent);
}
.encounter-header .floor-label {
    color: var(--fg-dim);
    font-size: 0.85rem;
}
.encounter-header .encounter-name {
    flex: 1;
    font-weight: bold;
}
.encounter-header .encounter-name.boss {
    color: var(--danger);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.act-chip {
    font-size: 0.75rem;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    border: 1px solid var(--fg-dim);
    color: var(--fg-dim);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}
.act-chip.act-sewer   { border-color: var(--good);    color: var(--good); }
.act-chip.act-ruins   { border-color: var(--accent);  color: var(--accent); }
.act-chip.act-sanctum { border-color: var(--amethyst); color: var(--amethyst); }

.codex-list {
    list-style: none;
    padding: 0;
    margin: 0.5rem 0;
    display: grid;
    gap: 0.6rem;
    max-height: 50vh;
    overflow-y: auto;
}
.codex-entry {
    background: var(--bg-elev-2);
    border-left: 3px solid var(--accent);
    border-radius: 5px;
    padding: 0.55rem 0.75rem;
}
.codex-title { font-weight: bold; color: var(--accent); margin-bottom: 0.2rem; }
.codex-body { color: var(--fg-dim); font-size: 0.9rem; line-height: 1.4; }

.elements-panel { text-align: left; }
.elements-panel .dim { color: var(--fg-dim); font-size: 0.85rem; }

.resume-panel code, .history-row code {
    background: var(--bg-elev-2);
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    font-family: ui-monospace, monospace;
    color: var(--accent);
}
.resume-panel .dim { color: var(--fg-dim); font-size: 0.85rem; }

.history-panel { text-align: left; max-width: 620px; }
.history-list {
    list-style: none;
    padding: 0;
    margin: 0.5rem 0;
    display: grid;
    gap: 0.6rem;
    max-height: 55vh;
    overflow-y: auto;
}
.history-row {
    background: var(--bg-elev-2);
    border-left: 3px solid var(--fg-dim);
    border-radius: 5px;
    padding: 0.55rem 0.75rem;
}
.history-row.outcome-victory   { border-left-color: var(--good); }
.history-row.outcome-defeat    { border-left-color: var(--danger); }
.history-row.outcome-abandoned { border-left-color: var(--accent); }
.history-line {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
    font-size: 0.85rem;
}
.history-line.dim { color: var(--fg-dim); }
.history-outcome {
    text-transform: uppercase;
    letter-spacing: 0.15em;
    font-size: 0.7rem;
    font-weight: bold;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    background: var(--bg-elev);
}
.history-row.outcome-victory   .history-outcome { color: var(--good);   border: 1px solid var(--good); }
.history-row.outcome-defeat    .history-outcome { color: var(--danger); border: 1px solid var(--danger); }
.history-row.outcome-abandoned .history-outcome { color: var(--accent); border: 1px solid var(--accent); }
.history-depth { color: var(--accent); font-weight: bold; }
.history-date { color: var(--fg-dim); margin-left: auto; }
.history-actions { margin-top: 0.4rem; }
.history-replay {
    background: var(--bg-elev);
    color: var(--accent);
    border: 1px solid var(--accent);
    font-size: 0.8rem;
    padding: 0.25rem 0.6rem;
}
.history-replay:hover { background: var(--accent); color: var(--bg); }

.history-footer {
    justify-content: space-between;
}
button.danger {
    background: transparent;
    color: var(--danger);
    border: 1px solid var(--danger);
}
button.danger:hover:not(:disabled) {
    background: var(--danger);
    color: var(--bg);
}

.board {
    display: grid;
    gap: 4px;
    padding: 8px;
    background: var(--bg-elev);
    border-radius: 8px;
    border: 1px solid var(--bg-elev-2);
    /* Square board sized to the smaller of the available column width or
       80% of viewport height, capped so it never gets absurd on huge screens. */
    width: min(100%, 80vh, 720px);
    aspect-ratio: 1 / 1;
    container-type: inline-size;
}

.gem {
    /* Each gem fills its grid track and stays square; font scales with the
       board's inline size via container query units. */
    width: 100%;
    height: 100%;
    aspect-ratio: 1 / 1;
    font-size: 6cqi;
    line-height: 1;
    background: var(--bg-elev-2);
    border: 2px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: transform 100ms ease-out, border-color 100ms ease-out;
}
.gem:hover { transform: scale(1.05); border-color: var(--fg-dim); }
.gem.selected { border-color: var(--accent); transform: scale(1.1); }
.gem.invalid { border-color: var(--danger); animation: shake 200ms; }
.gem.special-flame {
    box-shadow: inset 0 0 12px #ff8a3d, 0 0 8px rgba(255, 138, 61, 0.5);
    animation: special-pulse 1.6s ease-in-out infinite;
}
.gem.special-hypercube {
    box-shadow: inset 0 0 12px var(--amethyst), 0 0 8px rgba(168, 127, 232, 0.5);
    animation: special-pulse 1.6s ease-in-out infinite;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-3px); }
    75% { transform: translateX(3px); }
}

@keyframes special-pulse {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.35); }
}

@keyframes gem-pulse-out {
    0%   { transform: scale(1);    opacity: 1; filter: brightness(1); }
    35%  { transform: scale(1.18); opacity: 1; filter: brightness(1.6); }
    100% { transform: scale(0);    opacity: 0; filter: brightness(2); }
}
.gem.matching {
    animation: gem-pulse-out 240ms ease-in forwards;
    pointer-events: none;
}

@keyframes gem-drop-in {
    0%   { transform: translateY(-180%); opacity: 0; }
    70%  { opacity: 1; }
    100% { transform: translateY(0);     opacity: 1; }
}
.gem.falling {
    animation: gem-drop-in 260ms cubic-bezier(0.34, 1.4, 0.64, 1);
    pointer-events: none;
}

.score-tally {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 4px;
    width: 100%;
    max-width: 460px;
}
.score-cell {
    background: var(--bg-elev);
    border-radius: 4px;
    padding: 0.4rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.85rem;
}
.score-cell[data-color="ruby"]     { border-bottom: 2px solid var(--ruby); }
.score-cell[data-color="sapphire"] { border-bottom: 2px solid var(--sapphire); }
.score-cell[data-color="emerald"]  { border-bottom: 2px solid var(--emerald); }
.score-cell[data-color="topaz"]    { border-bottom: 2px solid var(--topaz); }
.score-cell[data-color="diamond"]  { border-bottom: 2px solid var(--diamond); }
.score-cell[data-color="amethyst"] { border-bottom: 2px solid var(--amethyst); }
.score-value { font-weight: bold; color: var(--accent); }

.combat-side {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.enemies {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.enemy-card {
    background: var(--bg-elev);
    border: 1px solid var(--danger);
    border-radius: 6px;
    padding: 0.6rem;
}
.enemy-card.dead { opacity: 0.4; filter: grayscale(80%); }
.enemy-card.boss {
    border: 2px solid var(--accent);
    box-shadow: 0 0 10px rgba(247, 201, 72, 0.3);
}

.enemy-chips {
    display: flex;
    gap: 0.25rem;
    margin-top: 0.3rem;
    flex-wrap: wrap;
}
.chip {
    font-size: 0.7rem;
    padding: 0.1rem 0.35rem;
    border-radius: 999px;
    background: var(--bg-elev-2);
    border: 1px solid var(--bg-elev-2);
}
.chip.weak { border-color: var(--good); color: var(--good); }
.chip.resist { border-color: var(--fg-dim); color: var(--fg-dim); opacity: 0.85; }

.intent {
    font-size: 0.8rem;
    color: var(--fg-dim);
    margin-top: 0.3rem;
    padding: 0.2rem 0.4rem;
    background: var(--bg-elev-2);
    border-radius: 4px;
    border-left: 3px solid var(--fg-dim);
}
.intent.big {
    color: var(--danger);
    border-left-color: var(--danger);
    font-weight: bold;
    animation: intent-pulse 1.4s ease-in-out infinite;
}
.intent.defend {
    color: var(--shield);
    border-left-color: var(--shield);
}
.intent.summon {
    color: var(--amethyst);
    border-left-color: var(--amethyst);
}
@keyframes intent-pulse {
    0%, 100% { background: var(--bg-elev-2); }
    50% { background: rgba(224, 90, 90, 0.18); }
}

.ult-meter {
    background: var(--bg-elev);
    border-radius: 6px;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.ult-label {
    font-size: 0.75rem;
    color: var(--fg-dim);
    text-transform: uppercase;
    letter-spacing: 0.15em;
}
.ult-bar {
    background: #00000040;
    border-radius: 3px;
    height: 1.1rem;
    position: relative;
    overflow: hidden;
}
.ult-bar-fill {
    background: var(--amethyst);
    height: 100%;
    transition: width 200ms ease-out;
}
.ult-text {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.8rem; font-weight: bold;
    text-shadow: 0 0 2px #000;
}
.ult-btn {
    background: var(--bg-elev-2);
    color: var(--fg-dim);
    border: 1px solid var(--bg-elev-2);
}
.ult-btn.ready {
    background: var(--amethyst);
    color: var(--bg);
    border-color: var(--amethyst);
    font-weight: bold;
    animation: ult-ready-pulse 1.2s ease-in-out infinite;
}
.ult-btn.ready:hover {
    filter: brightness(1.15);
}
@keyframes ult-ready-pulse {
    0%, 100% { box-shadow: 0 0 6px rgba(168, 127, 232, 0.4); }
    50%      { box-shadow: 0 0 16px rgba(168, 127, 232, 0.85); }
}
.enemy-name { font-weight: bold; margin-bottom: 0.3rem; }
.enemy-intent { font-size: 0.8rem; color: var(--fg-dim); margin-top: 0.3rem; }

/* The log is accumulated in DOM but only surfaced via the HUD "Log"
 * button. `log-hidden` is the baseline — remove it inside the overlay
 * clone (see `.log-modal .log`) to show the entries. */
.log {
    list-style: none;
    margin: 0;
    padding: 0.5rem;
    background: var(--bg-elev);
    border-radius: 6px;
    max-height: 60vh;
    overflow-y: auto;
    font-size: 0.85rem;
}
.log-hidden { display: none; }

.log-modal {
    text-align: left;
    width: min(96vw, 780px);
    max-height: 86vh;
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.log-modal h2 {
    margin: 0;
    color: var(--accent);
}
.log-modal .log {
    display: block;  /* overrides the baseline .log-hidden inside the overlay */
    flex: 1 1 auto;
    min-height: 0;
}
.log-modal .log-empty {
    color: var(--fg-dim);
    font-style: italic;
    padding: 0.6rem;
}
.log li {
    padding: 0.25rem 0.4rem;
    border-bottom: 1px solid var(--bg-elev-2);
    color: var(--fg-dim);
}
.log li:last-child { border-bottom: none; }
.log li.log-damage { color: var(--ruby); }
.log li.log-heal { color: var(--good); }
.log li.log-shield { color: var(--shield); }
.log li.log-meter { color: var(--amethyst); }
.log li.log-enemy-attack { color: var(--accent); }
.log li.log-enemy-miss { color: var(--fg-dim); font-style: italic; }

.overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 6, 20, 0.85);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
}
.overlay.visible { display: flex; }

.rest-panel {
    background: var(--bg-elev);
    border: 2px solid var(--accent);
    border-radius: 12px;
    padding: 2rem 2.5rem;
    max-width: 480px;
    text-align: center;
    box-shadow: 0 0 40px rgba(247, 201, 72, 0.2);
}
.rest-panel.victory { border-color: var(--good); box-shadow: 0 0 40px rgba(94, 209, 143, 0.25); }
.rest-panel.defeat { border-color: var(--danger); box-shadow: 0 0 40px rgba(224, 90, 90, 0.25); }
.rest-panel h2 {
    margin: 0 0 0.75rem;
    letter-spacing: 0.1em;
    color: var(--accent);
}
.rest-panel.victory h2 { color: var(--good); }
.rest-panel.defeat h2 { color: var(--danger); }
.rest-panel p {
    color: var(--fg-dim);
    margin: 0 0 1.5rem;
    line-height: 1.4;
}
.rest-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

.reward-heading, .rest-heading {
    margin: 1rem 0 0.5rem;
    color: var(--fg-dim);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
}

.element-offers {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.element-offer-card {
    background: var(--bg-elev-2);
    border: 2px solid var(--bg-elev-2);
    border-radius: 6px;
    padding: 0.75rem;
    cursor: pointer;
    text-align: center;
    color: var(--fg);
    font: inherit;
    transition: transform 100ms, border-color 100ms;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-height: 9rem;
}
.element-offer-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}
.element-offer-glyph { font-size: 1.7rem; }
.element-offer-name { font-weight: bold; color: var(--accent); }
.element-offer-grade {
    font-size: 0.7rem;
    color: var(--fg-dim);
    text-transform: uppercase;
    letter-spacing: 0.15em;
}
.element-offer-card.grade-2 { border-color: #7aa2ff; }
.element-offer-card.grade-3 { border-color: #c78bff; }
.element-offer-card.grade-4 {
    border-color: gold;
    box-shadow: 0 0 14px rgba(255, 215, 0, 0.25) inset;
}
.element-offer-desc {
    font-size: 0.75rem;
    color: var(--fg-dim);
    line-height: 1.3;
    flex: 1;
}
.element-offer-hint { margin: 0 0 0.5rem; font-size: 0.8rem; text-align: center; }

.reward-skip-row { text-align: center; margin-bottom: 0.5rem; }
.link-button {
    background: transparent;
    border: none;
    color: var(--fg-dim);
    text-decoration: underline;
    cursor: pointer;
    font-size: 0.75rem;
    padding: 0.25rem;
}
.link-button:hover { color: var(--fg); background: transparent; }

.resources {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.95rem;
}
.resource {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    color: var(--fg);
    background: var(--bg-elev-2);
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    border: 1px solid var(--bg-elev-2);
}
.resource .resource-num { font-weight: bold; }
.resource.low {
    border-color: var(--danger);
    color: var(--danger);
}
.resource.warn {
    border-color: var(--danger);
    background: rgba(224, 90, 90, 0.18);
    color: var(--danger);
    font-weight: bold;
    letter-spacing: 0.1em;
    animation: intent-pulse 1.4s ease-in-out infinite;
}

.stash-shelf {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
    max-width: 380px;
    flex: 1;
    justify-content: flex-end;
}
.stash-shelf.empty {
    color: var(--fg-dim);
    font-size: 0.8rem;
    font-style: italic;
}
.stash-chip {
    background: var(--bg-elev-2);
    color: var(--accent);
    font-size: 0.75rem;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    border: 1px solid var(--accent);
    cursor: help;
}

/* Stash / crafting / potion overlay */
.elements-panel {
    max-width: min(1200px, 92vw);
    width: min(1200px, 92vw);
    max-height: 90vh;
    overflow-y: auto;
}
.elements-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
    gap: 1.5rem;
    align-items: start;
    text-align: left;
}
.elements-col h3 { margin-top: 0; }
@media (max-width: 820px) {
    .elements-layout { grid-template-columns: 1fr; }
}
.stash-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
    font-size: 0.85rem;
}
.stash-table th, .stash-table td {
    padding: 0.3rem 0.5rem;
    text-align: center;
    border-bottom: 1px solid var(--bg-elev-2);
}
.stash-table th.stash-label,
.stash-table th.grade-col { background: var(--bg-elev-1); }
.stash-table th.stash-label { text-align: left; }
.stash-row .element-glyph { margin-right: 0.4rem; }
.stash-row .element-family { font-size: 0.75rem; margin-left: 0.4rem; }
.stash-cell.empty { color: var(--fg-dim); }
.stash-cell.has { color: var(--accent); font-weight: bold; }
.stash-cell .craft-upgrade-btn {
    margin-left: 0.4rem;
    padding: 0 0.35rem;
    background: var(--accent);
    color: var(--bg);
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.8rem;
}
.stash-cell .craft-upgrade-btn:hover { filter: brightness(1.1); }

.crafting-heading { margin: 1.25rem 0 0.5rem; }
.potion-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem;
}
.potion-row {
    background: var(--bg-elev-1);
    border: 1px solid var(--bg-elev-2);
    border-radius: 6px;
    padding: 0.55rem 0.7rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}
.potion-row.can-brew { border-color: var(--accent); }
.potion-head { display: flex; justify-content: space-between; }
.potion-name { font-weight: bold; color: var(--accent); }
.potion-desc { font-size: 0.78rem; line-height: 1.3; }
.potion-recipe { font-size: 0.72rem; }
.potion-actions {
    display: flex;
    gap: 0.4rem;
    margin-top: 0.35rem;
}
.potion-actions button {
    padding: 0.2rem 0.7rem;
    border-radius: 3px;
    border: 1px solid var(--accent);
    background: transparent;
    color: var(--accent);
    cursor: pointer;
    font-size: 0.8rem;
}
.potion-actions button:disabled {
    border-color: var(--bg-elev-2);
    color: var(--fg-dim);
    cursor: not-allowed;
}
.potion-actions button:not(:disabled):hover {
    background: var(--accent);
    color: var(--bg);
}
