/* ============================================================
   D&D 2024 Character Creator — Fantasy Theme
   Deep ink, parchment, and gold. Dark-first, D&D Beyond inspired.
   ============================================================ */

:root {
    --ink-950: #0e0b14;
    --ink-900: #161120;
    --ink-850: #1b1527;
    --ink-800: #201a30;
    --ink-700: #2b2340;
    --ink-600: #3d3057;
    --gold: #c9a227;
    --gold-bright: #e6c75e;
    --gold-dim: #8f741a;
    --parchment: #f4ecd7;
    --parchment-soft: #ece0c2;
    --parchment-deep: #d8c39a;
    --burgundy: #7a1f2b;
    --ruby: #b03a2e;
    --forest: #3c7a5a;
    --ink-text: #efe9da;
    --muted: #a297ba;
    --border: #3a2f57;
    --ok: #4c9a6a;
    --warn: #c9a227;
    --bad: #d25b4d;
    --radius: 12px;
    --sidebar-width: 252px;
}

* { box-sizing: border-box; }

html, body {
    height: 100%;
    margin: 0;
    font-family: 'Segoe UI', 'Trebuchet MS', system-ui, sans-serif;
    color: var(--ink-text);
    background-color: var(--ink-900);
    background-image:
        radial-gradient(1200px 600px at 82% -10%, rgba(122, 31, 43, .20), transparent 60%),
        radial-gradient(900px 520px at -12% 108%, rgba(201, 162, 39, .08), transparent 60%),
        radial-gradient(600px 400px at 50% 120%, rgba(43, 35, 64, .5), transparent 70%);
    background-attachment: fixed;
}

h1, h2, h3, h4, h5, .font-display {
    font-family: Georgia, 'Palatino Linotype', 'Book Antiqua', 'Times New Roman', serif;
    letter-spacing: .3px;
}
h1 { font-size: 1.9rem; margin: 0 0 .5rem; }
h2 { font-size: 1.45rem; }
h3 { font-size: 1.15rem; }
h4 { font-size: 1rem; }

a { color: var(--gold-bright); text-decoration: none; }
a:hover { color: #f3dc8c; }

.text-muted { color: var(--muted) !important; }
.text-gold { color: var(--gold-bright) !important; }
.text-burgundy { color: var(--burgundy) !important; }
.text-parchment { color: var(--parchment) !important; }

/* ---------------- App shell ---------------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--ink-950) 0%, var(--ink-850) 100%);
    border-right: 1px solid var(--border);
    padding: 1.3rem 1rem;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.main-area { flex: 1; min-width: 0; }

.main-content {
    max-width: 1220px;
    margin: 0 auto;
    padding: 1.7rem 1.7rem 3.5rem;
}

@media (max-width: 900px) {
    .app-shell { flex-direction: column; }
    .sidebar {
        width: 100%; min-width: 0; height: auto; position: static;
        flex-direction: row; align-items: center; flex-wrap: wrap; gap: .6rem;
        padding: .8rem 1rem;
    }
    .sidebar nav { flex-direction: row; flex-wrap: wrap; }
    .sidebar-footer { display: none; }
    .brand { padding: 0 1rem 0 0; }
}

/* ---------------- Brand ---------------- */
.brand { display: flex; align-items: center; gap: .7rem; padding: .2rem .3rem 1.1rem; }
.brand-die {
    width: 46px; height: 46px;
    display: grid; place-items: center;
    background: linear-gradient(160deg, var(--burgundy), #57131c);
    color: var(--gold-bright);
    font-family: Georgia, serif; font-weight: 700;
    clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
    font-size: .8rem; letter-spacing: .5px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-family: Georgia, serif; font-size: 1.18rem; color: var(--gold); }
.brand-text span { font-size: .68rem; color: var(--muted); text-transform: uppercase; letter-spacing: 1.6px; }

/* ---------------- Sidebar nav ---------------- */
.sidebar nav { display: flex; flex-direction: column; gap: .35rem; flex: 1; }
.sidebar .nav-link {
    display: flex; align-items: center; gap: .6rem;
    color: var(--muted);
    padding: .62rem .85rem;
    border-radius: 9px;
    border: 1px solid transparent;
    font-size: .95rem;
    transition: background .15s, color .15s, border-color .15s, transform .15s;
}
.sidebar .nav-link:hover { color: var(--ink-text); background: rgba(255, 255, 255, .045); transform: translateX(2px); }
.sidebar .nav-link.active {
    color: var(--gold-bright);
    background: rgba(201, 162, 39, .10);
    border-color: rgba(201, 162, 39, .35);
}
.sidebar-footer { margin-top: 1.2rem; font-size: .7rem; color: #6d628a; text-align: center; line-height: 1.5; }


/* ---------------- Cards ---------------- */
.card-theme {
    background: var(--ink-800);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.1rem 1.25rem;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .28);
}

.parchment-card {
    background: linear-gradient(165deg, var(--parchment) 0%, var(--parchment-soft) 100%);
    color: #2c2416;
    border-radius: var(--radius);
    border: 1px solid var(--parchment-deep);
    box-shadow: 0 8px 22px rgba(0, 0, 0, .4);
    padding: 1.15rem 1.3rem;
}
.parchment-card h1, .parchment-card h2, .parchment-card h3, .parchment-card h4 { color: #3d2e10; }
.parchment-card .text-muted { color: #6b5b33; }
.parchment-card .table { color: #2c2416; }
.parchment-card .form-control, .parchment-card .form-select {
    background-color: rgba(255, 255, 255, .55);
    border-color: var(--parchment-deep);
    color: #2c2416;
}

.hover-card { transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease; cursor: pointer; }
.hover-card:hover { transform: translateY(-3px); box-shadow: 0 12px 28px rgba(0, 0, 0, .45); }

.choice-card {
    position: relative;
    border: 1px solid var(--border);
    background: var(--ink-800);
    border-radius: var(--radius);
    padding: .95rem 1.05rem;
    cursor: pointer;
    transition: border-color .15s, background .15s, transform .15s, box-shadow .15s;
    height: 100%;
}
.choice-card:hover { border-color: var(--gold); transform: translateY(-2px); }
.choice-card.selected {
    border-color: var(--gold);
    background: rgba(201, 162, 39, .10);
    box-shadow: inset 0 0 0 1px var(--gold), 0 6px 16px rgba(0, 0, 0, .3);
}
.choice-card.selected .choice-check { opacity: 1; }

.choice-check {
    position: absolute; top: .7rem; right: .7rem;
    width: 22px; height: 22px; border-radius: 50%;
    background: var(--gold); color: #1c1505;
    display: grid; place-items: center; font-weight: 700; font-size: .75rem;
    opacity: 0; transition: opacity .15s;
}

/* ---------------- Buttons ---------------- */
.btn-gold {
    color: #1c1505;
    background: linear-gradient(180deg, var(--gold-bright), var(--gold));
    border: 1px solid var(--gold-dim);
    border-radius: 9px;
    font-weight: 600;
    padding: .55rem 1.2rem;
    transition: filter .15s, transform .15s, box-shadow .15s;
}
.btn-gold:hover { filter: brightness(1.08); transform: translateY(-1px); box-shadow: 0 6px 16px rgba(201, 162, 39, .35); color: #1c1505; }
.btn-gold:disabled { filter: grayscale(.6) brightness(.8); transform: none; }

.btn-ghost {
    color: var(--gold-bright);
    background: transparent;
    border: 1px solid var(--gold-dim);
    border-radius: 9px;
    padding: .5rem 1.1rem;
    transition: background .15s, color .15s, transform .15s;
}
.btn-ghost:hover { background: rgba(201, 162, 39, .12); color: #f3dc8c; transform: translateY(-1px); }

.btn-danger-theme {
    color: #ffd9d4;
    background: transparent;
    border: 1px solid var(--ruby);
    border-radius: 9px;
    padding: .5rem 1.1rem;
    transition: background .15s;
}
.btn-danger-theme:hover { background: rgba(176, 58, 46, .18); color: #ffb0a6; }


/* ---------------- Ability score hexes ---------------- */
.ability-hex {
    width: 100%;
    background: linear-gradient(160deg, var(--ink-700), var(--ink-950));
    border: 1px solid rgba(201, 162, 39, .55);
    color: var(--parchment);
    clip-path: polygon(50% 0, 100% 7%, 100% 93%, 50% 100%, 0 93%, 0 7%);
    padding: .8rem .5rem;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    text-align: center;
    min-height: 128px;
}
.ability-hex .score-label { font-size: .72rem; text-transform: uppercase; letter-spacing: 1.4px; color: var(--gold-bright); font-weight: 600; }
.ability-hex .score-value { font-family: Georgia, serif; font-size: 1.9rem; font-weight: 700; line-height: 1.05; margin: .1rem 0; }
.ability-hex .score-mod { font-size: 1.05rem; color: var(--muted); }
.ability-hex .save-link { font-size: .72rem; color: var(--parchment-soft); opacity: .85; }
.ability-hex .save-link b { color: var(--parchment); }

/* ---------------- Stat blocks ---------------- */
.stat-block {
    background: var(--ink-800);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: .7rem .9rem;
    display: flex; flex-direction: column; gap: .1rem;
}
.stat-block .label { font-size: .7rem; text-transform: uppercase; letter-spacing: 1.2px; color: var(--muted); }
.stat-block .value { font-family: Georgia, serif; font-size: 1.55rem; font-weight: 700; color: var(--gold-bright); line-height: 1.1; }
.stat-block .sub { font-size: .78rem; color: var(--muted); }

/* ---------------- Skill rows ---------------- */
.skill-row {
    display: flex; align-items: center; gap: .6rem;
    padding: .32rem .55rem;
    border-radius: 7px;
    cursor: pointer;
    transition: background .12s;
}
.skill-row:hover { background: rgba(255, 255, 255, .05); }
.skill-row .skill-total { font-family: Georgia, serif; font-weight: 700; font-size: 1.05rem; width: 2.2rem; text-align: right; }
.skill-row .skill-name { flex: 1; }
.skill-row .skill-proficiency { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: .7rem; }

/* ---------------- Tables ---------------- */
.table { color: var(--ink-text); }
.table-theme thead th {
    font-size: .72rem; text-transform: uppercase; letter-spacing: 1.2px;
    color: var(--muted); border-bottom: 1px solid var(--border); padding: .55rem .6rem;
}
.table-theme tbody td { padding: .55rem .6rem; border-bottom: 1px solid rgba(58, 47, 87, .5); vertical-align: middle; }

/* ---------------- Forms ---------------- */
.form-control, .form-select {
    background-color: var(--ink-850);
    border: 1px solid var(--border);
    color: var(--ink-text);
    border-radius: 8px;
}
.form-control:focus, .form-select:focus {
    background-color: var(--ink-850);
    color: var(--ink-text);
    border-color: var(--gold);
    box-shadow: 0 0 0 .2rem rgba(201, 162, 39, .18);
}
.form-control::placeholder { color: #6d628a; }
.form-label { font-size: .8rem; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin-bottom: .3rem; }


/* ---------------- Wizard stepper ---------------- */
.stepper { display: flex; gap: .35rem; flex-wrap: wrap; margin-bottom: 1.4rem; }
.stepper .step-dot {
    display: flex; align-items: center; gap: .45rem;
    padding: .4rem .85rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    color: var(--muted);
    font-size: .82rem;
    cursor: pointer;
    transition: all .15s;
    background: var(--ink-800);
}
.stepper .step-dot:hover { border-color: var(--gold); color: var(--ink-text); }
.stepper .step-dot.current { border-color: var(--gold); color: var(--gold-bright); background: rgba(201, 162, 39, .12); }
.stepper .step-dot.done { border-color: rgba(76, 154, 106, .6); color: var(--ok); }
.stepper .step-num {
    width: 20px; height: 20px; border-radius: 50%;
    display: grid; place-items: center; font-size: .68rem; font-weight: 700;
    background: var(--border); color: var(--muted);
}
.stepper .step-dot.current .step-num, .stepper .step-dot.done .step-num { background: var(--gold); color: #1c1505; }
.stepper .step-dot.done .step-num { background: var(--ok); }

/* ---------------- Misc ---------------- */
.badge-gold { background: rgba(201, 162, 39, .16); color: var(--gold-bright); border: 1px solid rgba(201, 162, 39, .4); border-radius: 999px; padding: .15rem .6rem; font-size: .72rem; }
.badge-muted { background: rgba(162, 151, 186, .12); color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: .15rem .6rem; font-size: .72rem; }
.badge-ok { background: rgba(76, 154, 106, .16); color: var(--ok); border: 1px solid rgba(76, 154, 106, .45); border-radius: 999px; padding: .15rem .6rem; font-size: .72rem; }
.badge-warn { background: rgba(201, 162, 39, .16); color: var(--warn); border: 1px solid rgba(201, 162, 39, .45); border-radius: 999px; padding: .15rem .6rem; font-size: .72rem; }
.badge-bad { background: rgba(210, 91, 77, .16); color: var(--bad); border: 1px solid rgba(210, 91, 77, .5); border-radius: 999px; padding: .15rem .6rem; font-size: .72rem; }

.money-chip {
    display: inline-flex; align-items: center; gap: .3rem;
    background: var(--ink-850); border: 1px solid var(--border); border-radius: 8px;
    padding: .3rem .7rem; font-size: .9rem;
}
.money-chip .coin { color: var(--gold-bright); font-weight: 600; }

.divider { border-top: 1px solid var(--border); margin: 1rem 0; }
.divider-gold { border-top: 1px solid rgba(201, 162, 39, .35); margin: 1rem 0; }

.empty-state { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.empty-state .icon { font-size: 2.6rem; display: block; margin-bottom: .6rem; opacity: .7; }

.portrait-circle {
    width: 74px; height: 74px; border-radius: 50%;
    display: grid; place-items: center; font-size: 2.1rem;
    border: 2px solid rgba(201, 162, 39, .6);
    box-shadow: 0 4px 14px rgba(0, 0, 0, .4);
    background: var(--ink-700);
}

.encumbrance-bar { height: 8px; border-radius: 4px; background: var(--ink-850); overflow: hidden; }
.encumbrance-bar .fill { height: 100%; border-radius: 4px; transition: width .25s; }

.die-badge {
    display: inline-block; min-width: 34px; text-align: center;
    font-family: Georgia, serif; font-weight: 700;
    background: var(--burgundy); color: var(--gold-bright);
    border-radius: 7px; padding: .2rem .45rem;
    clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
}

/* Toast */
.toast-theme {
    position: fixed; bottom: 1.4rem; right: 1.4rem; z-index: 2000;
    background: var(--ink-700); color: var(--ink-text);
    border: 1px solid var(--gold); border-left: 4px solid var(--gold);
    border-radius: 10px; padding: .8rem 1.1rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
    max-width: 340px;
    animation: toast-in .25s ease;
}
.toast-theme.toast-error { border-color: var(--ruby); border-left-color: var(--ruby); }
@keyframes toast-in { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Dice roll animation */
.dice-roll {
    display: inline-block;
    animation: dice-spin .5s ease;
}
@keyframes dice-spin {
    0% { transform: rotate(0deg) scale(1); }
    40% { transform: rotate(180deg) scale(1.25); }
    100% { transform: rotate(360deg) scale(1); }
}

/* Detail sections */
.detail-section { margin-bottom: 1.1rem; }
.detail-section .detail-title {
    font-size: .78rem; text-transform: uppercase; letter-spacing: 1.6px;
    color: var(--gold-bright); margin-bottom: .5rem; font-weight: 700;
}

.progress-track { display: flex; gap: .3rem; }
.progress-track .segment { flex: 1; height: 10px; border-radius: 3px; background: var(--ink-850); border: 1px solid var(--border); }
.progress-track .segment.filled { background: var(--gold); border-color: var(--gold-dim); }

/* ---------------- Print styles: clean paper sheet ---------------- */
@media print {
    body { background: #fff !important; color: #111; }
    .sidebar { display: none !important; }
    .main-content { max-width: 100%; padding: 0; }
    .parchment-card, .card-theme {
        background: #fff !important;
        color: #111 !important;
        border: 1px solid #999 !important;
        box-shadow: none !important;
    }
    .parchment-card h1, .parchment-card h2, .parchment-card h3, .parchment-card h4,
    .parchment-card .text-muted { color: #111 !important; }
    .ability-hex { background: #eee !important; border-color: #666 !important; color: #111 !important; }
    .ability-hex .score-label, .ability-hex .score-mod, .ability-hex .save-link { color: #333 !important; }
    .stat-block { background: #fff !important; border-color: #999 !important; }
    .stat-block .label, .stat-block .sub { color: #444 !important; }
    .stat-block .value { color: #111 !important; }
    .table, .table-theme tbody td { color: #111 !important; }
    .table-theme thead th { color: #444 !important; border-color: #999 !important; }
    .btn, .stepper, .toast-theme, .divider { display: none !important; }
    .skill-row:hover { background: transparent !important; }
    .card-theme { page-break-inside: avoid; }
    details > div { display: block !important; }
}

/* 3D dice stage (pure CSS transforms — no WebGL) */
.dice-stage {
    position: relative; width: 100%; min-height: 180px;
    display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: .75rem;
    padding: 1rem;
    background: radial-gradient(ellipse at center, rgba(201, 162, 39, .08), transparent 70%);
    border-radius: 10px; overflow: hidden;
    perspective: 600px; perspective-origin: 50% 30%;
}
.d3d-die {
    position: relative; width: 60px; height: 60px;
    display: flex; align-items: center; justify-content: center;
    background: radial-gradient(circle at 32% 28%, #3a3152, #1b1730 72%);
    border: 2px solid var(--gold);
    box-shadow: 0 10px 20px rgba(0,0,0,.45), inset 0 0 18px rgba(201,162,39,.10);
    animation: d3d-tumble .85s cubic-bezier(.2,.85,.3,1) both, d3d-settle .35s ease-out .85s both;
    animation-delay: var(--delay), calc(var(--delay) + .85s);
    will-change: transform;
}
.d3d-die .d3d-value {
    font-size: 1.55rem; font-weight: 700; color: var(--gold-bright);
    text-shadow: 0 2px 4px rgba(0,0,0,.6);
}
.d3d-square { border-radius: 10px; }
.d3d-triangle { clip-path: polygon(50% 4%, 96% 96%, 4% 96%); }
.d3d-kite { clip-path: polygon(50% 2%, 98% 42%, 50% 98%, 2% 42%); }
.d3d-pentagon { clip-path: polygon(50% 2%, 98% 36%, 80% 98%, 20% 98%, 2% 36%); }
@keyframes d3d-tumble {
    0%   { transform: perspective(600px) rotateX(var(--rx)) rotateY(var(--ry)) translate3d(var(--tx), -130px, 0) scale(.35); opacity: 0; }
    55%  { transform: perspective(600px) rotateX(0deg) rotateY(0deg) translate3d(0, 0, 0) scale(1.15); opacity: 1; }
    75%  { transform: perspective(600px) rotateX(0deg) rotateY(0deg) translate3d(0, -5px, 0) scale(.98); opacity: 1; }
    100% { transform: perspective(600px) rotateX(0deg) rotateY(0deg) translate3d(0, 0, 0) scale(1); opacity: 1; }
}
@keyframes d3d-settle {
    from { transform: perspective(600px) rotateX(0deg) rotateY(0deg) translate3d(0, 0, 0) scale(1); }
    to   { transform: perspective(600px) rotateX(10deg) rotateY(-12deg) translate3d(0, 0, 0) scale(1); }
}




/* ---------------- Battle Maps ---------------- */
.map-shell { display: flex; gap: 1rem; align-items: flex-start; flex-wrap: wrap; }
.map-wrap { flex: 1 1 680px; min-width: 0; }
.map-grid {
    position: relative;
    display: grid;
    background: radial-gradient(circle at 30% 20%, #3a3a2e, #1c1a14 70%);
    border: 2px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    touch-action: none;
}
/* Grid-line overlay: paints the cell pattern ON TOP of a background image, but stays below the tokens. */
.map-grid-lines {
    position: absolute;
    inset: 0;
    z-index: 2;
    pointer-events: none;
    background:
        linear-gradient(rgba(201, 162, 39, .12) 1px, transparent 1px),
        linear-gradient(90deg, rgba(201, 162, 39, .12) 1px, transparent 1px);
    background-size: var(--cell, 44px) var(--cell, 44px), var(--cell, 44px) var(--cell, 44px);
}
.map-cell { position: relative; }
.map-token {
    position: absolute;
    z-index: 5;
    width: var(--cell, 44px);
    height: var(--cell, 44px);
    display: grid;
    place-items: center;
    font-size: calc(var(--cell, 44px) * .5);
    border-radius: 8px;
    cursor: pointer;
    user-select: none;
    transition: box-shadow .12s ease;
}
.map-token.size-2 { width: calc(var(--cell, 44px) * 2); height: calc(var(--cell, 44px) * 2); font-size: calc(var(--cell, 44px) * .8); }
.map-token:hover { box-shadow: 0 0 0 2px rgba(201, 162, 39, .7), 0 4px 14px rgba(0,0,0,.5); }
.map-token.selected { box-shadow: 0 0 0 3px var(--gold-bright), 0 6px 18px rgba(0,0,0,.6); z-index: 6; }
.map-token .token-label {
    position: absolute; bottom: -4px; left: 50%; transform: translateX(-50%);
    background: rgba(14,11,20,.85); border: 1px solid var(--border); color: var(--ink-text);
    font-size: .62rem; padding: 0 4px; border-radius: 4px; white-space: nowrap;
}
.map-token .token-hp {
    position: absolute; top: -4px; right: -4px;
    background: var(--burgundy); border: 1px solid rgba(255,255,255,.25); color: #fff;
    font-size: .6rem; padding: 0 3px; border-radius: 4px; line-height: 1.3;
}
.map-overlay { position: absolute; inset: 0; pointer-events: none; z-index: 10; }
.map-sidebar { flex: 0 1 320px; min-width: 280px; }
.map-cell.hover-measure:hover { background: rgba(201, 162, 39, .18); }

.map-background { position:absolute; z-index:1; pointer-events:none; border-radius:8px; }
.emoji-picker { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; max-height: 140px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; padding: 4px; background: var(--ink-850); }
.emoji-tile { background: transparent; border: 1px solid transparent; border-radius: 6px; font-size: 1.15rem; padding: 2px; cursor: pointer; line-height: 1.2; }
.emoji-tile:hover { background: rgba(201, 162, 39, .15); }
.emoji-tile.selected { background: rgba(201, 162, 39, .25); border-color: var(--gold); }
.map-modal-backdrop { position: fixed; inset: 0; background: rgba(8,6,14,.82); backdrop-filter: blur(3px); z-index: 1100; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.map-modal { background: var(--ink-850); border: 1px solid var(--border); border-radius: 14px; width: min(760px, 100%); max-height: 90vh; overflow-y: auto; padding: 1.2rem; box-shadow: 0 24px 60px rgba(0,0,0,.6); }

/* ---------------- Read-only sheet (viewing another player's character) ---------------- */
fieldset.sheet-readonly { border: 0; margin: 0; padding: 0; min-width: 0; }
fieldset.sheet-readonly:disabled .form-control,
fieldset.sheet-readonly:disabled input,
fieldset.sheet-readonly:disabled select,
fieldset.sheet-readonly:disabled textarea {
    color: var(--ink-text);
    background: rgba(255, 255, 255, 0.04);
    border-color: var(--border);
    opacity: 0.8;
    cursor: not-allowed;
    box-shadow: none;
}
fieldset.sheet-readonly:disabled input[type="checkbox"] { opacity: 0.55; cursor: not-allowed; }
fieldset.sheet-readonly:disabled button,
fieldset.sheet-readonly:disabled .btn {
    opacity: 0.45;
    cursor: not-allowed;
    filter: grayscale(0.35);
}
fieldset.sheet-readonly:disabled .portrait-circle { opacity: 0.7; }

/* ---------------- Map viewport + panning ---------------- */
.map-viewport {
    position: relative;
    overflow: hidden;
    height: min(72vh, 720px);
    border: 2px solid var(--border);
    border-radius: 10px;
    background: radial-gradient(circle at 30% 20%, #3a3a2e, #1c1a14 70%);
    cursor: grab;
    touch-action: none;
    user-select: none;
}
.map-viewport.panning { cursor: grabbing; }
.map-viewport .map-grid { will-change: transform; transform-origin: 0 0; }
.map-edge-indicators { position: absolute; inset: 0; z-index: 30; pointer-events: none; }
.map-edge {
    position: absolute;
    color: var(--gold-bright);
    opacity: 0;
    transition: opacity .18s ease;
    text-shadow: 0 0 10px rgba(0,0,0,.8), 0 0 3px rgba(0,0,0,.8);
    font-size: 1.05rem;
    line-height: 1;
}
.map-edge.edge-hidden { display: none; }
.map-edge.edge-live { opacity: .9; }
.map-edge.edge-at { opacity: .14; }
.map-edge-left { left: 10px; top: 50%; transform: translateY(-50%); }
.map-edge-right { right: 10px; top: 50%; transform: translateY(-50%); }
.map-edge-top { top: 10px; left: 50%; transform: translateX(-50%); }
.map-edge-bottom { bottom: 10px; left: 50%; transform: translateX(-50%); }
.map-viewport.panning .map-edge.edge-live { animation: map-edge-pulse 1s ease-in-out infinite; }
@keyframes map-edge-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .4; } }
.map-pan-hint {
    position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%);
    background: rgba(14,11,20,.85); border: 1px solid var(--border); color: var(--ink-text);
    font-size: .72rem; padding: 4px 10px; border-radius: 999px; z-index: 31; pointer-events: none;
    opacity: 1; transition: opacity .6s ease;
}
.map-pan-hint.faded { opacity: 0; }

/* ---------------- Spell components (V / S / M) ---------------- */
.spell-comps { display: inline-flex; gap: 4px; vertical-align: middle; }
.spell-comp {
    position: relative;
    display: inline-grid; place-items: center;
    min-width: 20px; height: 20px; padding: 0 5px;
    font-size: .7rem; font-weight: 700;
    color: var(--gold-bright);
    background: rgba(201, 162, 39, .12);
    border: 1px solid rgba(201, 162, 39, .4);
    border-radius: 5px;
    cursor: help;
}
.spell-comp .spell-tip {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    width: max-content;
    max-width: 260px;
    background: var(--ink-900);
    color: var(--ink-text);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 10px;
    font-size: .72rem;
    font-weight: 400;
    line-height: 1.45;
    text-align: left;
    box-shadow: 0 6px 18px rgba(0,0,0,.55);
    opacity: 0;
    visibility: hidden;
    transition: opacity .12s ease;
    z-index: 60;
    pointer-events: none;
    white-space: normal;
}
.spell-comp:hover .spell-tip { opacity: 1; visibility: visible; }

/* ---------------- Map zoom controls ---------------- */
.map-zoom {
    position: absolute;
    right: 12px; bottom: 12px;
    z-index: 32;
    display: flex;
    align-items: center;
    gap: 2px;
    background: rgba(14,11,20,.88);
    border: 1px solid var(--border);
    border-radius: 9px;
    padding: 3px;
    user-select: none;
    box-shadow: 0 6px 18px rgba(0,0,0,.4);
}
.map-zoom-btn {
    background: transparent;
    border: none;
    color: var(--gold-bright);
    font-size: 1.05rem;
    line-height: 1;
    padding: 5px 9px;
    border-radius: 6px;
    cursor: pointer;
}
.map-zoom-btn:hover { background: rgba(201,162,39,.22); }
.map-zoom-label {
    min-width: 46px;
    text-align: center;
    font-size: .74rem;
    color: var(--ink-text);
    padding: 5px 3px;
    border-radius: 6px;
    cursor: pointer;
}
.map-zoom-label:hover { background: rgba(201,162,39,.22); }
