* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --outer-bg: #fff;
    --card-bg: #fff;
    --main-text: #0a0a0a;
    --secondary-text: rgba(0,0,0,.82);
    --settings-bg: rgba(255,255,255,.72);
    --settings-border: rgba(0,0,0,.08);
    --settings-text: #111;
    --settings-secondary: rgba(0,0,0,.55);
    --button-bg: rgba(0,0,0,.07);
    --button-hover: rgba(0,0,0,.11);
    --button-text: #111;
    --glass-shadow: 0 30px 100px rgba(0,0,0,.24);
    --main-shadow: 0 0 10px rgba(0,0,0,.12),0 0 25px rgba(0,0,0,.05);
    --telegram-shadow: 0 0 7px rgba(0,0,0,.10),0 0 18px rgba(0,0,0,.045);
    --telegram-hover-shadow: 0 0 8px rgba(0,0,0,.25),0 0 22px rgba(0,0,0,.12),0 0 45px rgba(0,0,0,.06);
    --telegram-light-color: rgba(0,0,0,.35);
}

@media (prefers-color-scheme: dark) {
    :root {
        --outer-bg: #000;
        --card-bg: #000;
        --main-text: rgba(255,255,255,.94);
        --secondary-text: rgba(255,255,255,.88);
        --settings-bg: rgba(25,25,25,.74);
        --settings-border: rgba(255,255,255,.10);
        --settings-text: #fff;
        --settings-secondary: rgba(255,255,255,.56);
        --button-bg: rgba(255,255,255,.08);
        --button-hover: rgba(255,255,255,.13);
        --button-text: #fff;
        --glass-shadow: 0 30px 100px rgba(0,0,0,.52);
        --main-shadow: 0 0 10px rgba(255,255,255,.20),0 0 25px rgba(255,255,255,.08);
        --telegram-shadow: 0 0 7px rgba(255,255,255,.16),0 0 18px rgba(255,255,255,.07);
        --telegram-hover-shadow: 0 0 8px rgba(255,255,255,.45),0 0 20px rgba(255,255,255,.18),0 0 40px rgba(255,255,255,.07);
        --telegram-light-color: rgba(255,255,255,.90);
    }
}

html, body { width: 100%; height: 100%; }

body {
    position: relative;
    min-height: 100%;
    overflow: hidden;
    background: var(--outer-bg);
    color: var(--main-text);
    font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    transition: background .6s ease, color .6s ease;
}

button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.app-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    background: var(--card-bg);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .6s ease;
}

.center {
    position: absolute;
    left: 50%;
    top: 42%;
    transform: translate(-50%,-50%);
    z-index: 10;
    text-align: center;
    pointer-events: none;
}

.center-glow {
    position: absolute;
    width: 290px;
    height: 180px;
    left: 50%;
    top: 50%;
    transform: translate(-50%,-50%);
    border-radius: 50%;
    background: radial-gradient(circle,
        rgba(255,60,180,.22) 0%,
        rgba(140,70,255,.17) 24%,
        rgba(0,190,255,.14) 43%,
        rgba(50,255,150,.10) 60%,
        rgba(255,190,50,.07) 74%,
        transparent 100%);
    filter: blur(58px);
    opacity: .78;
    z-index: -1;
    animation: centerGlowMove 12s ease-in-out infinite alternate;
}

@keyframes centerGlowMove {
    0% { transform: translate(-50%,-50%) scale(.88); filter: blur(58px); }
    25% { transform: translate(-50%,-50%) scale(1.04); filter: blur(66px); }
    50% { transform: translate(-50%,-50%) scale(.94); filter: blur(52px); }
    75% { transform: translate(-50%,-50%) scale(1.08); filter: blur(62px); }
    100% { transform: translate(-50%,-50%) scale(.92); filter: blur(58px); }
}

.title {
    position: relative;
    color: var(--main-text);
    font-size: clamp(50px, 7vw, 100px);
    font-weight: 600;
    letter-spacing: -4px;
    line-height: 1;
    text-shadow: var(--main-shadow);
    transition: color .6s ease, text-shadow .6s ease;
}

.orbs-layer {
    position: absolute;
    inset: 0;
    z-index: 7;
    pointer-events: none;
}

.orb {
    position: absolute;
    width: 60px;
    height: 60px;
    left: 50%;
    top: 42%;
    border-radius: 50%;
    opacity: .93;
    pointer-events: auto;
    cursor: pointer;
    transform: translate3d(-50%, -50%, 0);
    will-change: transform, background;
    filter: blur(17px) saturate(1.5);
    mix-blend-mode: screen;
    transition: transform .55s cubic-bezier(.22,1,.36,1), filter .6s ease, opacity .6s ease;
}

.orb:nth-child(1) { filter: blur(18px) saturate(1.5); }
.orb:nth-child(2) { filter: blur(17px) saturate(1.58); }
.orb:nth-child(3) { filter: blur(19px) saturate(1.46); }

.merge-blob {
    position: absolute;
    left: 0;
    top: 0;
    width: 0;
    height: 0;
    opacity: 0;
    pointer-events: none;
    transform-origin: center;
    border-radius: 999px;
    filter: blur(13px) saturate(1.35);
    mix-blend-mode: screen;
    will-change: left, top, width, height, transform, opacity, background;
    transition: opacity .28s ease, filter .28s ease, width .18s ease, height .18s ease;
}

.account-widget {
    position: absolute;
    top: max(22px, env(safe-area-inset-top));
    left: max(22px, env(safe-area-inset-left));
    z-index: 50;
    min-width: 168px;
    min-height: 58px;
    padding: 10px 14px;
    border: 1px solid var(--settings-border);
    border-radius: 22px;
    display: inline-flex;
    align-items: center;
    gap: 11px;
    background: var(--button-bg);
    color: var(--button-text);
    box-shadow: 0 10px 35px rgba(0,0,0,.08);
    backdrop-filter: blur(24px) saturate(1.15);
    -webkit-backdrop-filter: blur(24px) saturate(1.15);
    cursor: pointer;
    text-align: left;
    transition: transform .35s cubic-bezier(.22,1,.36,1), background .35s ease, border-color .35s ease;
}

.account-widget:hover { transform: translateY(-2px) scale(1.015); background: var(--button-hover); }
.account-widget:active { transform: translateY(0) scale(.985); }

.account-label {
    font-size: 15px;
    line-height: 1.05;
    font-weight: 600;
    letter-spacing: -.45px;
    white-space: nowrap;
}

.account-avatar-wrap {
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--button-text);
}

.account-avatar { width: 100%; height: 100%; display: block; object-fit: cover; }

.telegram-wrapper {
    position: absolute;
    left: 50%;
    bottom: 22vh;
    transform: translateX(-50%);
    z-index: 20;
}

.telegram-link {
    position: relative;
    display: inline-block;
    color: var(--secondary-text);
    text-decoration: none;
    font-size: clamp(18px, 2.2vw, 28px);
    font-weight: 500;
    letter-spacing: -.7px;
    white-space: nowrap;
    text-shadow: var(--telegram-shadow);
    transition: transform .35s ease, color .6s ease, text-shadow .6s ease;
}

.telegram-link:hover { transform: scale(1.025); color: var(--main-text); text-shadow: var(--telegram-hover-shadow); }

.telegram-light {
    position: fixed;
    left: 0;
    top: 0;
    width: 125px;
    height: 125px;
    border-radius: 50%;
    background: var(--telegram-light-color);
    filter: blur(42px);
    pointer-events: none;
    opacity: 0;
    transform: translate(-50%,-50%) scale(.65);
    z-index: -1;
    transition: opacity .16s ease, transform .16s ease;
}

.telegram-wrapper:hover .telegram-light { opacity: .18; transform: translate(-50%,-50%) scale(1); }

.settings-button {
    position: absolute;
    left: 50%;
    bottom: max(28px, env(safe-area-inset-bottom));
    transform: translateX(-50%);
    z-index: 30;
    border: none;
    background: transparent;
    color: var(--secondary-text);
    font-family: inherit;
    font-size: 15px;
    font-weight: 500;
    letter-spacing: -.2px;
    cursor: pointer;
    padding: 8px 14px;
    transition: color .35s ease, transform .35s ease, text-shadow .35s ease;
}

.settings-button:hover { color: var(--main-text); transform: translateX(-50%) scale(1.05); text-shadow: var(--main-shadow); }

.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(0,0,0,.38);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .4s ease, visibility .4s ease;
}

.modal-overlay.active { opacity: 1; visibility: visible; pointer-events: auto; }

.glass-window {
    position: relative;
    width: min(430px, calc(100vw - 32px));
    padding: 28px;
    border-radius: 28px;
    background: var(--settings-bg);
    border: 1px solid var(--settings-border);
    box-shadow: var(--glass-shadow);
    backdrop-filter: blur(30px) saturate(1.2);
    -webkit-backdrop-filter: blur(30px) saturate(1.2);
    transform: translateY(35px) scale(.9);
    opacity: 0;
    transition: transform .5s cubic-bezier(.22,1,.36,1), opacity .35s ease, background .6s ease, border-color .6s ease;
}

.modal-overlay.active .glass-window { transform: translateY(0) scale(1); opacity: 1; }

.window-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 24px; }
.window-title { color: var(--settings-text); font-size: 24px; font-weight: 600; letter-spacing: -.8px; }
.window-subtitle { margin-top: 6px; color: var(--settings-secondary); font-size: 12px; line-height: 1.4; }

.close-button {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    flex: 0 0 36px;
    background: var(--button-bg);
    color: var(--button-text);
    font-family: inherit;
    font-size: 21px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform .35s cubic-bezier(.22,1,.36,1), background .25s ease, color .3s ease;
}

.close-button:hover { transform: rotate(90deg) scale(1.08); background: var(--button-hover); }

.setting { padding: 17px 0; border-bottom: 1px solid var(--settings-border); }
.setting-name { color: var(--settings-text); font-size: 16px; font-weight: 500; }
.language-buttons { display: flex; gap: 8px; margin-top: 14px; }
.language-button, .auth-tab {
    flex: 1;
    border: none;
    border-radius: 14px;
    padding: 11px 12px;
    background: var(--button-bg);
    color: var(--button-text);
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: transform .3s ease, background .3s ease, color .3s ease;
}
.language-button:hover, .auth-tab:hover { transform: translateY(-2px); background: var(--button-hover); }
.language-button.active, .auth-tab.active { background: var(--button-text); color: var(--settings-bg); }

.account-button, .close-settings, .logout-button {
    width: 100%;
    margin-top: 12px;
    border: none;
    border-radius: 15px;
    padding: 13px;
    background: var(--button-bg);
    color: var(--button-text);
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: transform .3s ease, background .3s ease, color .3s ease;
}
.account-button:hover, .close-settings:hover, .logout-button:hover { transform: translateY(-2px); background: var(--button-hover); }

.settings-version {
    margin-top: 17px;
    text-align: center;
    color: var(--settings-secondary);
    opacity: .62;
    font-size: 11px;
    letter-spacing: -.1px;
}

.auth-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.auth-tab { flex: 1; padding: 10px 12px; }
.auth-content { position: relative; z-index: 2; }

.glass-input {
    width: 100%;
    border: 1px solid var(--settings-border);
    outline: none;
    border-radius: 16px;
    padding: 15px 16px;
    margin-bottom: 11px;
    background: var(--button-bg);
    color: var(--settings-text);
    font-family: inherit;
    font-size: 14px;
    transition: border-color .25s ease, box-shadow .25s ease, transform .25s ease, background .25s ease;
}
.glass-input::placeholder { color: var(--settings-secondary); }
.glass-input:focus { border-color: rgba(120,120,120,.5); box-shadow: 0 0 0 4px rgba(120,120,120,.06); transform: translateY(-1px); }

.primary-button {
    width: 100%;
    margin-top: 8px;
    border: none;
    border-radius: 16px;
    padding: 15px;
    background: var(--button-text);
    color: var(--settings-bg);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform .3s ease, box-shadow .3s ease, opacity .3s ease;
}
.primary-button:hover { transform: translateY(-2px); box-shadow: 0 10px 35px rgba(0,0,0,.15); }
.primary-button:active { transform: translateY(0) scale(.98); }
.primary-button.loading { pointer-events: none; opacity: .55; }

.message { min-height: 20px; margin-top: 12px; text-align: center; color: var(--settings-secondary); font-size: 12px; line-height: 1.4; }
.message.error { color: #ff5b66; }
.message.success { color: #4fd68a; }

.auth-hint { margin-top: 20px; text-align: center; color: var(--settings-secondary); font-size: 12px; }
.auth-hint button { border: none; background: transparent; color: var(--settings-text); font-family: inherit; font-size: 12px; font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.auth-hint button:hover { color: var(--main-text); }

.profile-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.profile-avatar-wrap { width: 72px; height: 72px; border-radius: 50%; overflow: hidden; flex: 0 0 72px; background: var(--button-text); position: relative; }
.profile-avatar { width: 100%; height: 100%; display: block; object-fit: cover; }
.profile-avatar-fallback { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; color: var(--settings-bg); font-size: 28px; font-weight: 700; }
.profile-head-text { min-width: 0; }
.profile-kicker { color: var(--settings-secondary); font-size: 11px; margin-bottom: 3px; }
.profile-username { color: var(--settings-text); font-size: 22px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }

.profile-card { border-radius: 17px; background: var(--button-bg); padding: 8px 15px; }
.profile-row { min-height: 46px; padding: 11px 0; display: flex; align-items: center; justify-content: space-between; gap: 14px; border-bottom: 1px solid var(--settings-border); color: var(--settings-secondary); font-size: 11px; }
.profile-row:last-child { border-bottom: none; }
.profile-row strong { color: var(--settings-text); font-size: 13px; font-weight: 600; text-align: right; overflow-wrap: anywhere; }
.profile-row-column { display: block; }
.profile-row-column strong { display: block; margin-top: 5px; text-align: left; }
.profile-row-column small { display: block; margin-top: 5px; color: var(--settings-secondary); font-size: 10px; line-height: 1.4; }

.avatar-upload {
    width: 100%;
    margin-top: 13px;
    border-radius: 15px;
    padding: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--button-bg);
    color: var(--button-text);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: transform .3s ease, background .3s ease;
}
.avatar-upload:hover { transform: translateY(-2px); background: var(--button-hover); }
.upload-hint { margin-top: 7px; text-align: center; color: var(--settings-secondary); font-size: 10px; }
.logout-button { margin-top: 11px; }

.hidden { display: none !important; }

@media (max-width: 600px) {
    .account-widget {
        top: max(14px, env(safe-area-inset-top));
        left: max(14px, env(safe-area-inset-left));
        min-width: 150px;
        min-height: 52px;
        border-radius: 19px;
        padding: 9px 12px;
    }
    .account-label { font-size: 14px; }
    .account-avatar-wrap { width: 30px; height: 30px; flex-basis: 30px; }
    .title { font-size: 52px; letter-spacing: -3px; }
    .center { top: 42%; }
    .center-glow { width: 220px; height: 140px; filter: blur(45px); }
    .orb { width: 50px; height: 50px; }
    .telegram-wrapper { bottom: 24vh; }
    .telegram-link { font-size: 22px; letter-spacing: -.8px; }
    .settings-button { bottom: max(18px, env(safe-area-inset-bottom)); font-size: 14px; }
    .glass-window { padding: 24px; border-radius: 23px; }
    .window-title { font-size: 22px; }
    .profile-username { font-size: 20px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: .001ms !important;
    }
}
