*, *::before, *::after { box-sizing: border-box; }

.auth-page {
    --auth-gutter: clamp(16px, 4vw, 30px);
    min-height: 100dvh;
    margin: 0;
    display: grid;
    grid-template-rows: 1fr auto;
    background:
        linear-gradient(180deg, transparent 65%, #171b2a9c),
        url('/assets/lobby/backgrounds/porto-sala-privada.webp') center / cover no-repeat fixed,
        #4c8eae;
    color: var(--hud-ink);
    font-family: var(--ui-display);
}

.auth-layout {
    width: min(100%, 1180px);
    margin-inline: auto;
    padding: clamp(56px, 8vh, 88px) clamp(24px, 5vw, 64px) 30px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(320px, 418px);
    align-items: center;
    gap: clamp(24px, 7vw, 108px);
}

.auth-logo {
    display: block;
    justify-self: center;
    width: min(100%, 520px);
    height: auto;
    filter: drop-shadow(0 10px 0 #39241455) drop-shadow(0 8px 18px #23162e7a);
}

.auth-panel {
    overflow: hidden;
    color-scheme: light;
    background: var(--hud-panel-sand);
    border: 4px solid var(--hud-ink);
    border-radius: 13px 22px 13px 22px;
    box-shadow: 0 7px #6b3820, 0 13px 0 -3px #321a0d, 0 23px 38px #271c3569;
}

.auth-heading {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px var(--auth-gutter);
    background: var(--hud-panel-blue);
    box-shadow: var(--hud-panel-rim);
    border-bottom: 3px solid var(--hud-ink);
}

.auth-heading img {
    flex: none;
    object-fit: contain;
}

.auth-heading h1 {
    margin: 0;
    color: #fff1ad;
    font: 900 clamp(23px, 3.2vw, 30px)/1.15 var(--hud-lettering);
    -webkit-text-stroke: 2.5px var(--hud-ink);
    paint-order: stroke fill;
    text-shadow: 0 3px var(--hud-ink);
}

.auth-body {
    padding: 20px var(--auth-gutter) 16px;
    background: repeating-linear-gradient(-27deg, transparent 0 20px, #b86a3710 21px 22px, transparent 23px 41px);
    box-shadow: inset 0 1px #fff7d8;
}

.auth-form, .auth-actions { display: grid; gap: 13px; }
.auth-form[hidden], .auth-progress[hidden] { display: none; }

.auth-field { display: grid; gap: 5px; }

.auth-field label {
    font-size: 15px;
    font-weight: 800;
}

.auth-field input {
    width: 100%;
    min-height: 48px;
    padding: 8px 12px;
    background: #fff7e3;
    color: var(--hud-ink);
    border: 2px solid #865537;
    border-radius: 7px 12px 7px 12px;
    box-shadow: inset 0 2px #dfb483, 0 1px #fff5d1;
    font: 700 16px var(--ui-display);
}

.auth-panel :is(input, button, a):focus-visible {
    outline: 3px solid #195775;
    outline-offset: 2px;
}

.auth-panel .auth-action {
    min-height: 50px;
    padding: 8px 18px 11px;
    border: 0;
    background: var(--hud-blue) center / 100% 100% no-repeat;
    box-shadow: none;
    filter: drop-shadow(0 3px 2px #49291645);
    color: #fff4d4;
    font: 900 clamp(12px, 2vw, 15px)/1.15 var(--hud-lettering);
    text-transform: uppercase;
    text-shadow: 0 2px var(--hud-ink);
    -webkit-text-stroke: 1.8px var(--hud-ink);
    paint-order: stroke fill;
}

.auth-panel .auth-primary {
    margin-top: 4px;
    min-height: 54px;
    background-image: var(--hud-orange);
    font-size: 18px;
}

.auth-primary img { flex: none; object-fit: contain; }

.auth-actions {
    gap: 6px;
    padding: 14px var(--auth-gutter) 10px;
    border-top: 2px solid var(--hud-panel-seam);
    background: #c67e422a;
    box-shadow: inset 0 1px #fff1c5;
}

.auth-link {
    display: grid;
    place-items: center;
    justify-self: center;
    min-height: 44px;
    padding-inline: 10px;
    color: #53301e;
    font-size: 14px;
    font-weight: 800;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

.auth-link:hover { color: #165571; }

.auth-message {
    margin-bottom: 12px;
    padding: 9px 12px;
    border: 2px solid #a84b32;
    border-radius: 6px 10px 6px 10px;
    background: #fff1db;
    color: #842e21;
    font-size: 14px;
    font-weight: 800;
    overflow-wrap: anywhere;
}

.auth-message.success {
    border-color: #477746;
    background: #eff7dd;
    color: #284f2b;
}

.register-layout {
    grid-template-areas: 'logo panel' 'rewards panel';
    grid-template-rows: 1fr 1fr;
    row-gap: 14px;
}

.register-layout .auth-logo {
    grid-area: logo;
    align-self: end;
    width: min(100%, 430px);
}

.register-layout .auth-panel { grid-area: panel; }
.register-layout .auth-form { gap: 10px; }

.register-layout .auth-actions {
    grid-template-columns: 1fr;
    padding-block: 4px;
}

.register-rewards {
    grid-area: rewards;
    align-self: start;
    justify-self: center;
    display: flex;
    align-items: center;
    gap: 12px;
    width: min(100%, 360px);
    padding: 12px 14px;
    border: 3px solid var(--hud-ink);
    border-radius: 9px 15px 9px 15px;
    background: var(--hud-panel-sand);
    box-shadow: inset 0 2px #fff7d4, 0 4px #64391f, 0 9px 18px #29190d59;
}

.register-rewards img { flex: none; object-fit: contain; }

.register-rewards h2 {
    margin: 0 0 4px;
    font: 900 16px/1.2 var(--hud-lettering);
}

.register-rewards p {
    margin: 0;
    font-size: 14px;
    line-height: 1.35;
}

.auth-field .form-help {
    color: #614027;
    font-size: 12px;
    line-height: 1.3;
}

.auth-field input.valid { border-color: #477746; }
.auth-field input.invalid { border-color: #a84b32; }
.auth-field .form-help.success { color: #315c31; }
.auth-field .form-help.error { color: #842e21; }

.password-strength {
    display: flex;
    align-items: center;
    gap: 8px;
}

.strength-bar {
    flex: 1;
    height: 8px;
    overflow: hidden;
    border: 1px solid var(--ui-outline);
    border-radius: 5px;
    background: #10242c;
}

.strength-fill { height: 100%; width: 0; }
.strength-weak { background: #b74529; }
.strength-medium { background: #a06b1d; }
.strength-strong { background: #477746; }
.password-strength .form-help:empty { display: none; }

.auth-progress {
    min-height: 204px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-weight: 800;
}

.auth-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid #b57448;
    border-top-color: #16658a;
    border-radius: 50%;
    animation: auth-spin .8s linear infinite;
}

@keyframes auth-spin { to { transform: rotate(360deg); } }

.auth-page .music-control {
    position: fixed;
    z-index: 5;
    top: max(12px, env(safe-area-inset-top));
    right: max(12px, env(safe-area-inset-right));
    width: 46px;
    height: 46px;
    padding: 0;
    border: 0;
    filter: drop-shadow(0 3px 2px #23140775);
}

.music-control svg { width: 24px; height: 24px; }

.auth-copyright {
    padding: 0 12px max(12px, env(safe-area-inset-bottom));
    color: var(--ui-paper);
    font-size: 12px;
    font-weight: 700;
    text-align: center;
    text-shadow: 0 2px 3px #1f1427;
    display: flex;
    justify-content: center;
}

.studio-footer-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
}

.studio-footer-logo {
    height: 24px;
    width: auto;
    display: block;
    object-fit: contain;
    filter: drop-shadow(0 2px 3px rgba(31, 20, 39, 0.9));
}

.studio-footer-sep {
    opacity: 0.45;
}

.lobby-load {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    margin: 0;
    padding: 0;
    border: 0;
    overflow: auto;
    overscroll-behavior: contain;
    background:
        linear-gradient(180deg, #1747681a 55%, #24192b66),
        url('/assets/lobby/backgrounds/porto-embarque.webp') center / cover no-repeat,
        #4c95c0;
    color: var(--hud-ink);
}

.auth-page:has(.lobby-load[open]) { overflow: hidden; }

.lobby-load-stage {
    display: grid;
    justify-items: center;
    align-content: center;
    gap: clamp(12px, 3vh, 25px);
    min-height: 100%;
    padding: clamp(16px, 4vw, 40px);
}

.lobby-load-logo {
    display: block;
    width: clamp(162px, 26vh, 270px);
    height: auto;
    filter: drop-shadow(0 6px 0 #39241462) drop-shadow(0 7px 13px #20122955);
}

.lobby-load-panel {
    width: min(100%, 600px);
}

.lobby-load-panel .auth-heading h1 {
    font-size: clamp(20px, 5vw, 29px);
}

.lobby-load-status {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    font-weight: 800;
}

.lobby-load-status p { margin: 0; font-size: clamp(14px, 3.8vw, 17px); }

#loadingPercent {
    flex: none;
    font-family: var(--hud-lettering);
    font-variant-numeric: tabular-nums;
}

.lobby-load-meter {
    --meter-fill: linear-gradient(180deg, #ffe989 0 22%, #ffc33e 23% 76%, #ee8a28 77%);
    display: block;
    width: 100%;
    height: 23px;
    appearance: none;
    overflow: hidden;
    border: 3px solid var(--hud-ink);
    border-radius: 5px 9px 5px 9px;
    background: #204a5e;
    box-shadow: 0 2px 0 #fff0c6;
}

.lobby-load-meter::-webkit-progress-bar { background: #204a5e; }
.lobby-load-meter::-webkit-progress-value { background: var(--meter-fill); }
.lobby-load-meter::-moz-progress-bar { background: var(--meter-fill); }

.lobby-load-steps {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 16px 0 0;
    padding: 0;
    list-style: none;
}

.lobby-load-step {
    display: flex;
    align-items: center;
    gap: 5px;
    min-height: 33px;
    padding: 3px 6px;
    border: 1px solid #a9704a;
    border-radius: 5px 9px 5px 9px;
    background: #fff3d7;
    font-size: 13px;
    font-weight: 800;
}

.lobby-load-step img { flex: none; object-fit: contain; }
.lobby-load-mark { width: 1em; text-align: center; }
.lobby-load-step[data-state="done"] { border-color: #3d849f; background: #caedfa; }
.lobby-load-step[data-state="failed"] { border-color: #a84b32; background: #ffdfc8; }
.lobby-load-step[data-state="failed"] .lobby-load-mark { color: #842e21; }

.lobby-load-footer p {
    margin: 0;
    color: #5b351f;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.35;
}

@media (orientation: landscape) and (min-width: 540px) and (max-height: 500px) {
    .lobby-load-stage {
        grid-template-columns: minmax(120px, 240px) minmax(0, 580px);
        align-items: center;
        justify-content: center;
        padding: 16px;
    }

    .lobby-load-logo { width: 100%; }
    .lobby-load-footer.auth-actions { grid-template-columns: 1fr; }
}

@media (max-width: 740px) {
    .auth-layout {
        width: min(100%, 460px);
        grid-template-columns: minmax(0, 1fr);
        align-content: center;
        gap: 10px;
        padding: 42px 14px 24px;
    }

    .auth-logo { width: min(66%, 244px); }
    .auth-heading { padding-block: 9px; }
    .auth-heading img { width: 36px; height: 36px; }
    .auth-body { padding-block: 15px 12px; }
    .register-layout {
        grid-template-areas: 'logo' 'panel' 'rewards';
        grid-template-rows: auto;
    }
    .register-layout .auth-logo { width: min(58%, 205px); }
    .register-rewards { margin-top: 8px; }
}

@media (orientation: landscape) and (min-width: 580px) and (max-height: 540px) {
    .auth-layout {
        width: min(100%, 940px);
        grid-template-columns: minmax(0, 1fr) minmax(320px, 385px);
        gap: clamp(16px, 5vw, 58px);
        padding: 12px 62px 18px 18px;
    }

    .auth-logo { width: min(100%, 340px); }
    .auth-panel { --auth-gutter: 14px; }
    .auth-heading { padding-block: 6px; }
    .auth-heading img { width: 34px; height: 34px; }
    .auth-body { padding-block: 9px; }
    .auth-form { gap: 6px; }
    .auth-field { gap: 3px; }
    .auth-field input { min-height: 42px; }
    .auth-panel .auth-action { min-height: 44px; }
    .auth-actions {
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
        padding-block: 7px;
    }
    .auth-actions .auth-action { padding-inline: 8px; font-size: 11px; }
    .auth-link { padding-inline: 3px; font-size: 13px; }
    .auth-progress { min-height: 166px; }
    .register-layout {
        grid-template-areas: 'logo panel' 'rewards panel';
        grid-template-rows: 1fr 1fr;
        row-gap: 10px;
    }
    .register-layout .auth-logo { width: min(100%, 260px); }
    .register-rewards { margin-top: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .auth-spinner { animation: none; }
}

/* Termos de conta na mesma moldura das telas de autenticação. */
.account-terms-modal {
    width: min(680px, calc(100% - 24px));
    max-height: min(88dvh, 760px);
    padding: 0;
    grid-template-rows: auto minmax(0, 1fr) auto;
}
.account-terms-modal[open] { display: grid; }
html:has(.account-terms-modal[open]) { overflow: hidden; }
.account-terms-modal::backdrop { background: #112a37cc; }
.account-terms-modal .auth-heading h1 { font-size: clamp(20px, 4vw, 27px); }
.account-terms-page {
    align-self: start;
    width: min(760px, calc(100% - 24px));
    margin: clamp(24px, 8vh, 72px) auto;
}
.account-terms-document {
    color: var(--hud-ink);
    line-height: 1.45;
    overflow: auto;
    overscroll-behavior: contain;
}
.account-terms-document h2 { margin: 1rem 0 .35rem; font-size: 1rem; }
.account-terms-document p { margin: .35rem 0 .6rem; }
.account-terms-document a { color: #195775; font-weight: 800; overflow-wrap: anywhere; }
.account-terms-document:focus-visible { outline: 3px solid #195775; outline-offset: -5px; }
.account-terms-version { font-size: .83rem; font-weight: 800; }
.account-terms-actions {
    display: grid;
    gap: .65rem;
    padding: .7rem var(--auth-gutter) .82rem;
    border-top: 2px solid #855237;
    background: #f5cc95;
}
.account-terms-check {
    display: flex;
    align-items: flex-start;
    gap: .6rem;
    font-size: .92rem;
    font-weight: 800;
}
.account-terms-check input {
    width: 19px;
    height: 19px;
    flex: none;
    margin: 2px 0 0;
    accent-color: #176e8c;
}
.account-terms-buttons { display: grid; grid-template-columns: 1fr 1.65fr; gap: .55rem; }
.account-terms-buttons .auth-action { padding-inline: .5rem; font-size: .86rem; }
.account-terms-buttons .auth-primary { margin: 0; }
.account-terms-buttons button:disabled { opacity: .55; cursor: not-allowed; }
.account-terms-reading .account-terms-check[hidden],
.account-terms-reading .auth-action[hidden] { display: none; }
.account-terms-reading .account-terms-buttons { grid-template-columns: minmax(120px, 160px); justify-content: end; }
.account-terms-link { justify-self: start; font-size: .82rem; }

/* ===== SELEÇÃO DE SERVIDOR ===== */
.server-layout {
    grid-template-columns: minmax(0, 1fr) minmax(330px, 448px);
}

.server-greeting {
    margin-bottom: 14px;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.35;
    color: #5b351f;
}

.server-greeting strong {
    color: var(--hud-ink);
    font-weight: 900;
}

.server-list {
    display: grid;
    gap: 12px;
    margin-bottom: 16px;
}

.server-card {
    width: 100%;
    padding: 14px 15px;
    display: grid;
    gap: 13px;
    text-align: left;
    color: var(--hud-ink);
    font-family: var(--ui-display);
    background: linear-gradient(180deg, #fff9e8 0%, #fae3b8 100%);
    border: 3px solid var(--hud-ink);
    border-radius: 10px 16px 10px 16px;
    box-shadow: inset 0 2px #fffdf2, 0 4px #8c532b, 0 7px 14px #2a180d33;
    cursor: pointer;
    transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}

.server-card:hover {
    transform: translateY(-1px);
    box-shadow: inset 0 2px #fffdf2, 0 5px #8c532b, 0 10px 18px #2a180d40;
}

.server-card.is-selected {
    border-color: #165d7c;
    box-shadow:
        inset 0 2px #fffdf2,
        0 0 0 2px #6fd2ff,
        0 4px #144961,
        0 9px 18px #182b3a44;
}

.server-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.server-identity {
    display: flex;
    align-items: center;
    gap: 11px;
    min-width: 0;
}

.server-flag {
    flex: none;
    display: grid;
    place-items: center;
    width: 42px;
    height: 30px;
    overflow: hidden;
    border: 2.5px solid var(--hud-ink);
    border-radius: 6px 9px 6px 9px;
    box-shadow: 0 2px 0 #7b4927;
    background: #009c3b;
}

.server-flag svg {
    width: 100%;
    height: 100%;
    display: block;
}

.server-titles {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.server-name {
    font: 900 18px/1.15 var(--hud-lettering);
    color: var(--hud-ink);
    letter-spacing: .01em;
}

.server-region {
    font-size: 13px;
    font-weight: 800;
    color: #6b4328;
}

.server-ping {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border: 2px solid var(--hud-ink);
    border-radius: 999px;
    background: #204a5e;
    color: #fff6dc;
    font: 900 13px/1 var(--hud-lettering);
    font-variant-numeric: tabular-nums;
    box-shadow: inset 0 1px #ffffff30, 0 2px 0 #3f221344;
}

.server-ping-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    border: 1.5px solid var(--hud-ink);
    background: #9db6c4;
}

.server-ping[data-quality="good"] .server-ping-dot {
    background: #52e067;
    box-shadow: 0 0 6px #52e067b0;
}

.server-ping[data-quality="medium"] .server-ping-dot {
    background: #ffd046;
    box-shadow: 0 0 6px #ffd046b0;
}

.server-ping[data-quality="bad"] .server-ping-dot,
.server-ping[data-quality="offline"] .server-ping-dot {
    background: #ff5d47;
    box-shadow: 0 0 6px #ff5d47b0;
}

.server-occupancy {
    display: grid;
    gap: 6px;
}

.server-occupancy-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 12.5px;
    font-weight: 800;
}

.server-occupancy-title {
    color: #6a4227;
}

.server-occupancy-state {
    text-transform: uppercase;
    letter-spacing: .03em;
    font-weight: 900;
}

.server-occupancy-state[data-level="low"] { color: #266b31; }
.server-occupancy-state[data-level="medium"] { color: #8c5a0b; }
.server-occupancy-state[data-level="high"] { color: #b24816; }
.server-occupancy-state[data-level="full"] { color: #9c221b; }

.server-load-track {
    width: 100%;
    height: 18px;
    overflow: hidden;
    border: 2.5px solid var(--hud-ink);
    border-radius: 6px 10px 6px 10px;
    background: #204a5e;
    box-shadow: inset 0 2px 3px #0e2430aa, 0 1px 0 #fff7db;
}

.server-load-fill {
    height: 100%;
    border-radius: 3px 6px 3px 6px;
    transition: width .35s ease, background .25s ease;
    box-shadow: inset 0 2px 0 #ffffff55;
}

.server-load-fill[data-level="low"] {
    background: linear-gradient(180deg, #7ef089 0 28%, #3bc454 29% 78%, #26993d 79%);
}

.server-load-fill[data-level="medium"] {
    background: linear-gradient(180deg, #ffe989 0 28%, #ffc33e 29% 78%, #e6921d 79%);
}

.server-load-fill[data-level="high"] {
    background: linear-gradient(180deg, #ffbd66 0 28%, #f57b24 29% 78%, #cf5112 79%);
}

.server-load-fill[data-level="full"] {
    background: linear-gradient(180deg, #ff8d7a 0 28%, #e53f2e 29% 78%, #b32217 79%);
}

.server-enter-btn {
    width: 100%;
}

.server-footer-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    justify-items: center;
    padding-block: 8px;
}

.server-text-btn {
    min-height: 40px;
    padding: 4px 10px;
    border: 0;
    background: transparent;
    color: #53301e;
    font: 800 14px var(--ui-display);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
    cursor: pointer;
}

.server-text-btn:hover { color: #165571; }
.server-text-btn:disabled { opacity: .55; cursor: wait; }

@media (max-width: 740px) {
    .server-layout {
        grid-template-columns: minmax(0, 1fr);
    }
    .server-card-top {
        flex-wrap: wrap;
    }
}
