* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --app-height: var(--tg-viewport-stable-height, 100vh);
    --safe-top: var(--tg-safe-area-inset-top, 0px);
    --safe-bottom: var(--tg-safe-area-inset-bottom, 0px);
    --content-safe-top: var(--tg-content-safe-area-inset-top, 0px);
    --total-top: calc(var(--safe-top) + var(--content-safe-top));

    --bg-primary: #0f1835;
    --bg-secondary: #132347;
    --text-primary: #ffffff;
    --text-hint: rgba(255, 255, 255, 0.72);
    --accent: #55b443;
    --accent-text: #ffffff;

    --header-height: 48px;
    --preview-height: 44px;
    --wheel-bottom-padding: 16px;
    --grid-padding: 12px;

    --section-color: #e94560;

    font-family: 'Avenir Next', 'Trebuchet MS', 'Gill Sans', sans-serif;
    color: var(--text-primary);
}

html, body {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: var(--app-height);
    background: var(--bg-primary);
}

html.parity-mode,
body.parity-mode {
    overflow: hidden;
}

body.parity-mode[data-parity-animation-phase="static"] *,
body.parity-mode[data-parity-animation-phase="static"] *::before,
body.parity-mode[data-parity-animation-phase="static"] *::after {
    animation-duration: 0s !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0s !important;
    transition-delay: 0s !important;
    caret-color: transparent !important;
}

#app {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
}

.screen.active {
    display: flex;
}
#screen-menu.active,
#screen-profile.active,
#screen-settings.active,
#screen-language.active {
    padding-top: var(--total-top);
    padding-bottom: var(--safe-bottom);
}

.loading-screen {
    position: fixed;
    inset: 0;
    z-index: 9998;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    background: linear-gradient(180deg, #7f60d9 0%, #6a4ac4 100%);
    padding-top: var(--total-top);
    padding-bottom: var(--safe-bottom);
    animation: loading-screen-in 0.18s ease-out;
}
.loading-screen-out {
    animation: loading-screen-out 0.3s ease-out forwards;
}
@keyframes loading-screen-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes loading-screen-out {
    from { opacity: 1; }
    to   { opacity: 0; }
}
.loading-screen-logo {
    width: min(70vw, 360px);
    filter: drop-shadow(0 2px 18px rgba(0,0,0,0.6));
}
.loading-screen-label {
    font-size: 18px;
    font-weight: 800;
    color: rgba(255,255,255,0.9);
    letter-spacing: 3px;
    text-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.wonder-intro-overlay {
    position: fixed;
    inset: 0;
    z-index: 1300;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: calc(var(--total-top, 0px) + 24px) 24px calc(var(--safe-bottom, 0px) + 24px);
    color: #fff;
    overflow: hidden;
    animation: wonder-in 0.3s ease-out;
}
.wonder-intro-overlay.wonder-intro-out {
    animation: wonder-out 0.3s ease-in forwards;
}
@keyframes wonder-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes wonder-out {
    from { opacity: 1; }
    to   { opacity: 0; }
}
.wonder-intro-bg {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    z-index: 0;
}
.wonder-intro-veil {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(10, 14, 42, 0.25) 0%, rgba(10, 14, 42, 0.85) 100%);
    z-index: 1;
}
.wonder-intro-title,
.wonder-intro-body,
.wonder-intro-start-btn {
    position: relative;
    z-index: 2;
}
.wonder-intro-title {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: 2px;
    text-align: center;
    text-shadow: 0 2px 8px rgba(0,0,0,0.6);
    margin-top: auto;
}
.wonder-intro-body {
    max-width: 520px;
    background: rgba(10, 14, 42, 0.55);
    padding: 16px 20px;
    border-radius: 14px;
    font-size: 15px;
    line-height: 1.5;
    color: rgba(255,255,255,0.92);
    text-align: center;
}
.wonder-intro-start-btn {
    background: #5bbf2a;
    color: #fff;
    border: none;
    font-size: 18px;
    font-weight: 800;
    letter-spacing: 2px;
    padding: 14px 40px;
    border-radius: 40px;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(91, 191, 42, 0.4);
    margin-top: auto;
}
.wonder-intro-start-btn:active {
    transform: scale(0.97);
}

.header {
    min-height: calc(var(--header-height) + var(--total-top));
    padding-top: var(--total-top);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-left: 12px;
    padding-right: 12px;
    flex-shrink: 0;
    z-index: 10;
    position: relative;
}

.header-title {
    font-size: 16px;
    font-weight: 600;
    text-align: center;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn {
    border: none;
    background: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    min-width: 40px;
    min-height: 40px;
    transition: background 0.2s;
}

.btn:active {
    background: rgba(255, 255, 255, 0.1);
}

.btn-accent {
    background: var(--accent);
    color: var(--accent-text);
    border-radius: 24px;
    padding: 10px 20px;
    font-size: 16px;
    font-weight: 600;
}

.btn-accent:active {
    opacity: 0.8;
}

.hidden {
    display: none !important;
}

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(4px);
}

.popup {
    background: var(--bg-secondary);
    border-radius: 20px;
    padding: 32px 24px;
    text-align: center;
    max-width: 320px;
    width: 90%;
}

.popup-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.popup-heading {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 8px;
}

.popup-reward {
    font-size: 18px;
    color: #ffd700;
    font-weight: 600;
    margin-bottom: 4px;
}

.popup-total {
    font-size: 14px;
    color: var(--text-hint);
    margin-bottom: 24px;
}

.popup-btn-next {
    width: 100%;
    margin-bottom: 10px;
}

.popup-btn-menu {
    width: 100%;
    font-size: 14px;
    color: var(--text-hint);
}

html, body {
    background: linear-gradient(180deg, #0d1733 0%, #15254c 100%);
}

body {
    color: var(--text-primary);
}

.language-screen {
    display: flex;
    align-items: stretch;
    justify-content: center;
    background:
        linear-gradient(180deg, rgba(8, 16, 36, 0.24) 0%, rgba(8, 16, 36, 0.78) 100%),
        url('../img/splash_bg.jpg') center center / cover no-repeat;
}

.language-screen::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(8, 14, 29, 0.08) 0%, rgba(10, 18, 42, 0.32) 42%, rgba(9, 15, 32, 0.76) 100%);
}

.language-wrap {
    position: relative;
    z-index: 1;
    width: min(100%, 460px);
    margin: auto 0 0;
    padding: calc(var(--total-top) + 44px) 24px calc(var(--safe-bottom) + 34px);
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.language-logo {
    width: min(66vw, 290px);
    align-self: center;
    filter: drop-shadow(0 10px 22px rgba(0, 0, 0, 0.32));
}

.language-title {
    text-align: center;
    font-size: 23px;
    font-weight: 800;
    letter-spacing: 0.02em;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.28);
}

.language-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.language-option {
    border: 0;
    border-radius: 18px;
    padding: 15px 18px;
    background: rgba(7, 13, 30, 0.66);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.01em;
    box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.2), 0 12px 24px rgba(0, 0, 0, 0.18);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

.language-option:active {
    transform: scale(0.98);
}

.language-option.active {
    background: linear-gradient(180deg, rgba(84, 180, 67, 0.96) 0%, rgba(63, 148, 48, 0.96) 100%);
    box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.3), 0 14px 28px rgba(39, 115, 26, 0.34);
}

.language-option-check {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.14);
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 0.12s ease, transform 0.12s ease;
}

.language-option.active .language-option-check {
    opacity: 1;
    transform: scale(1);
    background: rgba(255, 255, 255, 0.28);
}

.language-more {
    text-align: center;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.72);
}

.language-play-btn {
    border: 0;
    border-radius: 999px;
    min-height: 58px;
    background: linear-gradient(180deg, #66c54e 0%, #449d30 100%);
    color: #fff;
    font-size: 21px;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    box-shadow: 0 16px 28px rgba(46, 130, 29, 0.34), inset 0 2px 0 rgba(255, 255, 255, 0.22);
}

.language-play-btn:disabled {
    opacity: 0.55;
}

body.rtl .language-option {
    direction: rtl;
}