/* Основные стили */
body {
    margin: 0;
    padding: 0;
    font-family: Arial, sans-serif;
    background-color: #f5f5f5;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    position: relative;
}
/* Стили для экрана загрузки */
#loading-screen {
    background-image: url('../assets/images/background.png');
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 999; /* Ниже фона, но выше других элементов */
    background-color: transparent;
    -webkit-user-drag: none;
    user-select: none !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    pointer-events: all; /* Блокируем все клики */
  }
  
  .loading-bar {
    width: 50vw;
    height: 1.5vh;
    background-color: rgba(0, 0, 0, 0.15); /* Темный фон для контраста */
    border-radius: 1vh;
    overflow: hidden;
    border: 0.3vh solid rgba(255, 255, 255, 0.3); /* Белая полупрозрачная обводка */
    box-shadow: 
      0 0 1vh rgba(0, 0, 0, 0.2), /* Внешняя тень */
      inset 0 0 1vh rgba(0, 0, 0, 0.1); /* Внутренняя тень */
  }
  
  .loading-progress {
    height: 100%;
    width: 0%;
    background: linear-gradient(
      90deg,
      #ff4d4d 0%,
      #FFCC00 50%,
      #74ff4d 100%
    ); /* Градиент для красоты */
    border-radius: 0.8vh; /* Чуть меньше, чем у родителя */
    transition: width 0.4s ease-out;
    position: relative;
    overflow: hidden;
  }
  
  /* Анимация "бегущего" эффекта */
  .loading-progress::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
      90deg,
      transparent 0%,
      rgba(255, 255, 255, 0.4) 50%,
      transparent 100%
    );
    animation: shine 1.5s infinite;
  }
  
  @keyframes shine {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
  }
  
  /* Плавное исчезновение */
  #loading-screen.hidden {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s ease, visibility 0.5s;
    pointer-events: none; /* Разблокируем после анимации */
  }


h1 {
    font-size: 4.5vh;
    font-weight: bold;
    margin-bottom: 2vh;
    text-align: center;
  }
  
  span, p {
    font-size: 2.2vh;
  }
  
#background-image {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('../assets/images/background.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    z-index: -1;
    -webkit-user-drag: none;
    pointer-events: none !important;
    user-select: none !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
}
.leaderboard-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    cursor: default;
}

.leaderboard-popup {
    background: white;
    border-radius: 1.5vh;
    padding: 3vh;
    width: 90%;
    max-width: 65vh;
    max-height: 80vh;
    overflow-y: auto;
    pointer-events: auto;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.leaderboard-list {
    margin: 2vh 0;
    user-select: none;
    width: 100%;
}
.leaderboard-list, 
.leaderboard-list * {
    pointer-events: none !important;
    user-select: none !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
}

.leaderboard-popup h1,
.leaderboard-item,
.leaderboard-item *,
.close-leaderboard {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    cursor: default;
}
.leaderboard-item {
    display: grid;
    grid-template-columns: 4vh 1fr 11vh;
    align-items: center;
    padding: 1.5vh 0.8vh;
    border-bottom: 0.15vh solid #eee;
    cursor: default;
}

.rank {
    text-align: center;
    padding-right: 1vh;
}

.name {
    padding: 0 1.5vh;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.score {
    text-align: right;
    font-weight: bold;
}

.close-leaderboard {
    display: block;
    width: calc(100% - 1.5vh);
    margin: 2vh auto 0;
    padding: 2vh 0;
    background: #FFDB4D;
    border: none;
    border-radius: 1vh;
    font-size: 2vh;
    cursor: pointer;
    text-align: center;
    transition: all 0.3s ease;
}

.close-leaderboard:hover {
    background: #FFCC00;
    transform: translateY(-0.3vh);
}

.leaderboard-item.top-1 {
    background: #ffd700;
    font-weight: bold;
}

.leaderboard-item.top-2 {
    background: #c0c0c0;
}

.leaderboard-item.top-3 {
    background: #cd7f32;
}

.rank, .name, .score {
    pointer-events: none !important;
    cursor: default !important;
    user-select: none !important;
}

.rewarded-ad-button {
    background-color: #4CAF50;
    color: white;
    border: none;
    padding: 2vh 3vh;
    margin-top: 2vh;
    border-radius: 1vh;
    font-size: 2vh;
    cursor: pointer;
}
body.no-scroll, html.no-scroll {
    overflow: hidden !important;
    position: fixed;
    width: 100%;
    height: 100%;
}
#leaderboard-container {
    top: 1.5vh;
    right: 1.5vh;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 1vh;
    z-index: 100;
}

#show-leaderboard-btn {
    background-color: #FFDB4D;
    border: none;
    border-radius: 2vh;
    font-size: 1.8vh;
    cursor: pointer;
    transition: transform 0.2s;
}

#show-leaderboard-btn:hover {
    transform: scale(1.05);
}

#show-leaderboard-btn:active {
    transform: scale(0.95);
}
.new-record {
    animation: pulse 0.5s ease-in-out;
    box-shadow: 0 0 2vh rgba(255, 215, 0, 0.7);
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}
#game-container {
    width: 100%;
    max-width: 110vh;
    background-color: white;
    border-radius: 1.5vh;
    box-shadow: 0 0 3vh rgba(0, 0, 0, 0.1);
    overflow: hidden;
    user-select: none;
    touch-action: manipulation;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

.screen {
    padding: 3vh;
    text-align: center;
}

.hidden {
    display: none;
}

button {
    background-color: #FFDB4D;
    border: none;
    padding: 2vh 4vh;
    margin: 1vh;
    border-radius: 1vh;
    font-size: 2vh;
    cursor: pointer;
    min-width: 24vh;
    transition: transform 0.2s;
    position: relative;
    overflow: hidden;
}

button:hover {
    background-color: #FFCC00;
    transform: translateY(-0.3vh);
}
@keyframes jump {
    0% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-4vh) scale(1.3); }
    100% { transform: translateY(-2.5vh) scale(1); }
}

/* Улучшаем анимацию появления очков */
@keyframes pointsEarned {
    0% { 
        transform: translateY(0) scale(0.8);
        opacity: 0;
    }
    50% {
        transform: translateY(-3vh) scale(1.2);
        opacity: 1;
    }
    100% {
        transform: translateY(-6vh) scale(0.9);
        opacity: 0;
    }
}
.points-earned {
    color: #4CAF50;
    position: absolute;
    font-size: 3vh;
    font-weight: bold;
    text-shadow: 0 0 1vh rgba(0,0,0,0.5);
    opacity: 0;
    transition: all 0.5s ease;
    z-index: 100;
    pointer-events: none;
    user-select: none;
    will-change: transform, opacity;
    transform: translateY(0) scale(1);
    animation: pointsEarned 1s ease-out forwards;
}

.game-header {
    display: flex;
    justify-content: space-between;
    padding: 0 3vh;
    font-size: 2.2vh;
    font-weight: bold;
}

#character-image {
    max-width: 40vh;
    max-height: 40vh;
    margin: 9vh auto;
    display: block;
    border-radius: 1vh;
    box-shadow: 0 0.5vh 1vh rgba(0, 0, 0, 0.1);
    transition: filter 0.3s ease, opacity 0.3s ease;
    will-change: filter, transform, opacity;
    transform-origin: center center;
    backface-visibility: hidden;
    pointer-events: none;
    -webkit-user-drag: none;
}

.options-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.2vh;
    padding: 3vh;
}

.correct-answer {
    background-color: #4CAF50 !important;
    color: white !important;
    animation: pulse 0.5s ease-in-out;
    box-shadow: 0 0 2vh rgba(76, 175, 80, 0.7);
}
.wrong-answer {
    background-color: #f44336 !important;
    color: white !important;
    animation: pulse-red 0.5s ease-in-out;
    box-shadow: 0 0 2vh rgba(244, 67, 54, 0.7);
}

@keyframes pulse-green {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

@keyframes pulse-red {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}
audio {
    display: none !important;
    visibility: hidden !important;
    position: absolute !important;
    left: -9999px !important;
}

#end-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    padding: 3vh;
    box-sizing: border-box;
    overflow: auto;
}

.end-content {
    background-color: #fff;
    border-radius: 2vh;
    padding: 3vh;
    max-width: 65vh;
    width: 100%;
    box-shadow: 0 0.5vh 3vh rgba(0, 0, 0, 0.15);
    text-align: center;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
#end-screen.hidden {
    display: none;
}
#end-screen.show {
    animation: fadeIn 0.3s ease-out;
}

#game-container {
    position: relative;
    transition: opacity 0.3s;
}
#game-container.inactive {
    opacity: 0.7;
}

button:disabled {
    opacity: 0.7;
}

button:disabled:not(.correct-answer) {
    background-color: #cccccc !important;
}

@media (max-width: 600px) {
    body {
        overflow-x: hidden;
        width: 100%;
        position: fixed;
    }
    #game-screen {
        overflow: hidden;
    }
    .leaderboard-popup {
        padding: 2vh;
    }
    .leaderboard-item {
        grid-template-columns: 3vh 1fr 9vh;
        padding: 1.2vh 0.8vh;
        font-size: 2vh;
    }
    .close-leaderboard {
        padding: 1.5vh 0;
        font-size: 2vh;
    }
    #character-image {
        max-height: 50vh;
        max-width: 60%;
        width: auto;
        margin: 9vh auto;
    }
    .options-grid {
        grid-template-columns: 1fr;
        padding: 0 1vh;
        margin: 0 -1vh;
        width: calc(100% + 2vh);
    }
    .options-grid button {
        min-width: auto;
        width: 100%;
        box-sizing: border-box;
    }
    #end-screen .end-content {
        width: 90%;
        max-width: 90%;
        margin: 0 auto;
        padding: 2vh;
        box-sizing: border-box;
    }
    .correct-answer, .wrong-answer {
        transform: scale(0.98);
    }
    button {
        min-width: 16vh;
        padding: 1.5vh 2vh;
        font-size: 1.8vh;
    }
}

@media (max-width: 480px) {    
    h1 {
        font-size: 5vh;
        font-weight: bold;
        margin-bottom: 2vh;
        text-align: center;
      }
      
      span, p {
        font-size: 3vh;
      }
      .close-leaderboard{
        font-size: 3.2vh
      }

    #character-image {
        max-height: 30vh;
        min-height: 20vh;
        max-width: 60%;
        object-fit: contain;
        margin: 9vh auto;
    }
    .options-grid {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        justify-content: center;
        gap: 1vh;
        padding: 0 1vh;
        width: 100%;
        max-height: none;
    }
    .options-grid button {
        padding: 1.2vh 1.4vh;
        font-size: 2.5vh;
        margin: 0.6vh 0;
        width: 100%;
        min-width: auto;
    }
    .game-header {
        font-size: 2.6vh;
        padding: 0 1.2vh;
    }
    button {
        min-width: 13vh;
        font-size: 3vh;
        padding: 1.4vh 1.6vh;
    }
    #end-screen .end-content {
        padding: 2vh;
        font-size: 2.4vh;
    }
    #game-container {
        padding: 0 1.2vh;
    }
}

@supports (-webkit-touch-callout: none) {
    .leaderboard-popup {
        -webkit-touch-callout: none;
    }
}
