:root {
            --dark-grey: #666e75;
            --darker-grey: #3b3b3b;
            --mid-grey: #888;
            --light-grey: #e0e0e0;
            --border-color: #a0a0a0;
            --bg-color: #222;
            --accent: #b33939;
            --calc-color: #2980b9;

            /* 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;
        }

        * { box-sizing: border-box; font-family: 'Helvetica Neue', Arial, sans-serif; -webkit-tap-highlight-color: transparent; }
        body { background-color: var(--bg-color); padding: 10px 10px 60px 10px; display: flex; justify-content: center; margin: 0; }
        .app-container { background-color: white; width: 100%; max-width: 900px; border-radius: 8px; padding: 15px; overflow: 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; }
        .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: center; 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: transparent; 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; }
        .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; }
        }