/* Базовые стили для игры-гадалки - v9 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    min-height: 100vh;
    min-height: -webkit-fill-available; /* iOS Safari */
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    padding: max(20px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
    position: relative;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

.snow-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    pointer-events: none;
    overflow: hidden;
    display: block !important;
}

.snowflake {
    position: absolute;
    color: rgba(255, 255, 255, 0.8);
    font-size: 20px;
    font-family: Arial, sans-serif;
    text-shadow: 0 0 3px rgba(255, 255, 255, 0.6);
    animation: fall linear;
    user-select: none;
    top: -50px;
    will-change: transform;
    transform: translateZ(0);
}

@keyframes fall {
    from {
        transform: translateY(0);
    }
    to {
        transform: translateY(calc(100vh + 50px));
    }
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    z-index: 3;
    pointer-events: none;
}

.container {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 20px;
    padding: 40px;
    max-width: 800px;
    width: 100%;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    position: relative;
    z-index: 4;
}

/* Убеждаемся, что только один экран виден */
.container > .screen:not(.hidden) {
    display: block;
}

.container > .screen.hidden {
    display: none !important;
}

h1 {
    text-align: center;
    color: rgb(175, 238, 238);
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5), 0 0 20px rgba(175, 238, 238, 0.8), 0 0 30px rgba(175, 238, 238, 0.6);
    margin-bottom: 30px;
    font-size: 2.5em;
    font-weight: bold;
}

h2 {
    text-align: center;
    color: #fff;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    margin-bottom: 30px;
}

.screen {
    display: block;
    opacity: 1;
    transition: opacity 0.3s ease-in-out;
    will-change: opacity;
}

.screen.hidden {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
    pointer-events: none !important;
}

/* Оптимизация для мобильных устройств */
@media (max-width: 600px) {
    .screen {
        transition: opacity 0.25s ease-in-out;
    }
}

#start-screen {
    text-align: center;
}

#start-screen p {
    color: #fff;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    font-size: 1.2em;
    margin-bottom: 20px;
}

.disclaimer {
    margin: 25px auto;
    max-width: 600px;
    text-align: center;
    padding: 0 20px;
}

.disclaimer-title {
    color: rgb(175, 238, 238);
    text-shadow: 0 0 10px rgba(175, 238, 238, 0.6), 0 2px 5px rgba(0, 0, 0, 0.3);
    font-size: 1.1em;
    font-weight: bold;
    margin-bottom: 12px;
}

.disclaimer-text {
    color: rgba(255, 255, 255, 0.7);
    text-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
    font-size: 0.85em;
    line-height: 1.6;
    margin-bottom: 10px;
}

.disclaimer-text:last-child {
    margin-bottom: 0;
}

.start-btn {
    font-size: 1.2em;
    padding: 15px 40px;
}

.options-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    margin-top: 30px;
}

.option-btn {
    padding: 20px;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    border-radius: 10px;
    font-size: 1.1em;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
    line-height: 1.4;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.option-btn:hover {
    transform: translateY(-5px);
    background: rgba(255, 255, 255, 0.3);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
}

/* Отключаем hover эффекты на мобильных устройствах */
@media (hover: none) and (pointer: coarse) {
    .option-btn:hover {
        transform: none;
        background: rgba(255, 255, 255, 0.2);
    }
    
    .btn:hover {
        background: rgba(255, 255, 255, 0.2);
    }
    
    .share-btn:hover {
        background: rgba(37, 211, 102, 0.3);
    }
}

.option-btn:active {
    transform: translateY(-2px);
}

#result-content {
    text-align: center;
    padding: 30px;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    margin-bottom: 20px;
    color: #fff;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    min-height: 100px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.result-title {
    font-size: 1.5em;
    margin-bottom: 15px;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.result-source {
    font-size: 0.9em;
    color: rgb(175, 238, 238);
    font-style: italic;
    margin-top: 10px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    text-shadow: 0 0 10px rgba(175, 238, 238, 0.6), 0 2px 5px rgba(0, 0, 0, 0.3);
}

.btn {
    display: block;
    margin: 20px auto 0;
    padding: 15px 30px;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    border-radius: 10px;
    font-size: 1.1em;
    cursor: pointer;
    transition: all 0.3s;
    text-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.btn:hover {
    background: rgba(255, 255, 255, 0.3);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
}

.share-btn {
    margin-top: 10px;
    background: rgba(37, 211, 102, 0.3);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(37, 211, 102, 0.5);
}

.share-btn:hover {
    background: rgba(37, 211, 102, 0.4);
    border-color: rgba(37, 211, 102, 0.7);
}

/* Адаптивность для планшетов */
@media (max-width: 768px) {
    .container {
        padding: 30px;
        margin: 10px;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
    }
    
    /* Убеждаемся, что скрытые экраны действительно скрыты */
    .screen.hidden {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        height: 0 !important;
        overflow: hidden !important;
        position: absolute !important;
        width: 0 !important;
        pointer-events: none !important;
    }
    
    #start-screen,
    #selection-screen,
    #result-screen {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        text-align: center;
        width: 100%;
    }
    
    h1 {
        font-size: 2.2em;
        text-align: center;
        width: 100%;
    }
    
    h2 {
        font-size: 1.4em;
        text-align: center;
        width: 100%;
    }
    
    #result-content {
        padding: 25px;
    }
    
    .result-title {
        font-size: 1.3em;
    }
    
    .result-source {
        font-size: 0.85em;
        color: rgb(175, 238, 238);
        text-shadow: 0 0 10px rgba(175, 238, 238, 0.6), 0 2px 5px rgba(0, 0, 0, 0.3);
    }
    
    .disclaimer {
        padding: 0 15px;
        margin: 20px auto;
    }
    
    .disclaimer-title {
        font-size: 1em;
        margin-bottom: 10px;
    }
    
    .disclaimer-text {
        font-size: 0.8em;
        line-height: 1.5;
    }
}

/* Адаптивность для мобильных устройств */
@media (max-width: 600px) {
    body {
        padding: 10px;
        padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
        background-attachment: scroll;
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
        -webkit-overflow-scrolling: touch;
        align-items: center;
        justify-content: center;
        min-height: 100vh;
        min-height: -webkit-fill-available;
        height: 100vh;
        height: -webkit-fill-available;
    }
    
    .container {
        padding: 25px 20px;
        margin: auto;
        border-radius: 20px;
        width: 90%;
        max-width: 90%;
        min-height: calc(100vh - 20px);
        min-height: calc(100vh - max(10px, env(safe-area-inset-top)) - max(10px, env(safe-area-inset-bottom)));
        max-height: calc(100vh - 20px);
        max-height: calc(100vh - max(10px, env(safe-area-inset-top)) - max(10px, env(safe-area-inset-bottom)));
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
    }
    
    /* Заголовок не должен мешать центрированию */
    .container > h1 {
        flex: 0 0 auto;
        margin-bottom: 15px;
        margin-top: 0;
    }
    
    /* Убеждаемся, что скрытые экраны действительно скрыты */
    .screen.hidden {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        height: 0 !important;
        overflow: hidden !important;
        position: absolute !important;
        width: 0 !important;
        pointer-events: none !important;
    }
    
    /* Первая страница - центрирована */
    #start-screen {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        text-align: center;
        width: 100%;
        flex: 1 1 auto;
        min-height: 0;
    }
    
    /* Вторая страница - по центру экрана (открывается ПОСЛЕ нажатия "Пачаць") */
    #selection-screen {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        text-align: center;
        width: 100%;
        flex: 1 1 auto;
        min-height: 0;
    }
    
    /* Третья страница - по центру экрана */
    #result-screen {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        text-align: center;
        width: 100%;
        flex: 1 1 auto;
        min-height: 0;
    }
    
    h1 {
        font-size: 2em;
        margin-bottom: 15px;
        text-align: center;
        width: 100%;
    }
    
    h2 {
        font-size: 1.4em;
        margin-bottom: 15px;
        text-align: center;
        width: 100%;
    }
    
    .disclaimer {
        padding: 0 5px;
        margin: 15px auto;
        max-width: 100%;
    }
    
    .disclaimer-title {
        font-size: 1em;
        margin-bottom: 8px;
    }
    
    .disclaimer-text {
        font-size: 0.85em;
        line-height: 1.4;
        margin-bottom: 6px;
    }
    
    #start-screen p {
        font-size: 1.2em;
        margin-bottom: 15px;
    }
    
    .start-btn {
        font-size: 1.2em;
        padding: 15px 35px;
        width: 100%;
        max-width: 100%;
        -webkit-tap-highlight-color: rgba(255, 255, 255, 0.3);
        touch-action: manipulation;
        min-height: 52px;
        margin-top: 10px;
    }
    
    .option-btn {
        padding: 18px;
        font-size: 1.1em;
        min-height: 80px;
        -webkit-tap-highlight-color: rgba(255, 255, 255, 0.3);
        touch-action: manipulation;
        line-height: 1.4;
    }
    
    #result-content {
        padding: 22px;
        min-height: 110px;
    }
    
    .result-title {
        font-size: 1.3em;
        margin-bottom: 12px;
        line-height: 1.4;
    }
    
    .result-source {
        font-size: 0.95em;
        margin-top: 10px;
        color: rgb(175, 238, 238);
        text-shadow: 0 0 10px rgba(175, 238, 238, 0.6), 0 2px 5px rgba(0, 0, 0, 0.3);
    }
    
    .btn {
        width: 100%;
        max-width: 100%;
        padding: 15px 22px;
        font-size: 1.1em;
        -webkit-tap-highlight-color: rgba(255, 255, 255, 0.3);
        touch-action: manipulation;
        min-height: 52px;
    }
    
    .share-btn {
        margin-top: 15px;
    }
    
    .options-container {
        gap: 15px;
        margin-top: 20px;
        width: 100%;
    }
    
    /* Центрирование всех элементов внутри экранов */
    #start-screen > *,
    #selection-screen > *,
    #result-screen > * {
        width: 100%;
        max-width: 100%;
    }
}

/* Адаптивность для очень маленьких экранов */
@media (max-width: 400px) {
    body {
        padding: 8px;
        padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
        align-items: center;
        justify-content: center;
        min-height: 100vh;
        min-height: -webkit-fill-available;
        height: 100vh;
        height: -webkit-fill-available;
    }
    
    .container {
        padding: 20px 15px;
        width: 92%;
        max-width: 92%;
        min-height: calc(100vh - 16px);
        min-height: calc(100vh - max(8px, env(safe-area-inset-top)) - max(8px, env(safe-area-inset-bottom)));
        max-height: calc(100vh - 16px);
        max-height: calc(100vh - max(8px, env(safe-area-inset-top)) - max(8px, env(safe-area-inset-bottom)));
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
    }
    
    /* Заголовок не должен мешать центрированию */
    .container > h1 {
        flex: 0 0 auto;
        margin-bottom: 12px;
        margin-top: 0;
    }
    
    /* Убеждаемся, что скрытые экраны действительно скрыты */
    .screen.hidden {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        height: 0 !important;
        overflow: hidden !important;
        position: absolute !important;
        width: 0 !important;
        pointer-events: none !important;
    }
    
    #start-screen,
    #selection-screen,
    #result-screen {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        text-align: center;
        width: 100%;
        flex: 1 1 auto;
        min-height: 0;
    }
    
    h1 {
        font-size: 1.8em;
        margin-bottom: 12px;
        text-align: center;
        width: 100%;
    }
    
    h2 {
        font-size: 1.3em;
        margin-bottom: 12px;
        text-align: center;
        width: 100%;
    }
    
    .options-container {
        width: 100%;
    }
    
    /* Центрирование всех элементов внутри экранов */
    #start-screen > *,
    #selection-screen > *,
    #result-screen > * {
        width: 100%;
        max-width: 100%;
    }
    
    .option-btn {
        font-size: 1.05em;
        padding: 16px;
        min-height: 75px;
    }
    
    .disclaimer {
        padding: 0 5px;
        margin: 12px auto;
    }
    
    .disclaimer-title {
        font-size: 0.95em;
        margin-bottom: 6px;
    }
    
    .disclaimer-text {
        font-size: 0.8em;
        line-height: 1.4;
        margin-bottom: 5px;
    }
    
    #result-content {
        padding: 20px;
        min-height: 100px;
    }
    
    .result-title {
        font-size: 1.2em;
        margin-bottom: 10px;
    }
    
    .result-source {
        font-size: 0.9em;
        margin-top: 8px;
        color: rgb(175, 238, 238);
        text-shadow: 0 0 10px rgba(175, 238, 238, 0.6), 0 2px 5px rgba(0, 0, 0, 0.3);
    }
    
    .btn {
        font-size: 1.05em;
        padding: 14px 20px;
        min-height: 50px;
    }
    
    .start-btn {
        font-size: 1.15em;
        padding: 14px 30px;
    }
    
    #start-screen p {
        font-size: 1.1em;
        margin-bottom: 12px;
    }
    
    .options-container {
        gap: 12px;
        margin-top: 15px;
    }
}

/* Адаптивность для больших экранов */
@media (min-width: 1200px) {
    .container {
        max-width: 900px;
        padding: 50px;
    }
    
    h1 {
        font-size: 3em;
    }
    
    h2 {
        font-size: 1.8em;
    }
    
    .result-title {
        font-size: 1.8em;
    }
    
    .result-source {
        font-size: 1em;
        color: rgb(175, 238, 238);
        text-shadow: 0 0 10px rgba(175, 238, 238, 0.6), 0 2px 5px rgba(0, 0, 0, 0.3);
    }
}
