/* ============================================
    공통 컴포넌트 (버튼, 모달, 입력, 테이블, 테그)
    ============================================ */

/* 스탯 선택기 */
.stat-display {
    background: #eef2ff;
    padding: 12px 20px;
    border-radius: 8px;
    color: #667eea;
    font-weight: 700;
    font-size: 1.2em;
    text-align: right;
    min-width: 50px;
    flex-shrink: 0;
}

.stat-selector {
    display: flex;
    align-items: center;
    gap: 12px;
    overflow: visible;
    flex-wrap: wrap;
}

.stat-circles {
    display: flex;
    gap: 25px;
    flex: 1;
    min-width: 0;
}

.stat-circle { position: relative; cursor: pointer; display: inline-block; }
.stat-circle input[type="radio"] { position: absolute; opacity: 0; }

.stat-circle span {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #ffffff;
    border: 3px solid #7a7a7a;
    font-weight: 700;
    font-size: 1.3rem;
    color: #636363;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.stat-circle:hover span { transform: translateY(-1px); }

.stat-circle input:checked + span {
    background: linear-gradient(#667eea, #764ba2, #fbb6ce);
    border-color: #ffffff;
    color: #ffffff;
    box-shadow: 0 6px 18px rgba(243, 109, 255, 0.35);
    transform: scale(1.05);
}

/* 스킬 타입 선택기 */
.skill-type-selector {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}

.skill-type-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    background: white;
    border: 2px solid #e3e6f0;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.skill-type-option:hover {
    border-color: #667eea;
    background: #f7fafc;
}

.skill-type-option input {
    display: none;
}

.skill-type-option:has(input:checked) {
    border-color: #667eea;
    background: #eef2ff;
}

.skill-type-option:has(input:checked) span {
    color: #667eea;
    font-weight: 700;
}

/* 스킬 대상 선택기 */
.skill-target-selector {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 10px;
}

.skill-target-option {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    background: white;
    border: 2px solid #e3e6f0;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.skill-target-option input {
    display: none;
}

.skill-target-option:hover {
    border-color: #667eea;
    background: #f7fafc;
}

.skill-target-option:has(input:checked) {
    border-color: #667eea;
    background: #eef2ff;
}

.skill-target-option:has(input:checked) span {
    color: #667eea;
    font-weight: 700;
}

.skill-include-self {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: #f8f9fc;
    border: 2px solid #e3e6f0;
    border-radius: 10px;
    margin-bottom: 16px;
    user-select: none;
}

.skill-include-self input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #667eea;
}

.skill-include-self input[type="checkbox"][disabled] {
    opacity: 0.5;
    cursor: not-allowed;
}

.skill-config-note {
    font-size: 12px;
    color: #718096;
    margin: -8px 0 16px 0;
    line-height: 1.4;
}

/* 스킬 사용 횟수 UI */
.skill-uses-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin: 8px 0 8px 0;
}

.skill-uses-field {
    background: #f8f9fc;
    border: 2px solid #e3e6f0;
    border-radius: 10px;
    padding: 10px;
}

.skill-uses-label {
    font-size: 12px;
    color: #718096;
    margin-bottom: 6px;
}

#skill-uses-max {
    width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    border: 2px solid #e3e6f0;
    background: #fff;
    font-size: 14px;
    transition: border-color 0.15s ease;
}

#skill-uses-max:focus {
    outline: none;
    border-color: #667eea;
}

.skill-uses-readonly {
    font-size: 18px;
    font-weight: 800;
    color: #2c3e50;
    padding: 8px 2px;
}

.skill-uses-status {
    margin-top: 6px;
    font-size: 13px;
    color: #4a5568;
    line-height: 1.4;
}

.skill-uses-status.is-locked {
    color: #c53030;
    font-weight: 800;
}

.skill-uses-note {
    margin-top: 6px;
    font-size: 12px;
    color: #718096;
    line-height: 1.4;
}

/* 숫자 입력 모달 (prompt 대체) */
.number-prompt-message {
    margin: 0 0 10px 0;
    line-height: 1.5;
    color: #4a5568;
    font-size: 14px;
}

.number-prompt-input {
    width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    border: 2px solid #e3e6f0;
    background: #fff;
    font-size: 16px;
    font-weight: 800;
    color: #2c3e50;
    transition: border-color 0.15s ease;
}

.number-prompt-input:focus {
    outline: none;
    border-color: #667eea;
}

.number-prompt-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 14px;
}

.skill-uses-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
    margin: 10px 0 4px 0;
}

@media (max-width: 520px) {
    .skill-uses-grid {
        grid-template-columns: 1fr;
    }
}

/* 상태 선택기 */
.status-selector {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.status-option {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px;
    background: white;
    border: 2px solid #e3e6f0;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.status-option:hover {
    border-color: #667eea;
}

.status-option input[type="radio"] {
    display: none;
}

.status-option input:checked ~ span {
    font-weight: 600;
}

.status-option:has(input:checked) {
    border-color: #667eea;
    background: #eef2ff;
}

/* 텍스트영역 */
textarea {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid #e3e6f0;
    border-radius: 10px;
    font-size: 0.95em;
    font-family: inherit;
    resize: vertical;
    transition: all 0.2s ease;
}

textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* 필터 패널 */
.filter-panel {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}

.filter-select {
    padding: 10px 14px;
    border: 2px solid #e3e6f0;
    border-radius: 10px;
    font-size: 0.9em;
    color: #2c3e50;
    background: white;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 180px;
}

.filter-select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* 캐릭터 목록 테이블 */
.character-list-table {
    background: #f8f9fc;
    border: 2px solid #e3e6f0;
    border-radius: 16px;
    padding: 20px;
    font-size: 15px;
}

/* 캐릭터 목록: 카드(가로로 긴 4:6 느낌) 레이아웃 */
.character-list-table.is-cards {
    display: grid;
    /* 기본은 3열: 카드가 넓게 보이도록 */
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    padding: 14px;
    align-items: stretch;
}

@media (max-width: 1280px) {
    .character-list-table.is-cards {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 980px) {
    .character-list-table.is-cards {
        grid-template-columns: 1fr;
    }
}

.char-card {
    background: #ffffff;
    border: 1px solid #e3e6f0;
    border-radius: 14px;
    padding: 10px 10px 8px;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.05);
    /* 가로를 더 길게(세로는 더 짧게) */
    aspect-ratio: 3 / 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow: hidden;
}

/* 소속별 테두리(왼쪽 얇은 라인) */
.char-card.team-hero { box-shadow: inset 4px 0 0 #60a5fa, 0 6px 18px rgba(0, 0, 0, 0.05); }
.char-card.team-gov { box-shadow: inset 4px 0 0 #a78bfa, 0 6px 18px rgba(0, 0, 0, 0.05); }
.char-card.team-villain { box-shadow: inset 4px 0 0 #f87171, 0 6px 18px rgba(0, 0, 0, 0.05); }

.char-card:hover {
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(102, 126, 234, 0.16);
}

.char-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-width: 0;
}

.char-card-team {
    font-weight: 900;
    color: #334155;
    font-size: 13px;
}

.char-card-name {
    font-weight: 1000;
    font-size: 17px;
    color: #1f2937;
    letter-spacing: -0.2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.char-card-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
}

.char-card-hp {
    display: grid;
    grid-template-columns: 1fr 58px;
    gap: 8px;
    align-items: center;
}

.char-card-hpbar {
    height: 8px;
    border-radius: 999px;
    overflow: hidden;
    background: #e2e8f0;
    border: 1px solid #cbd5e0;
}

.char-card-hpfill {
    display: block;
    height: 100%;
    width: 0;
    transition: width 0.3s ease;
}

.char-card-hpfill.hp-level--green {
    background: linear-gradient(90deg, #22c55e, #16a34a);
}

.char-card-hpfill.hp-level--yellow {
    background: linear-gradient(90deg, #facc15, #eab308);
}

.char-card-hpfill.hp-level--orange {
    background: linear-gradient(90deg, #fb923c, #f97316);
}

.char-card-hpfill.hp-level--red {
    background: linear-gradient(90deg, #ef4444, #dc2626);
}

.char-card-hptext {
    text-align: right;
    font-size: 12px;
    font-weight: 900;
    color: #475569;
    letter-spacing: -0.2px;
}

.char-card-stat {
    background: #f8fafc;
    border: 1px solid #e3e6f0;
    border-radius: 9px;
    padding: 4px 6px;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 5px;
    font-weight: 900;
    min-width: 0;
}

.char-card-stat .k {
    font-size: 10px;
    color: #64748b;
    white-space: nowrap;
    min-width: 0;
}

.char-card-stat .v {
    font-size: 13px;
    color: #0f172a;
    white-space: nowrap;
}

.char-card-skill {
    margin-top: 0;
}

.char-card-skillline {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.char-card-skill-types {
    display: flex;
    gap: 6px;
    flex-wrap: nowrap;
    align-items: center;
    white-space: nowrap;
    min-width: 0;
}

/* 카드 안에서 스킬 유형(태그)은 더 크게 */
.char-card .skill-tag {
    font-size: 12px;
    padding: 3px 8px;
    border-radius: 8px;
    flex: 0 0 auto;
}

.char-card-skill-sep {
    font-size: 13px;
    font-weight: 900;
    color: #94a3b8;
    flex: 0 0 auto;
}

.char-card-target {
    font-size: 13px;
    font-weight: 900;
    color: #475569;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (max-width: 520px) {
    .character-list-table.is-cards {
        grid-template-columns: 1fr;
    }
    .char-card {
        aspect-ratio: auto;
        min-height: 126px;
    }
}

.char-table-row {
    display: grid;
    grid-template-columns: 88px 190px 60px 56px 56px 56px 56px 150px 170px 120px;
    column-gap: 0;
    padding: 20px 16px;
    background: white;
    border: 1px solid #e3e6f0;
    border-radius: 12px;
    margin-bottom: 10px;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s ease;
    pointer-events: auto;
}

/* 소속별 테두리(왼쪽 얇은 라인) */
.char-table-row.team-hero { box-shadow: inset 4px 0 0 #60a5fa; }
.char-table-row.team-gov { box-shadow: inset 4px 0 0 #a78bfa; }
.char-table-row.team-villain { box-shadow: inset 4px 0 0 #f87171; }

.char-table-row:hover {
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
    transform: translateX(4px);
}

.char-table-row.header {
    background: #667eea;
    color: white;
    font-weight: 600;
    cursor: default;
    margin-bottom: 16px;
}

.char-table-row.header:hover {
    transform: none;
    box-shadow: none;
}

.char-table-cell {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 0 10px;
}

/* 컬럼 구분선 */
.char-table-cell + .char-table-cell {
    border-left: 1px solid #e3e6f0;
    padding-left: 14px;
}

.char-table-row.header .char-table-cell + .char-table-cell {
    border-left-color: rgba(255, 255, 255, 0.28);
}

/* 상태 셀은 클리핑되지 않도록 허용 */
.char-table-cell.status-cell {
    overflow: visible;
}

.char-skill-tags {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.skill-tag {
    font-size: 0.9em;
    padding: 3px 10px;
    background: #f1f5f9;
    color: #334155;
    border-radius: 6px;
    border: 1px solid #cbd5e0;
    font-weight: 700;
}

/* 스킬 타입별(저채도) */
.skill-tag.skill-tag--attack { background: #fff7ed; color: #9a3412; border-color: #fed7aa; }
.skill-tag.skill-tag--defense { background: #eff6ff; color: #1e3a8a; border-color: #bfdbfe; }
.skill-tag.skill-tag--support { background: #ecfeff; color: #155e75; border-color: #a5f3fc; }
.skill-tag.skill-tag--heal { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }

.char-status {
    font-size: 0.85em;
    padding: 4px 10px;
    border-radius: 6px;
    font-weight: 600;
    text-align: center;
}

.char-status.active {
    background: #c6f6d5;
    color: #276749;
}

.char-status.dead {
    background: #fed7d7;
    color: #9b2c2c;
}

.char-status.missing {
    background: #feebc8;
    color: #7c2d12;
}

/* 전투 기록 */
.battle-history-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.battle-record {
    background: #f8f9fc;
    border: 2px solid #e3e6f0;
    border-radius: 16px;
    padding: 20px;
    transition: all 0.2s ease;
}

.battle-record:hover {
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

.battle-record-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid #e3e6f0;
}

.battle-record-title {
    font-size: 1.1em;
    font-weight: 600;
    color: #667eea;
}

.battle-record-date {
    color: #718096;
    font-size: 0.9em;
}

.battle-record-body {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.battle-record-summary {
    grid-column: 1 / -1;
}

.battle-record-actions {
    grid-column: 1 / -1;
}

.battle-team-section {
    background: white;
    padding: 12px;
    border-radius: 10px;
    border: 2px solid #e3e6f0;
    min-width: 0;
}

.battle-team-title {
    font-weight: 600;
    color: #4a5568;
    margin-bottom: 8px;
    font-size: 0.95em;
}

.battle-team-chars {
    font-size: 0.85em;
    color: #718096;
    line-height: 1.6;
    overflow-wrap: anywhere;
}

.battle-winner {
    background: #c6f6d5;
    border-color: #9ae6b4;
}

.battle-winner .battle-team-title {
    color: #276749;
}

/* 버튼 */
.btn {
    padding: 14px 24px;
    border-radius: 12px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #e3e6f0;
    color: #4a5568;
}

.btn-secondary:hover {
    background: #cbd5e0;
}

.btn-management {
    padding: 12px;
    border: 2px solid #e3e6f0;
    border-radius: 10px;
    background: white;
    color: #4a5568;
    font-size: 0.9em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-management:hover {
    border-color: #667eea;
    background: #eef2ff;
    color: #667eea;
}

.btn-danger {
    background: #e53e3e;
    color: white;
}

.btn-danger:hover {
    background: #c53030;
}

.btn-action {
    background: #ffffff;
    color: #c53030;
    border: 1px solid #fca5a5;
    font-weight: 800;
    padding: 12px 16px;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.btn-action:hover {
    background: #ffecec;
}

/* 모달 */
.modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

/* 중앙 정렬 모달 */
.modal.centered {
    display: none; /* 기본은 숨김, 표시 시 block → flex로 변경 필요 */
}
.modal.centered[style*="display: block"],
.modal.centered[style*="display: flex"],
.modal.centered.show {
    display: flex !important;
    align-items: center;
    justify-content: center;
}
.modal.centered .modal-content {
    margin: 0;
    max-height: 90vh;
}

.modal-content {
    background: white;
    margin: 5% auto;
    padding: 0;
    border-radius: 20px;
    width: 90%;
    max-width: 560px;
    max-height: 84vh;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    position: relative;
    z-index: 10000;
    overflow: hidden; /* 내용이 모서리를 넘치지 않도록 클리핑 */
}

.modal-header {
    padding: 24px 28px;
    border-bottom: 2px solid #e3e6f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background: white;
    z-index: 1;
}

.modal-header h2 {
    color: #667eea;
    font-size: 1.4em;
    font-weight: 600;
}

.modal-actions {
    display: flex;
    gap: 30px;
    align-items: center;
}

.modal-close {
    background: none;
    border: none;
    font-size: 2em;
    color: #718096;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s ease;
}

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

.modal-body {
    padding: 28px 28px 36px; /* 하단 버튼이 튀어나오지 않도록 여유 추가 */
    overflow-y: auto;
    overflow-x: hidden;
    max-height: calc(80vh - 90px);
}

/* ===== 복붙용 프로필 텍스트(공용) ===== */
.profiles-text {
    width: 100%;
    min-height: 280px;
    resize: vertical;
    padding: 12px;
    border: 1px solid #0b1220;
    border-radius: 10px;
    background: #111827;
    color: #f8fafc;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 12px;
    line-height: 1.45;
}

.profiles-text:focus {
    outline: none;
    border-color: #1f2937;
    box-shadow: 0 0 0 3px rgba(17, 24, 39, 0.25);
}

.profiles-modal-actions {
    margin-top: 12px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* 전투 화면 복붙 모달: 더 큰 높이 + 더 넓은 폭 */
.profiles-copy-modal .modal-content {
    max-width: 920px;
    width: min(920px, calc(100% - 32px));
    max-height: 94vh;
    background: #0b1220;
    color: #e5e7eb;
    border: 1px solid rgba(255, 255, 255, 0.10);
    box-shadow: 0 16px 60px rgba(0, 0, 0, 0.55);
}

.profiles-copy-modal .modal-header {
    background: #0b1220;
    border-bottom: 1px solid rgba(255, 255, 255, 0.10);
}

.profiles-copy-modal .modal-header h2 {
    color: #f8fafc;
}

.profiles-copy-modal .modal-close {
    color: #cbd5e1;
}

.profiles-copy-modal .modal-close:hover {
    color: #ffffff;
}

.profiles-copy-modal .modal-body {
    background: #0b1220;
}

.profiles-copy-modal .modal-body {
    max-height: calc(94vh - 90px);
}

.profiles-copy-modal .profiles-text {
    min-height: 55vh;
}

/* 티커 편집 */
.ticker-editor-textarea {
    width: 100%;
    min-height: 220px;
    resize: vertical;
    padding: 12px;
    border: 1px solid #cbd5e0;
    border-radius: 10px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 12px;
    line-height: 1.55;
    background: #f8fafc;
    color: #1f2937;
}

.ticker-editor-controls {
    margin-top: 14px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}

.ticker-control {
    padding: 12px;
    border-radius: 12px;
    background: #ffffff;
    border: 1px solid #e3e6f0;
}

.ticker-control-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.ticker-control-label {
    font-weight: 900;
    color: #1f2937;
    font-size: 13px;
}

.ticker-control-hint {
    font-size: 12px;
    font-weight: 800;
    color: #64748b;
}

.ticker-control-range {
    width: 100%;
}

/* ===== 캐릭터 상세 모달(2단 레이아웃) ===== */
#custom-character-modal .modal-content {
    max-width: 1180px;
    width: min(1180px, 98vw);
}

#custom-character-modal .modal-body {
    overflow-x: auto; /* 스탯/라디오가 잘리지 않도록 */
}

#custom-character-modal .form-group {
    overflow: visible; /* stat-circles 클리핑 방지 */
}

#custom-character-modal .stat-circles {
    flex-wrap: wrap;
    gap: 40px;
}

.char-modal-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    align-items: start;
}

.char-modal-col {
    min-width: 0;
}

.char-modal-section-title {
    font-weight: 900;
    color: #2c3e50;
    margin: 0 0 10px;
    padding: 10px 12px;
    border-radius: 10px;
    background: #f3f6ff;
    border: 1px solid #e3e6f0;
}

.skill-template-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 10px 0;
}

.skill-template-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 14px;
    border: 2px solid #e3e6f0;
    background: linear-gradient(180deg, #ffffff 0%, #fbfcff 100%);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.05);
    transition: transform 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}

.skill-template-option:hover {
    border-color: #c7d2fe;
    box-shadow: 0 10px 24px rgba(102, 126, 234, 0.12);
    transform: translateY(-1px);
}

.skill-template-option input[type="checkbox"] {
    appearance: none;
    width: 44px;
    height: 26px;
    border-radius: 999px;
    background: #e2e8f0;
    border: 2px solid #cbd5e0;
    position: relative;
    cursor: pointer;
    flex: 0 0 auto;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.skill-template-option input[type="checkbox"]::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    transition: transform 0.15s ease;
}

.skill-template-option input[type="checkbox"]:checked {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: #667eea;
}

.skill-template-option input[type="checkbox"]:checked::after {
    transform: translateX(18px);
}

.skill-template-option:has(input[type="checkbox"]:checked) {
    border-color: #667eea;
}

.skill-template-option .desc {
    font-size: 13px;
    color: #4a5568;
    line-height: 1.35;
}

.skill-template-preview {
    border: 1px solid #e3e6f0;
    border-radius: 12px;
    background: #f8f9fc;
    padding: 12px;
    margin: 10px 0 14px;
    color: #2c3e50;
    font-size: 13px;
    line-height: 1.45;
}

.skill-template-preview .title {
    font-weight: 900;
    margin-bottom: 8px;
}

.skill-template-preview .row {
    margin: 6px 0;
    color: #4a5568;
}

.skill-template-preview .row strong {
    color: #2c3e50;
}

@media (max-width: 920px) {
    .char-modal-grid {
        grid-template-columns: 1fr;
    }
}

/* ===== 스킬 템플릿 라이브러리 모달(캐릭터 모달 톤) ===== */
#skill-template-library-modal .modal-content.skill-template-library-content {
    max-width: 1180px;
    width: min(1180px, 98vw);
}

/* 2단 분할 대신: 위(목록) / 아래(편집) 단일 컬럼 */
.skill-template-library-stack {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.skill-template-library-sidebar {
    min-width: 0;
    border: 1px solid #e3e6f0;
    border-radius: 14px;
    background: linear-gradient(180deg, #ffffff 0%, #fbfcff 100%);
    padding: 14px;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.06);
}

.skill-template-library-sidebar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}

.skill-template-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 26vh;
    overflow: auto;
}

.skill-template-list-item {
    padding: 12px 14px;
    border-radius: 12px;
    border: 2px solid #e3e6f0;
    background: #ffffff;
    color: #2c3e50;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}

.skill-template-list-item:hover {
    border-color: #c7d2fe;
    box-shadow: 0 10px 24px rgba(102, 126, 234, 0.12);
    transform: translateY(-1px);
}

.skill-template-library-editor {
    min-width: 0;
    border: 1px solid #e3e6f0;
    border-radius: 14px;
    background: #ffffff;
    padding: 14px;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.06);
}

/* 템플릿 스킬 타입(체크박스)도 캐릭터 모달 칩 스타일 그대로 사용 */
.template-skill-type-selector {
    margin-bottom: 0;
}

@media (max-width: 520px) {
    .template-skill-type-selector {
        grid-template-columns: 1fr;
    }
}

/* 라이브러리 셀렉트도 입력 UI와 톤 맞추기 */
#skill-template-library-modal .form-group select,
#skill-template-library-modal .form-group textarea {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid #e3e6f0;
    border-radius: 10px;
    font-size: 1em;
    transition: all 0.2s ease;
    background: linear-gradient(180deg, #ffffff 0%, #fbfcff 100%);
}

#skill-template-library-modal .form-group textarea {
    min-height: 90px;
    resize: vertical;
}

#skill-template-library-modal .form-group select:focus,
#skill-template-library-modal .form-group textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.12);
}

.skill-template-editor-block {
    border: 1px solid #e3e6f0;
    border-radius: 14px;
    background: #f8f9fc;
    padding: 12px;
}

.skill-template-editor-title {
    margin: 0 0 10px;
    color: #2c3e50;
    font-weight: 900;
}

/* 블록 상단에 너무 붙어 보이지 않게(템플릿 에디터 전용) */
.skill-template-editor-block .skill-template-editor-title {
    margin-top: 6px;
}

/* =============================
   Chase Event (도주 이벤트)
   ============================= */

#chase-event-modal .modal-content {
    font-size: 18px;
    font-weight: 750;
    font-family: 'Noto Sans KR', system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
    letter-spacing: -0.2px;
}

#chase-event-modal .modal-body {
    padding: 18px;
}

.chase-readonly {
    width: 100%;
    box-sizing: border-box;
    padding: 12px 12px;
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    background: rgba(255, 255, 255, 0.92);
    font-weight: 900;
    font-size: 18px;
    color: rgba(0, 0, 0, 0.8);
}

.chase-grid {
    display: grid;
    grid-template-columns: 360px 1fr;
    gap: 14px;
}

@media (max-width: 820px) {
    .chase-grid {
        grid-template-columns: 1fr;
    }
}

.chase-card {
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 14px;
    padding: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
    font-weight: 750;
}

.chase-board {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 10px;
}

.chase-cell {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    padding: 12px 10px;
    min-height: 74px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
    font-size: 16px;
}

.chase-cell-index {
    font-size: 13px;
    color: rgba(0, 0, 0, 0.55);
    font-weight: 800;
}

.chase-tokens {
    display: flex;
    gap: 6px;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
}

.chase-token {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 8px;
    border-radius: 999px;
    font-weight: 900;
    font-size: 16px;
    line-height: 1;
}

.chase-token.runner {
    background: rgba(46, 204, 113, 0.14);
    border: 1px solid rgba(46, 204, 113, 0.32);
    color: #1e874b;
}

.chase-token.chaser {
    background: rgba(231, 76, 60, 0.14);
    border: 1px solid rgba(231, 76, 60, 0.32);
    color: #a52e22;
}

.chase-log {
    width: 100%;
    box-sizing: border-box;
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    padding: 10px 12px;
    /* 전투 로그(로그 패널) 느낌의 모노스페이스 기반 */
    font-family: 'Courier New', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: 16px;
    font-weight: 750;
    line-height: 1.55;
    background: rgba(255, 255, 255, 0.9);
}

.chase-log {
    min-height: 360px;
    resize: vertical;
}

/* 상태 텍스트(현재 차례/종료) 가독성 */
#chase-status {
    font-size: 22px;
    font-weight: 900;
    line-height: 1.25;
}

/* 도주 이벤트 버튼 통일감(크기) + 색상 구분 */
.chase-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.chase-actions .btn {
    min-width: 150px;
    height: 46px;
    padding: 0 14px;
    border-radius: 12px;
    font-weight: 900;
    font-size: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(0, 0, 0, 0.12);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
}

.chase-actions .btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    box-shadow: none;
}

#chase-start {
    background: #3498db;
    border-color: rgba(0, 0, 0, 0.12);
    color: #ffffff;
}

#chase-roll {
    background: #1f5fa8;
    border-color: rgba(0, 0, 0, 0.12);
    color: #ffffff;
}

#chase-mini-attack {
    background: #f1c40f;
    border-color: rgba(0, 0, 0, 0.12);
    color: rgba(0, 0, 0, 0.85);
}

#chase-reset {
    background: #ffffff;
    border: 2px solid #e74c3c;
    color: #e74c3c;
    box-shadow: 0 6px 18px rgba(231, 76, 60, 0.18);
}

/* 종료 연출 배너 */
.chase-fx-banner {
    position: sticky;
    top: 0;
    z-index: 5;
    margin: 0 0 14px;
    padding: 14px 16px;
    border-radius: 14px;
    font-weight: 1000;
    font-size: 22px;
    line-height: 1.2;
    text-align: center;
    border: 1px solid rgba(0, 0, 0, 0.12);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
    backdrop-filter: blur(6px);
    animation: chaseFxPop 180ms ease-out;
}

.chase-fx-banner.is-escaped {
    background: rgba(46, 204, 113, 0.16);
    color: #1e874b;
    border-color: rgba(46, 204, 113, 0.35);
}

.chase-fx-banner.is-caught {
    background: rgba(231, 76, 60, 0.16);
    color: #a52e22;
    border-color: rgba(231, 76, 60, 0.35);
}

@keyframes chaseFxPop {
    from { transform: translateY(-8px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.template-cond-row,
.template-eff-row {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    padding: 10px;
    border-radius: 12px;
    border: 2px solid #e3e6f0;
    background: #ffffff;
    margin-bottom: 10px;
}

.template-eff-row .eff-extra {
    width: 100%;
}

.skill-template-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 14px;
    flex-wrap: wrap;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow: visible;
}

.form-group label {
    color: #4a5568;
    font-weight: 600;
    font-size: 0.95em;
}

.form-group input[type="text"],
.form-group input[type="number"] {
    padding: 12px 14px;
    border: 2px solid #e3e6f0;
    border-radius: 10px;
    font-size: 1em;
    transition: all 0.2s ease;
}

/* 셀렉트(소속 등)도 입력 UI와 통일 */
#custom-character-modal .form-group select {
    width: 100%;
    padding: 12px 44px 12px 14px; /* 우측 화살표 공간 */
    border: 2px solid #e3e6f0;
    border-radius: 10px;
    font-size: 1em;
    font-weight: 700;
    color: #2c3e50;
    background: linear-gradient(180deg, #ffffff 0%, #fbfcff 100%);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.04);
    transition: all 0.2s ease;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    cursor: pointer;

    /* 드롭다운 화살표 */
    background-image:
        linear-gradient(45deg, transparent 50%, #667eea 50%),
        linear-gradient(135deg, #667eea 50%, transparent 50%),
        linear-gradient(180deg, #ffffff 0%, #fbfcff 100%);
    background-position:
        calc(100% - 20px) 52%,
        calc(100% - 14px) 52%,
        0 0;
    background-size:
        6px 6px,
        6px 6px,
        100% 100%;
    background-repeat: no-repeat;
}

#custom-character-modal .form-group select:hover {
    border-color: #c7d2fe;
    box-shadow: 0 10px 24px rgba(102, 126, 234, 0.12);
}

#custom-character-modal .form-group select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.12);
}

/* 소속 셀렉트는 조금 더 강조 */
#custom-character-modal #char-team {
    border-color: #dbe4ff;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* 폼 필드 힌트(예: 수정 전 HP) */
.field-hint {
    margin-top: 6px;
    font-size: 12px;
    color: #64748b;
}

.form-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 24px;
}

/* 확인 모달 버튼 정렬: 오른쪽 정렬 */
.confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* 토스트 */
.toast-container {
    position: fixed;
    bottom: 48px;
    right: 48px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    z-index: 10001;
}

.toast {
    min-width: 520px;
    max-width: 840px;
    background: #ffffff;
    border: 2px solid #e3e6f0;
    border-radius: 24px;
    box-shadow: 0 10px 24px rgba(0,0,0,0.12);
    padding: 24px 28px;
    display: flex;
    align-items: flex-start;
    gap: 20px;
    color: #2d3748;
    font-size: 20px;
    animation: toast-slide-in 250ms ease-out;
}

.toast-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast-title { font-weight: 800; color: #4a5568; font-size: 0.95em; }
.toast-message { font-size: 1em; line-height: 1.4; }

.toast.success { border-color: #9ae6b4; background: #f0fff4; }
.toast.success .toast-title { color: #276749; }

.toast.info { border-color: #90cdf4; background: #ebf8ff; }
.toast.info .toast-title { color: #2b6cb0; }

.toast.warning { border-color: #fbd38d; background: #fffaf0; }
.toast.warning .toast-title { color: #b7791f; }

.toast.danger { border-color: #feb2b2; background: #fff5f5; }
.toast.danger .toast-title { color: #c53030; }

@keyframes toast-slide-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes toast-fade-out {
    from { opacity: 1; }
    to   { opacity: 0; }
}

@media (max-width: 520px) {
    .toast-container {
        left: 12px;
        right: 12px;
        bottom: 12px;
    }
    .toast {
        min-width: 0;
        max-width: none;
        width: 100%;
        padding: 18px 18px;
        border-radius: 18px;
        font-size: 18px;
    }
}
