/* =========================================================
   Elemental Legacy — écran d'accueil
   Le décor desktop existe déjà dans client/assets/ui.
   Le mobile utilise un artwork portrait dédié pour préserver
   les deux biomes sans crop destructif.
   ========================================================= */
body.home-screen-open {
    overflow: hidden;
}

.homeScreen {
    --home-text: #fff8dc;
    --home-muted: rgba(232, 239, 255, .78);
    --home-gold: #f2bd52;
    --home-gold-border: rgba(246, 192, 80, .78);
    --home-blue-border: rgba(84, 193, 255, .72);
    --home-green: #67ef8b;
    position: fixed;
    inset: 0;
    z-index: 2000;
    min-height: 520px;
    overflow: hidden;
    isolation: isolate;
    color: var(--home-text);
    font-family: Georgia, "Times New Roman", serif;
    background: #071126 url("/client/assets/ui/game-page-background.png") center center / cover no-repeat;
}

.homeScreen[hidden] {
    display: none !important;
}

.homeScreen::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background:
        radial-gradient(ellipse at 50% 54%, transparent 0 22%, rgba(4, 8, 27, .08) 48%, rgba(2, 6, 19, .18) 76%, rgba(0, 3, 12, .28) 100%),
        linear-gradient(180deg, rgba(2, 6, 20, .01) 0 48%, rgba(2, 6, 20, .06) 66%, rgba(1, 4, 15, .38) 100%);
}

.homeScreenLogo {
    position: absolute;
    z-index: 2;
    top: clamp(30px, 6.5vh, 72px);
    left: 50%;
    width: min(540px, 42vw);
    height: auto;
    transform: translateX(-50%);
    filter: drop-shadow(0 10px 20px rgba(0, 0, 0, .34));
    user-select: none;
    pointer-events: none;
}

.homeScreenMenu {
    position: absolute;
    z-index: 3;
    top: 55.5%;
    left: 50%;
    display: grid;
    gap: 12px;
    width: min(420px, calc(100vw - 40px));
    transform: translateX(-50%);
}

.homeScreenButton {
    position: relative;
    display: grid;
    place-items: center;
    width: 100%;
    min-height: 60px;
    padding: 10px 24px 12px;
    border: 1px solid transparent;
    border-radius: 9px;
    background: rgba(8, 20, 56, .76);
    color: var(--home-text);
    box-shadow: inset 0 1px rgba(255, 255, 255, .09), 0 8px 24px rgba(0, 0, 0, .28);
    backdrop-filter: blur(7px);
    -webkit-backdrop-filter: blur(7px);
    cursor: pointer;
    font-family: Georgia, "Times New Roman", serif;
    line-height: 1;
    text-shadow: 0 2px 4px rgba(0, 0, 0, .72);
    transition: transform .15s ease, filter .15s ease, box-shadow .15s ease, opacity .15s ease;
    -webkit-tap-highlight-color: transparent;
}

.homeScreenButton::after {
    content: "";
    position: absolute;
    inset: 4px;
    border: 1px solid currentColor;
    border-radius: 6px;
    opacity: .20;
    pointer-events: none;
}

.homeScreenButton--primary {
    min-height: 64px;
    border-color: var(--home-gold-border);
    background: linear-gradient(180deg, rgba(26, 50, 104, .76), rgba(7, 18, 52, .90));
    color: #ffe4a6;
    font-size: clamp(23px, 2vw, 30px);
    font-weight: 700;
}

.homeScreenButton--secondary {
    border-color: var(--home-blue-border);
    background: linear-gradient(180deg, rgba(17, 39, 85, .68), rgba(6, 16, 48, .86));
    color: #eef6ff;
    font-size: clamp(19px, 1.65vw, 25px);
    font-weight: 600;
}

.homeScreenButton:hover:not(:disabled),
.homeScreenButton:focus-visible:not(:disabled) {
    outline: 0;
    transform: translateY(-2px);
    filter: brightness(1.08);
}

.homeScreenButton:active:not(:disabled) {
    transform: scale(.992);
}

.homeScreenButton:disabled {
    cursor: wait;
    opacity: .54;
}

.homeScreenFooter {
    position: absolute;
    z-index: 3;
    left: 50%;
    bottom: max(18px, env(safe-area-inset-bottom));
    display: grid;
    justify-items: center;
    gap: 5px;
    transform: translateX(-50%);
    color: var(--home-muted);
    font: 500 clamp(11px, .9vw, 14px)/1.1 system-ui, -apple-system, "Segoe UI", sans-serif;
    text-shadow: 0 2px 4px rgba(0, 0, 0, .76);
    white-space: nowrap;
}

.homeScreenLegalLinks {
    display:flex;
    align-items:center;
    justify-content:center;
    gap:6px;
    font-size:.84em;
    opacity:.82;
}
.homeScreenLegalLinks a {
    color:inherit;
    text-decoration:none;
}
.homeScreenLegalLinks a:hover,
.homeScreenLegalLinks a:focus-visible {
    color:#e8fbff;
    outline:0;
    text-decoration:underline;
}

.homeScreenFooterRule {
    display: flex;
    align-items: center;
    width: 170px;
    height: 7px;
    opacity: .58;
}

.homeScreenFooterRule span {
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(230, 238, 255, .78));
}

.homeScreenFooterRule span:last-child {
    transform: scaleX(-1);
}

.homeScreenFooterRule i {
    width: 6px;
    height: 6px;
    margin: 0 7px;
    border: 1px solid rgba(230, 238, 255, .85);
    transform: rotate(45deg);
}

.homeServerStatus {
    display: flex;
    align-items: center;
    gap: 6px;
}

.homeServerStatus strong {
    color: #c9d4e6;
    font-weight: 700;
}

.homeServerStatus > i {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #97a5ba;
    box-shadow: 0 0 8px rgba(151, 165, 186, .38);
}

.homeServerStatus[data-state="online"] strong {
    color: var(--home-green);
}

.homeServerStatus[data-state="online"] > i {
    background: var(--home-green);
    box-shadow: 0 0 9px rgba(103, 239, 139, .8);
}

.homeServerStatus[data-state="offline"] strong {
    color: #ff9b9b;
}

.homeServerStatus[data-state="offline"] > i {
    background: #ff7878;
    box-shadow: 0 0 9px rgba(255, 120, 120, .62);
}


.homeScreenLoading {
    position: absolute;
    z-index: 4;
    top: 57%;
    left: 50%;
    display: grid;
    gap: 9px;
    width: min(520px, calc(100vw - 38px));
    min-height: 88px;
    padding: 12px 16px 13px;
    transform: translate(-50%, -50%);
    border: 1px solid rgba(84, 193, 255, .32);
    border-radius: 10px;
    background: rgba(4, 13, 38, .72);
    box-shadow: inset 0 1px rgba(255, 255, 255, .05), 0 10px 28px rgba(0, 0, 0, .26);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    color: rgba(239, 246, 255, .88);
    font: 600 clamp(12px, 1vw, 14px)/1.2 system-ui, -apple-system, "Segoe UI", sans-serif;
    letter-spacing: .02em;
    text-shadow: 0 2px 6px rgba(0, 0, 0, .72);
}

.homeScreenLoadingHeadline {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.homeScreenLoadingProgress {
    position: relative;
    width: 100%;
    height: 9px;
    overflow: hidden;
    border: 1px solid rgba(140, 198, 236, .38);
    border-radius: 999px;
    background: rgba(1, 8, 25, .72);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, .56);
}

.homeScreenLoadingProgressFill {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #50bff3, #f2bd52);
    box-shadow: 0 0 10px rgba(84, 193, 255, .36);
    transition: width .16s ease-out;
}

.homeScreenLoadingMeta {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 14px;
    min-width: 0;
    color: rgba(226, 237, 252, .78);
    font-size: clamp(10px, .9vw, 12px);
    font-weight: 500;
}

.homeScreenLoadingMeta > span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.homeScreenLoadingMeta > strong {
    flex: 0 0 auto;
    color: #ffe08a;
    font-size: 1.05em;
}

.homeScreenLoading[hidden] {
    display: none !important;
}

.homeScreenLoadingSpinner {
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    border: 2px solid rgba(196, 219, 255, .24);
    border-top-color: #f2bd52;
    border-right-color: rgba(101, 205, 255, .88);
    border-radius: 50%;
    box-shadow: 0 0 9px rgba(84, 193, 255, .18);
    animation: homeLoadingSpin .78s linear infinite;
}

@keyframes homeLoadingSpin {
    to { transform: rotate(360deg); }
}

/* Même langage de particules que les bordures du jeu, mais dans le stacking
   context de l'accueil afin qu'elles passent derrière le logo et l'UI. */
.homeAmbientMagic {
    position: absolute;
    inset: 0;
    z-index: 1;
    overflow: hidden;
    pointer-events: none;
}

.homeAmbientMagicSide {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 50%;
}

.homeAmbientMagicSide--left { left: 0; }
.homeAmbientMagicSide--right { right: 0; }

.homeAmbientMagicParticle {
    position: absolute;
    left: var(--particle-left);
    bottom: var(--particle-bottom);
    width: var(--particle-size);
    height: var(--particle-size);
    border-radius: 999px;
    opacity: 0;
    background: radial-gradient(circle, rgba(246, 252, 255, 1) 0%, rgba(170, 231, 255, .98) 22%, rgba(131, 193, 255, .94) 48%, rgba(137, 145, 255, .55) 74%, rgba(137, 145, 255, 0) 100%);
    box-shadow: 0 0 10px rgba(176, 235, 255, .8), 0 0 24px rgba(111, 137, 255, .38), 0 0 34px rgba(91, 46, 255, .16);
    mix-blend-mode: screen;
    animation: pageAmbientMagicFloat var(--particle-duration) linear infinite;
    animation-delay: var(--particle-delay);
    will-change: transform, opacity;
}

.homeAmbientMagicParticle::before,
.homeAmbientMagicParticle::after {
    content: "";
    position: absolute;
    border-radius: inherit;
    pointer-events: none;
}

.homeAmbientMagicParticle::before {
    inset: -42%;
    background: inherit;
    filter: blur(7px);
    opacity: .72;
}

.homeAmbientMagicParticle::after {
    inset: -8%;
    background: radial-gradient(circle, rgba(255, 255, 255, .98) 0%, rgba(255, 255, 255, .4) 38%, rgba(255, 255, 255, 0) 100%);
    animation: pageAmbientMagicTwinkle 4.6s ease-in-out infinite;
    animation-delay: var(--particle-delay);
}

.homeResetOverlay {
    position: absolute;
    inset: 0;
    z-index: 8;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgba(1, 7, 20, .68);
    backdrop-filter: blur(7px);
    -webkit-backdrop-filter: blur(7px);
}

.homeResetOverlay[hidden] {
    display: none !important;
}

.homeResetCard {
    width: min(92vw, 390px);
    padding: 20px;
    border: 1px solid rgba(246, 192, 80, .55);
    border-radius: 14px;
    background: linear-gradient(180deg, rgba(15, 42, 78, .97), rgba(5, 18, 42, .99));
    box-shadow: 0 20px 60px rgba(0, 0, 0, .58);
    color: #fff;
    font-family: "Poppins", Arial, sans-serif;
    text-align: center;
}

.homeResetCard small {
    color: #f2bd52;
    font-weight: 900;
    letter-spacing: 1px;
}

.homeResetCard h2 {
    margin: 5px 0 9px;
    color: #fff5d4;
    font-size: 22px;
}

.homeResetCard p {
    margin: 0 0 14px;
    color: #d8e5ef;
    font-size: 12px;
    line-height: 1.45;
}

.homeResetActions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.homeResetActions button {
    min-height: 42px;
    border-radius: 8px;
    font: 800 12px/1 "Poppins", sans-serif;
    cursor: pointer;
}

.homeResetCancel {
    border: 1px solid rgba(210, 235, 255, .30);
    background: rgba(8, 28, 53, .82);
    color: #d7ecfa;
}

.homeResetConfirm {
    border: 1px solid rgba(255, 185, 92, .72);
    background: linear-gradient(180deg, #b76f20, #75400c);
    color: #fff5db;
}

.homeResetActions button:disabled {
    cursor: wait;
    opacity: .55;
}

@media (max-width: 700px), (max-aspect-ratio: 4 / 5) {
    .homeScreen {
        min-height: 100dvh;
        background-image: url("/client/assets/ui/game-page-background-mobile.webp");
        background-position: center center;
        background-size: cover;
    }

    .homeScreen::before {
        background:
            radial-gradient(ellipse at 50% 46%, rgba(8, 13, 49, .01) 0 19%, rgba(5, 9, 31, .04) 48%, rgba(2, 5, 18, .13) 100%),
            linear-gradient(180deg, rgba(1, 4, 15, .01) 0 46%, rgba(1, 4, 15, .08) 68%, rgba(0, 2, 10, .46) 100%);
    }

    .homeScreenLogo {
        /* Placement mobile validé visuellement : le logo descend dans la zone
           de ciel et laisse respirer le haut du décor, comme sur la référence. */
        top: max(calc(env(safe-area-inset-top) + 8px), clamp(96px, 19dvh, 170px));
        width: min(66vw, 340px);
    }

    .homeScreenMenu {
        top: 54%;
        width: min(84vw, 390px);
        gap: 11px;
    }

    .homeScreenButton {
        min-height: 52px;
        border-radius: 8px;
    }

    .homeScreenButton--primary {
        min-height: 56px;
        font-size: clamp(22px, 7vw, 29px);
    }

    .homeScreenButton--secondary {
        font-size: clamp(18px, 5.8vw, 24px);
    }

    .homeScreenFooter {
        bottom: max(14px, env(safe-area-inset-bottom));
        font-size: 11px;
    }

    .homeScreenLoading {
        top: 55%;
        font-size: 12px;
    }
}

@media (max-width: 420px) {
    .homeScreenLogo {
        width: min(68vw, 300px);
    }

    .homeScreenMenu {
        width: 84vw;
    }
}

@media (max-height: 650px) {
    .homeScreenLogo {
        top: max(12px, env(safe-area-inset-top));
        width: min(420px, 68vw);
    }

    .homeScreenMenu {
        top: 50%;
    }

    .homeScreenFooter {
        bottom: max(8px, env(safe-area-inset-bottom));
    }
}

.homeResetError {
    min-height: 15px;
    margin: -5px 0 8px !important;
    color: #ff9b9b !important;
    font-size: 11px !important;
    font-weight: 700;
}

@media (prefers-reduced-motion: reduce) {
    .homeAmbientMagicParticle,
    .homeAmbientMagicParticle::after,
    .homeScreenLoadingSpinner {
        animation: none !important;
    }

    .homeAmbientMagicParticle {
        display: none;
    }
}

.homeActivePlayers {
    color: #aebed2;
    font-weight: 600;
}
