.legal-overlay {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(0, 0, 0, 0.78);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.legal-overlay.active {
    display: flex;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.legal-popup {
    position: relative;
    width: min(920px, 96vw);
    max-height: 88vh;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
    animation: legalFadeIn 0.35s ease-out;
    background-color: #f7fafc;
}

.legal-popup-inner {
    max-height: 88vh;
    overflow-y: auto;
    padding: 28px 24px 24px;
    background-color: #f7fafc;
    background-repeat: no-repeat;
    background-position: center;
    background-size: 100% 100%;
}

.legal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 5;
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 50%;
    background: #dc3545;
    color: #fff;
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.legal-close:hover {
    background: #b71c1c;
    transform: scale(1.06);
}

.legal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
    padding-right: 44px;
}

.legal-header-text {
    flex: 1;
    min-width: 0;
}

.legal-title {
    margin: 0 0 8px;
    font-size: clamp(1.4rem, 3vw, 2rem);
    font-weight: 700;
    color: #1a365d;
    font-family: 'Poppins', sans-serif;
}

.legal-logo {
    flex-shrink: 0;
    height: 46px;
    width: auto;
    max-width: 170px;
    object-fit: contain;
    margin-top: 2px;
}

.legal-body {
    color: #1a365d;
    font-size: 16px;
    line-height: 1.65;
}

.legal-body p {
    margin: 0 0 12px;
}

.legal-body h3,
.legal-body h4 {
    margin: 18px 0 8px;
    color: inherit;
    font-family: 'Poppins', sans-serif;
}

.legal-body ul,
.legal-body ol {
    margin: 0 0 12px 1.2em;
    padding: 0;
}

.legal-body li {
    margin-bottom: 6px;
}

.legal-body a {
    color: inherit;
    text-decoration: underline;
}

.legal-changelog {
    margin: 22px 0 0;
    padding-top: 14px;
    border-top: 1px solid rgba(26, 54, 93, 0.18);
}

.legal-changelog-line {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.6;
    color: inherit;
}

.legal-changelog-empty {
    font-weight: 400;
    opacity: 0.75;
}

.legal-close-bottom {
    display: block;
    margin: 20px auto 0;
    padding: 10px 32px;
    border: none;
    border-radius: 24px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: #1a365d;
    background: linear-gradient(135deg, #d4af37, #f1c40f);
    box-shadow: 0 0 10px 2px rgba(212, 175, 55, 0.35);
}

.legal-close-bottom:hover {
    transform: scale(1.03);
}

.terms-checkbox a.legal-popup-link {
    color: inherit;
    text-decoration: underline;
    cursor: pointer;
    font-weight: 600;
}

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

@media (max-width: 640px) {
    .legal-popup-inner { padding: 22px 14px 16px; }
    .legal-header { flex-wrap: wrap; padding-right: 40px; }
    .legal-logo { height: 38px; max-width: 140px; margin-left: auto; }
    .legal-header-text { width: 100%; }
}
