:root {
    --dark-grey: #666e75;
    --darker-grey: #3b3b3b;
    --mid-grey: #888;
    --light-grey: #e0e0e0;
    --border-color: #a0a0a0;
    --accent: #b33939;
    --calc-color: #2980b9;
    --theme-color: #c0392b; /* Blade color fallback */

    /* Light Theme (Default) */
    --app-bg: #ecf0f1;
    --sheet-bg: #ffffff;
    --text-color: #333333;
    --input-bg: #ffffff;
    --input-border: #cccccc;
    --sidebar-bg: #2c3e50;
    --sidebar-text: #ffffff;

    /* Colores de Dominios */
    --valor-color: #e67e22;
    --bone-color: #7f8c8d;
    --sage-color: #27ae60;
    --blade-color: #c0392b;
    --splendor-color: #f1c40f;
    --codex-color: #2980b9;
    --grace-color: #8e44ad;
    --arcana-color: #9b59b6;
    --midnight-color: #2c3e50;
}

[data-theme="dark"] {
    --app-bg: #121212;
    --sheet-bg: #1e1e1e;
    --text-color: #e0e0e0;
    --input-bg: #2a2a2a;
    --input-border: #444444;
    --sidebar-bg: #1a1a1a;
    --sidebar-text: #e0e0e0;
    --border-color: #555555;
    --light-grey: #333333;
    --dark-grey: #888888;
}

        * { box-sizing: border-box; font-family: 'Helvetica Neue', Arial, sans-serif; -webkit-tap-highlight-color: transparent; }
        body { background-color: var(--app-bg); color: var(--text-color); padding: 10px 10px 60px 10px; display: flex; justify-content: center; margin: 0; }
        .app-container { background-color: var(--sheet-bg); color: var(--text-color); width: 100%; max-width: 900px; border-radius: 8px; padding: 15px; overflow-x: hidden; box-shadow: 0 4px 15px rgba(0,0,0,0.5); }

        .save-bar { position: fixed; bottom: 0; left: 0; width: 100%; background: var(--darker-grey); display: flex; justify-content: center; gap: 15px; padding: 10px; z-index: 1000; box-shadow: 0 -2px 10px rgba(0,0,0,0.5); }
        .save-btn { background: white; color: var(--darker-grey); border: none; padding: 8px 15px; border-radius: 4px; font-weight: bold; cursor: pointer; display: flex; align-items: center; gap: 5px; }
        .save-btn:active { background: var(--light-grey); }
        .toast-msg { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); background: #2ecc71; color: white; padding: 10px 20px; border-radius: 20px; font-weight: bold; opacity: 0; transition: opacity 0.3s; z-index: 2000; pointer-events: none; }

        /* CABECERA DINÁMICA */
        .top-row { display: flex; background-color: var(--light-grey); border-radius: 4px; margin-bottom: 15px; overflow: hidden; }
        .class-banner { background-color: var(--darker-grey); color: white; padding: 15px 20px; width: 300px; clip-path: polygon(0 0, 100% 0, 85% 100%, 0 100%); display: flex; flex-direction: column; justify-content: center; transition: 0.3s; }

        /* RETRATO DE PERSONAJE (Sidebar) */
        .sidebar-portrait { width: 80px; height: 80px; border-radius: 50%; border: 3px solid rgba(255,255,255,0.3); overflow: hidden; cursor: pointer; margin: 0 auto; background: rgba(255,255,255,0.08); display: flex; align-items: center; justify-content: center; transition: border-color 0.3s, transform 0.2s; }
        .sidebar-portrait:hover { border-color: var(--accent); transform: scale(1.05); }
        .sidebar-portrait img { width: 100%; height: 100%; object-fit: cover; }
        .portrait-placeholder { font-size: 28px; opacity: 0.4; user-select: none; }
        .class-title { font-size: 26px; font-weight: 900; margin: 0; line-height: 1; text-transform: uppercase; }
        .class-subtitle { font-size: 14px; font-weight: bold; margin: 5px 0 0 0; color: #aaa; text-transform: uppercase; letter-spacing: 1px; }

        .info-fields { flex-grow: 1; display: grid; grid-template-columns: 1fr 1fr 1fr; grid-template-rows: 1fr 1fr; gap: 8px; padding: 10px; }
        .input-group { position: relative; background: white; border: 1px solid var(--border-color); border-radius: 4px; display: flex; align-items: flex-end; padding: 2px 8px; }
        .input-group label { position: absolute; top: 2px; left: 6px; font-size: 9px; font-weight: bold; color: var(--darker-grey); }
        .input-group input, .input-group select { border: none; width: 100%; outline: none; font-size: 13px; font-weight: bold; color: #333; background: transparent; padding-top: 12px; }
        .input-group select { appearance: none; cursor: pointer; }

        .level-section { width: 90px; display: flex; flex-direction: column; align-items: center; justify-content: center; position: relative; padding-right: 10px; }
        .level-shield { width: 50px; height: 60px; background: white; border: 2px solid var(--border-color); clip-path: polygon(0 0, 100% 0, 100% 70%, 50% 100%, 0 70%); display: flex; justify-content: center; align-items: center; }
        .level-shield input { width: 100%; text-align: center; font-size: 20px; font-weight: bold; border: none; outline: none; }
        .level-label { background-color: var(--darker-grey); color: white; font-size: 9px; font-weight: bold; padding: 2px 10px; border-radius: 10px; position: absolute; bottom: 5px; }

        /* DEFENSAS Y ATRIBUTOS */
        .bottom-row { display: flex; gap: 15px; margin-bottom: 20px; }
        .defenses { display: flex; gap: 10px; padding-right: 15px; border-right: 1px dashed var(--border-color); align-items: center; flex-shrink: 0; min-width: 190px; }
        .defense-box { display: flex; flex-direction: column; align-items: center; }
        .defense-shield { width: 55px; height: 65px; border: 2px solid var(--darker-grey); clip-path: polygon(15% 0, 85% 0, 100% 20%, 100% 70%, 50% 100%, 0 70%, 0 20%); display: flex; justify-content: center; align-items: center; flex-direction: column; }
        .defense-shield.evasion { border-radius: 25px 25px 0 0; clip-path: none; color: var(--calc-color); }
        .defense-shield.armor { color: var(--calc-color); }
        .defense-label { background-color: var(--darker-grey); color: white; font-size: 10px; font-weight: bold; padding: 2px 8px; margin-top: -8px; border-radius: 3px; z-index: 2; }
        .defense-subtext { font-size: 9px; color: #666; margin-top: 3px; }

        .armor-slots { display: grid; grid-template-columns: repeat(3, 14px); gap: 4px; align-content: center; margin-left: 5px; height: 65px; flex-shrink: 0; }
        .armor-slot { width: 14px; height: 18px; border: 1px solid var(--border-color); clip-path: polygon(0 0, 100% 0, 100% 70%, 50% 100%, 0 70%); cursor: pointer; }
        .armor-checkbox { display: none; }
        .armor-checkbox:checked + .armor-slot { background-color: var(--darker-grey); }

        .stats-container { display: flex; flex-grow: 1; justify-content: center; gap: 5px; }
        .stat-group { display: flex; flex-direction: column; align-items: center; flex: 1; position: relative; max-width: 85px; min-width: 60px; }
        .stat-header { background-color: var(--darker-grey); color: white; font-size: 10px; font-weight: bold; width: 100%; text-align: center; padding: 3px 0; border-radius: 3px 3px 0 0; position: relative; }
        .stat-checkbox { display: none; }
        .stat-circle { width: 18px; height: 18px; border: 2px solid var(--darker-grey); background: white; border-radius: 50%; position: absolute; top: -5px; right: -5px; cursor: pointer; transition: 0.2s; z-index: 5; }
        .stat-checkbox:checked + .stat-circle { background-color: var(--calc-color); box-shadow: inset 0 0 0 2px white; border-color: var(--calc-color); }
        .stat-shield { width: 100%; height: 55px; border: 1px solid var(--darker-grey); border-top: none; clip-path: polygon(0 0, 100% 0, 100% 70%, 50% 100%, 0 70%); display: flex; justify-content: center; align-items: center; }
        .stat-shield input { width: 80%; text-align: center; font-size: 20px; font-weight: bold; border: none; outline: none; background: transparent; }
        .stat-skills { text-align: center; font-size: 9px; color: #777; margin-top: 5px; line-height: 1.2; }

        .section-box { border: 2px solid var(--darker-grey); border-radius: 6px; margin-top: 25px; padding: 20px 15px 15px; position: relative; }
        .section-title-wrapper { position: absolute; top: -12px; left: 0; width: 100%; display: flex; justify-content: center; flex-direction: column; align-items: center; z-index: 10; }
        .section-title { background: white; padding: 0 10px; display: flex; align-items: center; position: relative; }
        .title-shape { background-color: var(--darker-grey); color: white; font-size: 14px; font-weight: 900; padding: 3px 30px; clip-path: polygon(15px 0, calc(100% - 15px) 0, 100% 50%, calc(100% - 15px) 100%, 15px 100%, 0 50%); }
        .helper-text { text-align: center; font-size: 11px; color: var(--mid-grey); margin-bottom: 10px; }

        /* UMBRALES DE DAÑO */
        .damage-thresholds { display: flex; justify-content: center; align-items: center; gap: 0; margin-bottom: 20px; padding-top: 10px; }
        .threshold-wrapper { display: flex; flex-direction: column; align-items: center; flex: 1; }
        .threshold-box { background: var(--dark-grey); color: white; text-align: center; padding: 10px; clip-path: polygon(5% 0, 95% 0, 100% 15%, 100% 85%, 95% 100%, 5% 100%, 0 85%, 0 15%); width: 100%; min-height: 60px; display: flex; flex-direction: column; justify-content: center; }
        .threshold-label { font-size: 14px; font-weight: 900; text-transform: uppercase; line-height: 1.1; margin: 0; }
        .threshold-sub { font-size: 11px; color: var(--dark-grey); text-align: center; font-weight: bold; margin-top: 5px; }
        .threshold-connector { display: flex; flex-direction: column; align-items: center; justify-content: center; margin: 0 -5px; z-index: 2; position: relative; top: -10px; }
        .connector-white-box { background: white; border: 2px solid var(--border-color); padding: 5px 15px; display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 60px; height: 50px; }
        .calc-number { font-size: 22px; font-weight: bold; color: var(--calc-color); line-height: 1; }
        .base-input-wrapper { font-size: 9px; color: var(--mid-grey); font-weight: bold; margin-top: 3px; display: flex; align-items: center; gap: 2px; }
        .base-input-wrapper input { border: none; border-bottom: 1px solid var(--border-color); color: var(--darker-grey); font-size: 10px; font-weight: bold; text-align: center; width: 20px; outline: none; padding: 0; }
        .threshold-math { font-size: 9px; color: var(--calc-color); font-weight: bold; text-align: center; margin-bottom: 8px; min-height: 12px; }
        .arrow-right { width: 0; height: 0; border-top: 10px solid transparent; border-bottom: 10px solid transparent; border-left: 12px solid var(--dark-grey); margin-left: -2px; z-index: 3; position: relative; top: -10px; }

        /* TRACKERS */
        .tracker-row { display: flex; align-items: flex-start; margin-bottom: 12px; gap: 10px; }
        .tracker-label { font-weight: 900; font-size: 14px; width: 60px; color: var(--darker-grey); }
        .slots-container { display: flex; flex-wrap: wrap; gap: 4px; }
        .slot-checkbox { display: none; }
        .slot-label { width: 24px; height: 16px; border: 2px solid var(--dark-grey); border-radius: 3px; display: inline-block; cursor: pointer; transition: 0.2s; }
        .slot-label.dashed { border: 1px dotted #ccc; background-color: transparent !important; cursor: default; pointer-events: none; }
        .slot-checkbox:checked + .slot-label { background-color: var(--darker-grey); border-color: var(--darker-grey); }

        .hope-track { background: var(--light-grey); border-radius: 20px; padding: 8px; display: flex; justify-content: space-around; align-items: center; margin-bottom: 10px; }
        .hope-checkbox { display: none; }
        .hope-diamond { width: 20px; height: 20px; background: white; border: 2px solid var(--mid-grey); clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%); cursor: pointer; }
        .hope-checkbox:checked + .hope-diamond { background: var(--darker-grey); border-color: var(--darker-grey); }
        .hope-divider { width: 2px; height: 15px; background: var(--mid-grey); }

        .exp-row { display: flex; align-items: flex-end; margin-bottom: 8px; gap: 10px; }
        .exp-input { flex-grow: 1; border: none; border-bottom: 1px solid var(--border-color); padding: 5px; font-size: 14px; outline: none; background: transparent; }
        .exp-mod { width: 40px; border: none; border-bottom: 2px solid var(--darker-grey); text-align: center; font-size: 16px; font-weight: bold; outline: none; background: var(--light-grey); clip-path: polygon(0 0, 100% 0, 100% 70%, 70% 100%, 0 100%); padding: 5px 0; }

        details.feature-block { margin-bottom: 10px; font-size: 13px; line-height: 1.4; background: #f9f9f9; border: 1px solid #eee; border-radius: 4px; padding: 10px; }
        details.feature-block > summary { font-size: 16px; font-weight: 900; color: var(--darker-grey); text-transform: uppercase; margin: 0; cursor: pointer; list-style: none; display: flex; align-items: center; gap: 10px; }
        details.feature-block > summary::-webkit-details-marker { display: none; }
        details.feature-block > summary::after { content: "▼"; font-size: 12px; margin-left: auto; color: var(--mid-grey); transition: 0.3s; }
        details[open].feature-block > summary::after { content: "▲"; }
        .feature-block ul { margin: 10px 0 10px 0; padding-left: 20px; }
        .feature-block li { margin-bottom: 4px; }
        .feature-content { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border-color); }

        .dice-selector { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 5px; }
        .dice-option { display: flex; align-items: center; gap: 4px; font-weight: bold; font-size: 16px; cursor: pointer; color: var(--darker-grey); }
        .dice-radio { display: none; }
        .dice-circle { width: 18px; height: 18px; border: 2px solid var(--darker-grey); border-radius: 50%; display: inline-block; transition: 0.2s; }
        .dice-radio:checked + .dice-circle { background-color: var(--darker-grey); box-shadow: inset 0 0 0 3px white; }

        .card-tier { font-size: 11px; font-style: italic; color: var(--accent); margin-bottom: 5px; text-transform: uppercase; font-weight: bold; border-bottom: 1px solid #ddd; padding-bottom: 3px; display:inline-block;}

        /* ARMAS Y ARMADURA */
        .proficiency-tracker { background: white; border: 1px solid var(--border-color); border-top: none; padding: 4px 15px; display: inline-flex; align-items: center; gap: 8px; border-radius: 0 0 10px 10px; font-size: 10px; font-weight: bold; color: var(--darker-grey); margin-top: -2px; z-index: 0; }
        .prof-number { background-color: var(--calc-color); color: white; border-radius: 50%; width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: bold; }
        .hands-container { position: absolute; right: -30px; display: flex; gap: 2px; }
        .hand-check { display: none; }
        .hand-icon { font-size: 20px; cursor: pointer; opacity: 0.2; transition: 0.3s; filter: grayscale(100%); }
        .hand-check:checked + .hand-icon { opacity: 1; filter: none; }
        .weapon-category { margin-top: 15px; margin-bottom: 20px; }
        .weapon-title { font-size: 16px; font-weight: 900; color: var(--darker-grey); margin-bottom: 5px; text-transform: uppercase; }
        .fields-row { display: flex; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
        .field-col { flex: 1; min-width: 120px; display: flex; flex-direction: column; }
        .line-input { border: none; border-bottom: 1px solid var(--darker-grey); outline: none; font-size: 14px; padding: 4px; background: var(--input-bg); color: var(--text-color); width: 100%; font-weight: bold; }
        select.line-input { cursor: pointer; color: var(--darker-grey); }
        .line-label { font-size: 9px; font-weight: bold; color: var(--darker-grey); text-align: center; margin-top: 2px; }
        .inventory-checkbox-group { display: flex; gap: 10px; align-items: center; font-size: 10px; font-weight: bold; color: var(--darker-grey); }
        .inventory-checkbox { width: 12px; height: 12px; border: 2px solid var(--darker-grey); appearance: none; cursor: pointer; position: relative; outline: none; border-radius: 2px; }
        .inventory-checkbox:checked { background: var(--darker-grey); }
        .weapon-header-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px; position: relative; flex-wrap: wrap; gap: 10px; }

        .page-divider { border-top: 4px dashed var(--mid-grey); margin: 40px 0 30px; text-align: center; position: relative; }
        .page-divider::after { background: white; padding: 0 10px; color: var(--mid-grey); font-weight: bold; font-size: 12px; position: absolute; top: -8px; left: 50%; transform: translateX(-50%); }

        /* POSTURAS DINÁMICAS (PÁGINA 2) */
        .martial-header { background-color: var(--darker-grey); color: white; padding: 20px; display: flex; justify-content: space-between; align-items: center; border-radius: 4px; margin-bottom: 15px; clip-path: polygon(0 0, 100% 0, 100% 85%, 95% 100%, 0 100%); }
        .martial-header h1 { font-size: 32px; font-weight: 900; margin: 0; text-transform: uppercase; line-height: 1; }
        .martial-header h2 { font-size: 18px; font-weight: 300; margin: 0; text-transform: uppercase; }
        .martial-desc { font-size: 11px; max-width: 45%; text-align: right; line-height: 1.3; }
        .tier-header { background-color: var(--light-grey); padding: 5px 15px; font-size: 18px; font-weight: 300; color: var(--darker-grey); margin-top: 20px; margin-bottom: 10px; }

        .stance-wrapper { margin-bottom: 15px; }
        .stance-row { display: flex; align-items: center; gap: 15px; padding-left: 10px; margin-bottom: 2px; }
        .active-btn-wrapper { display: flex; flex-direction: column; align-items: center; flex-shrink: 0; }
        .active-stance-check { display: none; }
        .active-stance-circle { width: 22px; height: 22px; border: 2px solid var(--dark-grey); border-radius: 50%; display: inline-block; cursor: pointer; transition: 0.2s; }
        .active-stance-check:checked + .active-stance-circle { background-color: var(--calc-color); box-shadow: inset 0 0 0 3px white; border-color: var(--calc-color); }
        .active-label { font-size: 8px; font-weight: bold; text-transform: uppercase; margin-top: 2px; }
        .stance-desc { font-size: 11px; font-style: italic; color: #555; padding-left: 55px; padding-right: 15px; display: none; line-height: 1.3; }

        /* MAZO DE CARTAS (PÁGINA 4) */
        .loadout-slot { display: flex; flex-direction: column; margin-bottom: 10px; background: #fff; border: 1px solid var(--border-color); border-radius: 6px; overflow: hidden; }
        .loadout-header { display: flex; background: var(--light-grey); padding: 5px; align-items: center; }
        .loadout-number { background: var(--darker-grey); color: white; width: 24px; height: 24px; display: flex; justify-content: center; align-items: center; font-weight: bold; border-radius: 50%; margin-right: 10px; flex-shrink: 0; }
        .loadout-select { flex-grow: 1; border: none; background: transparent; font-size: 14px; font-weight: bold; outline: none; cursor: pointer; padding: 5px; }
        .loadout-desc { padding: 10px; font-size: 13px; line-height: 1.4; display: none; background: #fdfdfd; border-top: 1px solid #eee; }
        .loadout-actions { display: flex; justify-content: flex-end; padding: 0 5px; }
        .loadout-move-btn { background: none; border: 1px solid var(--border-color); border-radius: 4px; font-size: 10px; padding: 2px 8px; cursor: pointer; color: var(--mid-grey); transition: 0.2s; margin: 0 0 5px; }
        .loadout-move-btn:hover { background: var(--light-grey); color: var(--darker-grey); }
        /* Vault/Reserve slots */
        #vault-container .loadout-slot { border-color: #ccc; background: #fafafa; }
        #vault-container .loadout-header { background: #eee; }
        #vault-container .loadout-number { background: var(--mid-grey); }
        .domain-tag { font-size: 10px; font-weight: bold; padding: 2px 6px; border-radius: 4px; color: white; margin-left: 10px; }

        .tag-valor { background-color: var(--valor-color); }
        .tag-bone { background-color: var(--bone-color); }
        .tag-sage { background-color: var(--sage-color); }
        .tag-blade { background-color: var(--blade-color); }
        .tag-splendor { background-color: var(--splendor-color); }
        .tag-codex { background-color: var(--codex-color); }
        .tag-grace { background-color: var(--grace-color); }
        .tag-arcana { background-color: var(--arcana-color); }
        .tag-midnight { background-color: var(--midnight-color); }

        /* NIVELES Y TRASFONDO */
        .tier-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; margin-top: 15px; }
        .tier-card { border: 1px solid var(--border-color); border-radius: 6px; overflow: hidden; font-size: 12px; }
        .tier-card-header { background-color: var(--darker-grey); color: white; padding: 10px; text-align: center; clip-path: polygon(5% 0, 95% 0, 100% 50%, 95% 100%, 5% 100%, 0 50%); margin: -2px -2px 10px; }
        .tier-card-header strong { font-size: 16px; }
        .tier-desc { text-align: center; font-style: italic; color: #555; padding: 0 10px 10px; border-bottom: 1px solid #eee; margin-bottom: 10px; }
        .tier-list { list-style: none; padding: 0 10px; margin: 0; }
        .tier-item { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 8px; }
        .tier-checkboxes { display: flex; gap: 2px; flex-wrap: nowrap; }
        .tier-box { width: 14px; height: 14px; border: 2px solid var(--dark-grey); appearance: none; cursor: pointer; outline: none; border-radius: 2px; flex-shrink: 0; }
        .tier-box:checked { background-color: var(--calc-color); border-color: var(--calc-color);}

        .guide-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; margin-top: 20px; font-size: 12px; line-height: 1.4; }
        .guide-col { border-right: 1px solid #eee; padding-right: 15px; }
        .guide-col:last-child { border-right: none; padding-right: 0; }
        .guide-title { font-weight: 900; color: var(--darker-grey); text-transform: uppercase; margin-bottom: 5px; }

        .bg-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 20px; }
        .bg-col-header { text-align: center; background: var(--light-grey); font-weight: bold; padding: 5px; clip-path: polygon(10px 0, calc(100% - 10px) 0, 100% 50%, calc(100% - 10px) 100%, 10px 100%, 0 50%); margin-bottom: 15px; }
        .bg-question { font-size: 12px; font-weight: bold; margin-bottom: 5px; color: var(--darker-grey); }
        .bg-textarea { width: 100%; border: 1px solid #ccc; border-radius: 4px; padding: 8px; font-size: 13px; font-family: inherit; resize: vertical; min-height: 60px; margin-bottom: 15px; }
        .bg-textarea:focus { outline: none; border-color: var(--darker-grey); }

        /* CHECKBOXES DENTRO DE LOS RASGOS DE CLASE PARA ACTIVAR EFECTOS MATEMÁTICOS */
        .feature-mod-toggle {
            display:flex; align-items:center; gap: 5px; cursor: pointer; margin-top: 10px;
            padding: 6px; background: var(--light-grey); border-radius: 4px; color: var(--calc-color); font-weight: bold; font-size: 11px;
        }

        @media (max-width: 768px) {
            .top-row { flex-direction: column; }
            .class-banner { width: 100%; clip-path: none; text-align: center; padding: 10px; }
            .info-fields { grid-template-columns: 1fr; grid-template-rows: auto; }
            .level-section { width: 100%; padding: 10px 0; }
            .bottom-row { flex-direction: column; }
            .defenses { border-right: none; border-bottom: 1px dashed var(--border-color); padding-bottom: 15px; justify-content: center; }
            .stats-container { flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 10px; }
            .stat-group { flex: 0 0 30%; }
            .fields-row { flex-direction: column; gap: 5px; }
            .field-col { width: 100%; }
            .hands-container { right: -40px; }
            .weapon-header-row { flex-direction: column; align-items: flex-start; }
            .weapon-header-row .hands-container { position: relative; right: 0; }
            .martial-header { flex-direction: column; align-items: flex-start; clip-path: none; gap: 10px; }
            .martial-desc { max-width: 100%; text-align: left; }
            .tier-grid { grid-template-columns: 1fr; }
            .guide-grid { grid-template-columns: 1fr; }
            .guide-col { border-right: none; border-bottom: 1px solid #eee; padding-right: 0; padding-bottom: 15px; }
            .bg-grid { grid-template-columns: 1fr; }

            .damage-thresholds { flex-direction: column; gap: 5px; }
            .threshold-connector { margin: 10px 0; top: 0; }
            .arrow-right { border-left: 10px solid transparent; border-right: 10px solid transparent; border-top: 12px solid var(--dark-grey); border-bottom: none; margin-left: 0; margin-top: -2px; top: 0; }
        }
/* Inventario Usos */
.inv-row { display: flex; gap: 10px; align-items: flex-start; }
.inv-select-wrapper { flex-grow: 1; }
.inv-qty-wrapper { width: 45px; flex-shrink: 0; display: flex; flex-direction: column; align-items: center; padding-top: 5px;}
.inv-qty-wrapper label { font-size: 9px; font-weight: bold; color: var(--darker-grey); margin-bottom: 2px; text-transform: uppercase; }
.inv-qty-wrapper input { width: 100%; border: none; border-bottom: 1px solid var(--border-color); text-align: center; font-size: 14px; outline: none; background: transparent; padding: 2px; font-weight: bold; color: var(--calc-color); }

/* Riqueza */
.money-section { padding: 0 10px 10px; margin-bottom: 20px;}
.money-toggle { display: flex; justify-content: center; gap: 20px; margin-bottom: 15px; font-size: 12px; font-weight: bold; color: var(--darker-grey); }
.money-grid { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.money-box { display: flex; flex-direction: column; align-items: center; width: 55px; }
.money-box label { font-size: 9px; font-weight: bold; text-transform: uppercase; color: var(--mid-grey); margin-bottom: 2px; }
.money-box input { width: 100%; border: 2px solid var(--border-color); border-radius: 4px; text-align: center; font-size: 16px; font-weight: bold; padding: 5px; outline: none; color: var(--darker-grey); background: var(--light-grey);}
.money-box input:focus { border-color: var(--darker-grey); }

/* Sidebar & Hamburger */
.sidebar { position: fixed; top: 0; left: 0; width: 220px; height: 100vh; background: var(--sidebar-bg); border-right: 1px solid var(--border-color); padding: 20px 0; z-index: 1000; overflow-y: auto; transition: transform 0.3s ease; }
.sidebar a { display: block; padding: 12px 20px; color: var(--sidebar-text); text-decoration: none; font-weight: bold; border-bottom: 1px solid rgba(255,255,255,0.1); font-size: 14px;}
.sidebar a:hover { background: rgba(255,255,255,0.1); color: var(--sidebar-text); }
.hamburger { position: fixed; top: 10px; left: 10px; z-index: 1001; background: var(--theme-color); color: white; padding: 8px 12px; border-radius: 5px; cursor: pointer; display: none; font-size: 24px; user-select: none;}
.app-container { margin-left: calc(220px + auto); } /* Desktop fallback */

@media (min-width: 769px) {
    .app-container { margin-left: 240px !important; }
}

@media (max-width: 768px) { 
    .sidebar { transform: translateX(-100%); box-shadow: 2px 0 10px rgba(0,0,0,0.5); } 
    .sidebar.open { transform: translateX(0); } 
    .hamburger { display: block; } 
    .app-container { margin-top: 50px; margin-left: auto !important;} 
}

@media print { 
    .no-print, .sidebar, .hamburger, iframe[title="kofi-iframe"] { display: none !important; } 
    .app-container { margin-left: auto !important; margin-top: 0 !important; padding: 0; width: 100%; box-shadow: none; border: none; } 
    body { background: white; margin: 0; padding: 0 !important; } 
    .page-divider { break-after: avoid; }
}

input, select, textarea {
    background-color: var(--input-bg) !important;
    color: var(--text-color) !important;
    border-color: var(--input-border);
}
.sheet-box, .section-box {
    border-color: var(--border-color);
}
.feature-block, .feature-content {
    color: var(--text-color);
}
.active-label { color: var(--text-color); }

/* ===== PANEL DADOS DE DUALIDAD ===== */
#dice-panel {
    position: fixed;
    top: 50%;
    right: 0;
    transform: translateY(-50%);
    width: 320px;
    background: var(--sheet-bg);
    border: 2px solid var(--border-color);
    border-right: none;
    border-radius: 12px 0 0 12px;
    padding: 15px 15px;
    z-index: 900;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    box-shadow: -4px 0 16px rgba(0,0,0,0.2);
}

/* Configuración */
.dice-config { width: 100%; display: flex; flex-direction: column; gap: 5px; }
.dice-config select {
    width: 100%; font-size: 14px; padding: 6px 4px;
    border: 1px solid var(--border-color); border-radius: 4px;
    background: var(--input-bg); color: var(--text-color); cursor: pointer;
}
#dice-exp-list { display: flex; flex-direction: column; gap: 4px; }
.dice-exp-item { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-color); cursor: pointer; }
.dice-exp-item input[type=checkbox] { margin: 0; cursor: pointer; }

/* Dados en fila */
.dice-row { display: flex; gap: 6px; align-items: flex-end; }
.dice-slot { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.dice-label { font-size: 12px; font-weight: bold; text-transform: uppercase; letter-spacing: 0.5px; }
.dice-label.hope  { color: #2471a3; }
.dice-label.fear  { color: #c0392b; }

[data-colorblind="true"] .dice-label.hope { color: #0077bb; }
[data-colorblind="true"] .dice-label.fear { color: #ee7733; }

.d12-svg { cursor: pointer; filter: drop-shadow(2px 4px 6px rgba(0,0,0,0.35)); transition: transform 0.1s; }
.d12-svg:hover { transform: scale(1.06); }

@keyframes dice-roll {
    0%   { transform: rotate(0deg) scale(1); }
    20%  { transform: rotate(120deg) scale(1.15); }
    50%  { transform: rotate(260deg) scale(0.9); }
    75%  { transform: rotate(340deg) scale(1.05); }
    100% { transform: rotate(360deg) scale(1); }
}
.dice-rolling { animation: dice-roll 0.6s ease-out; }

/* Resultado */
#dice-total-box { width: 100%; text-align: center; }
#dice-total-num { font-size: 34px; font-weight: 900; line-height: 1; color: var(--text-color); }
#dice-total-breakdown { font-size: 11px; color: var(--mid-grey); margin: 4px 0; line-height: 1.4; }
#dice-damage-breakdown { font-size: 12px; color: var(--mid-grey); margin: 6px 0; line-height: 1.6; text-align: center; letter-spacing: 0.2px; }
#dice-outcome-msg {
    font-size: 14px; font-weight: bold; padding: 4px 8px;
    border-radius: 4px; margin-top: 3px; line-height: 1.3;
}
#dice-outcome-msg.hope { background: #d6eaf8; color: #1a5276; }
#dice-outcome-msg.fear { background: #fadbd8; color: #922b21; }
[data-theme="dark"] #dice-outcome-msg.hope { background: #1a3a52; color: #aed6f1; }
[data-theme="dark"] #dice-outcome-msg.fear { background: #4a1a18; color: #f1948a; }

.dice-divider { width: 80%; border: none; border-top: 1px dashed var(--border-color); margin: 2px 0; }

#dice-roll-btn {
    width: 100%; padding: 10px 6px; border: none; border-radius: 6px;
    background: var(--accent); color: white; font-weight: bold;
    font-size: 14px; cursor: pointer;
}
#dice-roll-btn:active { opacity: 0.8; }

#dice-colorblind-btn {
    background: none; border: 1px solid var(--border-color); border-radius: 4px;
    font-size: 11px; color: var(--text-color); cursor: pointer; padding: 4px 6px; width: 100%;
}

/* Visual dice area */
.dice-visual-area {
    width: 100%; display: flex; flex-direction: column; gap: 6px;
    min-height: 40px; padding: 4px 0;
}
/* Fila por grupo de dados */
.dmg-group-row {
    display: flex; align-items: center; gap: 8px; width: 100%;
    padding: 4px 0; border-bottom: 1px dashed var(--border-color);
}
.dmg-group-row:last-child { border-bottom: none; }
.dmg-group-label {
    font-size: 11px; font-weight: bold; text-transform: uppercase;
    letter-spacing: 0.5px; color: var(--mid-grey);
    white-space: nowrap; min-width: 48px;
}
.dmg-group-dice {
    display: flex; flex-wrap: wrap; gap: 4px; flex: 1; align-items: center;
}
.dmg-group-sub {
    font-size: 14px; font-weight: 900; color: var(--accent);
    white-space: nowrap; min-width: 36px; text-align: right;
}
.dice-shape-svg {
    filter: drop-shadow(1px 2px 3px rgba(0,0,0,0.35));
    transition: transform 0.1s; cursor: default;
}
.dice-shape-svg.rolling { animation: dice-roll 0.6s ease-out; }
.dice-damage-breakdown {
    font-size: 11px; color: var(--mid-grey); margin: 4px 0; line-height: 1.4; text-align: center;
}
.dice-exp-list-shared { display: flex; flex-direction: column; gap: 4px;
}

/* Mode selector */
#dice-mode-select {
    width: 100%; font-size: 14px; padding: 6px 4px; font-weight: bold;
    border: 1px solid var(--accent); border-radius: 4px;
    background: var(--input-bg); color: var(--text-color); cursor: pointer;
}

/* Weapon info */
.dice-weapon-info { width: 100%; text-align: center; padding: 6px 0; }
.dice-weapon-name { font-size: 14px; font-weight: 900; color: var(--text-color); line-height: 1.2; }
.dice-weapon-formula { font-size: 12px; color: var(--accent); font-weight: bold; margin-top: 2px; }

/* Weapon modifiers */
#dice-weapon-modifiers, #dice-unarmed-combo { width: 100%; }
.dice-mod-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-color); cursor: pointer; margin: 4px 0; }
.dice-mod-item input[type=checkbox] { margin: 0; cursor: pointer; }

/* Damage result */
.dice-damage-rolls {
    font-size: 12px; color: var(--mid-grey); margin: 6px 0; line-height: 1.5;
    display: flex; flex-wrap: wrap; gap: 4px; justify-content: center;
}
.dice-roll-chip {
    display: inline-block; padding: 4px 6px; border-radius: 3px;
    font-weight: bold; font-size: 12px; line-height: 1;
}
.dice-roll-chip.physical { background: #f0e6d3; color: #7d5a3c; }
.dice-roll-chip.magical { background: #dce6f5; color: #2c5282; }
.dice-roll-chip.bonus { background: #e8e8e8; color: #555; }
[data-theme="dark"] .dice-roll-chip.physical { background: #3d2e1e; color: #d4a574; }
[data-theme="dark"] .dice-roll-chip.magical { background: #1e2d3d; color: #8ab4f8; }
[data-theme="dark"] .dice-roll-chip.bonus { background: #333; color: #aaa; }
.dice-damage-total { font-size: 30px; font-weight: 900; line-height: 1; color: var(--text-color); text-align: center; }
.dice-damage-type {
    font-size: 11px; font-weight: bold; text-transform: uppercase; text-align: center;
    letter-spacing: 0.5px; margin-top: 4px; padding: 3px 8px; border-radius: 3px;
}
.dice-damage-type.physical { color: #7d5a3c; background: #f0e6d3; }
.dice-damage-type.magical { color: #2c5282; background: #dce6f5; }
[data-theme="dark"] .dice-damage-type.physical { color: #d4a574; background: #3d2e1e; }
[data-theme="dark"] .dice-damage-type.magical { color: #8ab4f8; background: #1e2d3d; }

/* FAB móvil */
#dice-fab {
    display: none; position: fixed; bottom: 70px; right: 16px;
    width: 60px; height: 60px; border-radius: 50%; background: var(--accent);
    color: white; font-size: 26px; border: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4); cursor: pointer; z-index: 1100;
    align-items: center; justify-content: center;
}

@media (max-width: 768px) {
    #dice-panel {
        position: fixed; top: 0; left: 0; right: 0; bottom: 0;
        transform: none; border-radius: 0; border: none;
        width: 100vw; height: 100vh; display: none; max-height: none;
        overflow-y: auto; -webkit-overflow-scrolling: touch;
        padding: 16px 16px 80px; box-sizing: border-box; z-index: 2000;
        gap: 12px;
    }
    #dice-panel.open { display: flex; }
    #dice-fab { display: flex; }
    #dice-fab.panel-open { display: none; }

    /* Botón cerrar más grande y fácil de tocar */
    #dice-close-btn {
        top: 12px; right: 12px;
        font-size: 28px;
        width: 44px; height: 44px;
        display: flex; align-items: center; justify-content: center;
        background: var(--input-bg);
        border: 1px solid var(--border-color) !important;
        border-radius: 50%;
    }

    /* Selector de modo más prominente */
    #dice-mode-select {
        font-size: 16px;
        padding: 10px 8px;
        margin-top: 8px;
    }

    /* Dados más grandes */
    .dice-row {
        justify-content: center;
        gap: 32px;
    }
    .d12-svg {
        width: 128px !important;
        height: 128px !important;
    }
    .dice-label {
        font-size: 16px;
    }

    /* Resultado más grande */
    #dice-total-num {
        font-size: 52px;
    }
    #dice-total-breakdown {
        font-size: 13px;
    }
    #dice-outcome-msg {
        font-size: 17px;
        padding: 8px 14px;
    }

    /* Botón tirar prominente, fijo al fondo, subido 50px */
    #dice-roll-btn {
        position: fixed;
        bottom: 66px; left: 16px; right: 16px;
        width: calc(100vw - 32px);
        padding: 16px;
        font-size: 18px;
        border-radius: 10px;
        z-index: 2001;
        box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    }

    /* Damage total */
    .dice-damage-total { font-size: 48px; }

    /* Dados de daño más grandes */
    .dice-visual-area {
        gap: 8px;
        min-height: 80px;
        padding: 8px 0;
    }
    .dmg-group-label { font-size: 13px; min-width: 56px; }
    .dmg-group-sub { font-size: 16px; min-width: 44px; }

    /* Pool de dados: botones más grandes para tocar */
    .pool-btn {
        font-size: 16px;
        padding: 12px 16px;
        min-width: 60px;
    }
    .pool-chip {
        font-size: 14px;
        padding: 6px 12px;
    }
    .pool-clear {
        font-size: 15px;
        padding: 10px 20px;
    }

    /* Controles +/- del pool */
    .pool-qty-btn {
        font-size: 20px;
        width: 40px; height: 40px;
        padding: 0;
    }
}

@media print { #dice-panel, #dice-fab { display: none !important; } }

/* Custom Pool */
.custom-pool-section { display: flex; flex-direction: column; width: 100%; border-top: 1px dashed var(--border-color); padding-top: 10px; margin-top: 10px; }
.custom-pool-header { font-size: 11px; font-weight: bold; text-transform: uppercase; color: var(--mid-grey); margin-bottom: 6px; text-align: center; }
.pool-buttons { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-bottom: 8px; }
.pool-btn { background: var(--input-bg); border: 1px solid var(--border-color); color: var(--text-color); border-radius: 4px; font-size: 12px; font-weight: bold; padding: 6px 8px; cursor: pointer; }
.pool-btn:hover { border-color: var(--accent); }
.pool-display { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; min-height: 28px; align-items: center; }
.pool-chip { background: var(--accent); color: white; border-radius: 4px; font-size: 12px; font-weight: bold; padding: 4px 8px; }
.pool-clear { background: #e74c3c; border: none; color: white; border-radius: 4px; font-size: 11px; font-weight: bold; padding: 4px 8px; cursor: pointer; }

/* Pool por filas */
.pool-row {
    display: flex; align-items: center; gap: 8px;
    width: 100%; padding: 4px 0;
    border-bottom: 1px dashed var(--border-color);
}
.pool-row-dice { display: flex; flex-wrap: wrap; gap: 4px; flex: 1; }
.pool-row-label { font-size: 12px; font-weight: bold; color: var(--mid-grey); white-space: nowrap; min-width: 32px; }
.pool-row-sum { font-size: 13px; font-weight: 900; color: var(--accent); white-space: nowrap; min-width: 32px; text-align: right; }
.pool-qty-btn {
    background: var(--input-bg); border: 1px solid var(--border-color);
    color: var(--text-color); border-radius: 4px;
    font-size: 14px; font-weight: bold;
    width: 28px; height: 28px; padding: 0; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.pool-qty-btn:hover { border-color: var(--accent); }
.pool-total-row {
    display: flex; justify-content: space-between; align-items: center;
    width: 100%; padding: 6px 0 2px;
    font-size: 13px; font-weight: bold; color: var(--text-color);
}
.pool-total-num {
    font-size: 20px; font-weight: 900; color: var(--accent);
}
#dice-close-btn {
    display: none; position: absolute; top: 15px; right: 15px; background: transparent; border: none;
    color: var(--text-color); font-size: 24px; cursor: pointer; font-weight: bold;
}
@media (max-width: 768px) { #dice-close-btn { display: flex; } }
