/* ===================================
   Lufel-style Party Selector UI v2
   =================================== */

:root {
    --lufel-bg: #1a1a2e;
    --lufel-card-bg: #22223a;
    --lufel-card-hover: #2d2d48;
    --lufel-border: rgba(255, 255, 255, 0.08);
    --lufel-accent: #e63946;
    --lufel-accent2: #f4a261;
    --lufel-text: #e0e0e0;
    --lufel-text-dim: #777;
    --lufel-slot-empty: rgba(255, 255, 255, 0.03);
}

/* === Selector Container === */
.lufel-party-selector {
    padding: 12px;
    background: rgba(26, 26, 46, 0.5);
    border-radius: 12px;
    border: 1px solid var(--lufel-border);
}

/* === Party Slots Row (horizontal cards) === */
.party-slots-row {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
}

/* === Slot Card (lufel-style) === */
.slot-card {
    flex: 1;
    min-width: 150px;
    background: var(--lufel-card-bg);
    border: 1px solid var(--lufel-border);
    border-radius: 10px;
    padding: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.slot-card:hover {
    border-color: rgba(255, 255, 255, 0.2);
    background: var(--lufel-card-hover);
}

.slot-card.selecting {
    border-color: var(--lufel-accent);
    box-shadow: 0 0 12px rgba(230, 57, 70, 0.25);
}

.slot-card.active {
    border-color: rgba(255, 255, 255, 0.2);
}

/* Wonder card has orange accent - slightly wider for weapon selects */
.slot-card-wonder {
    border-color: rgba(244, 162, 97, 0.3);
    background: rgba(244, 162, 97, 0.06);
    cursor: default;
    flex: 1.5 1 220px;
    max-width: 400px;
}

.slot-card-wonder:hover {
    border-color: rgba(244, 162, 97, 0.4);
    background: rgba(244, 162, 97, 0.08);
}

/* Persona row inside wonder slot card */
.wonder-persona-row {
    display: flex;
    gap: 6px;
    margin-top: 4px;
}

.wonder-persona-row .persona-slot {
    min-height: 70px;
    padding: 5px;
}

.wonder-persona-row .persona-slot .persona-card-img {
    width: 45px;
    height: 62px;
}

/* === Slot Content === */
.slot-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Character info row */
.slot-char-info {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 50px;
}

.slot-char-info .slot-char-img {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.15);
    flex-shrink: 0;
}

.slot-char-info .slot-char-details {
    flex: 1;
    min-width: 0;
}

.slot-char-info .slot-char-name {
    font-size: 0.85em;
    font-weight: 600;
    color: var(--lufel-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.slot-char-info .slot-char-sub {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.7em;
    color: var(--lufel-text-dim);
    margin-top: 2px;
}

.slot-char-info .slot-char-sub .meta-icon {
    width: 14px;
    height: 14px;
}

.slot-char-info .empty-text {
    color: var(--lufel-text-dim);
    font-size: 0.85em;
    width: 100%;
    text-align: center;
}

/* === Slot Options Grid (order/ritual/mod/revelation) === */
.slot-options-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.slot-option-row-top {
    display: flex;
    gap: 6px;
}

.slot-option-row-bottom {
    display: flex;
    gap: 6px;
}

.slot-option-group {
    flex: 1;
}

.slot-option-group label {
    display: block;
    font-size: 10px;
    color: var(--lufel-text-dim);
    margin-bottom: 2px;
    opacity: 0.8;
}

/* Styled select (lufel-style) */
.styled-select {
    width: 100%;
    padding: 4px 6px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    color: var(--lufel-text);
    font-size: 0.8em;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
    -webkit-appearance: none;
    appearance: none;
}

.styled-select:hover {
    border-color: rgba(255, 255, 255, 0.25);
}

.styled-select:focus {
    border-color: var(--lufel-accent);
}

/* === Character Selector Panel === */
.char-selector-panel {
    display: none;
    background: var(--lufel-card-bg);
    border: 1px solid var(--lufel-border);
    border-radius: 12px;
    padding: 16px;
    width: 92%;
    max-width: 1000px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
    animation: charSelectFadeIn 0.2s ease;
}

@keyframes charSelectFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Char select modal overlay */
.charselect-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    z-index: 1100;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.charselect-modal-overlay.open {
    display: flex;
}

/* Show panel only when inside open overlay */
.charselect-modal-overlay.open .char-selector-panel {
    display: block;
}

.char-selector-panel.open {
    display: block;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.char-search-bar {
    width: 100%;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--lufel-border);
    border-radius: 6px;
    color: var(--lufel-text);
    font-size: 0.85em;
    margin-bottom: 8px;
    outline: none;
}

.char-search-bar:focus {
    border-color: var(--lufel-accent);
}

.char-search-bar::placeholder {
    color: var(--lufel-text-dim);
}

/* Element filter chips */
.element-filters {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--lufel-border);
}

.element-filter-btn {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    padding: 2px;
    background: rgba(255, 255, 255, 0.05);
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.element-filter-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    transform: scale(1.1);
}

.element-filter-btn.active {
    border-color: var(--lufel-accent);
    background: rgba(230, 57, 70, 0.2);
}

.element-filter-btn img {
    width: 18px;
    height: 18px;
}

/* Character grid */
.char-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 6px;
    max-height: 300px;
    overflow-y: auto;
    padding-right: 4px;
}

.char-grid::-webkit-scrollbar {
    width: 5px;
}

.char-grid::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 3px;
}

.char-grid-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 6px 3px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
    text-align: center;
}

.char-grid-item:hover {
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(255, 255, 255, 0.15);
    transform: translateY(-1px);
}

.char-grid-item.selected {
    background: rgba(230, 57, 70, 0.12);
    border-color: var(--lufel-accent);
}

.char-grid-item .char-thumb {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.1);
    transition: border-color 0.15s;
}

.char-grid-item:hover .char-thumb {
    border-color: rgba(255, 255, 255, 0.3);
}

.char-grid-item.selected .char-thumb {
    border-color: var(--lufel-accent);
}

.char-grid-item .char-name-label {
    font-size: 0.65em;
    color: var(--lufel-text-dim);
    max-width: 75px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.char-grid-item .char-element-badge img {
    width: 12px;
    height: 12px;
}

/* ===== Compact Character Grid (lufel.net style) ===== */
.char-filter-row {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--lufel-border);
}

.char-filter-chip {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    padding: 2px;
    background: rgba(255, 255, 255, 0.05);
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.char-filter-chip:hover {
    background: rgba(255, 255, 255, 0.12);
    transform: scale(1.1);
}

.char-filter-chip.active {
    border-color: var(--lufel-accent);
    background: rgba(230, 57, 70, 0.2);
}

.char-filter-chip img {
    width: 18px;
    height: 18px;
    object-fit: contain;
}

.char-filter-sep {
    width: 1px;
    height: 20px;
    background: rgba(255, 255, 255, 0.15);
    margin: 0 4px;
}

.char-grid-compact {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 180px));
    gap: 4px;
    max-height: 400px;
    min-height: 400px;
    overflow-y: auto;
    padding-right: 4px;
}

.char-grid-compact::-webkit-scrollbar {
    width: 5px;
}

.char-grid-compact::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 3px;
}

.char-compact-card {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.12s;
}

.char-compact-card:hover {
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(255, 255, 255, 0.18);
}

.char-compact-card.selected {
    background: rgba(230, 57, 70, 0.12);
    border-color: var(--lufel-accent);
}

.char-compact-icon {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    object-fit: cover;
    border: 1.5px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.char-compact-card:hover .char-compact-icon {
    border-color: rgba(255, 255, 255, 0.3);
}

.char-compact-card.selected .char-compact-icon {
    border-color: var(--lufel-accent);
}

.char-compact-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
    flex: 1;
}

.char-compact-name {
    font-size: 0.78em;
    font-weight: 600;
    color: var(--lufel-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.char-compact-meta {
    display: flex;
    align-items: center;
    gap: 2px;
    font-size: 0.62em;
    color: var(--lufel-text-dim);
    white-space: nowrap;
}

.char-meta-icon {
    width: 12px;
    height: 12px;
    object-fit: contain;
    flex-shrink: 0;
}

/* === Wonder Config Panel === */
.wonder-config-panel {
    background: rgba(244, 162, 97, 0.06);
    border: 1px solid rgba(244, 162, 97, 0.2);
    border-radius: 10px;
    padding: 12px;
    margin-top: 10px;
}

.wonder-config-panel h3 {
    color: var(--lufel-accent2);
    margin: 0 0 10px 0;
    font-size: 0.95em;
}

.wonder-info-row {
    display: flex;
    gap: 15px;
    align-items: flex-start;
}

.wonder-weapon-section {
    min-width: 140px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.wonder-weapon-section label {
    font-size: 10px;
    color: var(--lufel-text-dim);
    opacity: 0.8;
}

/* === Persona Slots === */
.persona-slots-row {
    display: flex;
    gap: 8px;
    flex: 1;
    flex-wrap: wrap;
}

.persona-slot {
    flex: 1;
    min-width: 200px;
    background: rgba(0, 0, 0, 0.15);
    border: 2px solid var(--lufel-border);
    border-radius: 8px;
    padding: 8px;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
    min-height: 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

/* Wonder card inside persona row */
.wonder-persona-card {
    border-color: rgba(255, 0, 51, 0.3) !important;
    background: rgba(255, 0, 51, 0.05) !important;
    cursor: default;
    text-align: left;
    align-items: stretch;
    justify-content: flex-start;
}

.wonder-config-compact {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 6px;
}

.wonder-config-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.wonder-config-row label {
    font-size: 0.7em;
    color: #a8dadc;
    min-width: 28px;
    text-align: right;
}

.wonder-config-row .styled-select {
    flex: 1;
    font-size: 0.75em;
    padding: 2px 4px;
}

.persona-slot:hover {
    border-color: var(--lufel-accent2);
    background: rgba(244, 162, 97, 0.08);
}

.persona-slot.filled {
    border-color: rgba(255, 255, 255, 0.15);
    text-align: left;
    align-items: stretch;
    justify-content: flex-start;
}

.persona-slot .persona-card-img {
    width: 60px;
    height: 82px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.persona-slot .persona-name-label {
    font-size: 0.7em;
    color: var(--lufel-text);
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* === Persona Slot Inner Layout (lufel.net style) === */
.persona-slot-inner {
    display: flex;
    gap: 10px;
    width: 100%;
    align-items: flex-start;
}

.persona-card-side {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.persona-card-side .persona-card-img {
    width: 60px;
    height: 82px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.persona-card-side .persona-name-label {
    font-size: 0.7em;
    color: var(--lufel-text);
    max-width: 70px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.persona-skill-side {
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex: 1;
    min-width: 0;
}

/* Fixed skill (uniqueSkill) display */
.persona-fixed-skill {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75em;
    color: var(--lufel-accent2);
    padding: 2px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.persona-fixed-skill .skill-icon {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

/* Skill select buttons (replacing dropdowns) */
.persona-skill-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    width: 100%;
    padding: 4px 6px;
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--lufel-text);
    border-radius: 4px;
    font-size: 0.72em;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.persona-skill-btn:hover {
    border-color: var(--lufel-accent2);
    background: rgba(0, 0, 0, 0.6);
}

.persona-skill-btn .skill-btn-icon {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.persona-skill-btn .skill-btn-label {
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Skill row wrapper (button + clear) */
.persona-skill-row {
    display: flex;
    align-items: center;
    gap: 3px;
}

.persona-skill-row .persona-skill-btn {
    flex: 1;
    min-width: 0;
}

.persona-skill-clear-btn {
    width: 20px;
    height: 20px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.04);
    color: #888;
    font-size: 0.7em;
    cursor: pointer;
    transition: all 0.15s;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.persona-skill-clear-btn:hover {
    background: rgba(230, 57, 70, 0.2);
    border-color: rgba(230, 57, 70, 0.5);
    color: #e63946;
}

/* Skill modal */
.skill-modal {
    max-width: 650px;
}

.skill-modal-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 8px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.skill-filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 3px 8px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 4px;
    color: #aaa;
    font-size: 0.75em;
    cursor: pointer;
    transition: all 0.2s;
}

.skill-filter-icon {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.skill-filter-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

.skill-filter-btn.active {
    background: var(--lufel-accent2);
    color: #000;
    border-color: var(--lufel-accent2);
    font-weight: 600;
}

/* Skill tiles in modal */
.skill-tile {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    cursor: pointer;
    transition: all 0.15s;
    margin-bottom: 4px;
}

.skill-tile:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--lufel-accent2);
}

.skill-tile.recommended {
    border-left: 3px solid var(--lufel-accent2);
}

.skill-tile-icon {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    margin-top: 2px;
}

.skill-tile-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.skill-tile-name {
    font-size: 0.85em;
    font-weight: 600;
    color: #f1faee;
}

.skill-tile-desc {
    font-size: 0.7em;
    color: #888;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.skill-loading {
    font-size: 0.65em;
    color: #888;
}

/* === Persona Loading Animation === */
.persona-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 0;
    min-height: 60px;
}

.persona-loading-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid rgba(244, 162, 97, 0.15);
    border-top: 3px solid var(--lufel-accent2);
    border-right: 3px solid rgba(244, 162, 97, 0.4);
    border-radius: 50%;
    animation: personaSpin 0.8s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes personaSpin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.persona-loading-text {
    font-size: 0.65em;
    color: var(--lufel-text-dim);
    animation: personaPulse 1.5s ease-in-out infinite;
    letter-spacing: 0.5px;
}

@keyframes personaPulse {

    0%,
    100% {
        opacity: 0.5;
    }

    50% {
        opacity: 1;
    }
}

.skill-icon {
    width: 14px;
    height: 14px;
    vertical-align: middle;
    margin-right: 2px;
}

/* === Persona Modal === */
.persona-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.persona-modal-overlay.open {
    display: flex;
}

.persona-modal {
    background: #1e1e32;
    border: 1px solid var(--lufel-border);
    border-radius: 12px;
    width: 90%;
    max-width: 750px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
}

.persona-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 18px;
    border-bottom: 1px solid var(--lufel-border);
}

.persona-modal-header h2 {
    font-size: 1em;
    color: var(--lufel-text);
    margin: 0;
}

.persona-modal-close {
    background: none;
    border: none;
    color: var(--lufel-text);
    font-size: 1.4em;
    cursor: pointer;
    padding: 0 4px;
}

.persona-modal-close:hover {
    color: var(--lufel-accent);
}

.persona-modal-filters {
    padding: 10px 18px;
    border-bottom: 1px solid var(--lufel-border);
}

.persona-modal-filters .persona-search {
    width: 100%;
    padding: 7px 10px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--lufel-border);
    border-radius: 6px;
    color: var(--lufel-text);
    font-size: 0.85em;
}

.persona-modal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(85px, 1fr));
    gap: 6px;
    padding: 12px 18px;
    overflow-y: auto;
    flex: 1;
}

.persona-grid-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 5px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
    text-align: center;
}

.persona-grid-item:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.15);
    transform: translateY(-1px);
}

.persona-grid-item.selected {
    border-color: var(--lufel-accent2);
    background: rgba(244, 162, 97, 0.12);
}

.persona-grid-item .persona-thumb {
    width: 60px;
    height: 82px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.persona-grid-item .persona-label {
    font-size: 0.65em;
    color: var(--lufel-text-dim);
    max-width: 75px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* === Responsive === */
@media (max-width: 900px) {
    .party-slots-row {
        flex-wrap: wrap;
    }

    .slot-card {
        min-width: 130px;
        flex: 1 1 45%;
    }

    .slot-card-wonder {
        flex: 1 1 100%;
        max-width: 100%;
    }

    .wonder-info-row {
        flex-direction: column;
    }

    .persona-slots-row,
    .wonder-persona-row {
        flex-wrap: wrap;
    }
}

@media (max-width: 600px) {
    .slot-card {
        min-width: 100%;
    }

    .char-grid {
        grid-template-columns: repeat(auto-fill, minmax(65px, 1fr));
    }

    .slot-option-row-top {
        flex-wrap: wrap;
    }
}

/* === Revelation Preview Image === */
.rev-select-wrapper {
    display: flex;
    align-items: center;
    gap: 4px;
}

.rev-preview-img {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    object-fit: cover;
    border: 1px solid rgba(255, 255, 255, 0.12);
    flex-shrink: 0;
}

.rev-select-wrapper .styled-select {
    flex: 1;
    min-width: 0;
}

/* Stat input bar inside NeedStat panel */
.nsp-stat-bar {
    display: flex;
    gap: 12px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.25);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-wrap: wrap;
}

.nsp-stat-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.8em;
    color: var(--lufel-text-dim);
}

.nsp-stat-item span:first-child {
    font-weight: 600;
    color: var(--lufel-text);
    min-width: 50px;
}

.nsp-stat-input {
    width: 80px;
}

.nsp-unit {
    font-size: 0.85em;
    color: var(--lufel-text-dim);
}

/* === Need Stat Inline Table (per-slot, lufel-style) === */
.need-stat-inline {
    margin-top: 6px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 6px;
    padding: 6px 8px;
}

.need-stat-header {
    font-size: 0.72em;
    color: var(--lufel-accent2);
    font-weight: 600;
    margin-bottom: 4px;
}

.need-stat-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.75em;
}

.need-stat-table th {
    color: var(--lufel-text-dim);
    font-weight: 500;
    text-align: center;
    padding: 2px 4px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 0.9em;
}

.need-stat-table td {
    text-align: center;
    padding: 3px 4px;
    color: var(--lufel-text);
}

.need-stat-table .stat-row-label {
    text-align: left;
    font-weight: 600;
    color: var(--lufel-text-dim);
    font-size: 0.95em;
}

.need-stat-table .stat-target {
    color: var(--lufel-text-dim);
}

.need-stat-table .stat-current {
    color: var(--lufel-accent2);
    font-weight: 600;
}

.need-stat-table .stat-needed {
    color: #e0e0e0;
    font-weight: 600;
}

/* Active need-stat highlight */
.need-stat-inline.active {
    border-color: var(--lufel-accent);
    background: rgba(255, 107, 107, 0.12);
}

/* === Need Stat Panel === */
.need-stat-panel {
    background: rgba(15, 15, 30, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 16px;
    margin-top: 10px;
    animation: nspSlideIn 0.2s ease;
}

@keyframes nspSlideIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.nsp-cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.nsp-col {
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.2);
}

.nsp-col-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 0.95em;
    font-weight: 700;
    color: var(--lufel-text);
}

.nsp-col-total {
    color: var(--lufel-accent2);
    font-size: 1.1em;
}

.nsp-inputs {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.nsp-inputs label {
    font-size: 0.72em;
    color: var(--lufel-text-dim);
    display: flex;
    align-items: center;
    gap: 4px;
}

.nsp-input {
    width: 70px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 4px;
    color: var(--lufel-text);
    padding: 3px 6px;
    font-size: 1.1em;
    -moz-appearance: textfield;
    appearance: textfield;
}

.nsp-input::-webkit-outer-spin-button,
.nsp-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.nsp-stat-input {
    -moz-appearance: textfield;
    appearance: textfield;
}

.nsp-stat-input::-webkit-outer-spin-button,
.nsp-stat-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.nsp-section-label {
    font-size: 0.72em;
    color: var(--lufel-text-dim);
    font-weight: 600;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    padding-bottom: 3px;
    margin-bottom: 4px;
}

.nsp-items {
    max-height: 400px;
    overflow-y: auto;
}

.nsp-group-label {
    font-size: 0.7em;
    color: var(--lufel-accent2);
    font-weight: 600;
    padding: 4px 0 2px;
}

.nsp-row {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 3px 4px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8em;
    transition: background 0.12s;
}

.nsp-row:hover {
    background: rgba(255, 255, 255, 0.04);
}

.nsp-row input[type="checkbox"] {
    accent-color: var(--lufel-accent);
    cursor: pointer;
    flex-shrink: 0;
}

.nsp-tgt {
    font-size: 0.7em;
    padding: 1px 4px;
    border-radius: 3px;
    font-weight: 600;
    flex-shrink: 0;
    min-width: 28px;
    text-align: center;
}

.nsp-tgt-all {
    background: rgba(220, 50, 50, 0.25);
    color: #ff8888;
}

.nsp-tgt-single {
    background: rgba(220, 180, 50, 0.2);
    color: #f0d060;
}

.nsp-tgt-self {
    background: rgba(60, 120, 220, 0.2);
    color: #80b0ff;
}

.nsp-icon {
    width: 20px;
    height: 20px;
    border-radius: 3px;
    object-fit: cover;
    flex-shrink: 0;
}

.nsp-type {
    font-size: 0.7em;
    color: var(--lufel-text-dim);
    flex-shrink: 0;
    min-width: 40px;
}

.nsp-name {
    flex: 1;
    color: var(--lufel-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nsp-opt {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 3px;
    color: var(--lufel-accent2);
    font-size: 0.85em;
    padding: 1px 3px;
    max-width: 110px;
}

.nsp-val {
    color: var(--lufel-accent2);
    font-weight: 600;
    font-size: 0.9em;
    flex-shrink: 0;
    min-width: 50px;
    text-align: right;
}

/* === Defense Calculation Summary (lufel.net style) === */
.nsp-def-summary {
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    padding: 8px 10px;
    margin-bottom: 10px;
}

.nsp-def-row-top {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82em;
    flex-wrap: wrap;
    margin-bottom: 6px;
}

.nsp-def-label {
    color: var(--lufel-text-dim);
    font-weight: 500;
}

.nsp-def-val {
    color: var(--lufel-accent2);
    font-weight: 700;
    font-size: 1.1em;
}

.nsp-def-needed {
    color: #ff6b6b;
}

.nsp-def-pen-pct {
    color: var(--lufel-text-dim);
    font-size: 0.9em;
    margin-left: auto;
}

.nsp-def-sep {
    color: rgba(255, 255, 255, 0.2);
    font-size: 0.9em;
}

.nsp-def-tabs {
    display: flex;
    gap: 2px;
    margin-bottom: 6px;
}

.nsp-def-tab {
    flex: 1;
    padding: 5px 10px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 4px 4px 0 0;
    color: var(--lufel-text-dim);
    font-size: 0.78em;
    cursor: pointer;
    transition: all 0.15s;
}

.nsp-def-tab:hover {
    background: rgba(255, 255, 255, 0.08);
}

.nsp-def-tab.active {
    background: rgba(230, 57, 70, 0.15);
    border-color: var(--lufel-accent);
    color: var(--lufel-text);
    font-weight: 600;
}

.nsp-def-enemies {
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    padding-top: 4px;
}

.nsp-def-enemy-header {
    font-size: 0.7em;
    color: var(--lufel-text-dim);
    text-align: right;
    margin-bottom: 2px;
}

.nsp-def-enemy-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78em;
    padding: 3px 0;
}

.nsp-def-enemy-icon {
    font-size: 1.1em;
    flex-shrink: 0;
}

.nsp-def-enemy-name {
    color: var(--lufel-text);
    flex: 1;
}

.nsp-def-input {
    width: 65px;
    text-align: right;
}

@media (max-width:768px) {
    .nsp-cols {
        grid-template-columns: 1fr;
    }
}

/* ===== Revelation Grid Tiles ===== */
.rev-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 5px;
    margin-top: 6px;
    overflow-y: auto;
    padding: 6px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 6px;
    scrollbar-width: thin;
    scrollbar-color: rgba(168, 218, 220, 0.3) transparent;
}

.rev-tile {
    width: 76px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    border-radius: 4px;
    border: 1.5px solid transparent;
    cursor: pointer;
    transition: all 0.15s;
    background: rgba(255, 255, 255, 0.04);
    font-size: 0.7em;
    color: #aaa;
    text-align: center;
    padding: 3px 2px;
}

.rev-tile:hover {
    background: rgba(168, 218, 220, 0.15);
    border-color: rgba(168, 218, 220, 0.4);
    transform: scale(1.06);
}

.rev-tile.selected {
    border-color: #f4a261;
    background: rgba(244, 162, 97, 0.2);
    box-shadow: 0 0 6px rgba(244, 162, 97, 0.4);
    color: #f4a261;
}

.rev-tile img {
    width: 56px;
    height: auto;
    border-radius: 3px;
    object-fit: contain;
    flex-shrink: 0;
}

.rev-tile span {
    line-height: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    font-size: 0.95em;
}

.revelation-wrapper {
    flex: 1;
    min-width: 0;
}

/* Revelation select button */
.rev-select-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(168, 218, 220, 0.3);
    border-radius: 6px;
    cursor: pointer;
    color: #f1faee;
    font-size: 0.8em;
    transition: all 0.2s;
    min-height: 32px;
    width: 100%;
}

.rev-select-btn:hover {
    background: rgba(168, 218, 220, 0.15);
    border-color: rgba(168, 218, 220, 0.5);
}

.rev-select-btn img {
    width: 24px;
    height: 24px;
    border-radius: 3px;
    object-fit: cover;
    flex-shrink: 0;
}

.rev-select-btn span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Revelation modal overlay */
.rev-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 10000;
    justify-content: center;
    align-items: center;
}

.rev-modal-overlay.open {
    display: flex;
}

.rev-modal {
    background: rgba(30, 30, 50, 0.98);
    border: 1px solid rgba(168, 218, 220, 0.4);
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.8);
    width: 90%;
    max-width: 680px;
    max-height: 85vh;
    overflow-y: auto;
    padding: 16px;
}

.rev-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-size: 1.1em;
    font-weight: bold;
    color: #f4a261;
}

.rev-modal-close {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #f1faee;
    font-size: 1.2em;
    cursor: pointer;
    border-radius: 4px;
    padding: 2px 8px;
    transition: all 0.15s;
}

.rev-modal-close:hover {
    background: rgba(255, 61, 61, 0.3);
    border-color: rgba(255, 61, 61, 0.5);
}

.rev-modal-section {
    margin-bottom: 12px;
}

.rev-modal-section h4 {
    color: #a8dadc;
    margin: 0 0 6px 0;
    font-size: 0.9em;
}

/* Set Effect Display */
.rev-set-effect-section {
    margin-top: 8px;
    padding: 10px 12px;
    background: rgba(155, 89, 182, 0.08);
    border: 1px solid rgba(155, 89, 182, 0.25);
    border-radius: 8px;
}

.rev-set-effect-section h4 {
    color: #bb86fc;
    margin: 0 0 8px 0;
    font-size: 0.9em;
}

.rev-set-effect-list {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.rev-set-effect-item {
    display: flex;
    align-items: baseline;
    gap: 6px;
    font-size: 0.82em;
    line-height: 1.4;
}

.rev-set-effect-badge {
    flex-shrink: 0;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 0.85em;
    font-weight: 600;
    white-space: nowrap;
}

.rev-set-effect-badge.set2 {
    background: rgba(46, 204, 113, 0.2);
    color: #2ecc71;
    border: 1px solid rgba(46, 204, 113, 0.3);
}

.rev-set-effect-badge.set4 {
    background: rgba(241, 196, 15, 0.2);
    color: #f1c40f;
    border: 1px solid rgba(241, 196, 15, 0.3);
}

.rev-set-effect-badge.combo {
    background: rgba(155, 89, 182, 0.2);
    color: #bb86fc;
    border: 1px solid rgba(155, 89, 182, 0.3);
}

.rev-set-effect-desc {
    color: #ccc;
}

.rev-set-effect-none {
    color: #666;
    font-size: 0.82em;
    font-style: italic;
}

/* J&C mask button */
.jc-mask-btn {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 8px;
    background: rgba(192, 132, 252, 0.15);
    border: 1px solid rgba(192, 132, 252, 0.4);
    border-radius: 4px;
    color: #c084fc;
    font-size: 0.7em;
    cursor: pointer;
    transition: all 0.2s;
    margin-left: auto;
    white-space: nowrap;
}

.jc-mask-btn:hover {
    background: rgba(192, 132, 252, 0.3);
    border-color: rgba(192, 132, 252, 0.6);
}

/* J&C mask modal options */
.jc-mask-options {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.jc-mask-tile {
    cursor: pointer;
    border-radius: 6px;
}

/* Slot corner badges container (top-right: ✕, mask, SP) */
.slot-corner-badges {
    position: absolute;
    top: 4px;
    right: 4px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    align-items: flex-end;
    z-index: 2;
}

/* Remove (✕) button */
.slot-remove-btn {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 1px solid rgba(230, 57, 70, 0.4);
    background: rgba(230, 57, 70, 0.15);
    color: #e63946;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    opacity: 0.6;
    line-height: 1;
}

.slot-remove-btn:hover {
    opacity: 1;
    background: rgba(230, 57, 70, 0.35);
    border-color: rgba(230, 57, 70, 0.7);
    transform: scale(1.15);
    box-shadow: 0 0 8px rgba(230, 57, 70, 0.3);
}

/* ===== Sync Party Button ===== */
.sync-party-btn {
    padding: 12px 36px;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a78bfa 100%);
    color: #fff;
    border: 2px solid rgba(139, 92, 246, 0.4);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95em;
    font-weight: 700;
    letter-spacing: 1px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.35);
    position: relative;
    overflow: hidden;
}

.sync-party-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

.sync-party-btn:hover {
    transform: translateY(-3px) scale(1.03);
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.5);
    border-color: rgba(139, 92, 246, 0.7);
}

.sync-party-btn:hover::before {
    left: 100%;
}

.sync-party-btn:active {
    transform: translateY(0) scale(0.98);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

/* Green variant for action order */
.sync-party-btn.btn-green {
    background: linear-gradient(135deg, #06d6a0 0%, #05a87d 50%, #0ac999 100%);
    border-color: rgba(6, 214, 160, 0.4);
    box-shadow: 0 4px 15px rgba(6, 214, 160, 0.35);
}

.sync-party-btn.btn-green:hover {
    box-shadow: 0 8px 25px rgba(6, 214, 160, 0.5);
    border-color: rgba(6, 214, 160, 0.7);
}

/* ===== Action Order D&D Cards ===== */
.action-order-section {
    margin-top: 16px;
    padding: 14px;
    background: rgba(168, 218, 220, 0.06);
    border-radius: 10px;
    border: 1px solid rgba(168, 218, 220, 0.15);
}

.action-order-title {
    color: #a8dadc;
    font-size: 0.95em;
    margin: 0 0 10px 0;
    font-weight: 600;
}

.order-labels {
    display: flex;
    gap: 10px;
    margin-bottom: 6px;
    padding: 0 4px;
}

.order-labels>div {
    flex: 1;
    text-align: center;
    font-size: 0.72em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
}

.action-order-cards {
    display: flex;
    gap: 10px;
    min-height: 60px;
}

.order-card {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.35);
    border: 2px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    cursor: grab;
    user-select: none;
    transition: all 0.2s ease;
    position: relative;
}

.order-card::after {
    content: '⠿';
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.2;
    font-size: 1em;
    pointer-events: none;
}

.order-card:hover {
    border-color: rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.04);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.order-card.dragging {
    opacity: 0.35;
    transform: scale(0.95);
    border-color: #e63946;
}

.order-card.drag-over {
    border-color: #f4a261;
    background: rgba(244, 162, 97, 0.12);
    box-shadow: 0 0 12px rgba(244, 162, 97, 0.25);
    transform: translateY(-3px) scale(1.02);
}

.order-card .card-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7em;
    font-weight: 800;
    color: #0d0d0d;
    flex-shrink: 0;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.1);
}

.order-card .card-name {
    font-size: 0.8em;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* === NeedStat Modal Overlay === */
.needstat-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    z-index: 1100;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.needstat-modal-overlay.open {
    display: flex;
}

.needstat-modal {
    width: 92%;
    max-width: 900px;
    max-height: 85vh;
    overflow-y: auto;
    margin: 0;
    border-radius: 12px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6);
    animation: needstatFadeIn 0.2s ease;
}

@keyframes needstatFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.needstat-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px 12px 0 0;
}

.needstat-modal-header h3 {
    margin: 0;
    font-size: 1em;
    color: var(--lufel-text);
}

.needstat-modal-close {
    background: none;
    border: none;
    color: var(--lufel-text-dim);
    font-size: 1.5em;
    cursor: pointer;
    padding: 0 6px;
    line-height: 1;
    transition: color 0.15s;
}

.needstat-modal-close:hover {
    color: var(--lufel-accent);
}