/* Tactic Maker V2 - Styled to match dmg-calc.css standards */

:root {
    --card-background: #1f1f1f;
    --border-red: #d11f1f;
    --accent-color: #d11f1f;
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --border-color: rgba(255, 255, 255, 0.2);
    --bg-dark: #121212;
}

/* ==========================================================================
   Loading Overlay
   ========================================================================== */
.tactic-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-dark);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    z-index: 9999;
    transition: opacity 0.3s ease-out;
}

.tactic-loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.tactic-loading-gif {
    width: 120px;
    height: auto;
    image-rendering: pixelated;
}

.tactic-loading-progress-container {
    width: 200px;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

.tactic-loading-progress-bar {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--accent-color), #ff6b6b);
    border-radius: 3px;
    transition: width 0.1s ease-out;
}

.tactic-loading-percent {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
    font-weight: 500;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: 'Noto Sans KR', sans-serif;
}

/* ==========================================================================
   Global Layout
   ========================================================================== */
.tactic-maker-page .header-container {
    padding: 0;
    margin-bottom: 12px;
}

/* Sheet Status: Single row below pageTitle, above title input */
.sheet-status {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.sheet-status-primary {
    display: flex;
    gap: 8px;
}

.sheet-status-secondary {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
}

/* Title/Memo Input Group */
.tactic-input-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 12px;
    background: #1f1f1f;
    padding: 16px 16px 12px 16px;
    border-radius: 12px;
}

.tactic-input-group .tactic-title-container,
.tactic-input-group .tactic-memo-container {
    margin: 0;
}

/* Buttons with visible text (Edit mode, Upload) */
.btn-with-text {
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 500;
}

.btn-with-text svg {
    flex-shrink: 0;
}

.btn-with-text span {
    white-space: nowrap;
}

/* Upload button accent style */
.btn-upload-primary {
    background: var(--accent-color);
    border-color: var(--accent-color);
}

.btn-upload-primary:hover {
    background: #ff3b3b;
    border-color: #ff3b3b;
}

/* Responsive: 768px and below */
@media (max-width: 768px) {
    .sheet-status {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .sheet-status-primary {
        width: 100%;
    }

    .sheet-status-primary .btn-with-text {
        flex: 1;
        justify-content: center;
    }

    .sheet-status-secondary {
        justify-content: flex-start;
    }
}

/* Hide edit-only buttons in non-edit mode */
body:not(.tactic-edit-mode) #btnAutoSave,
body:not(.tactic-edit-mode) #btnReset,
body:not(.tactic-edit-mode) #btnImport {
    display: none !important;
}

.btn-storage {
    padding: 6px 12px;
    background: #2a2a2a;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: #fff;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
    position: relative;
}

.btn-storage:hover {
    background: #333;
    border-color: rgba(255, 255, 255, 0.4);
}

/* Icon-only buttons with tooltip on hover */
.btn-icon-hover {
    padding: 6px 8px;
}

.btn-icon-hover .btn-label {
    display: none;
}

/* Tooltip style for icon buttons */
.btn-icon-hover::after {
    content: attr(data-tooltip);
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 6px;
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    font-size: 11px;
    white-space: nowrap;
    color: #fff;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
    z-index: 1000;
}

.btn-icon-hover::before {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-bottom-color: rgba(0, 0, 0, 0.9);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
    z-index: 1001;
}

.btn-icon-hover:hover::after,
.btn-icon-hover:hover::before {
    opacity: 1;
}

/* Auto save time display - outside button */
.auto-save-status {
    display: flex;
    align-items: center;
    font-size: 10px;
    color: rgba(255, 255, 255, 0.5);
    white-space: nowrap;
    padding: 0 4px;
}

.auto-save-status.hidden {
    display: none;
}

/* Edit mode button keeps text always visible */
.btn-edit-toggle {
    flex-direction: row !important;
    padding: 6px 12px !important;
    gap: 6px !important;
}

.btn-edit-toggle span {
    display: inline !important;
}

/* No tooltip for edit toggle */
.btn-edit-toggle::after,
.btn-edit-toggle::before {
    display: none !important;
}

.btn-edit-toggle.active {
    background: rgba(209, 31, 31, 0.25);
    border-color: rgba(209, 31, 31, 0.95);
}

.tactic-title-container {
    margin-bottom: 30px;
}

.tactic-title-input {
    width: 100%;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border-color);
    padding: 4px 0 12px 0;
    font-size: 1.4rem;
    font-weight: 700;
    color: #fff;
    outline: none;
}

.tactic-title-input:focus {
    border-bottom-color: var(--accent-color);
}

/* ==========================================================================
   Tactic Memo (Description Box)
   ========================================================================== */
.tactic-memo-container {
    margin-bottom: 30px;
}

.tactic-memo-input {
    width: 100%;
    background: #1a1a1a;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 14px;
    font-size: 0.9rem;
    color: #ccc;
    outline: none;
    resize: vertical;
    min-height: 60px;
    max-height: 200px;
    font-family: inherit;
    box-sizing: border-box;
    transition: border-color 0.2s, background 0.2s;
}

.tactic-memo-input:focus {
    border-color: var(--accent-color);
    background: #1f1f1f;
}

.tactic-memo-input::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

/* Non-edit mode: tactic-memo-input minimal style */
body:not(.tactic-edit-mode) .tactic-memo-input {
    padding: 4px 4px 8px 4px;
    border: 0;
    background: transparent;
    min-height: 0;
    height: auto;
    resize: none;
    overflow: hidden;
    line-height: 1.5;
    box-sizing: border-box;
}

/* ==========================================================================
   Party Section (Slot Cards) - Styled like dmg-calc
   ========================================================================== */
.party-section {
    margin-bottom: 40px;
}

.party-section h2,
.tactic-board-section h2 {
    font-size: 1.2rem;
    margin-bottom: 15px;
    color: var(--text-secondary);
    font-weight: 500;
}

.party-slots-wrapper {
    background: var(--card-background);
    border-radius: 12px;
    padding: 16px;
}

/* Non-edit mode: connected with wonder-config-panel */
body:not(.tactic-edit-mode) .party-slots-wrapper {
    border-radius: 12px 12px 0px 0px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.party-slots-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 0px;
}

/* In view mode, use grid for right-aligned wrapping */
body:not(.tactic-edit-mode) .party-slots-container {
    display: grid;
    grid-template-columns: repeat(5, minmax(200px, 1fr));
    gap: 16px;
    max-width: 1464px;
    margin-left: auto;
}

body:not(.tactic-edit-mode) .party-slots-container > .slot-card,
body:not(.tactic-edit-mode) .party-slots-container > .wonder-in-party {
    min-width: 200px;
    max-width: 280px;
}

/* Wonder slot when moved into party container (view mode) */
.wonder-in-party.slot-card {
    background: rgba(255, 255, 255, 0.08) !important;
    border: none !important;
    padding: 0 !important;
    grid-template-columns: 1fr !important;
}

.wonder-in-party .ws-header {
    padding: 12px;
}

.wonder-in-party .ws-details {
    padding: 0 12px 0px 12px;
}

/* Hide empty slots in view mode */
body:not(.tactic-edit-mode) .slot-card.empty {
    display: none !important;
}

.slot-card {
    border: 1px dashed var(--border-color);
    border-radius: 12px;
    padding: 12px;
    background: rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    transition: all 0.2s;
    cursor: pointer;
    position: relative;
    user-select: none;
}

.slot-card:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.4);
}

.slot-card.active {
    border-style: none;
    background: rgba(255, 255, 255, 0.08);
    /* dmg-calc style */
}

/* Character color tint on slot card */
.slot-card.has-char-color {
    position: relative;
    overflow: visible;
}

.slot-card.has-char-color::before {
    content: "";
    position: absolute;
    inset: 0;
    background: var(--slot-char-color, transparent);
    opacity: 0.15;
    pointer-events: none;
    border-radius: inherit;
    z-index: 0;
}

.slot-card.has-char-color > * {
    position: relative;
    z-index: 1;
}

.slot-card.selecting {
    border-color: var(--accent-color);
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 0 0 1px var(--accent-color);
}

.slot-header {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 15px;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

/* Consistent styling for order/ritual/mod selects in ritual-mod-wrapper */
.ritual-mod-wrapper .slot-option-group .styled-select {
    height: 28px;
    padding: 4px 8px;
    font-size: 12px;
}

/* Slot options grid */
.slot-options-grid {
    margin-top: 12px;
}

/* Wonder slot mod/stamp wrapper - inherits from ritual-mod-wrapper via class */
/* Grid columns set inline based on number of options (2 or 3) */

/* Hide only ritual-mod-wrapper (order/ritual/mod dropdowns) in non-edit mode, keep revelation visible */
body:not(.tactic-edit-mode) .ritual-mod-wrapper {
    display: none !important;
}

.slot-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.empty-text {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.3);
    text-align: center;
    pointer-events: none;
}

/* Character Info inside Slot */
.slot-char-info {
    display: flex;
    gap: 12px;
    margin-bottom: 0px;
}

.slot-char-link {
    display: inline-block;
    line-height: 0;
}

.slot-char-img:hover{
    filter: brightness(1.2);
    transition: all 0.2s;
}

.slot-char-img {
    width: 42px;
    height: 48px;
    border-radius: 8px;
    object-fit: cover;
    background: rgba(0, 0, 0, 0.3);
}

.slot-char-details {
    display: flex;
    flex-direction: column;
    overflow: visible;
}

.slot-char-name {
    font-weight: 700;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
}

.slot-name-text {
    display: inline-block;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.slot-char-sub {
    font-size: 11px;
    opacity: 0.7;
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 4px;
}

.slot-char-sub .slot-meta-text {
    display: inline-block;
    max-width: 50px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.meta-icon {
    width: 16px;
    height: 16px;
    object-fit: contain;
}

/* Order image in slot-char-info (shown only in non-edit mode) */
.slot-char-info {
    position: relative;
}

.order-img {
    position: absolute;
    right: 0;
    top: 0;
    width: 32px;
    height: auto;
    opacity: 0.9;
}

/* Hide order image in edit mode */
.tactic-edit-mode .order-img {
    display: none;
}

/* Dropdowns in Slot */
.slot-dropdowns-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
    margin-top: auto;
}

.slot-dropdown-group label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.slot-option-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.slot-option-group .revelation-dropdown {
    display: block;
    flex: 1 1 auto;
}

.slot-option-group .revelation-button {
    width: 100%;
}

.slot-option-group .revelation-menu {
    width: 100%;
}

.slot-option-group>label {
    margin-bottom: 0 !important;
    white-space: nowrap;
    flex: 0 0 auto;
}

/*
.slot-option-group>select,
.slot-option-group .styled-select {
    flex: 1 1 auto;
}*/

/* Styled Dropdowns (Button-like) */
.target-dropdown {
    position: relative;
}

.target-dropdown-btn {
    width: 100%;
    padding: 6px 8px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.3);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    font-size: 0.85rem;
    height: 32px;
}

.target-dropdown-btn:hover {
    border-color: rgba(255, 255, 255, 0.4);
}

.target-dropdown-btn img {
    width: 20px;
    height: 20px;
    object-fit: contain;
}

.target-dropdown-menu {
    position: absolute;
    bottom: 100%;
    left: 0;
    width: 100%;
    background: #1f1f1f;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    z-index: 50;
    max-height: 200px;
    overflow-y: auto;
    display: none;
    margin-bottom: 4px;
}

.target-dropdown-menu.active {
    display: block;
}

.target-dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    width: 100%;
    text-align: left;
    background: transparent;
    border: none;
    color: #fff;
    cursor: pointer;
}

.target-dropdown-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.target-dropdown-item img {
    width: 20px;
    height: 20px;
    object-fit: contain;
}

/* Revelation Rows */
.revelation-row {
    margin-top: 10px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.revelation-group label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

/* Revelation Selects Container */
.revelation-selects {
    margin-top: 8px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
}

.revelation-selects.disabled {
    opacity: 0.5;
    pointer-events: none;
}

.revelation-select {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Dropdown Wrapper */
.revelation-dropdown {
    position: relative;
    width: 100%;
}

/* Button Trigger */
.revelation-button {
    width: 100%;
    padding: 6px 8px;
    border-radius: 8px;
    border: 0px solid rgba(255, 255, 255, 0.2);
    background: rgba(0, 0, 0, 0.3);
    color: #fff;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 12px;
    min-height: 32px;
    transition: background 0.2s, border-color 0.2s;
    overflow: hidden;
}

.revelation-button span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}

.revelation-button:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
}

.revelation-button:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

/* Dropdown Menu */
.revelation-menu {
    display: none;
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 4px);
    background: #1b1b1b;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 4px;
    z-index: 2000;
    max-height: 200px;
    overflow-y: auto;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.revelation-dropdown.open .revelation-menu {
    display: grid;
    gap: 2px;
}

/* Option Items */
.revelation-option {
    border: none;
    background: rgba(255, 255, 255, 0.04);
    color: #fff;
    font-size: 12px;
    border-radius: 6px;
    padding: 6px 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    text-align: left;
    width: 100%;
    transition: background 0.2s;
}

.revelation-option:hover {
    background: rgba(255, 255, 255, 0.12);
}

.revelation-icon {
    width: 20px;
    height: 20px;
    object-fit: contain;
    flex-shrink: 0;
}

/* Role Selector (J&C) */
.role-selector {
    display: flex;
    gap: 4px;
}

.role-icon-row {
    display: grid;
    grid-template-columns: repeat(6, auto);
    gap: 4px;
}

.role-icon {
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.2);
    cursor: pointer;
}

.role-icon.active {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 1px var(--accent-color);
}

.role-icon img {
    width: 18px;
    height: 18px;
    object-fit: contain;
}

.role-btn {
    flex: 1;
    padding: 4px;
    border: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.3);
    color: var(--text-secondary);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
}

.role-btn.active {
    background: var(--accent-color);
    color: #fff;
    border-color: var(--accent-color);
}

.btn-remove-slot {
    position: absolute;
    top: 8px;
    right: 8px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
    padding: 4px;
}

.btn-remove-slot:hover {
    color: #ff6b6b;
}

/* ==========================================================================
   Roster & Wonder Container (Bottom Panel)
   ========================================================================== */
.roster-container {
    background: var(--card-background);
    border-radius: 12px;
    border-bottom: 3px solid var(--border-red);
    padding: 20px;
    margin-top: 20px;
    display: none;
}

.wonder-config-panel {
    background: var(--card-background);
    border-radius: 12px;
    padding: 16px;
    margin-top: 16px;
}

/* Non-edit mode: connected with party-slots-wrapper */
body:not(.tactic-edit-mode) .wonder-config-panel {
    border-radius: 0px 0px 12px 12px;
    margin-top: 0;
}

.roster-container.expanded {
    display: block;
    animation: slideDown 0.3s ease-out;
}

.roster-header {
    display: none !important;
}

.roster-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--accent-color);
}

#toggleRoster {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
}

#toggleRoster:hover {
    color: #fff;
}

.roster-filter-bar {
    margin-bottom: 20px;
    padding: 0px;
}

.roster-filter-search {
    margin-bottom: 12px;
}

.roster-search-input {
    width: 100%;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    color: #fff;
    font-size: 13px;
    box-sizing: border-box;
}

.roster-search-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.roster-filter-groups {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: center;
}

/* Spoiler Toggle in Roster */
.roster-spoiler-toggle {
    margin-left: auto;
}

.roster-spoiler-toggle .spoiler-toggle-label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
}

.roster-spoiler-toggle .spoiler-toggle-checkbox {
    width: 14px;
    height: 14px;
    cursor: pointer;
    accent-color: var(--accent-color, #d11f1f);
}

.roster-spoiler-toggle .spoiler-toggle-text {
    white-space: nowrap;
}

.roster-filter-group {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.roster-filter-positions {
    position: relative;
}

.roster-filter-reset {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    padding: 4px;
    margin-left: 2px;
    display: none;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.roster-filter-reset.active {
    display: inline-flex;
}

.roster-filter-reset:hover {
    color: rgba(255, 255, 255, 0.9);
}

.roster-filter-chip {
    display: inline-flex;
    align-items: center;
    padding: 4px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.roster-filter-chip:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.25);
}

.roster-filter-chip input[type="checkbox"] {
    display: none;
}

.roster-filter-chip input[type="checkbox"]:checked+img {
    filter: brightness(1.5) drop-shadow(0 0 4px rgba(255, 255, 255, 0.5));
}

.roster-filter-chip:has(input[type="checkbox"]:checked) {
    box-shadow: inset 0 0 0 1px #d11f1f;
}

.roster-filter-chip img {
    width: 20px;
    height: 20px;
    object-fit: contain;
    pointer-events: none;
}

/* Roster Item - Matched to dmg-calc.css */
.roster-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
    max-height: 400px;
    overflow-y: auto;
    padding: 4px;
}

.roster-item {
    padding: 6px 8px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 12px;
    cursor: grab;
    text-align: left;
    display: grid;
    grid-template-columns: 24px 1fr;
    gap: 8px;
    align-items: center;
    transition: all 0.2s;
}

.roster-item:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--accent-color);
}

.roster-thumb {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    object-fit: cover;
    background: rgba(255, 255, 255, 0.08);
}

.roster-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
}

.roster-name {
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.roster-sub {
    font-size: 11px;
    opacity: 0.7;
    display: flex;
    align-items: center;
    gap: 4px;
}

.roster-sub .meta-icon {
    width: 14px;
    height: 14px;
    object-fit: contain;
}

/* ==========================================================================
   Wonder Config Panel
   ========================================================================== */
.wonder-config-body {
    width: 100%;
    display: block;
}

.wonder-controls-row {
    display: flex;
    gap: 20px;
    margin-bottom: 30px;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.control-group.weapon-main {
    flex: 2;
}

.control-group label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Wonder Weapon Dropdown */
.custom-dropdown-container {
    position: relative;
    width: 100%;
}

.weapon-input {
    width: 100%;
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
}

.dropdown-list {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    max-height: 250px;
    overflow-y: auto;
    background: #1f1f1f;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    z-index: 100;
    margin-top: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    cursor: pointer;
    transition: background 0.2s;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.dropdown-item:last-child {
    border-bottom: none;
}

.dropdown-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Hide Ritual/Mod wrapper in non-edit mode */
body:not(.tactic-edit-mode) .ritual-mod-wrapper {
    display: none !important;
}

/* Stamp type dropdown - same style as wonder-weapon-dropdown */
.stamp-type-dropdown {
    margin-top: 0px;
}

/* In non-edit mode, stamp type dropdown is visible but read-only */
body:not(.tactic-edit-mode) .stamp-type-dropdown {
    pointer-events: none !important;
}

body:not(.tactic-edit-mode) .stamp-type-dropdown .revelation-button[data-tooltip] {
    pointer-events: auto !important;
}

/* ==========================================================================
   Persona Cards (Ported from persona.css)
   ========================================================================== */
.personas-section-title {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 5px;
}

.persona-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    /* Adaptive grid */
    gap: 15px;
}

/* Base Card Style */
.card {
    position: relative;
    width: 100%;
    /* fluid */
    aspect-ratio: 1/1.67;
    cursor: pointer;
    transition: filter 0.1s;
    overflow: hidden;
    border-radius: 10px;
}

.card:hover {
    filter: brightness(1.1);
    z-index: 1;
}

.image-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    border-radius: 10px;
    z-index: 2;
    isolation: isolate;
    mask-image: radial-gradient(white, black);
}

.card-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    border-radius: 10px;
    object-fit: cover;
}

.persona-img {
    position: relative;
    width: 100%;
    height: 100%;
    object-fit: cover;
    --hover-magnify: 1;
    transform: translate(var(--tx, 1%), var(--ty, 5%)) scale(calc(var(--scale, 1) * var(--hover-magnify)));
    transition: transform 0.2s ease;
    z-index: 2;
    overflow: initial;
}

.card:hover .persona-img {
    --hover-magnify: 1.15;
}

.element-icon {
    width: 11% !important;
    height: auto !important;
    position: absolute;
    top: 0px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 4;
    object-fit: contain !important;
}

.cover-star {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 3;
    object-fit: cover;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

.position-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 4;
}

.position-icon {
    width: 60% !important;
    height: auto !important;
    object-fit: contain !important;
    box-shadow: none !important;
    border-radius: 0 !important;
}

.tier-label {
    position: absolute;
    top: 15px;
    right: 0;
    left: auto;
    z-index: 6;
    background: #333;
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 4px 0 0 4px;
    box-shadow: -2px 2px 4px rgba(0, 0, 0, 0.2);
    line-height: 1;
    font-family: sans-serif;
    letter-spacing: -0.5px;
}

.tier-label.tier-s {
    background: linear-gradient(45deg, #cbebea, #e0b1f2, #cbebea, #e8baf9);
    color: #111;
}

.tier-label.tier-a {
    background: linear-gradient(45deg, #efd16e, #fef0a2);
    color: #111;
}

.tier-label.tier-b {
    background: #8d6e63;
    color: #fff;
}

.wild-emblem {
    position: absolute;
    bottom: 12px;
    left: 51%;
    transform: translateX(-50%);
    width: 18%;
    height: auto;
    z-index: 5;
    object-fit: contain;
    pointer-events: none;
}

.persona-detail-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
}

.persona-card-section {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.persona-name {
    margin-top: 4px;
    text-align: center;
    font-weight: 500;
    font-size: 11px;
    color: #eee;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 100%;
}

/* ==========================================================================
   Utility
   ========================================================================== */
.hidden {
    display: none !important;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal[hidden] {
    display: none !important;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
}

.modal-dialog {
    position: relative;
    width: 100%;
    max-width: 520px;
    max-height: 85vh;
    background: #1b1b1b;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.modal-header h2,
.modal-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: #fff;
}

.modal-close {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 20px;
    cursor: pointer;
    line-height: 1;
}

.modal-close:hover {
    color: #fff;
}

.modal-content {
    padding: 14px 16px;
    overflow: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.modal-footer {
    padding: 12px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
}

.input-select,
.input-text {
    width: 100%;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: #111;
    color: #fff;
    padding: 8px 10px;
    outline: none;
    box-sizing: border-box;
}

.input-text {
    resize: vertical;
    min-height: 60px;
}

.btn-primary,
.btn-secondary,
.btn-danger {
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 13px;
}

.btn-primary {
    background: rgba(209, 31, 31, 0.95);
    border-color: rgba(209, 31, 31, 0.95);
    color: #fff;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.btn-danger {
    background: rgba(255, 107, 107, 0.18);
    border-color: rgba(255, 107, 107, 0.5);
    color: #ffb3b3;
}

.btn-primary:hover {
    filter: brightness(1.05);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.12);
}

.btn-danger:hover {
    background: rgba(255, 107, 107, 0.24);
}

.action-type-toggle {
    display: flex;
    gap: 8px;
}

.action-type-toggle button {
    flex: 1;
    height: 32px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(0, 0, 0, 0.18);
    color: rgba(255, 255, 255, 0.85);
    cursor: pointer;
}

.action-type-toggle button.active {
    border-color: rgba(209, 31, 31, 0.95);
    background: rgba(209, 31, 31, 0.22);
    color: #fff;
}

/* Animations */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}


/* ==========================================================================
   Wonder UI Specific Styles (Added in Hotfix)
   ========================================================================== */

/* Wonder Slot Preview */
/*
.wonder-card {
    border-color: #9d4edd !important;
    background: linear-gradient(135deg, rgba(30, 0, 30, 0.4), rgba(0, 0, 0, 0.2)) !important;
}*/

.wonder-personas-preview {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    margin-top: 8px;
    height: 32px;
    width: 100%;
}

.mini-persona {
    aspect-ratio: 1/1.67;
    border-radius: 4px;
    object-fit: cover;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(0, 0, 0, 0.3);
    width: 100%;
}

.mini-persona.empty {
    border-style: dashed;
    opacity: 0.3;
}

/* Wonder Config Panel - 4 column grid (edit mode), 3 column (view mode) */
.wonder-personas-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

/* In view mode, Wonder slot moves out so grid becomes 3 columns */
body:not(.tactic-edit-mode) .wonder-personas-grid {
    grid-template-columns: repeat(3, 1fr);
}

@media (max-width: 1200px) {
    .wonder-personas-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .wonder-personas-grid {
        grid-template-columns: 1fr;
    }
}

/* Wonder Persona Card - 2 column grid layout */
.wonder-persona-card {
    background: rgba(255, 255, 255, 0.09);
    border: 0px solid var(--border-color);
    border-radius: 8px;
    overflow: visible;
    transition: all 0.2s;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0;
}

.wonder-persona-card:hover {
    border-color: var(--accent-color);
    background: rgba(255, 255, 255, 0.05);
}

/* Column 1: Card + Name */
.wp-header {
    padding: 10px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px 0 0 8px;
}

.wp-header:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Card wrapper - 90px same as modal */
.wp-img-wrapper {
    width: 64px;
    flex-shrink: 0;
    position: relative;
    z-index: 0;
}

.wp-img-wrapper .card {
    border-radius: 4px;
    overflow: hidden;
}

/* card uses width: 100% from base, fills the 90px wrapper */

.empty-wp {
    width: 64px;
    aspect-ratio: 1/1.67;
    border-radius: 10px;
    background: repeating-linear-gradient(45deg,
            #222,
            #222 10px,
            #333 10px,
            #333 20px);
    border: 1px dashed rgba(255, 255, 255, 0.2);
}

/* Name row below card */
.wp-name-row {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    width: 100%;
}

.wp-name {
    font-weight: 600;
    font-size: 0.7rem;
    color: #fff;
    text-align: center;
    max-width: 90px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.wp-name-icons {
    display: flex;
    gap: 4px;
    align-items: center;
    justify-content: center;
}

.wp-el-icon,
.wp-pos-icon {
    width: 16px;
    height: 16px;
    object-fit: contain;
}

/* Column 2: Skills + Memo */
.wp-details {
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    justify-content: center;
}

.wp-skills {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.wp-skill-input {
    width: 100%;
    background: transparent;
    border: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.9);
    padding: 4px 0;
    font-size: 0.85rem;
    transition: border-color 0.2s;
}

.wp-skill-input:focus {
    border-bottom-color: var(--accent-color);
    outline: none;
}

.wp-skill-input::placeholder {
    color: rgba(255, 255, 255, 0.2);
}

.wp-memo-input {
    display: none;
    margin-top: 8px;
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid transparent;
    border-radius: 4px;
    color: #ccc;
    padding: 6px 8px;
    font-size: 0.8rem;
    box-sizing: border-box;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.wp-memo-input:focus {
    background: rgba(0, 0, 0, 0.4);
    border-color: rgba(255, 255, 255, 0.2);
    outline: none;
}

/* Wonder Slot Card (inside grid) - compact layout */
.wonder-slot-card {
    display: flex;
    flex-direction: column;
}

.ws-header {
    padding: 12px;
    background: rgb(0, 0, 0, 0.2);
    border-radius: 8px 8px 0 0;
    display: flex;
    justify-content: flex-start;
    align-items: flex-start;
}

/* ws-char-info - same style as slot-char-info */
.ws-char-info {
    display: flex;
    gap: 12px;
    margin-bottom: 0px;
    flex: 1;
}

/* Order image in Wonder slot - position relative to ws-header */
.ws-header {
    position: relative;
}

.ws-header .order-img {
    position: absolute;
    right: 12px;
    top: 12px;
}

.ws-char-img {
    width: 42px;
    height: 48px;
    border-radius: 8px;
    object-fit: cover;
    background: rgba(0, 0, 0, 0.3);
}

.ws-char-details {
    display: flex;
    flex-direction: column;
    overflow: visible;
}

.ws-char-name {
    font-weight: 700;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
}

.ws-char-details .slot-char-sub {
    font-size: 11px;
    opacity: 0.7;
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 4px;
}

.ws-char-details .slot-char-sub .meta-icon {
    width: 16px;
    height: 16px;
    object-fit: contain;
}

.ws-details {
    padding: 10px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
    justify-content: center;
}

.ws-order {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

/* Hide ws-order in non-edit mode */
body:not(.tactic-edit-mode) .ws-order {
    display: none !important;
}

/* Remove justify-content center in non-edit mode */

body:not(.tactic-edit-mode) .ws-details {
    padding: 10px;
}

.ws-order .order-label {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
}

.ws-order-select {
    width: 48px;
}

/* Styled Selects (reused from party slot) */
.styled-select-wrapper {
    position: relative;
    width: 100%;
}

.styled-select {
    width: 24px;
    padding: 4px 8px;
    background: #1f1f1f;
    border: 0px solid var(--border-color);
    border-radius: 6px;
    color: #fff;
    appearance: none;
    cursor: pointer;
    font-size: 12px;
    text-align: center;
}

.styled-select:focus {
    border-color: var(--accent-color);
    outline: none;
}

/* Wider dropdown options for ritual/mod/order selects (only affects expanded options) */
.ritual-select option,
.mod-select option,
.order-select option {
    min-width: 80px;
    padding: 4px 12px;
}

/* Preset Icons */
.preset-icons {
    display: inline-flex;
    align-items: center;
    gap: 0px;
    margin-left: 4px;
    vertical-align: middle;
}

.preset-icon {
    width: 20px;
    height: 20px;
    object-fit: contain;
}

.preset-icons img[src*="r0"],
.preset-icons img[src*="r1"],
.preset-icons img[src*="r2"],
.preset-icons img[src*="r3"],
.preset-icons img[src*="r4"],
.preset-icons img[src*="r5"],
.preset-icons img[src*="r6"] {
    scale: 0.85;
}

.preset-icons .stamp-icon {
    width: 18px;
    height: 18px;
    margin-bottom: 1px;
}

.preset-icons .stamp-roman {
    font-size: 11px;
    font-weight: 400;
    color: #ffffff;
    margin-left: 1px;
}

/* ==========================================================================
   Persona Modal Cards (Ported from persona.css)
   ========================================================================== */
.persona-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 16px;
    padding: 10px;
    justify-content: center;
}

.persona-detail-container {
    cursor: pointer;
    text-align: center;
    transition: transform 0.2s;
}

.persona-detail-container:active {
    transform: scale(0.95);
}

.persona-card-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.persona-detail-container .card {
    position: relative;
    width: 90px;
    aspect-ratio: 1/1.67;
    border-radius: 8px;
    overflow: hidden;
    transition: filter 0.2s, box-shadow 0.2s;
    background: #111;
}

.persona-detail-container:hover .card {
    filter: brightness(1.2);
    box-shadow: 0 0 0 2px var(--accent-color);
}

.persona-detail-container .image-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.persona-detail-container .card-background {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
    opacity: 0.5;
}

.persona-detail-container .persona-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 2;
    transform: translate(1%, 5%) scale(1.1);
    /* Slight zoom for better fill */
}

.persona-detail-container .element-icon {
    width: 16px;
    height: 16px;
    object-fit: contain;
    position: absolute;
    top: 4px;
    right: 4px;
    z-index: 5;
    filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.8));
}

.persona-detail-container .persona-name {
    font-size: 11px;
    color: #eee;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 90px;
    font-weight: 500;
}

/* J&C Role Change Button */
.btn-role-change {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    padding: 2px 6px;
    margin-left: 8px;
    cursor: pointer;
    transition: all 0.2s;
    height: 24px;
}

.btn-role-change:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
}

.btn-role-change .role-icon-img {
    width: 18px;
    height: 18px;
    object-fit: contain;
}

.role-change-hint {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
    line-height: 1;
}

.btn-role-change:hover .role-change-hint {
    color: #fff;
}

/* Force Downward positioning for Modal Dropdowns */
.target-dropdown {
    position: relative;
}

.target-dropdown-menu {
    position: absolute;
    top: 100% !important;
    bottom: auto !important;
    left: 0;
    width: 100%;
    margin-top: 4px;
    z-index: 1000;
    max-height: 200px;
    overflow-y: auto;
    background: #1b1b1b;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    display: none;
}

.target-dropdown-menu.active {
    display: block !important;
}

/* Modal specific dropdown item styling */
.target-dropdown-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: #ccc;
    cursor: pointer;
    transition: background 0.2s;
    text-align: left;
}

.target-dropdown-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.target-dropdown-item img {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    object-fit: cover;
}

.target-dropdown-item.selected {
    background: rgba(209, 31, 31, 0.2);
    color: #fff;
}


/* Action List for proper drag drop */
.action-list {
    min-height: 20px;
    display: flex;
    flex-direction: column;
    gap: 0px;
}

/* Action Item Styles */
.action-item .actor-dropdown .custom-select-text {
    font-size: 0.7rem;
}

.action-item .action-dropdown .custom-select-text {
    font-size: 0.8rem;
}

/* ==========================================================================
   Non-Edit Mode Restrictions (Global Party Settings)
   ========================================================================== */
body:not(.tactic-edit-mode) .ws-order-select,
body:not(.tactic-edit-mode) .styled-select,
body:not(.tactic-edit-mode) .btn-role-change,
body:not(.tactic-edit-mode) .weapon-select,
body:not(.tactic-edit-mode) .slot-card,
body:not(.tactic-edit-mode) .wp-header,
body:not(.tactic-edit-mode) .wonder-persona-card {
    pointer-events: none !important;
    cursor: default !important;
}

/* Allow character image link to be clickable in non-edit mode */
body:not(.tactic-edit-mode) .slot-char-link {
    pointer-events: auto !important;
    cursor: pointer !important;
}

/* Allow tooltip hover in non-edit mode for persona, weapon, revelation (but no click) */
body:not(.tactic-edit-mode) .revelation-button[data-tooltip],
body:not(.tactic-edit-mode) .wp-img-wrapper[data-tooltip],
body:not(.tactic-edit-mode) .wp-header .wp-img-wrapper[data-tooltip] {
    pointer-events: auto !important;
    cursor: help !important;
}

/* Prevent dropdown menu from opening in non-edit mode */
body:not(.tactic-edit-mode) .revelation-dropdown .revelation-menu,
body:not(.tactic-edit-mode) .revelation-dropdown.open .revelation-menu {
    display: none !important;
}

body:not(.tactic-edit-mode) .wonder-weapon-dropdown {
    padding: 0;
}

body:not(.tactic-edit-mode) .revelation-dropdown {
    pointer-events: none !important;
}

body:not(.tactic-edit-mode) .revelation-dropdown .revelation-button[data-tooltip] {
    pointer-events: auto !important;
}

body:not(.tactic-edit-mode) .btn-remove-slot {
    display: none !important;
}

/* Hide dropdown arrows in non-edit mode for cleaner look */
body:not(.tactic-edit-mode) .styled-select {
    appearance: none;
    background-image: none;
    padding-right: 6px;
    /* Remove space for arrow */
    text-align: center;
}

/* Dim disabled inputs slightly to indicate read-only */
body:not(.tactic-edit-mode) .styled-select,
body:not(.tactic-edit-mode) .revelation-button {
    opacity: 0.8;
    background: rgba(0, 0, 0, 0.2);
    border-color: transparent;
}

/* ==========================================================================
   View Mode - Hide Empty Elements
   ========================================================================== */

/* Hide tactic title container when input is empty (placeholder shown) in view mode */
body:not(.tactic-edit-mode) .tactic-title-container:has(.tactic-title-input:placeholder-shown) {
    display: none;
}

/* Hide tactic memo container when textarea is empty in view mode */
body:not(.tactic-edit-mode) .tactic-memo-container:has(.tactic-memo-input:placeholder-shown) {
    display: none;
}

/* Hide empty wp-memo-input in view mode */
body:not(.tactic-edit-mode) .wp-memo-input:placeholder-shown {
    display: none;
}

/* Also hide skill inputs in view mode if they're empty */
body:not(.tactic-edit-mode) .wp-skill-input:placeholder-shown {
    display: none;
}

/* ==========================================================================
   Critical Card Accordion (Simplified)
   ========================================================================== */

.critical-card-accordion,
.need-stat-card-accordion {
    background: rgba(0, 0, 0, 0.25);
    border-radius: 6px;
    margin-top: 0;
    overflow: hidden;
}

/* Need Stat Container - styled like roster-container */
.need-stat-container {
    background: var(--card-background);
    border-radius: 12px;
    border-bottom: 3px solid var(--border-red);
    padding: 12px 16px 12px 16px;
    margin-top: 16px;
}

/* Panel header with character name */
.need-stat-panel-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.need-stat-panel-char-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--accent-color);
}

/* Revelation Sum input row */
.need-stat-rev-sum-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 6px;
}

.need-stat-rev-sum-label {
    font-size: 11px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.6);
}

.need-stat-rev-sum-input {
    width: 70px;
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    color: #fff;
    font-size: 12px;
    text-align: center;
}

.need-stat-rev-sum-input:focus {
    outline: none;
    border-color: var(--accent-color);
}

.need-stat-extra-label {
    margin-left: 12px;
}

.need-stat-extra-sum-input {
    width: 60px;
    padding: 4px 6px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    color: #fff;
    font-size: 11px;
    text-align: center;
}

.need-stat-extra-sum-input:focus {
    outline: none;
    border-color: var(--accent-color);
}

.need-stat-extra-defense-input {
    width: 60px;
    padding: 4px 6px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    color: #fff;
    font-size: 11px;
    text-align: center;
}

.need-stat-extra-defense-input:focus {
    outline: none;
    border-color: var(--accent-color);
}

/* Two-column layout: Critical (left) / Pierce (right) */
.need-stat-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

/* Label hints for current/needed */
.need-stat-label-hint {
    font-size: 9px;
    color: rgba(255, 255, 255, 0.35);
    text-align: center;
}

/* Inline layout for total pair with / separator */
.need-stat-total-inline {
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

.need-stat-column-header .need-stat-total-inline .need-stat-current {
    margin-left: 4px;
    font-size: 13px;
    font-weight: 600;
}

.need-stat-separator {
    color: rgba(255, 255, 255, 0.4);
    font-size: 11px;
}

/* Revelation icon in label */
.need-stat-rev-icon {
    width: 14px;
    height: 14px;
    vertical-align: middle;
    margin-right: 4px;
    opacity: 0.8;
}

.need-stat-rev-sum-label {
    display: flex;
    align-items: center;
}

/* Elucidator inline input in trigger */
.need-stat-elucidator-inline-input {
    width: 48px;
    padding: 1px 6px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    color: #a4a4a4;
    font-size: 12px;
    font-weight: 600;
    text-align: center;
}

.need-stat-elucidator-inline-input:focus {
    outline: none;
    border-color: var(--accent-color);
}

.need-stat-elucidator-input-wrap {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    color: #a4a4a4;
    font-size: 12px;
}

.need-stat-total-editable {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.need-stat-column {
    background: rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

.need-stat-column-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: #1f1f1f;
    font-size: 12px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.8);
    gap: 6px;
}

.need-stat-column-header > span:first-child {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.need-stat-external-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.5);
    transition: color 0.2s;
    flex-shrink: 0;
}

.need-stat-external-link:hover {
    color: var(--accent-color);
}

.need-stat-external-link svg {
    width: 14px;
    height: 14px;
}

.need-stat-column .need-stat-body {
    max-height: 350px;
}

/* Pending state for Pierce column */
.need-stat-pending {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.3);
    text-align: center;
    padding: 20px;
    font-style: italic;
}

/* Elucidator input row */
.need-stat-elucidator-input-row {
    padding: 12px;
    display: flex;
    justify-content: center;
}

.need-stat-elucidator-input {
    width: 100px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    color: #fff;
    font-size: 14px;
    text-align: center;
}

.need-stat-elucidator-input:focus {
    outline: none;
    border-color: var(--accent-color);
}

/* Revelation sum row inside column */
.need-stat-column .need-stat-rev-sum-row {
    margin: 0;
    padding: 6px 10px;
    background: rgba(0, 0, 0, 0.15);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

/* Trigger: Need Stat title + 2 rows (Critical/Pierce) */
.need-stat-trigger {
    background: rgba(0, 0, 0, 0.25);
    border-radius: 6px;
    margin-top: 10px;
    margin-bottom: auto; /* Push to top, not bottom */
    overflow: hidden;
    position: relative;
    z-index: 0 !important; /* Lower than revelation dropdown */
}

/* Active trigger with inner shadow border */
.need-stat-trigger.open {
    box-shadow: inset 0 0 0 1px rgba(168, 0, 0);
}

/* Ensure revelation dropdown in slot-card is above need-stat-trigger */
.slot-card .revelation-dropdown {
    position: relative;
    z-index: 10;
}

.slot-card .revelation-dropdown.open {
    z-index: 2001;
}

.need-stat-trigger-header {
    display: flex;
    align-items: center;
    padding: 6px 10px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.03);
    transition: background 0.15s;
}

.need-stat-trigger-header:hover {
    background: rgba(255, 255, 255, 0.06);
}

/* Elucidator slot: no hover effect on trigger header */
.need-stat-trigger[data-slot-index="3"] .need-stat-trigger-header:hover {
    background: rgba(255, 255, 255, 0.03);
    cursor: default;
}

/* Table layout for trigger */
.need-stat-trigger-table {
    padding: 4px 10px 8px;
}

.need-stat-trigger-row {
    display: grid;
    grid-template-columns: 1fr 50px 50px 50px;
    align-items: center;
    padding: 2px 0;
    font-size: 11px;
}

.need-stat-trigger-header-row {
    padding-bottom: 4px;
    margin-bottom: 2px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.need-stat-trigger-col-header {
    color: rgba(255, 255, 255, 0.4);
    font-size: 9px;
    text-align: center;
}

.need-stat-trigger-label {
    color: rgba(255, 255, 255, 0.5);
    font-weight: 500;
}

.need-stat-trigger-row .need-stat-target,
.need-stat-trigger-row .need-stat-current,
.need-stat-trigger-row .need-stat-needed {
    text-align: center;
    font-size: 11px;
}

.need-stat-trigger-row .need-stat-target {
    color: rgba(255, 255, 255, 0.4);
}

.need-stat-trigger-row .need-stat-current {
    color: rgba(255, 255, 255, 0.6);
}

.need-stat-trigger-row .need-stat-needed {
    color: #bf9999;
    font-weight: 600;
}

/* Header: [toggle] [total] */
.crit-header,
.need-stat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.03);
    transition: background 0.15s;
}

.crit-header:hover,
.need-stat-header:hover {
    background: rgba(255, 255, 255, 0.06);
}

.crit-toggle,
.need-stat-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.6);
}

/* Caret: points right, rotates 90° clockwise when open */
.crit-caret,
.need-stat-caret {
    color: rgba(255, 255, 255, 0.4);
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.crit-caret.open,
.need-stat-caret.open {
    transform: rotate(90deg);
}

.crit-total {
    font-size: 13px;
    font-weight: 700;
    color: #ff6b6b;
}

.need-stat-total {
    display: inline-flex;
    align-items: baseline;
    gap: 2px;
}

.need-stat-current {
    font-size: 11px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.45);
}

.need-stat-sep {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.25);
}

.need-stat-needed {
    font-size: 13px;
    font-weight: 700;
    color: #ff6b6b;
}

/* Boss Settings Row */
.need-stat-boss-row {
    padding: 8px;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 4px;
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.need-stat-boss-header {
    display: flex;
    align-items: center;
    gap: 4px;
}

.need-stat-boss-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 4px 6px;
    font-size: 10px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 4px;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    transition: all 0.2s;
}

.need-stat-boss-tab:hover {
    background: rgba(255, 255, 255, 0.12);
}

.need-stat-boss-tab.active {
    background: rgba(209, 31, 31, 0.12);
    border-color: rgba(209, 31, 31, 0.3);
    color: white;
}

.need-stat-boss-type-icon {
    width: 14px;
    height: 14px;
    object-fit: contain;
}

.need-stat-boss-content {
    display: grid;
    grid-template-columns: 1fr 70px 70px;
    gap: 6px;
    align-items: end;
}

.need-stat-boss-content.need-stat-boss-content-2col {
    grid-template-columns: 1fr 80px;
}

.need-stat-boss-select-wrapper {
    width: 100%;
}

.need-stat-boss-dropdown {
    width: 100%;
    position: relative;
}

.need-stat-boss-button {
    width: 100%;
    padding: 5px 8px;
    font-size: 11px;
    display: flex;
    align-items: center;
    gap: 6px;
    justify-content: flex-start;
}

.need-stat-boss-btn-icon {
    width: 20px;
    height: 20px;
    border-radius: 3px;
    object-fit: cover;
}

.need-stat-boss-menu {
    max-height: 150px;
    overflow-y: auto;
    z-index: 100;
}

.need-stat-boss-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    box-sizing: border-box;
}

.need-stat-boss-option-icon {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    object-fit: cover;
}

.need-stat-boss-stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.need-stat-boss-stat label {
    font-size: 9px;
    color: rgba(255, 255, 255, 0.5);
}

.need-stat-boss-input {
    width: 100%;
    padding: 4px 6px;
    font-size: 11px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    color: white;
    text-align: center;
    box-sizing: border-box;
}

.need-stat-boss-input:focus {
    outline: none;
    border-color: var(--accent-color, #4a90d9);
}

/* Defense info row */
.need-stat-defense-info {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    margin-bottom: 6px;
    font-size: 10px;
}

.need-stat-defense-label {
    color: rgba(255, 255, 255, 0.5);
}

.need-stat-defense-value {
    color: #ff6b6b;
    font-weight: 600;
}

.need-stat-defense-sep {
    color: rgba(255, 255, 255, 0.3);
}

.need-stat-defense-required {
    color: #4ecdc4;
    font-weight: 600;
}

/* Defense info inline in header */
.need-stat-defense-info-inline {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    margin-left: auto;
    margin-right: 8px;
}

/* 주원 element icon scale */
img[src*="주원.png"] {
    transform: scale(0.85);
}

/* Body: hidden by default, shown when .open */
.crit-body,
.need-stat-body {
    display: none;
    padding: 8px;
    background: rgba(0, 0, 0, 0.15);
    max-height: 280px;
    overflow-y: auto;
}

.crit-body.open,
.need-stat-body.open {
    display: block;
}

/* Section: Buff / Self */
.crit-section,
.need-stat-section {
    margin-bottom: 8px;
}

.crit-section:last-child,
.need-stat-section:last-child {
    margin-bottom: 0;
}

.crit-section-title,
.need-stat-section-title {
    font-size: 10px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.4);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 6px;
    padding-bottom: 3px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

/* Row: [check] [icon] [source] [name] [select?] [value] */
.crit-row,
.need-stat-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 6px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 0;
    font-size: 11px;
    margin-bottom: 0;
    transition: background 0.15s;
    cursor: pointer;
}

.crit-row:hover,
.need-stat-row:hover {
    background: rgba(255, 255, 255, 0.07);
}

.crit-row.checked,
.need-stat-row.checked {
    background: rgba(209, 31, 31, 0.12);
}

/* Check icon */
.crit-check,
.need-stat-check {
    width: 16px;
    height: 16px;
    object-fit: contain;
    cursor: pointer;
    flex-shrink: 0;
    opacity: 0.8;
}

/* Check off state is smaller (75%) */
.need-stat-check.check-off {
    width: 12px;
    height: 12px;
    margin: 2px; /* center align with 16px container */
}

.crit-check:hover,
.need-stat-check:hover {
    opacity: 1;
}

/* Skill icon */
.crit-icon,
.need-stat-icon {
    width: 18px;
    height: 18px;
    object-fit: contain;
    flex-shrink: 0;
    border-radius: 3px;
}

span.crit-icon,
span.need-stat-icon {
    display: inline-block;
}

/* Target type label (자신/광역 등) */
.need-stat-target-type {
    font-size: 9px;
    color: rgba(255, 255, 255, 0.5);
    flex-shrink: 0;
    width: 42px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Source label */
.crit-source,
.need-stat-source {
    font-size: 9px;
    color: rgba(255, 255, 255, 0.45);
    flex-shrink: 0;
    min-width: 48px;
    max-width: 60px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Skill name */
.crit-name,
.need-stat-name {
    flex: 1;
    min-width: 0;
    color: rgba(255, 255, 255, 0.85);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* J&C 페르소나 성능 입력 필드 */
.need-stat-persona-performance {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    margin-right: 4px;
}

.need-stat-persona-label {
    font-size: 9px;
    color: rgba(255, 255, 255, 0.5);
    white-space: nowrap;
}

.need-stat-persona-input {
    width: 48px;
    padding: 2px 4px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 3px;
    color: #fff;
    font-size: 10px;
    text-align: center;
    flex-shrink: 0;
}

.need-stat-persona-input:focus {
    outline: none;
    border-color: var(--accent-color);
}

/* Options dropdown */
.crit-select,
.need-stat-select,
.need-stat-options {
    padding: 2px 4px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 3px;
    color: #fff;
    font-size: 10px;
    cursor: pointer;
    flex-shrink: 0;
}

.crit-select:focus,
.need-stat-select:focus,
.need-stat-options:focus {
    outline: none;
    border-color: var(--accent-color);
}

/* Value */
.crit-value,
.need-stat-value {
    font-weight: 600;
    color: #ff6b6b;
    flex-shrink: 0;
    min-width: 32px;
    text-align: right;
    font-size: 11px;
}

/* Empty state */
.crit-empty,
.need-stat-empty {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.25);
    text-align: center;
    padding: 8px;
}

/* Hide critical card in non-edit mode (but keep need-stat-trigger and need-stat-container visible) */
body:not(.tactic-edit-mode) .critical-card-accordion {
    display: none;
}

/* Allow need-stat-trigger to be clickable even in non-edit mode */
body:not(.tactic-edit-mode) .need-stat-trigger {
    pointer-events: auto !important;
    cursor: pointer !important;
}

body:not(.tactic-edit-mode) .need-stat-trigger input {
    pointer-events: auto !important;
    cursor: text !important;
}

/* Elucidator's need-stat-trigger-table should not show pointer in non-edit mode */
body:not(.tactic-edit-mode) .need-stat-trigger-table {
    pointer-events: none !important;
    cursor: default !important;
}

/* ==========================================================================
   Non-Edit Mode Adjustments
   ========================================================================== */

/* Adjust need-stat-trigger-row grid in non-edit mode */
body:not(.tactic-edit-mode) .need-stat-trigger-row {
    grid-template-columns: 1fr 44px 44px 44px;
}

/* ==========================================================================
   Responsive Styles (max-width: 1200px)
   ========================================================================== */
@media (max-width: 1200px) {
    /* Party slots container - flex wrap */
    body:not(.tactic-edit-mode) .party-slots-container {
        display: flex;
        flex-wrap: wrap;
        gap: 12px;
        max-width: none;
        margin-left: 0;
    }

    body:not(.tactic-edit-mode) .party-slots-container > .slot-card,
    body:not(.tactic-edit-mode) .party-slots-container > .wonder-in-party {
        flex: 1 1 200px;
        min-width: 180px;
        max-width: 300px;
    }

    /* Need stat columns - flex wrap */
    .need-stat-columns {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }

    .need-stat-columns > .need-stat-column {
        flex: 1 1 calc(50% - 4px);
        min-width: 280px;
    }

    /* Wonder personas grid - flex wrap */
    body:not(.tactic-edit-mode) .wonder-personas-grid {
        display: flex;
        flex-wrap: wrap;
        gap: 12px;
    }

    body:not(.tactic-edit-mode) .wonder-personas-grid > .wonder-persona-card {
        flex: 1 1 calc(33.33% - 8px);
        min-width: 280px;
        max-width: 400px;
    }

    /* Tactic table responsive */
    .tactic-table {
        min-width: 600px;
    }

    .tactic-cell {
        min-width: 120px;
    }
}

@media (max-width: 900px) {
    /* Further reduce for smaller screens */
    body:not(.tactic-edit-mode) .wonder-personas-grid > .wonder-persona-card {
        flex: 1 1 calc(50% - 6px);
        min-width: 250px;
    }

    .tactic-table {
        min-width: 500px;
    }

    .tactic-cell {
        min-width: 100px;
    }

    .col-turn {
        width: 40px;
        min-width: 40px;
    }
}

@media (max-width: 600px) {
    /* Stack on mobile */
    body:not(.tactic-edit-mode) .party-slots-container > .slot-card,
    body:not(.tactic-edit-mode) .party-slots-container > .wonder-in-party {
        flex: 1 1 100%;
        max-width: none;
    }

    .need-stat-columns > .need-stat-column {
        flex: 1 1 100%;
        min-width: 0;
    }

    body:not(.tactic-edit-mode) .wonder-personas-grid > .wonder-persona-card {
        flex: 1 1 100%;
        min-width: 0;
        max-width: none;
    }

    .tactic-table {
        min-width: 400px;
    }

    .tactic-cell {
        min-width: 80px;
        padding: 8px 4px;
    }

    .cell-char-header {
        padding: 4px 6px;
        margin: -8px -4px 6px -4px;
    }

    .cell-char-name {
        font-size: 0.7rem;
    }

    .action-item {
        padding: 2px 6px 2px 2px;
    }
}
