/* Character select + New Character wizard — combat-menu popup shell */

#character-creation-wizard-overlay {
    z-index: 1180;
}

body.character-creation-wizard-open #race-selection-modal,
body.character-creation-wizard-open #conduit-creation-modal,
body.character-creation-wizard-open #crop-image-modal {
    z-index: 1260;
}

.sheet-popup-shell {
    max-width: 52rem;
    width: 100%;
    max-height: min(90vh, 820px);
    margin-bottom: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 16px;
    border: 1px solid rgba(255, 193, 7, 0.38);
    background:
        radial-gradient(120% 80% at 50% -30%, rgba(255, 193, 7, 0.14) 0%, transparent 55%),
        linear-gradient(168deg, #2c2629 0%, #1c191d 52%, #111014 100%);
    box-shadow:
        0 28px 64px rgba(0, 0, 0, 0.72),
        0 0 0 1px rgba(255, 255, 255, 0.04) inset,
        0 0 42px rgba(255, 193, 7, 0.1);
    color: rgba(248, 242, 236, 0.95);
    font-family: Inter, system-ui, sans-serif;
}

#character-select-modal .sheet-popup-shell {
    max-width: 42rem;
}

.sheet-popup-header {
    position: relative;
    flex-shrink: 0;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 16px 16px 14px 20px;
    border-bottom: 1px solid rgba(255, 193, 7, 0.22);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.04) 0%, transparent 100%),
        rgba(0, 0, 0, 0.22);
}

.sheet-popup-eyebrow {
    margin: 0 0 4px;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: rgba(255, 193, 7, 0.82);
}

.sheet-popup-title {
    margin: 0;
    font-family: 'Cinzel Decorative', Cinzel, serif;
    font-size: 1.28rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    color: rgba(248, 242, 236, 0.98);
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.45);
    line-height: 1.2;
}

.sheet-popup-close {
    flex-shrink: 0;
    width: 2rem;
    height: 2rem;
    border: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    color: rgba(248, 242, 236, 0.9);
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
}

.sheet-popup-close:hover {
    background: rgba(255, 255, 255, 0.16);
}

.sheet-popup-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 0.9rem 1.1rem 1.1rem;
}

.sheet-popup-shell .btn,
.sheet-popup-btn {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.1) 0%, rgba(0, 0, 0, 0.28) 100%);
    border: 1px solid rgba(255, 193, 7, 0.38);
    color: rgba(248, 242, 236, 0.95);
    font-family: Cinzel, serif;
    font-weight: 700;
    letter-spacing: 0.05em;
    border-radius: 10px;
    box-shadow: none;
}

.sheet-popup-shell .btn:hover,
.sheet-popup-btn:hover {
    background: linear-gradient(180deg, rgba(255, 193, 7, 0.22) 0%, rgba(0, 0, 0, 0.32) 100%);
    border-color: rgba(255, 193, 7, 0.62);
    color: #fff;
}

.sheet-popup-shell .btn.bg-gray-500,
.sheet-popup-shell .btn.bg-gray-500:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.16);
    color: rgba(248, 242, 236, 0.82);
}

.sheet-popup-shell input[type="text"],
.sheet-popup-shell input[type="number"],
.sheet-popup-shell select,
.sheet-popup-shell textarea {
    color: rgba(248, 242, 236, 0.95) !important;
    background-color: rgba(0, 0, 0, 0.38);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 8px;
}

.sheet-popup-shell input::placeholder,
.sheet-popup-shell textarea::placeholder {
    color: rgba(248, 242, 236, 0.42);
}

.sheet-popup-shell label,
.sheet-popup-shell p,
.sheet-popup-shell h4,
.sheet-popup-shell strong,
.sheet-popup-shell span,
.sheet-popup-shell dt,
.sheet-popup-shell dd {
    color: inherit;
}

#character-select-modal .char-select-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 193, 7, 0.22);
    color: rgba(248, 242, 236, 0.95);
}

#character-select-modal .char-select-card:hover {
    background: rgba(255, 193, 7, 0.1);
    border-color: rgba(255, 193, 7, 0.5);
    transform: translateY(-2px);
}

#character-select-modal .char-select-portrait-wrapper {
    border-color: rgba(255, 255, 255, 0.12);
    background: rgba(0, 0, 0, 0.28);
}

#character-select-modal .char-select-portrait-wrapper.create-new {
    color: rgba(255, 193, 7, 0.75);
    background: rgba(255, 193, 7, 0.08);
}

#character-select-modal .char-select-card:hover .char-select-portrait-wrapper.create-new {
    color: rgba(255, 220, 120, 0.95);
    background: rgba(255, 193, 7, 0.16);
}

#character-select-modal .char-select-name {
    color: rgba(248, 242, 236, 0.95);
}

#char-create-options h4 {
    font-family: Cinzel, serif;
    color: rgba(248, 242, 236, 0.98);
}

#char-create-options p,
#char-create-options label {
    color: rgba(248, 242, 236, 0.82);
}

#ccw-body {
    flex: 1 1 auto;
    overflow-y: auto;
    min-height: 14rem;
}

.ccw-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
    padding: 0.85rem 1.1rem 1rem;
    border-top: 1px solid rgba(255, 193, 7, 0.18);
    background: rgba(0, 0, 0, 0.22);
}

.ccw-toolbar-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

.ccw-lead {
    margin: 0 0 1rem;
    line-height: 1.5;
    color: rgba(248, 242, 236, 0.82);
}

.ccw-h4 {
    margin: 1.25rem 0 0.5rem;
    font-family: Cinzel, serif;
    color: rgba(255, 220, 140, 0.95);
}

.ccw-progress {
    margin: 0;
    padding: 0.55rem 1.15rem 0;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: rgba(255, 193, 7, 0.72);
    flex-shrink: 0;
}

.ccw-identity-grid {
    display: grid;
    grid-template-columns: 9rem 1fr;
    gap: 1rem;
}

.ccw-portrait-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    color: rgba(248, 242, 236, 0.7);
    font-size: 0.78rem;
}

.ccw-portrait-btn img {
    width: 8.5rem;
    height: 8.5rem;
    object-fit: cover;
    border-radius: 0.75rem;
    border: 1px solid rgba(255, 193, 7, 0.35);
    background: #111014;
}

.ccw-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem 0.75rem;
}
.ccw-name-with-gen {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.ccw-name-with-gen input {
    flex: 1;
    min-width: 0;
}

.ccw-fields label,
.ccw-block-label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: rgba(248, 242, 236, 0.62);
}

.ccw-fields input,
.ccw-fields select,
.ccw-block-label input,
.ccw-block-label select,
#ccw-body textarea,
#ccw-province {
    font-weight: 400;
    width: 100%;
    text-transform: none;
    letter-spacing: 0;
}

.ccw-province-card,
.ccw-summary-box {
    margin-top: 1rem;
    padding: 0.9rem 1rem;
    border: 1px solid rgba(255, 193, 7, 0.22);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.04);
}

.ccw-summary-box {
    margin-top: 0;
    margin-bottom: 0.85rem;
}

.ccw-province-card h4 {
    margin: 0 0 0.4rem;
    font-family: Cinzel, serif;
    color: rgba(255, 220, 140, 0.95);
}

.ccw-meta {
    margin: 0.2rem 0;
    font-size: 0.9rem;
    color: rgba(248, 242, 236, 0.78);
}

.ccw-kit-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(10.5rem, 1fr));
    gap: 0.5rem;
}

.ccw-kit-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.2rem;
    text-align: left;
    padding: 0.55rem 0.65rem;
    border-radius: 9px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.04);
    color: rgba(248, 242, 236, 0.92);
    cursor: pointer;
}

.ccw-kit-card:hover {
    background: rgba(255, 193, 7, 0.1);
    border-color: rgba(255, 193, 7, 0.4);
}

.ccw-kit-card.selected {
    outline: none;
    border-color: rgba(255, 193, 7, 0.72);
    background: rgba(255, 193, 7, 0.16);
}

.ccw-kit-name {
    font-weight: 700;
    font-size: 0.88rem;
}

.ccw-kit-badge {
    font-size: 0.75rem;
    opacity: 0.75;
}

.ccw-notes p,
.ccw-footer-note {
    margin: 0.25rem 0 0.55rem;
    font-size: 0.88rem;
    color: rgba(248, 242, 236, 0.78);
}

.ccw-gold {
    font-size: 1.05rem;
}

.ccw-warn {
    padding: 0.6rem 0.75rem;
    border-radius: 0.5rem;
    background: rgba(127, 29, 29, 0.28);
    border: 1px solid rgba(248, 113, 113, 0.28);
}

.ccw-muted {
    opacity: 0.7;
}

.ccw-related-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.35rem;
    margin-bottom: 0.85rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.ccw-confirm-dl {
    display: grid;
    grid-template-columns: 8.5rem 1fr;
    gap: 0.4rem 0.75rem;
}

.ccw-confirm-dl dt {
    font-weight: 700;
    color: rgba(255, 193, 7, 0.82);
}

.ccw-confirm-dl dd {
    margin: 0;
}

.ccw-tip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.15rem;
    height: 1.15rem;
    border-radius: 50%;
    border: 1px solid rgba(255, 193, 7, 0.55);
    background: transparent;
    color: rgba(255, 193, 7, 0.9);
    font-size: 0.75rem;
    font-weight: 700;
    cursor: help;
    vertical-align: middle;
    margin-left: 0.2rem;
}

.ccw-included {
    display: grid;
    grid-template-columns: minmax(7.5rem, auto) 1fr;
    gap: 0.5rem;
    margin: 0 0 0.75rem;
}

.ccw-included-card {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding: 0.65rem 0.8rem;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.04);
    font-size: 0.8rem;
    color: rgba(248, 242, 236, 0.72);
}

.ccw-included-card strong {
    color: rgba(248, 242, 236, 0.95);
    font-size: 0.88rem;
}

.sheet-popup-shell .ccw-gold,
.sheet-popup-shell .ccw-gold strong {
    color: #FFC107;
}

.ccw-gold {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 1.15rem;
    font-weight: 700;
}

.ccw-gold-coin {
    font-size: 1.05em;
    line-height: 1;
}

.ccw-gold-note {
    margin-left: 0.2rem;
    font-size: 0.72rem;
    font-weight: 600;
    color: #FFC107;
    opacity: 0.75;
}

.ccw-help-line {
    margin: 0.45rem 0 1rem;
    font-size: 0.8rem;
    line-height: 1.45;
    color: rgba(248, 242, 236, 0.72);
}

.ccw-armor-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.ccw-armor-tile {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.2rem;
    text-align: left;
    padding: 0.65rem 0.7rem;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.04);
    color: rgba(248, 242, 236, 0.9);
    cursor: pointer;
}

.ccw-armor-tile:hover {
    background: rgba(255, 193, 7, 0.1);
    border-color: rgba(255, 193, 7, 0.4);
}

.ccw-armor-tile.selected {
    border-color: rgba(255, 193, 7, 0.72);
    background: rgba(255, 193, 7, 0.16);
}

.ccw-armor-type {
    font-family: Cinzel, serif;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255, 220, 140, 0.92);
}

.ccw-armor-name {
    font-size: 0.84rem;
    font-weight: 600;
}

.ccw-armor-meaning {
    font-size: 0.75rem;
    line-height: 1.35;
    color: rgba(248, 242, 236, 0.68);
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
}

.ccw-kit-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin: 0 0 0.85rem;
}

.ccw-kit-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    max-width: 100%;
    margin: 0;
    padding: 0.22rem 0.7rem 0.22rem 0.28rem;
    border-radius: 999px;
    border: 1px solid rgba(255, 193, 7, 0.32);
    background: rgba(255, 193, 7, 0.08);
    color: rgba(248, 242, 236, 0.92);
    font: inherit;
    cursor: pointer;
}

.ccw-kit-pill:hover {
    background: rgba(255, 193, 7, 0.16);
    border-color: rgba(255, 193, 7, 0.55);
}

.ccw-kit-pill.is-empty {
    opacity: 0.58;
    border-color: rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.04);
}

.ccw-kit-pill-slot {
    flex-shrink: 0;
    font-family: Cinzel, serif;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 0.18rem 0.45rem;
    border-radius: 999px;
    background: rgba(255, 193, 7, 0.22);
    color: rgba(255, 235, 180, 0.95);
}

.ccw-kit-pill-name {
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1.2;
    text-align: left;
}

.ccw-kit-tabs {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
    padding: 0.15rem 0 0.7rem;
    border-bottom: 1px solid rgba(255, 193, 7, 0.18);
    margin-bottom: 0.85rem;
}

.ccw-kit-tab {
    padding: 0.35rem 0.9rem;
    border-radius: 20px;
    border: 1px solid rgba(255, 193, 7, 0.28);
    background: rgba(255, 255, 255, 0.04);
    color: rgba(255, 220, 140, 0.75);
    font-family: Cinzel, serif;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    cursor: pointer;
}

.ccw-kit-tab:hover {
    background: rgba(255, 193, 7, 0.12);
    color: rgba(255, 235, 180, 0.95);
}

.ccw-kit-tab.is-active {
    background: rgba(255, 193, 7, 0.22);
    border-color: rgba(255, 193, 7, 0.65);
    color: rgba(255, 245, 210, 1);
}

.ccw-kit-select {
    width: 100%;
}

.ccw-kit-pane {
    margin-bottom: 0.5rem;
}

.ccw-bonus-compare {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.5rem;
    margin: 0 0 0.85rem;
}

.ccw-bonus-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.2rem;
    padding: 0.55rem 0.65rem;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.04);
}

.ccw-bonus-card .ccw-armor-meaning em {
    font-style: italic;
    color: rgba(255, 220, 140, 0.88);
}

@media (max-width: 720px) {
    .ccw-identity-grid,
    .ccw-fields,
    .ccw-armor-grid,
    .ccw-included,
    .ccw-bonus-compare {
        grid-template-columns: 1fr;
    }

    .ccw-confirm-dl {
        grid-template-columns: 1fr;
    }
}

/* Global modal-content adds margin-bottom: 3.5rem — that parks Next/Continue
   below the visible screen on phones. Always zero it for creation flow. */
#character-select-modal .modal-content,
#character-creation-wizard-overlay .modal-content,
#race-selection-modal .modal-content,
#conduit-creation-modal .modal-content,
#crop-image-modal .modal-content {
    margin-bottom: 0;
}

.ccw-toolbar .btn,
.ccw-toolbar-actions .btn {
    min-height: 2.75rem;
    min-width: 5.5rem;
    touch-action: manipulation;
}

/* Phone + tablet: full-screen wizard so Back/Next stay pinned */
@media (max-width: 900px) {
    #character-select-modal,
    #character-creation-wizard-overlay,
    body.character-creation-wizard-open #race-selection-modal,
    body.character-creation-wizard-open #conduit-creation-modal,
    body.character-creation-wizard-open #crop-image-modal {
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        height: 100dvh !important;
        max-height: none !important;
        padding: env(safe-area-inset-top, 0px) 0 env(safe-area-inset-bottom, 0px) !important;
        align-items: stretch;
        justify-content: stretch;
        box-sizing: border-box;
        overflow: hidden;
    }

    #character-select-modal .sheet-popup-shell,
    #character-creation-wizard-overlay .ccw-modal {
        width: 100% !important;
        max-width: none !important;
        max-height: none !important;
        height: auto;
        flex: 1 1 auto;
        min-height: 0;
        margin: 0 !important;
        border-radius: 0;
    }

    .sheet-popup-header {
        padding: 12px 14px 10px 16px;
    }

    .sheet-popup-title {
        font-size: 1.08rem;
    }

    #ccw-body,
    #character-select-modal .sheet-popup-body {
        -webkit-overflow-scrolling: touch;
        padding: 0.75rem 0.9rem 1rem;
        min-height: 0;
    }

    .ccw-toolbar {
        padding: 0.65rem 0.9rem calc(0.7rem + env(safe-area-inset-bottom, 0px));
        gap: 0.5rem;
        position: relative;
        z-index: 2;
        box-shadow: 0 -10px 24px rgba(0, 0, 0, 0.28);
    }

    .ccw-toolbar-actions {
        display: flex;
        justify-content: flex-end;
        flex: 1 1 auto;
        min-width: 0;
    }

    .ccw-toolbar-actions .btn {
        width: auto;
        min-width: 6.5rem;
    }

    .ccw-kit-tab {
        min-height: 2.5rem;
        padding: 0.45rem 0.85rem;
    }

    .ccw-kit-card,
    .ccw-armor-tile {
        min-height: 2.75rem;
    }

    #race-selection-modal .modal-content,
    #conduit-creation-modal .modal-content,
    #crop-image-modal .modal-content {
        width: 100% !important;
        max-width: none !important;
        max-height: none !important;
        height: auto;
        flex: 1 1 auto;
        min-height: 0;
        margin: 0 !important;
        border-radius: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    #race-selection-content,
    #conduit-selection-content {
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    #race-selection-modal .race-modal-footer,
    #race-selection-modal .race-journal-foot {
        position: sticky;
        bottom: 0;
        z-index: 3;
        margin-top: 0.5rem;
        padding: 0.75rem 0.85rem calc(0.75rem + env(safe-area-inset-bottom, 0px));
        background: linear-gradient(180deg, rgba(28, 24, 22, 0.94) 0%, rgba(17, 16, 16, 0.98) 100%);
        border-top: 1px solid rgba(180, 140, 90, 0.28);
    }

    #race-selection-modal .race-modal-footer .btn {
        min-height: 2.75rem;
        touch-action: manipulation;
    }

    #conduit-creation-modal .conduit-modal-footer {
        position: sticky;
        bottom: 0;
        z-index: 3;
        background: color-mix(in srgb, var(--card-bg-color, #1c191d) 96%, black);
        padding: 0.75rem 1rem calc(0.85rem + env(safe-area-inset-bottom, 0px));
    }

    #conduit-creation-modal .conduit-modal-footer .btn,
    #conduit-creation-modal .conduit-modal-continue-btn {
        min-height: 2.75rem;
        min-width: 7rem;
        touch-action: manipulation;
    }

    #conduit-creation-modal .conduit-choice-card--martial {
        max-width: 100%;
    }

    #crop-image-modal .modal-content {
        overflow-y: auto;
        padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom, 0px));
    }

    #char-create-options .flex.justify-center {
        flex-direction: column;
        align-items: stretch;
        gap: 0.65rem;
    }

    #char-create-options .btn {
        min-height: 2.75rem;
        width: 100%;
    }
}
