.modal-overlay {
    position: fixed;
    inset: 0;
    background-color: #000000b3;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
    -webkit-backdrop-filter: blur(5px);
    backdrop-filter: blur(5px)
}

.modal-content {
    background-color: var(--card-bg);
    color: var(--text-color);
    border-radius: 16px;
    width: 100%;
    max-width: 1000px;
    max-height: 90vh;
    position: relative;
    box-shadow: 0 10px 25px #0003;
    animation: modalFadeIn .3s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden
}

@keyframes modalFadeIn {
    0% {
        opacity: 0;
        transform: translateY(20px)
    }

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

.close-button {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 2rem;
    background: none;
    border: none;
    color: var(--text-color);
    cursor: pointer;
    z-index: 20;
    background-color: #ffffff80;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1
}

.modal-body {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow-y: auto
}

.modal-image-section {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
    position: relative;
    padding: 1rem 0
}

.modal-image-section img {
    width: auto;
    height: auto;
    max-width: 50%;
    max-height: 35vh;
    object-fit: contain
}

.modal-info-section {
    flex: 1.5;
    padding: 2rem;
    overflow-y: auto
}

@media(min-width:768px) {
    .modal-body {
        flex-direction: row;
        overflow: hidden
    }

    .modal-image-section {
        flex: 1;
        min-height: 300px;
        padding: 0
    }

    .modal-image-section img {
        width: 100%;
        height: 100%;
        max-width: 100%;
        max-height: 80vh
    }

    .modal-info-section {
        max-height: 90vh
    }
}

.mobile-mode .modal-body {
    flex-direction: column !important;
    overflow-y: auto !important
}

overflow: hidden;
}

.modal-image-section {
    flex: 1;
    min-height: 300px;
    padding: 0
}

.modal-image-section img {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 80vh
}

.modal-info-section {
    max-height: 90vh
}
}

.mobile-mode .modal-body {
    flex-direction: column !important;
    overflow-y: auto !important
}

.mobile-mode .modal-image-section {
    flex: 0 0 auto !important;
    padding: 1rem 0 !important
}

.mobile-mode .modal-image-section img {
    max-width: 50% !important;
    max-height: 35vh !important
}

.bonus-box {
    background-color: var(--bg-color);
    padding: 1rem;
    max-height: 35vh !important
}

.mobile-mode .modal-info-section {
    overflow-y: visible !important;
    max-height: none !important
}

.modal-header h2 {
    margin: .5rem 0;
    font-size: 2rem
}

.info-group {
    margin-bottom: 2rem
}

.info-group h3 {
    font-size: 1.1rem;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: .5rem;
    margin-bottom: 1rem;
    display: inline-block
}

.bonus-box ul {
    list-style: none
}

.tags {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap
}

.tag {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: .9rem;
    font-weight: 500
}

.tag.training {
    background-color: #e3f2fd;
    color: #1565c0
}

.tag.support {
    background-color: #e8f5e9;
    color: #2e7d32
}

.ability-box {
    background-color: var(--bg-color);
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: .8rem;
    border: 1px solid var(--input-border)
}

.ability-box strong {
    display: block;
    margin-bottom: .4rem;
    color: var(--primary-color)
}

.journey-list {
    display: flex;
    flex-direction: column;
    gap: 1rem
}

.journey-stage-card {
    background-color: var(--bg-color);
    border-radius: 8px;
    padding: 1rem;
    border: 1px solid var(--input-border)
}

.stage-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: .8rem;
    border-bottom: 1px solid var(--input-border);
    padding-bottom: .5rem
}

.stage-header h4 {
    margin: 0;
    color: var(--primary-color)
}

.events-list {
    display: flex;
    flex-direction: column;
    gap: .8rem
}

.event-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: .9rem
}

.event-num {
    font-weight: 700;
    color: #888;
    width: 30px
}

.choices-wrapper {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    align-items: stretch
}

.choice-box {
    display: flex;
    align-items: flex-start;
    gap: .8rem;
    background: #fff;
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
    width: 100%;
    box-sizing: border-box;
    box-shadow: 0 1px 3px #0000000d;
    word-break: break-all;
    white-space: normal
}

.choice-placeholder {
    width: 100%
}

[data-theme=dark] .choice-box {
    background: #2c2c2c;
    border-color: #444
}

.choice-label {
    font-weight: 700;
    font-size: .8rem;
    padding: 2px 6px;
    border-radius: 4px;
    min-width: 24px;
    text-align: center;
    margin-top: 2px
}

.choice-a .choice-label {
    background-color: #e3f2fd;
    color: #1565c0
}

.choice-b .choice-label {
    background-color: #fce4ec;
    color: #c2185b
}

.choice-content-single,
.effect-row {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    width: 100%
}

@media(min-width:768px) {

    .choice-content-single,
    .effect-row {
        flex-direction: row;
        align-items: center;
        gap: .5rem
    }
}

.mobile-mode .choice-content-single,
.mobile-mode .effect-row {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem
}

.bonus-box {
    background-color: var(--bg-color);
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid var(--input-border)
}

.bonus-box h4 {
    margin: 0 0 .5rem;
    font-size: .95rem;
    color: var(--text-color)
}

.choice-type {
    font-weight: 700;
    font-size: .9rem;
    color: var(--text-color)
}

.choice-value {
    font-size: .9rem;
    color: var(--primary-color);
    font-weight: 400
}

.bonus-box ul {
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: .9rem
}

.bonus-box li {
    margin-bottom: .2rem
}

.bonus-value {
    color: var(--primary-color);
    font-weight: 400
}

.app {
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1rem 2rem;
    background-color: #ffffffd9;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(0, 0, 0, .1);
    width: 100%;
    box-sizing: border-box;
    transition: background-color .3s
}

[data-theme=dark] .app-header {
    background-color: #1a1a1ad9;
    border-bottom: 1px solid rgba(255, 255, 255, .1)
}

.header-top {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%
}

.app-header h1 {
    margin: 0;
    font-size: 1.8rem;
    color: var(--text-color);
    text-align: center
}

.header-controls {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    gap: .5rem
}

.theme-toggle,
.mobile-toggle {
    background: transparent;
    border: 1px solid var(--input-border);
    padding: 8px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    color: var(--text-color);
    font-size: 1.2rem;
    transition: all .2s ease;
    display: flex;
    align-items: center;
    justify-content: center
}

.theme-toggle:hover,
.mobile-toggle:hover {
    background-color: var(--input-bg);
    border-color: var(--primary-color);
    transform: scale(1.1)
}

.header-bottom {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto
}

.filter-group {
    display: flex;
    gap: .8rem;
    flex-wrap: nowrap
}

.filter-select {
    padding: 10px 16px;
    font-size: 1rem;
    border: 2px solid var(--input-border);
    border-radius: 20px;
    background-color: var(--input-bg);
    color: var(--text-color);
    cursor: pointer;
    outline: none;
    transition: border-color .3s;
    white-space: nowrap
}

.filter-select:focus {
    border-color: var(--primary-color)
}

.search-input {
    flex: 1;
    max-width: 400px;
    padding: 10px 20px;
    font-size: 1rem;
    border: 2px solid var(--input-border);
    border-radius: 25px;
    transition: border-color .3s;
    background-color: var(--input-bg);
    color: var(--text-color);
    box-sizing: border-box
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-color)
}

@media(max-width:768px) {
    .app-header {
        padding: 1rem
    }

    .app-header h1 {
        font-size: 1.5rem
    }

    .header-bottom {
        flex-direction: column;
        gap: .8rem
    }

    .filter-group {
        width: 100%;
        justify-content: space-between
    }

    .filter-select {
        flex: 1;
        text-align: center
    }

    .search-input {
        width: 100%;
        max-width: none
    }
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
    padding: 1rem 2rem;
    width: 100%;
    box-sizing: border-box
}

@media(min-width:600px) {
    .card-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
        gap: 1.2rem
    }
}

@media(min-width:1200px) {
    .card-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 1.5rem
    }
}

.card-item {
    background: var(--card-bg);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 6px #0000001a;
    transition: transform .2s, box-shadow .2s;
    display: flex;
    flex-direction: column;
    cursor: pointer;
    border: 1px solid transparent
}

[data-theme=dark] .card-item {
    border-color: #333
}

.card-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 15px #00000026;
    border-color: var(--primary-color)
}

.card-image-wrapper {
    width: 100%;
    aspect-ratio: 2/3;
    background-color: #f9f9f9;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative
}

[data-theme=dark] .card-image-wrapper {
    background-color: #2a2a2a
}

.card-image-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .3s
}

.card-item:hover .card-image-wrapper img {
    transform: scale(1.05)
}

.no-image {
    color: #ccc;
    font-weight: 700
}

.card-content {
    padding: 1rem;
    flex-grow: 1;
    display: flex;
    flex-direction: column
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: .5rem
}

.rarity-badge {
    font-size: .75rem;
    padding: 2px 8px;
    border-radius: 10px;
    background-color: #eee;
    color: #555;
    font-weight: 700
}

.rarity-badge.SSR {
    background: linear-gradient(135deg, #f2aa4c, #ffc270);
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, .3);
    box-shadow: 0 2px 4px #f2aa4c4d
}

.rarity-badge.SR {
    background: linear-gradient(135deg, #cb85f7, #e0aaff);
    color: #fff;
    box-shadow: 0 2px 4px #cb85f74d
}

.rarity-badge.R {
    background-color: #cd7f32;
    color: #fff
}

h3 {
    margin: 0 0 .3rem;
    font-size: 1.1rem;
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis
}

.character-name {
    margin: 0;
    color: #888;
    font-size: .9rem
}

.stat-tag {
    background-color: var(--bg-color);
    color: var(--primary-color);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: .75rem;
    font-weight: 700;
    border: 1px solid var(--input-border)
}

[data-theme=dark] .card-item {
    color: #e0e0e0
}

[data-theme=dark] h3 {
    color: #fff
}

[data-theme=dark] .character-name {
    color: #b0b0b0
}

.app-footer {
    margin-top: auto;
    padding: 2rem;
    text-align: center;
    color: #888;
    font-size: .9rem;
    border-top: 1px solid var(--input-border);
    background-color: var(--bg-color);
    display: flex;
    flex-direction: column;
    align-items: center
}

.app-footer p {
    margin: .5rem 0;
    text-align: center
}

[data-theme=dark] .app-footer {
    color: #aaa;
    border-color: #444
}

:root {
    --primary-color: #646cff;
    --bg-color: #f0f2f5;
    --card-bg: #ffffff;
    --text-color: #213547;
    --header-bg: #ffffff;
    --input-bg: #ffffff;
    --input-border: #ddd
}

[data-theme=dark] {
    --primary-color: #a6acff;
    --bg-color: #1a1a1a;
    --card-bg: #242424;
    --text-color: rgba(255, 255, 255, .87);
    --header-bg: #242424;
    --input-bg: #2a2a2a;
    --input-border: #444
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: background-color .3s, color .3s;
    margin-bottom: 2rem
}

h1 {
    margin: 0
}

.theme-toggle {
    background: var(--card-bg);
    border: 1px solid var(--input-border);
    color: var(--text-color);
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: .9rem;
    transition: all .3s
}

.theme-toggle:hover {
    border-color: var(--primary-color)
}

/* Level Toggle Styles from deck.css */
.level-toggle {
    display: flex;
    gap: 5px;
    background: var(--bg-color);
    padding: 4px;
    border-radius: 8px;
}

.level-btn {
    padding: 6px 12px;
    border: none;
    background: transparent;
    color: var(--text-color);
    cursor: pointer;
    border-radius: 6px;
    font-weight: bold;
    transition: all 0.2s;
}

.level-btn.active {
    background: var(--primary-color);
    color: white;
}