
/* ==========================================
   CARD 4 - ROAD TO T10
   ========================================== */

/* Ventana modal */
#card4-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10000;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

/* Se mostrará al activar la carta */
#card4-modal.is-open {
    display: flex;
}

/* Fondo oscurecido */
#card4-modal .modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.88);
}

/* Contenedor principal */
#card4-modal .card4-window {
    position: relative;
    z-index: 2;
    display: block;
    width: min(1100px, 100%);
    height: auto;
    margin-top: 0;
    max-height: 94vh;
    overflow-x: hidden;
    overflow-y: auto;
    box-sizing: border-box;

    background: #100b19;
    color: #f1e4c5;

    border: 2px solid #a9803d;
    border-radius: 12px;
    /* Reinforce inward without changing the border box or child positions. */
    outline: 1px solid #a9803d;
    outline-offset: -3px;

    box-shadow: 0 0 35px rgba(112, 52, 165, 0.35);
}



/* The shared parchment sheen ends at the scroll viewport, creating a seam. */
#card4-modal .card4-window::after {
    content: none;
}

/* CABECERA ROAD TO T10 */

#card4-modal .card4-window {
    padding: 0;
}

#card4-modal .card4-header {
    width: 100%;
    height: 250px;
    overflow: hidden;
    background: #100b19;
}

#card4-modal .card4-header img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: fill;
   
}



/* Contenido */
#card4-modal .card4-content {
    position: relative;
    z-index: 2;
    min-width: 0;
    padding: 25px 35px 32px;
}

/* Pestañas */
.card4-tabs {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 25px;
}

.card4-tab {
    width: 180px;
    height: 36px;
    padding: 0 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #c6a15b;
    border-radius: 6px;
    background: #21142e;
    color: #e8cc8c;
    font-family: inherit;
    font-size: 16px;
    cursor: pointer;
}

.card4-tab.active {
    background: #7950a0;
    color: #fff;
    border-color: #e5c77e;
}

/* Espacio de la calculadora */
#card4-modal .card4-calculator {
    min-width: 0;
    min-height: 0;
}

/* Keep navigation flexible at intermediate widths. */
#card4-modal .card4-tab,
#card4-modal .card4-branch {
    min-width: 0;
    flex: 0 1 180px;
}

/* One composition: full-width frame behind Queenie, protected content inside. */
#card4-modal .card4-total-composition {
    --card4-queen-width: clamp(120px, 28.8vw, 276px);
    position: relative;
    isolation: isolate;
    width: 100%;
    max-width: none;
    margin: 32px auto 12px;
}

#card4-modal .card4-total-composition .card4-total {
    margin: 0 auto;
}

/* Symmetric content stays on the frame's axis; compact results clear Queenie. */
#card4-modal .card4-total-composition .card4-total-content {
    padding-inline: 0;
}

#card4-modal .card4-total-composition .card4-total-stats {
    max-width: 360px;
    margin-inline: auto;
}

#card4-modal .card4-queen {
    position: absolute;
    right: -35px;
    bottom: -44px;
    z-index: 2;
    display: block;
    width: var(--card4-queen-width);
    max-width: none;
    height: auto;
    object-fit: contain;
    box-sizing: border-box;
    padding: 0;
    margin: 0;
    filter: drop-shadow(-8px 6px 9px rgba(7, 3, 13, 0.45));
    pointer-events: none;
}

/* Botón cerrar */
#card4-modal .modal-close {
    z-index: 10;
}



/* ROAD TO T10 - SCROLL INVISIBLE */

#card4-modal .card4-window {
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

#card4-modal .card4-window::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}


/* ==========================================
   ROAD TO T10 - CALCULATOR PANELS
   ========================================== */

/* Mostrar únicamente el panel seleccionado */
#card4-modal .card4-panel,
#card4-modal .card4-research-panel {
    display: none;
}

/* TOTAL COST: the SVG defines the silhouette, never the content layout. */
#card4-modal .card4-total {
    position: relative;
    isolation: isolate;
    width: 100%;
    max-width: 800px;
    margin: 32px auto 12px;
    padding: 60px clamp(30px, 9%, 76px);
    text-align: center;
    color: #f1e4c5;
    filter: drop-shadow(0 12px 18px rgba(0, 0, 0, 0.4));
}

#card4-modal .card4-total-frame {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: visible;
    pointer-events: none;
}

#card4-modal .card4-total-flourish {
    position: absolute;
    left: 50%;
    width: min(55%, 300px);
    height: auto;
    color: #d9b875;
    pointer-events: none;
}

#card4-modal .card4-total-flourish--top {
    top: -9px;
    transform: translateX(-50%);
}

#card4-modal .card4-total-flourish--bottom {
    bottom: -9px;
    transform: translateX(-50%) rotate(180deg);
}

#card4-modal .card4-total-content {
    min-width: 0;
}

#card4-modal #card4-total-title {
    margin: 0;
    color: #f1d79c;
    font-size: clamp(23px, 4vw, 30px);
    font-weight: 400;
    letter-spacing: 0.12em;
    text-shadow: 0 2px 14px rgba(226, 173, 91, 0.25);
}

/* Intrinsic columns accommodate a third indicator and long result values. */
#card4-modal .card4-total-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr));
    gap: 18px 24px;
    margin: 26px 0;
}

#card4-modal .card4-total-stat {
    min-width: 0;
    padding: 12px 8px;
    background: radial-gradient(ellipse at center, rgba(156, 99, 180, 0.15), transparent 75%);
}

#card4-modal .card4-total-stat dt {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: #d8c6df;
    font-size: 16px;
}

#card4-modal .card4-total-icon {
    display: block;
    flex: 0 0 auto;
    height: 30px;
    width: auto;
    object-fit: contain;
}

#card4-modal .card4-total-stat dd {
    margin: 8px 0 0;
    color: #ffe9b7;
    font-size: clamp(24px, 4vw, 34px);
    line-height: 1.3;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}

#card4-modal .card4-total-calculate {
    max-width: 100%;
    padding: 13px 36px;
    border: 1px solid #c9a369;
    border-radius: 24px 6px;
    background: linear-gradient(135deg, #56336c, #2d193e);
    box-shadow: inset 0 0 0 3px #2a1838, inset 0 0 0 4px #826147, 0 4px 18px #09050e;
    color: #f9dfaa;
    font: inherit;
    font-size: 14px;
    letter-spacing: 0.14em;
    cursor: pointer;
    transition: background 0.2s, box-shadow 0.2s;
}

#card4-modal .card4-total-calculate:hover {
    background: linear-gradient(135deg, #704586, #422454);
    box-shadow: inset 0 0 0 3px #2a1838, inset 0 0 0 4px #b89564, 0 0 20px #74418b55;
}

#card4-modal .card4-total-calculate:focus-visible {
    outline: 2px solid #e8c7ff;
    outline-offset: 5px;
}

#card4-modal .card4-panel.active,
#card4-modal .card4-research-panel.active {
    display: block;
}

/* Cajas de las calculadoras */
#card4-modal .card4-box {
    background: linear-gradient(145deg, #211529, #100b18);
    border: 1px solid #8d683e;
    border-radius: 14px;
    outline: 1px solid #8d683e;
    outline-offset: -2px;
    padding: 24px;
    margin-top: 20px;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.35);
}

/* Títulos */
#card4-modal .card4-panel h3 {
    color: #e5c58a;
    font-size: 23px;
    text-align: center;
    margin-bottom: 20px;
}

#card4-modal .card4-box h4 {
    color: #e8d1a3;
    font-size: 19px;
    margin-bottom: 18px;
}

/* Buildings only: readable form type with the modal's existing palette. */
#card4-modal .card4-buildings-fields {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) repeat(2, minmax(0, 1fr));
    gap: 16px;
}

#card4-modal .card4-building-field {
    display: grid;
    gap: 8px;
    min-width: 0;
    color: #e8d1a3;
    line-height: 24px;
}

#card4-buildings .card4-building-heading {
    display: flex;
    align-items: center;
    gap: 8px;
}

#card4-buildings .card4-building-heading img {
    display: block;
    flex: 0 0 auto;
    height: 28px;
    width: auto;
    object-fit: contain;
}

#card4-modal .card4-calculator select {
    width: 100%;
    height: 48px;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
    padding: 10px 12px;
    border: 2px solid #8d683e;
    border-radius: 6px;
    background: #21142e;
    color: #f1e4c5;
    font: inherit;
    font-size: 16px;
}

#card4-modal .card4-calculator select option {
    font-family: inherit;
}

#card4-modal .card4-calculator select:disabled {
    opacity: 0.6;
}

#card4-modal .card4-calculator select:focus-visible {
    outline: 2px solid #e8c7ff;
    outline-offset: 3px;
}

#card4-modal .card4-selection-status {
    min-height: 1.3em;
    margin: 12px 0 0;
    color: #d8c6df;
    font-size: 0.9em;
    line-height: 22px;
}

/* Keep calculated values and partial-data notes in the original numeric slots. */
#card4-modal .card4-total-stat output {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    height: 1.3em;
}

#card4-modal .card4-result-main {
    /* Scoped exception to the site's unified-font preview. */
    font-family: 'Cinzel', serif !important;
    font-weight: 600;
    font-style: normal;
    display: block;
    max-width: 100%;
    white-space: nowrap;
    line-height: 1.05;
}

#card4-modal .card4-result-note {
    font-size: 12px;
    line-height: 1.1;
    white-space: nowrap;
    color: #d8c6df;
}

#card4-modal .card4-result-note[hidden] {
    display: none;
}

#card4-modal .card4-selection-status[data-calculation-message] {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Readable Card 4 form text; decorative headings and results stay unchanged. */
#card4-modal .card4-calculator label,
#card4-modal .card4-calculator label span,
#card4-modal .card4-calculator select,
#card4-modal .card4-calculator select option,
#card4-modal .card4-calculator [role="status"] {
    font-family: 'Metamorphous', serif !important;
    font-weight: 400;
    font-style: normal;
}

/* Botones de las ramas de investigación */
#card4-modal .card4-research-branches {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin: 20px 0;
}


#card4-modal .card4-branch {
    width: 180px;
    min-width: 180px;
    height: 36px;
    padding: 0 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #81518e;
    border-radius: 6px;
    background: linear-gradient(145deg, #28152f, #160d1e);
    color: #e8cc9a;
    font-family: inherit;
    font-size: 16px;
    cursor: pointer;
    transition: 0.2s ease;
}


#card4-modal .card4-branch:hover {
    border-color: #d9ad6a;
    box-shadow: 0 0 12px rgba(178, 100, 213, 0.3);
}

#card4-modal .card4-branch.active {
    background: linear-gradient(145deg, #67407b, #392347);
    border-color: #d9ad6a;
    box-shadow: 0 0 12px rgba(215, 164, 91, 0.25);
}


/* Research artwork: preserve button boxes and keep icons proportional. */
#card4-modal .card4-branch {
    gap: 6px;
    white-space: nowrap;
}

#card4-modal .card4-branch-icon {
    display: block;
    width: 24px;
    height: 24px;
    flex: 0 0 24px;
    object-fit: contain;
}

#card4-modal .card4-research-heading {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 28px;
}

#card4-modal .card4-research-heading img {
    display: block;
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
    object-fit: contain;
}

/* In-memory upgrade plan, kept in the content flow above the result artwork. */
#card4-modal .card4-plan-actions { margin-top: 16px; text-align: center; }
#card4-modal .card4-plan-button {
    border: 1px solid #81518e;
    border-radius: 6px;
    padding: 8px 12px;
    background: linear-gradient(145deg, #28152f, #160d1e);
    color: #e8cc9a;
    font: inherit;
    cursor: pointer;
}
#card4-modal .card4-plan-button:hover:not(:disabled) { border-color: #d9ad6a; }
#card4-modal .card4-plan-button:disabled { opacity: .5; cursor: default; }
#card4-modal .card4-plan-button:focus-visible { outline: 2px solid #e8c7ff; outline-offset: 3px; }
#card4-modal .card4-upgrade-plan { margin-top: 24px; min-width: 0; }
#card4-modal .card4-plan-heading-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
#card4-modal #card4-plan-heading { font-size: 18px; color: #e5c58a; margin: 0; }
#card4-modal #card4-plan-message { color: #d8c6df; overflow-wrap: anywhere; }
#card4-modal #card4-plan-list { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 10px; }
#card4-modal .card4-plan-entry { border: 1px solid #8d683e; border-radius: 10px; padding: 12px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 12px; color: #e8d1a3; }
#card4-modal .card4-plan-entry p { margin: 4px 0 0; overflow-wrap: anywhere; }
#card4-modal .card4-plan-entry strong { overflow-wrap: anywhere; }
#card4-modal .card4-plan-costs { font-family: 'Cinzel', serif !important; font-weight: 600; }
#card4-modal .card4-plan-empty { color: #d8c6df; }

/* Clear Queenie's 44px overhang without moving the result composition. */
#card4-modal .card4-calculation-note {
    margin: 68px auto 0;
    max-width: 760px;
    text-align: center;
    font-size: 13px;
    line-height: 1.6;
    color: #d8c6df;
}
#card4-modal .card4-calculation-note-marker {
    color: #e5c58a;
}

#card4-modal .card4-mobile-selection-name { display: none; }
