.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 500;
    background: rgba(9, 11, 16, .92);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s;
}

.modal-overlay.open {
    opacity: 1;
    pointer-events: all;
}

/* ─── SHARED ─────────────────────────────────────────────────── */

.modal,
.login-modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    width: 100%;
    transform: scale(.97) translateY(10px);
    transition: transform .3s;
}

.modal-overlay.open .modal,
.modal-overlay.open .login-modal {
    transform: scale(1) translateY(0);
}

/* ─── DETAIL MODAL ───────────────────────────────────────────── */

.modal {
    max-width: 820px;
    max-height: 90vh;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
}

.modal-banner-placeholder {
    width: 100%;
    height: 200px;
    background: linear-gradient(135deg, #1a1e2b 0%, #0e1118 100%);
    border-radius: 18px 18px 0 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background-size: cover;
    background-position: center;
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(0, 0, 0, .6);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--muted);
    width: 36px;
    height: 36px;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color .2s;
}

.modal-close:hover {
    color: var(--text);
}

.modal-inner {
    display: grid;
    grid-template-columns: 150px 1fr;
    gap: 1.5rem;
    padding: 1.5rem;
    align-items: start;
}

.modal-poster {
    width: 150px;
    aspect-ratio: 2/3;
    object-fit: cover;
    border-radius: 10px;
    margin-top: -70px;
    position: relative;
    border: 3px solid var(--surface);
    box-shadow: 0 8px 30px rgba(0, 0, 0, .5);
    background: var(--surface2);
}

.modal-content {
    min-width: 0;
}

.modal-title {
    font-family: 'Cinzel', serif;
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: .25rem;
}

.modal-title-jp {
    font-family: 'Noto Serif JP', serif;
    font-size: .85rem;
    color: var(--muted);
    margin-bottom: .9rem;
}

.modal-stats {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.modal-stat {
    text-align: center;
}

.modal-stat-val {
    font-size: 1.2rem;
    font-weight: 500;
    color: var(--text);
}

.modal-stat-val.gold { color: var(--gold); }
.modal-stat-val.cyan { color: var(--cyan); }
.modal-stat-val.accent { color: var(--accent); }

.modal-stat-lbl {
    font-size: .7rem;
    color: var(--muted);
    letter-spacing: .06em;
    text-transform: uppercase;
}

.modal-desc {
    font-size: .88rem;
    line-height: 1.7;
    color: rgba(232, 234, 240, .75);
    margin-bottom: 1.2rem;
}

.modal-tags {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
    margin-bottom: 1.2rem;
}

.tag {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: .28rem .75rem;
    font-size: .75rem;
    color: var(--muted);
    transition: color .2s, border-color .2s;
}

.tag:hover {
    color: var(--text);
    border-color: var(--muted);
}

.modal-actions {
    display: flex;
    gap: .75rem;
    flex-wrap: wrap;
}

/* ─── BUTTONS ────────────────────────────────────────────────── */

.btn-outline,
.btn-fav-modal,
.btn-mal {
    border-radius: 9px;
    font-size: .85rem;
    padding: .6rem 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: .45rem;
    transition: opacity .2s, transform .15s, border-color .2s, background .2s;
}

.btn-outline {
    background: none;
    border: 1px solid var(--border);
    color: var(--text);
    font-weight: 400;
}

.btn-outline:hover {
    background: var(--surface2);
    border-color: var(--muted);
}

#btn-login-skip {
    width:100%;
    justify-content:center;
}

.btn-fav-modal {
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    border: none;
    color: #fff;
    font-weight: 500;
}

.btn-fav-modal:hover {
    opacity: .85;
    transform: translateY(-1px);
}

.btn-mal {
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text);
    text-decoration: none;
}

.btn-mal:hover {
    border-color: var(--cyan);
    color: var(--cyan);
}

/* ─── RELATED ────────────────────────────────────────────────── */

.modal-section {
    padding: 0 1.5rem 1.5rem;
}

.modal-section-title {
    font-size: .7rem;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: .75rem;
}

.related-grid {
    display: flex;
    gap: .75rem;
    overflow-x: auto;
    padding-bottom: .5rem;
    scrollbar-width: thin;
}

.related-card {
    flex: 0 0 100px;
    cursor: pointer;
}

.related-card img {
    width: 100px;
    aspect-ratio: 2/3;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--border);
    display: block;
    margin-bottom: .4rem;
    transition: border-color .2s;
}

.related-card:hover img {
    border-color: var(--accent);
}

.related-card p {
    font-size: .72rem;
    color: var(--muted);
    line-height: 1.3;
}

/* ─── LOGIN MODAL ────────────────────────────────────────────── */

.login-modal {
    max-width: 420px;
    padding: 2.5rem 2rem;
    text-align: center;
}

.login-icon {
    width: 60px;
    height: 60px;
    background-image: url("/favicon.svg");
    background-size: cover;
    border-radius: 14px;
    margin: 0 auto 1.25rem;
}

.login-title {
    font-family: 'Cinzel', serif;
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: .5rem;
}

.login-sub {
    font-size: .88rem;
    color: var(--muted);
    line-height: 1.6;
    margin-bottom: 1.75rem;
}

.btn-mal-login {
    width: 100%;
    background: #2e51a2;
    border: none;
    border-radius: 10px;
    color: #fff;
    font-size: .92rem;
    font-weight: 500;
    padding: .85rem;
    cursor: pointer;
    margin-bottom: .75rem;
    transition: opacity .2s;
}

.btn-mal-login:hover {
    opacity: .85;
}

.login-note {
    font-size: .75rem;
    color: var(--muted);
    margin-top:1rem;
}