.twofactor-modal,
.discord-confirm-modal {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    padding: 24px;
    background: rgba(2, 7, 18, 0.82);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    backdrop-filter: blur(6px);
}
html.twofactor-modal-open,
body.twofactor-modal-open {
    overflow: hidden !important;
}

.twofactor-modal-content,
.discord-confirm-content {
    position: relative;
    width: min(100%, 460px);
    padding: 28px 24px 24px;
    border-radius: 18px;
    border: 1px solid rgba(32, 212, 248, 0.24);
    background:
        radial-gradient(circle at top, rgba(22, 100, 127, 0.18), transparent 42%),
        linear-gradient(180deg, rgba(18, 22, 30, 0.98), rgba(8, 11, 18, 0.98));
    box-shadow:
        0 28px 70px rgba(0, 0, 0, 0.58),
        0 0 24px rgba(32, 212, 248, 0.12),
        inset 0 1px 0 rgba(255, 255, 255, 0.04);
    color: #eef7ff;
    overflow: hidden;
}
.twofactor-modal-content::before,
.discord-confirm-content::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    background:
        linear-gradient(rgba(32, 212, 248, 0.7), rgba(32, 212, 248, 0.7)) left top / 42px 2px no-repeat,
        linear-gradient(rgba(32, 212, 248, 0.7), rgba(32, 212, 248, 0.7)) left top / 2px 42px no-repeat,
        linear-gradient(rgba(32, 212, 248, 0.7), rgba(32, 212, 248, 0.7)) right top / 42px 2px no-repeat,
        linear-gradient(rgba(32, 212, 248, 0.7), rgba(32, 212, 248, 0.7)) right top / 2px 42px no-repeat,
        linear-gradient(rgba(32, 212, 248, 0.7), rgba(32, 212, 248, 0.7)) left bottom / 42px 2px no-repeat,
        linear-gradient(rgba(32, 212, 248, 0.7), rgba(32, 212, 248, 0.7)) left bottom / 2px 42px no-repeat,
        linear-gradient(rgba(32, 212, 248, 0.7), rgba(32, 212, 248, 0.7)) right bottom / 42px 2px no-repeat,
        linear-gradient(rgba(32, 212, 248, 0.7), rgba(32, 212, 248, 0.7)) right bottom / 2px 42px no-repeat;
    filter: drop-shadow(0 0 10px rgba(32, 212, 248, 0.35));
}
.twofactor-close,
.discord-confirm-close {
    background: transparent;
    border: none;
    color: #eaf8ff;
    font-size: 24px;
    position: absolute;
    top: 10px;
    right: 12px;
    line-height: 1;
    cursor: pointer;
    z-index: 2;
}
.twofactor-modal-content h3,
.discord-confirm-content h3 {
    margin: 0 0 10px;
    color: #ffffff;
    font-family: "Oxanium", sans-serif;
    font-size: clamp(24px, 2.2vw, 30px);
    font-weight: 700;
    line-height: 1.1;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.twofactor-modal-content p,
.discord-confirm-content p {
    margin: 0 0 16px;
    color: #c4d9ea;
    line-height: 1.55;
}
.twofactor-modal-content label,
.discord-confirm-content label {
    display: block;
    margin-bottom: 8px;
    color: #a6c7dc;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.twofactor-modal .action-btn,
.discord-confirm-modal .action-btn {
    width: 100%;
    min-height: 44px;
    padding: 0 16px;
    border: 1px solid #22d3ee;
    border-radius: 8px;
    color: #d8fbff;
    background: linear-gradient(180deg, rgba(32, 212, 248, 0.3), rgba(22, 100, 127, 0.38));
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.6px;
    cursor: pointer;
    transition: box-shadow 0.2s ease, filter 0.2s ease;
}

.discord-confirm-modal .action-btn {
    width: 48%;

}
.twofactor-modal .action-btn:hover,
.discord-confirm-modal .action-btn:hover {
    box-shadow: 0 0 16px rgba(32, 212, 248, 0.35);
    filter: brightness(1.05);
}
.twofactor-modal .action-btn:disabled,
.discord-confirm-modal .action-btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    box-shadow: none;
}
.twofactor-qr {
    display: flex;
    justify-content: center;
    margin: 12px 0;
}
.twofactor-qr img {
    border: 4px solid rgba(32, 212, 248, 0.14);
    border-radius: 12px;
    background: #fff;
}
.twofactor-secret {
    background: rgba(7, 12, 22, 0.9);
    border: 1px dashed rgba(32, 212, 248, 0.32);
    padding: 12px 14px;
    border-radius: 12px;
    margin-bottom: 12px;
    word-break: break-all;
    color: #d6efff;
}
#twofactor-code,
#twofactor-login-code,
#twofactor-pin-code,
#twofactor-password-code,
#twofactor-email-code,
#twofactor-deletechar-code,
.discord-confirm-content input {
    width: 100%;
    height: 48px;
    padding: 0 14px;
    margin: 8px 0 6px 0;
    border: 1px solid rgba(32, 212, 248, 0.22);
    border-radius: 10px;
    background: rgba(4, 8, 15, 0.88);
    color: #fff;
    box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.35);
}
#twofactor-code:focus,
#twofactor-login-code:focus,
#twofactor-pin-code:focus,
#twofactor-password-code:focus,
#twofactor-email-code:focus,
#twofactor-deletechar-code:focus,
.discord-confirm-content input:focus {
    outline: none;
    border-color: rgba(32, 212, 248, 0.7);
    box-shadow: 0 0 0 3px rgba(32, 212, 248, 0.12), inset 0 0 12px rgba(0, 0, 0, 0.35);
}
#twofactor-message,
#twofactor-login-message,
#twofactor-pin-message,
#twofactor-password-message,
#twofactor-email-message,
#twofactor-deletechar-message {
    min-height: 22px;
    margin-bottom: 8px;
    color: #fff;
}
.messageSuccess { color: #fff; }
.messageError { color: #fff; }
.twofactor-enabled {
    position: relative;
    cursor: not-allowed;
    overflow: visible;
}
.twofactor-enabled::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 50%;
    bottom: calc(100% + 8px);
    transform: translateX(-50%);
    background: linear-gradient(180deg, rgba(18, 22, 30, 0.98), rgba(8, 11, 18, 0.98));
    color: #fff;
    padding: 8px 10px;
    border: 1px solid rgba(32, 212, 248, 0.22);
    border-radius: 8px;
    white-space: nowrap;
    font-size: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.35);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease, transform 0.15s ease;
    z-index: 100000;
}
.twofactor-enabled:hover::after {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -10px);
}

/* Discord link badge */
.discord-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid #233044;
    background: linear-gradient(135deg, #5865f2, #4752c4);
    color: #fff;
    text-decoration: none;
    min-width: 180px;
}
.discord-link[type="submit"],
button.discord-link {
    appearance: none;
    -webkit-appearance: none;
    font: inherit;
    cursor: pointer;
    text-align: left;
}
.discord-unlink-form {
    display: inline-flex;
    margin: 0;
}
.discord-unlink-button {
    width: auto;
    flex: 0 0 auto;
    max-width: 100%;
}
.account-modal-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 8px;
}
.account-modal-actions .action-btn {
    min-width: 140px;
}
.discord-confirm-modal .table-action-danger {
    border-color: rgba(255, 111, 127, 0.68);
    color: #ffd9df;
    background: linear-gradient(180deg, rgba(120, 24, 46, 0.62), rgba(78, 13, 30, 0.74));
}
.discord-confirm-modal .table-action-danger:hover {
    box-shadow: 0 0 18px rgba(255, 111, 127, 0.28);
}
#discord-unlink-message {
    min-height: 0;
    margin-bottom: 6px;
}
#discord-unlink-message:empty {
    display: none;
}
#discord-unlink-message:not(:empty) {
    display: block;
}
.discord-link img {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #0e1726;
}
.discord-link .discord-name {
    font-weight: 600;
    font-size: 14px;
    line-height: 1.2;
    white-space: nowrap;
}
.discord-link .discord-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #0e1726;
}
.discord-link .discord-icon {
    font-size: 20px;
    color: #fff;
    line-height: 1;
}
.discord-linked {
    position: relative;
    overflow: hidden;
    box-shadow: 0 0 10px rgba(88,101,242,0.45), 0 0 18px rgba(88,101,242,0.35);
}
.discord-linked::after {
    content: "";
    position: absolute;
    top: -30%;
    left: -60%;
    width: 60%;
    height: 160%;
    background: linear-gradient(120deg, transparent 0%, rgba(255,255,255,0.35) 45%, rgba(255,255,255,0.6) 55%, transparent 100%);
    transform: skewX(-20deg);
    animation: discordShine 1s ease-in-out infinite;
}
@keyframes discordShine {
    0%   { transform: translateX(-120%) skewX(-20deg); }
    50%  { transform: translateX(180%) skewX(-20deg); }
    100% { transform: translateX(320%) skewX(-20deg); }
}

@media (max-width: 600px) {
    .twofactor-modal,
    .discord-confirm-modal {
        padding: 14px;
    }
    .twofactor-modal-content,
    .discord-confirm-content {
        padding: 24px 16px 18px;
        border-radius: 16px;
    }
}
