@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@700&family=Inter:wght@400;600&display=swap');
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}
html,
body {
    height: 100%;
    overflow: hidden;
    font-family: 'Inter', sans-serif;
    color: #fff;
}
body {
    background: #0b0d2b;
    display: flex;
    flex-direction: column;
    position: relative;
    padding: 20px;
    overscroll-behavior: contain; /* Фикс: Smooth scroll в TG */
}
.stars {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background: radial-gradient(2px 2px at 20px 30px, #fff, transparent),
                radial-gradient(2px 2px at 90px 80px, #fff, transparent),
                radial-gradient(1px 1px at 150px 20px, #fff, transparent);
    background-repeat: repeat;
    background-size: 200px 200px;
    animation: twinkle 10s infinite;
    opacity: .6;
}
@keyframes twinkle {
    0%, 100% {
        opacity: .4;
    }
    50% {
        opacity: .8;
    }
}
.header {
    position: absolute;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    z-index: 10;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}
.player-identity {
    position: fixed;
    top: calc(12px + env(safe-area-inset-top));
    left: 50%;
    transform: translateX(-50%);
    z-index: 8; /* below header/logo (z-index:10) */
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
}
.header.moved .player-identity {
    opacity: 0.95;
}
.header.moved {
    transform: translateX(-50%) translateY(-50px) scale(.85);
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}
.logo {
    font-size: 68px;
    filter: drop-shadow(0 0 20px #8a2be2);
    animation: float 6s ease-in-out infinite;
}
@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}
.fact-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 0 16px clamp(140px, 26vh, 180px);
    z-index: 1;
    max-width: 100%;
}
.fact {
    font-size: clamp(1rem, 4.2vw, 1.25rem);
    line-height: 1.6;
    max-width: 95%;
    padding: 20px;
    background: rgba(138, 43, 226, .15);
    border-radius: 24px;
    border: 1.5px solid rgba(138, 43, 226, .4);
    backdrop-filter: blur(14px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, .5);
    /* Disable height transition to avoid jitter; size is computed up-front */
    transition: none;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    word-break: keep-all !important;
    overflow-wrap: break-word !important;
    hyphens: none !important;
    -webkit-hyphens: none !important;
    -moz-hyphens: none !important;
    max-height: none;
    height: auto;
    min-height: auto;
    margin-top: 20px;
    text-align: left;
    overflow: hidden;
}
.fact.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    transition: opacity 0.3s ease-out,
                transform 0.3s ease-out;
}
.fact small {
    display: block;
    margin-top: 16px;
    font-size: 1rem;
    opacity: .8;
    font-style: italic;
    animation: fadeInText 0.6s ease-out 0.3s both;
}
.fact small.welcome-caption {
    font-style: italic; /* Match author quote style */
    margin-top: 8px;
    opacity: 0; /* Start invisible for animation */
    /* Animation will fade in the caption phrase only */
    animation: fadeInWelcomeCaption 0.6s ease-out 0.3s forwards; /* Match quiz mode animation style */
}
/* When parent is visible and caption is not animated yet, allow animation to play */
.fact.visible small.welcome-caption:not(.animated) {
    animation: fadeInWelcomeCaption 0.6s ease-out 0.3s forwards;
}
/* Prevent animation from replaying when content is updated while already visible */
.fact.visible small.welcome-caption.animated {
    animation: none !important;
    opacity: 0.7 !important; /* Maintain final opacity */
}
/* Ensure caption without animated class starts invisible */
.fact small.welcome-caption:not(.animated) {
    opacity: 0;
}
.fact.quiz-fact {
    max-height: none;
    height: auto;
    overflow: hidden;
    padding: 20px;
    overscroll-behavior: contain;
}
@keyframes fadeInText {
    from {
        opacity: 0;
        transform: translateY(5px);
    }
    to {
        opacity: 0.8;
        transform: translateY(0);
    }
}
@keyframes fadeInWelcomeCaption {
    from {
        opacity: 0;
        transform: translateY(5px);
    }
    to {
        opacity: 0.7;
        transform: translateY(0);
    }
}
/* Наследование правил типографики для всех вложенных элементов */
.fact i,
.fact small,
.fact p {
    word-break: keep-all !important;
    overflow-wrap: break-word !important;
    hyphens: none !important;
    -webkit-hyphens: none !important;
    -moz-hyphens: none !important;
}
/* КНОПКА КИТА (ГЛАВНАЯ) */
.action-buttons {
    position: fixed;
    bottom: 150px; /* Позиция выше боковых кнопок */
    left: 50%;
    transform: translateX(-50%);
    z-index: 10; /* Below modals (z-index: 9999+) */
    gap: 0;
}
.btn {
    width: 80px;
    height: 80px;
    min-width: 80px;
    min-height: 80px;
    border-radius: 20px;
    border: none;
    font-size: 2.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 8px 24px rgba(0, 0, 0, .4);
    backdrop-filter: blur(8px);
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
    position: relative;
    overflow: hidden;
}
.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.3s, height 0.3s;
    pointer-events: none;
}
.btn:active::before {
    width: 200px;
    height: 200px;
}
.btn:hover {
    transform: translateY(-4px) scale(1.05);
    box-shadow: 0 16px 36px rgba(0, 0, 0, .6);
}
.btn:active {
    transform: translateY(-2px) scale(0.95);
    box-shadow: 0 4px 12px rgba(0, 0, 0, .4);
}
#cube-btn {
    background: linear-gradient(135deg, #8a2be2, #5e35b1);
    border: 3px solid #a855f7;
}
#cube-btn:active {
    background: linear-gradient(135deg, #7a1bd2, #4e25a1);
    border-color: #9855e7;
}
/* СТИЛИ ИКОНОК */
.icon {
    width: 56px;
    height: 56px;
    min-width: 56px;
    min-height: 56px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.9rem;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .5);
    z-index: 1000;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    touch-action: manipulation;
}
.icon::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
    transform: translate(-50%, -50%);
    transition: width 0.3s, height 0.3s;
    pointer-events: none;
}
.icon:active::before {
    width: 150px;
    height: 150px;
}
.icon:hover {
    transform: translateY(-3px) scale(1.08);
    box-shadow: 0 12px 28px rgba(0, 0, 0, .7);
}
.icon:active {
    transform: translateY(-1px) scale(0.92);
    box-shadow: 0 4px 12px rgba(0, 0, 0, .5);
}
/* КОЛОКОЛЬЧИК (Bottom Right) */
#notification-bell {
    position: fixed;
    bottom: 50px; /* Позиция над футером */
    right: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ff5722;
    font-size: 1.5rem;
    line-height: 1;
    width: 56px;
    height: 56px;
    min-width: 56px;
    min-height: 56px;
    z-index: 1100;
    transform: translateY(-3px);
    padding-top: 2px;
    border-radius: 16px;
}
.notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: red;
    color: white;
    border-radius: 50%;
    padding: 2px 6px;
    font-size: 0.7rem;
    font-weight: bold;
    line-height: 1;
    min-width: 18px;
    text-align: center;
    display: none;
}
/* FAB МЕНЮ (Bottom Left) */
.fab-menu-container {
    position: fixed;
    bottom: 50px;
    left: 16px;
    z-index: 1100;
    display: flex;
    flex-direction: column-reverse;
    align-items: center;
}
.menu-toggle-btn {
    position: relative !important;
    background: #0088cc;
    width: 56px;
    height: 56px;
    min-width: 56px;
    min-height: 56px;
}
.fab-items {
    display: flex;
    flex-direction: column-reverse;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.fab-item {
    width: 56px;
    height: 56px;
    min-width: 56px;
    min-height: 56px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    background: rgba(0, 136, 204, 0.9);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0;
    transform: scale(0);
    pointer-events: none;
    position: relative;
    overflow: hidden;
    touch-action: manipulation;
}
.fab-item::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
    transform: translate(-50%, -50%);
    transition: width 0.3s, height 0.3s;
    pointer-events: none;
}
.fab-item:active::before {
    width: 150px;
    height: 150px;
}
.fab-item:hover {
    background: #4ab7f7;
    transform: scale(1.08);
}
.fab-item:active {
    transform: scale(0.92);
    background: rgba(0, 120, 180, 0.9);
}
/* СОСТОЯНИЕ АКТИВНОГО МЕНЮ */
.fab-menu-container.active .fab-items .fab-item {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}
/* Анимация задержки выезда */
.fab-menu-container.active .fab-items :nth-child(1) { transition-delay: 0.05s; }
.fab-menu-container.active .fab-items :nth-child(2) { transition-delay: 0.10s; }
.fab-menu-container.active .fab-items :nth-child(3) { transition-delay: 0.15s; }
.fab-menu-container.active .fab-items :nth-child(4) { transition-delay: 0.20s; }
.fab-menu-container.active .fab-items :nth-child(5) { transition-delay: 0.25s; }
.fab-menu-container.active .fab-items :nth-child(6) { transition-delay: 0.30s; }
.fab-menu-container.active .fab-items :nth-child(7) { transition-delay: 0.35s; }
.footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px 8px;
    font-size: .7rem;
    text-align: center;
    background: linear-gradient(transparent, rgba(11, 13, 43, .95));
    opacity: .9;
    z-index: 2;
    pointer-events: none;
}
/* СТИЛИ ДЛЯ КНОПОК КВИЗА */
.quiz-buttons {
    position: fixed;
    bottom: calc(140px + var(--btn-size));
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 16px;
    z-index: 1000;
    width: auto;
    max-width: 90vw;
    opacity: 0;
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}
.quiz-buttons.visible {
    opacity: 1;
    pointer-events: auto;
}
.quiz-buttons .btn {
    transform: scale(0.8);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
                opacity 0.3s ease;
}
.quiz-buttons.visible .btn {
    transform: scale(1);
}
.quiz-buttons.visible .btn:nth-child(1) {
    transition-delay: 0.1s;
}
.quiz-buttons.visible .btn:nth-child(2) {
    transition-delay: 0.15s;
}
.quiz-buttons .btn {
    width: var(--quiz-btn-size);
    height: var(--quiz-btn-size);
    min-width: var(--quiz-btn-size);
    min-height: var(--quiz-btn-size);
    max-width: var(--quiz-btn-size);
    max-height: var(--quiz-btn-size);
    border-radius: 18px;
    font-size: clamp(1.4rem, 5vw, 1.8rem);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35), 0 2px 4px rgba(0, 0, 0, 0.2);
    transform: none;
    border: 3px solid;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    touch-action: manipulation;
    position: relative;
    overflow: hidden;
}
.quiz-buttons .btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.3s, height 0.3s;
}
.quiz-buttons .btn:active::before {
    width: 200px;
    height: 200px;
}
.quiz-buttons .btn:active {
    transform: scale(0.92);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
}
.quiz-buttons .btn:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4), 0 4px 6px rgba(0, 0, 0, 0.25);
}
/* ПРАВДА/ВЕРНО (Green/Success) */
#true-btn {
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    border-color: #66BB6A;
    color: #ffffff;
}
#true-btn:hover {
    background: linear-gradient(135deg, #5CBF60 0%, #4CAF50 100%);
    box-shadow: 0 8px 20px rgba(76, 175, 80, 0.4), 0 4px 6px rgba(0, 0, 0, 0.25);
}
#true-btn:active {
    background: linear-gradient(135deg, #3d8f40 0%, #358039 100%);
    border-color: #55aa59;
}
/* ЛОЖЬ/ОТМЕНА (Red/Danger) */
#false-btn {
    background: linear-gradient(135deg, #F44336 0%, #e53935 100%);
    border-color: #E57373;
    color: #ffffff;
}
#false-btn:hover {
    background: linear-gradient(135deg, #FF5252 0%, #F44336 100%);
    box-shadow: 0 8px 20px rgba(244, 67, 54, 0.4), 0 4px 6px rgba(0, 0, 0, 0.25);
}
#false-btn:active {
    background: linear-gradient(135deg, #d32f2f 0%, #c62828 100%);
    border-color: #d45555;
}
/* Stack vertically on narrow screens */
@media (max-width: 360px) {
    .quiz-buttons {
        flex-direction: row;
        gap: 12px;
    }
}
/* Responsive adjustments for medium screens */
@media (min-width: 361px) and (max-width: 480px) {
    .quiz-buttons .btn {
        width: 68px;
        height: 68px;
        min-width: 68px;
        min-height: 68px;
        max-width: 68px;
        max-height: 68px;
    }
}
/* СТИЛИ ДЛЯ УВЕДОМЛЕНИЙ */
#notification-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 10000; /* Above whale button (z-index: 10) */
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease-in-out, visibility 0s 0.3s;
}
#notification-modal.active {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s ease-in-out;
}
#notification-content {
    background: #1e0f3b;
    padding: 25px;
    border-radius: 15px;
    max-width: 90%;
    width: 350px;
    text-align: center;
    color: white;
    border: 1px solid rgba(138, 43, 226, 0.6);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
    max-height: 80vh;
    overflow-y: auto;
}
#xp-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.88);
    backdrop-filter: blur(8px);
    z-index: 10000; /* Increased to ensure it's above whale button (z-index: 10) */
    display: flex;
    align-items: flex-start;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease-out, visibility 0s 0.25s;
    padding: 20px;
    padding-top: 90px;
    box-sizing: border-box;
}
#xp-modal.active { 
    opacity: 1; 
    visibility: visible; 
    transition: opacity 0.25s ease-out; 
}
#xp-content {
    background: linear-gradient(135deg, #1a0d35 0%, #2d1a4a 100%);
    padding: 0;
    border-radius: 20px;
    max-width: 100%;
    width: 420px;
    max-width: calc(100vw - 40px);
    color: #ffffff;
    border: 1px solid rgba(138, 43, 226, 0.4);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(138, 43, 226, 0.1);
    max-height: 90vh;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    text-align: left;
    scrollbar-width: thin;
    scrollbar-color: rgba(138, 43, 226, 0.4) transparent;
    position: relative; /* Ensure proper stacking context */
    z-index: 1; /* Local stacking order within modal */
}
#xp-content::-webkit-scrollbar {
    width: 6px;
}
#xp-content::-webkit-scrollbar-track {
    background: transparent;
}
#xp-content::-webkit-scrollbar-thumb {
    background: rgba(138, 43, 226, 0.4);
    border-radius: 3px;
}
#xp-content::-webkit-scrollbar-thumb:hover {
    background: rgba(138, 43, 226, 0.6);
}
.xp-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 24px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.xp-header h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    color: #ffffff;
    letter-spacing: -0.02em;
}
.xp-close {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.2s;
}
.xp-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}
.xp-section {
    padding: 24px;
}
.xp-divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.08), transparent);
    margin: 0;
}
.xp-progress-section {
    padding-bottom: 20px;
}
.xp-current-level {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}
.xp-level-badge {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    background: linear-gradient(135deg, #8a2be2 0%, #4ab7f7 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    font-weight: 700;
    color: #ffffff;
    box-shadow: 0 8px 24px rgba(138, 43, 226, 0.4);
    flex-shrink: 0;
}
.xp-level-info {
    flex: 1;
    min-width: 0;
}
.xp-level-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #ffffff;
    margin-bottom: 4px;
    letter-spacing: -0.01em;
}
.xp-progress-text {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.7);
    font-weight: 500;
}
.xp-bar-container {
    margin-bottom: 16px;
}
.xp-bar {
    width: 100%;
    height: 12px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 6px;
    position: relative;
}
.xp-bar-fill {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, #8a2be2 0%, #4ab7f7 100%);
    border-radius: 10px;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 12px rgba(138, 43, 226, 0.5);
}
.xp-bar-label {
    text-align: right;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.6);
    font-weight: 500;
}
.xp-streak-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.8);
    padding: 10px 14px;
    background: rgba(255, 165, 0, 0.1);
    border-radius: 10px;
    border: 1px solid rgba(255, 165, 0, 0.2);
}
.xp-streak-icon {
    font-size: 1.1rem;
}
.xp-section-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #ffffff;
    margin: 0 0 16px 0;
    letter-spacing: -0.01em;
}
.xp-sources-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.xp-source-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: all 0.2s;
}
.xp-source-item:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(138, 43, 226, 0.3);
}
.xp-source-icon {
    font-size: 1.5rem;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.xp-source-details {
    flex: 1;
    min-width: 0;
}
.xp-source-name {
    font-size: 0.95rem;
    color: #ffffff;
    font-weight: 500;
    margin-bottom: 2px;
}
.xp-source-value {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.7);
    font-weight: 500;
}
.xp-source-cap {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.8rem;
    font-weight: 400;
}
.xp-levels-scroll {
    max-height: 320px;
    overflow-y: auto;
    margin: -8px;
    padding: 8px;
    scrollbar-width: thin;
    scrollbar-color: rgba(138, 43, 226, 0.4) transparent;
}
.xp-levels-scroll::-webkit-scrollbar {
    width: 6px;
}
.xp-levels-scroll::-webkit-scrollbar-track {
    background: transparent;
}
.xp-levels-scroll::-webkit-scrollbar-thumb {
    background: rgba(138, 43, 226, 0.4);
    border-radius: 3px;
}
.xp-levels-scroll::-webkit-scrollbar-thumb:hover {
    background: rgba(138, 43, 226, 0.6);
}
.xp-levels-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.xp-level-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: all 0.2s;
}
.xp-level-item:hover {
    background: rgba(255, 255, 255, 0.06);
}
.xp-level-item.current-level {
    background: linear-gradient(135deg, rgba(138, 43, 226, 0.25) 0%, rgba(74, 183, 247, 0.15) 100%);
    border-color: rgba(138, 43, 226, 0.5);
    box-shadow: 0 4px 12px rgba(138, 43, 226, 0.2);
}
.xp-level-item-number {
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    min-width: 32px;
}
.xp-level-item.current-level .xp-level-item-number {
    color: #ffd700;
    font-size: 1.05rem;
}
.xp-level-item-title {
    flex: 1;
    margin: 0 12px;
    color: rgba(255, 255, 255, 0.85);
    font-weight: 500;
}
.xp-level-item.current-level .xp-level-item-title {
    color: #ffffff;
    font-weight: 600;
}
.xp-level-item-xp {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.6);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}
.xp-level-item.current-level .xp-level-item-xp {
    color: rgba(255, 215, 0, 0.9);
}
/* Level-up toast */
.toast-levelup {
    position: fixed;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    max-width: 85vw;
    width: auto;
    z-index: 1200;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: 14px;
    background: rgba(18, 20, 48, 0.85);
    border: 1px solid rgba(138, 43, 226, 0.35);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    color: #fff;
    backdrop-filter: blur(8px);
    animation: toast-slide-in 300ms ease-out forwards;
}
.toast-levelup.hide {
    animation: toast-fade-out 250ms ease-in forwards;
}
.toast-icon {
    font-size: 1.25rem;
}
.toast-text {
    font-size: 0.95rem;
    line-height: 1.3;
}
@keyframes toast-slide-in {
    from { opacity: 0; transform: translateX(-50%) translateY(-10px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}
@keyframes toast-fade-out {
    from { opacity: 1; transform: translateX(-50%) translateY(0); }
    to { opacity: 0; transform: translateX(-50%) translateY(-6px); }
}

/* Compact-height adjustments (e.g., iPhone SE, small Android devices) */
@media (max-height: 640px) {
    .header { top: 48px; }
    .header.moved { transform: translateX(-50%) translateY(-36px) scale(.85); }
    .fact { font-size: clamp(0.95rem, 4.6vw, 1.15rem); line-height: 1.5; padding: 16px; }
    .fact-container { padding: 0 14px clamp(130px, 24vh, 160px); }
    .action-buttons { bottom: 120px; }
    .quiz-buttons { bottom: calc(120px + var(--btn-size)); gap: 12px; }
    .fab-items { display: grid; grid-template-columns: repeat(2, var(--icon-size)); gap: 10px 12px; align-items: center; justify-items: center; }
}
@media (max-width: 480px) {
    #xp-content {
        width: 100%;
        max-width: 100%;
        border-radius: 20px 20px 0 0;
        max-height: 95vh;
    }
    .xp-section {
        padding: 20px;
    }
    .xp-level-item-title {
        font-size: 0.9rem;
    }
    /* Adjust button sizes for smaller screens */
    .btn {
        width: var(--btn-size);
        height: var(--btn-size);
        min-width: var(--btn-size);
        min-height: var(--btn-size);
        font-size: clamp(1.8rem, 6vw, 2.2rem);
    }
    .icon {
        width: var(--icon-size);
        height: var(--icon-size);
        min-width: var(--icon-size);
        min-height: var(--icon-size);
        font-size: clamp(1.4rem, 5vw, 1.8rem);
    }
    #notification-bell,
    .menu-toggle-btn,
    .fab-item {
        width: var(--icon-size);
        height: var(--icon-size);
        min-width: var(--icon-size);
        min-height: var(--icon-size);
    }
    .action-buttons {
        bottom: 130px;
    }
}
@media (max-width: 360px) {
    .btn {
        width: var(--btn-size);
        height: var(--btn-size);
        min-width: var(--btn-size);
        min-height: var(--btn-size);
        font-size: clamp(1.6rem, 6.2vw, 2rem);
    }
    .icon,
    #notification-bell,
    .menu-toggle-btn,
    .fab-item {
        width: var(--icon-size);
        height: var(--icon-size);
        min-width: var(--icon-size);
        min-height: var(--icon-size);
        font-size: clamp(1.3rem, 5.2vw, 1.7rem);
    }
    #notification-bell {
        right: 12px;
        bottom: 45px;
    }
    .fab-menu-container {
        left: 12px;
        bottom: 45px;
    }
    .action-buttons {
        bottom: 120px;
    }
    .fact-container {
        padding: 0 14px 150px;
    }
}
@media (min-width: 481px) and (max-width: 768px) {
    .btn {
        width: 76px;
        height: 76px;
        min-width: 76px;
        min-height: 76px;
    }
}
#notification-content h3 {
    font-size: 1.8rem;
    color: #ffd700;
    margin-bottom: 20px;
}
#daily-section h4 {
    color: #8aff8a;
    margin-top: 15px;
    margin-bottom: 5px;
}
#daily-section p {
    font-size: 1rem;
    line-height: 1.5;
    margin-bottom: 15px;
    padding: 0 10px;
}
#achievements-section {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    opacity: 0.8;
}
/* Исправление для модалок */
#notification-modal .modal-content {
    background: #1e0f3b;
    padding: 25px;
    border-radius: 15px;
    max-width: 90%;
    width: 350px;
    text-align: center;
    color: white;
    border: 1px solid rgba(138, 43, 226, 0.6);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
    max-height: 80vh;
    overflow-y: auto;
}
/* АУДИО МОДАЛ */
#audio-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.88);
    backdrop-filter: blur(8px);
    z-index: 10000; /* Above whale button (z-index: 10) */
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease-out, visibility 0s 0.25s;
    padding: 20px;
    box-sizing: border-box;
}
#audio-modal.active {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.25s ease-out;
}
.audio-modal-content {
    background: linear-gradient(135deg, #1a0d35 0%, #2d1a4a 100%);
    padding: 0;
    border-radius: 20px;
    max-width: 100%;
    width: 420px;
    max-width: calc(100vw - 40px);
    color: #ffffff;
    border: 1px solid rgba(138, 43, 226, 0.4);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(138, 43, 226, 0.1);
    max-height: 90vh;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    text-align: left;
}
.audio-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 24px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.audio-modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    color: #ffffff;
    letter-spacing: -0.02em;
}
.audio-close {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    min-width: 32px;
    min-height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.2s;
    touch-action: manipulation;
}
.audio-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}
.audio-close:active {
    transform: scale(0.9);
}
.audio-controls {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}
.audio-control-item {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.audio-control-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1rem;
    font-weight: 500;
    color: #ffffff;
}
.audio-icon {
    font-size: 1.3rem;
}
.audio-control-slider-container {
    display: flex;
    align-items: center;
    gap: 12px;
}
.audio-slider {
    flex: 1;
    height: 8px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.1);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
    touch-action: manipulation;
}
.audio-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, #8a2be2 0%, #4ab7f7 100%);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    transition: all 0.2s;
}
.audio-slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 8px rgba(138, 43, 226, 0.5);
}
.audio-slider::-webkit-slider-thumb:active {
    transform: scale(0.95);
}
.audio-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, #8a2be2 0%, #4ab7f7 100%);
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    transition: all 0.2s;
}
.audio-slider::-moz-range-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 8px rgba(138, 43, 226, 0.5);
}
.audio-slider::-moz-range-thumb:active {
    transform: scale(0.95);
}
.audio-volume-value {
    min-width: 45px;
    text-align: right;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.7);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}
.audio-control-buttons {
    display: flex;
    gap: 8px;
}
.audio-mute-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ffffff;
    font-size: 1.2rem;
    padding: 8px 16px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    touch-action: manipulation;
    min-width: 48px;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.audio-mute-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
}
.audio-mute-btn:active {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 0.2);
}
.audio-mute-btn.muted {
    background: rgba(244, 67, 54, 0.2);
    border-color: rgba(244, 67, 54, 0.4);
}
@media (max-width: 480px) {
    .audio-modal-content {
        width: 100%;
        max-width: 100%;
        border-radius: 20px 20px 0 0;
        max-height: 95vh;
    }
    .audio-controls {
        padding: 20px;
    }
}

/* Responsive sizing and safe-area adjustments */
:root {
    --btn-size: clamp(64px, 16vw, 80px);
    --icon-size: clamp(48px, 14vw, 56px);
    --quiz-btn-size: clamp(56px, 14vw, 70px);
}

/* Override base sizes for better mobile adaptation */
.btn {
    width: var(--btn-size);
    height: var(--btn-size);
    min-width: var(--btn-size);
    min-height: var(--btn-size);
    font-size: clamp(1.8rem, 6vw, 2.4rem);
}
.icon,
#notification-bell,
.menu-toggle-btn,
.fab-item {
    width: var(--icon-size);
    height: var(--icon-size);
    min-width: var(--icon-size);
    min-height: var(--icon-size);
    font-size: clamp(1.4rem, 5vw, 1.9rem);
}

/* Quiz buttons bounce-back animation */
@keyframes press-bounce {
    0% { transform: scale(1); }
    50% { transform: scale(0.92); }
    100% { transform: scale(1); }
}
.quiz-buttons .btn.pressed {
    animation: press-bounce 0.12s ease-out;
}

/* Use safe-area insets for bottom-anchored controls */
@supports (bottom: env(safe-area-inset-bottom)) {
    .action-buttons { bottom: calc(140px + env(safe-area-inset-bottom)); }
    #notification-bell { bottom: calc(45px + env(safe-area-inset-bottom)); }
    .fab-menu-container { bottom: calc(45px + env(safe-area-inset-bottom)); }
    .fact-container { padding: 0 16px calc(160px + env(safe-area-inset-bottom)); }
}

@supports (bottom: env(safe-area-inset-bottom)) {
    .quiz-buttons { bottom: calc(140px + env(safe-area-inset-bottom) + var(--btn-size)); }
}

/* Registration modal (full-screen, blocks UI until completed) */
#registration-modal {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(6px);
    z-index: 30000; /* Highest priority - above all interactive UI */
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease-out, visibility 0s 0.25s;
}
#registration-modal.active {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.25s ease-out;
}
#registration-modal .modal-content {
    background: linear-gradient(135deg, #1a0d35 0%, #2d1a4a 100%);
    border: 1px solid rgba(138, 43, 226, 0.4);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(138, 43, 226, 0.1);
    color: #fff;
    border-radius: 20px;
    width: 420px;
    max-width: calc(100vw - 40px);
    padding: 22px;
    text-align: center;
}
#registration-modal .reg-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
#registration-modal .reg-input {
    width: 100%;
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    outline: none;
    font-size: 1rem;
}
#registration-modal .reg-input::placeholder {
    color: rgba(255, 255, 255, 0.7);
}
#registration-modal .reg-btn {
    width: 100%;
    padding: 14px 16px;
    border-radius: 14px;
    border: 2px solid #ffd70033;
    background: linear-gradient(135deg, #4ab7f7 0%, #8a2be2 100%);
    color: #ffffff;
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 10px 28px rgba(74, 183, 247, 0.25);
    transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}
#registration-modal .reg-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 36px rgba(74, 183, 247, 0.35);
    filter: brightness(1.05);
}
#registration-modal .reg-btn:active {
    transform: translateY(0) scale(0.98);
    box-shadow: 0 6px 18px rgba(74, 183, 247, 0.25);
}
@media (max-width: 480px) {
    #registration-modal .modal-content {
        width: 100%;
        max-width: 100%;
        border-radius: 20px;
        padding: 20px;
    }
}

/* LEADERBOARD MODAL */
#leaderboard-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.88);
    backdrop-filter: blur(8px);
    z-index: 10000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease-out, visibility 0s 0.25s;
    padding: 20px;
    padding-top: 90px;
    box-sizing: border-box;
}
#leaderboard-modal.active {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.25s ease-out;
}
.leaderboard-content {
    background: linear-gradient(135deg, #1a0d35 0%, #2d1a4a 100%);
    padding: 0;
    border-radius: 20px;
    max-width: 100%;
    width: 420px;
    max-width: calc(100vw - 40px);
    color: #ffffff;
    border: 1px solid rgba(138, 43, 226, 0.4);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(138, 43, 226, 0.1);
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    text-align: left;
}
.leaderboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 24px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}
.leaderboard-header h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    color: #ffffff;
    letter-spacing: -0.02em;
}
.leaderboard-close {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    min-width: 32px;
    min-height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.2s;
    touch-action: manipulation;
}
.leaderboard-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}
.leaderboard-close:active {
    transform: scale(0.9);
}
.leaderboard-list {
    padding: 16px 24px 24px;
    overflow-y: auto;
    flex: 1;
    scrollbar-width: thin;
    scrollbar-color: rgba(138, 43, 226, 0.4) transparent;
}
.leaderboard-list::-webkit-scrollbar {
    width: 6px;
}
.leaderboard-list::-webkit-scrollbar-track {
    background: transparent;
}
.leaderboard-list::-webkit-scrollbar-thumb {
    background: rgba(138, 43, 226, 0.4);
    border-radius: 3px;
}
.leaderboard-list::-webkit-scrollbar-thumb:hover {
    background: rgba(138, 43, 226, 0.6);
}
.leaderboard-loading {
    text-align: center;
    padding: 40px 20px;
    color: rgba(255, 255, 255, 0.6);
    font-size: 1rem;
}
.leaderboard-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    margin-bottom: 8px;
    transition: all 0.2s;
}
.leaderboard-item:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(138, 43, 226, 0.3);
}
.leaderboard-item.current-player {
    background: linear-gradient(135deg, rgba(138, 43, 226, 0.25) 0%, rgba(74, 183, 247, 0.15) 100%);
    border-color: rgba(138, 43, 226, 0.5);
    box-shadow: 0 4px 12px rgba(138, 43, 226, 0.2);
}
.leaderboard-rank {
    font-weight: 700;
    font-size: 1.2rem;
    min-width: 36px;
    text-align: center;
    color: rgba(255, 255, 255, 0.7);
}
.leaderboard-item.top-1 .leaderboard-rank {
    color: #ffd700;
    font-size: 1.4rem;
}
.leaderboard-item.top-2 .leaderboard-rank {
    color: #c0c0c0;
    font-size: 1.3rem;
}
.leaderboard-item.top-3 .leaderboard-rank {
    color: #cd7f32;
    font-size: 1.2rem;
}
.leaderboard-player-info {
    flex: 1;
    min-width: 0;
}
.leaderboard-nickname {
    font-weight: 600;
    font-size: 1rem;
    color: #ffffff;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.leaderboard-level {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.6);
}
.leaderboard-xp {
    font-weight: 600;
    font-size: 1rem;
    color: #4ab7f7;
    text-align: right;
    min-width: 80px;
    font-variant-numeric: tabular-nums;
}
.leaderboard-item.current-player .leaderboard-xp {
    color: #ffd700;
}
@media (max-width: 480px) {
    .leaderboard-content {
        width: 100%;
        max-width: 100%;
        border-radius: 20px 20px 0 0;
        max-height: 95vh;
    }
    .leaderboard-list {
        padding: 12px 20px 20px;
    }
    .leaderboard-nickname {
        font-size: 0.95rem;
    }
    .leaderboard-xp {
        font-size: 0.9rem;
        min-width: 70px;
    }
}
