:root {
    --base-font-size: calc(10px + 1vmin);
    --base-padding: calc(5px + 1vmin);
    --base-margin: calc(10px + 2vmin);
    --button-radius: calc(5px + 0.5vmin);
}

* {
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
    -ms-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    box-sizing: border-box;
}

img {
    width: 100%;
    height: auto;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
    touch-action: none;
}

html {
    background: #fff;
}

body {
    font-family: "Helvetica Neue", Arial, Helvetica, sans-serif;
    font-size: var(--base-font-size);
    margin: 0;
    text-align: center;
    background: #f95240 url(../assets/main-bg.png);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

#canvas {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    aspect-ratio: auto;
    background-color: #000;
}

/* Кнопка "Играть" */
.button-play {
    position: fixed;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    padding: var(--base-padding);
    margin: var(--base-margin);
    font-size: var(--base-font-size);
    background-color: #fff;
    color: #000;
    border-radius: var(--button-radius);
    text-align: center;
}

/* Адаптивные стили для кнопки «Играть» */
@media screen and (max-width: 768px) {
    .button-play {
        bottom: 20px;
        font-size: calc(8px + 2vmin);
    }
}

@media screen and (min-width: 1024px) {
    .button-play {
        bottom: 30px;
        font-size: calc(12px + 2vmin);
    }
}

/* Дополнительные медиазапросы для адаптации */
@media screen and (min-height: 560px) {
    html {
        font-size: 100px;
    }
}

@media screen and (min-height: 640px) {
    html {
        font-size: 112.5px;
    }
}

@media screen and (min-height: 720px) {
    html {
        font-size: 125px;
    }
}

@media screen and (min-height: 800px) {
    html {
        font-size: 137.5px;
    }
}

@media screen and (min-height: 880px) {
    html {
        font-size: 150px;
    }
}

@media screen and (min-height: 960px) {
    html {
        font-size: 162.5px;
    }
}

@media screen and (min-height: 1040px) {
    html {
        font-size: 180px;
    }
}

@media screen and (min-height: 1200px) {
    html {
        font-size: 200px;
    }
}

.hide {
    display: none;
}

.sound-toggle {
    position: absolute;
    z-index: 30;
    top: max(12px, env(safe-area-inset-top));
    left: max(10px, env(safe-area-inset-left));
    width: clamp(30px, 8vw, 42px);
    height: clamp(30px, 8vw, 42px);
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
    touch-action: manipulation;
}

.sound-toggle img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.sound-toggle:active {
    transform: scale(.92);
}

.clear {
    clear: both;
}

.loading {
    background-color: #f05a50;
    height: 100%;
    width: 100%;
}

.loading .main {
    width: 60%;
    margin: 0 auto;
    color: #fff;
}

.loading .main img {
    width: 60%;
    margin: 1rem auto 0;
}

.loading .main .title {
    font-size: .3rem;
}

.loading .main .text {
    font-size: .15rem;
}

.loading .main .bar {
    height: .12rem;
    width: 100%;
    border: 3px solid #fff;
    border-radius: .6rem;
    margin: .1rem 0;
}

.loading .main .bar .sub {
    height: .1rem;
    width: 98%;
    margin: .008rem auto 0;
}

.loading .main .bar .percent {
    height: 100%;
    width: 0;
    background-color: #fff;
    border-radius: .6rem;
}

.loading .logo {
    position: absolute;
    bottom: .3rem;
    left: 0;
    right: 0;
}

.loading .logo img {
    width: 1rem;
}

.content {
    width: min(100vw, calc(100vh / 1.5));
    height: 100vh;
    height: 100dvh;
    max-width: 100vw;
    max-height: 100vh;
    max-height: 100dvh;
    margin: 0 auto;
    position: relative;
}

.landing .title {
    width: 60%;
}

.locale-en {
    display: none;
}

html[lang="en"] .locale-ru {
    display: none;
}

html[lang="en"] .locale-en {
    display: block;
}

.landing .game-title {
    position: relative;
    width: 58%;
    margin: 8% auto 0;
    padding: .12rem .08rem;
    border: .04rem solid #161616;
    border-radius: .04rem;
    background: linear-gradient(#573516, #17110d);
    color: #ffd43b;
    font-family: wenxue, Impact, sans-serif;
    font-size: clamp(28px, 8vw, 58px);
    line-height: .9;
    text-transform: uppercase;
    text-shadow: 3px 3px 0 #000, -1px -1px 0 #000;
    box-shadow: 0 .04rem .05rem rgba(0, 0, 0, .45);
}

.landing .game-title::before {
    content: "";
    position: absolute;
    left: 50%;
    bottom: 100%;
    width: .055rem;
    height: .28rem;
    border-radius: .03rem;
    background: #3c302b;
    transform: translateX(-50%);
}

.landing .logo {
    width: 30%;
    position: absolute;
    right: .2rem;
    top: .2rem;
}

.landing .action-2 {
    position: absolute;
    bottom: .2rem;
    width: 100%;
}

.landing .start {
    width: 65%;
}

.game-button {
    position: relative;
    min-height: clamp(66px, 18vw, 105px);
    padding: 0 .06rem 0 .3rem;
    border: clamp(4px, 1vw, 8px) solid #fff4de;
    border-radius: .2rem;
    background: linear-gradient(#f35d61, #c72f37);
    box-shadow: 0 .07rem 0 #a6967e, inset 0 .025rem 0 rgba(255, 255, 255, .55);
    color: #fff;
    font: 500 clamp(22px, .26rem, 33px)/1 "Helvetica Neue", Arial, sans-serif;
    text-transform: uppercase;
    cursor: pointer;
    touch-action: manipulation;
}

.game-button-icon {
    position: absolute;
    left: .07rem;
    top: 50%;
    width: 0;
    height: 0;
    border-top: .12rem solid transparent;
    border-bottom: .12rem solid transparent;
    border-left: .18rem solid #51d5ee;
    filter: drop-shadow(0 .025rem 0 #17697d);
    transform: translateY(-50%);
}

.game-button:active,
.modal-game-button:active {
    transform: translateY(.035rem);
    box-shadow: 0 .025rem 0 #8c7e6b;
}

/* Анимации */
.slideTop {
    -webkit-animation: st 1s ease-in-out;
    animation: st 1s ease-in-out;
}

@-webkit-keyframes st {
    0% {
        transform: translateZ(0)
    }
    100% {
        transform: translate3d(0, -100%, 0)
    }
}

@keyframes st {
    0% {
        transform: translateZ(0)
    }
    100% {
        transform: translate3d(0, -100%, 0)
    }
}

.slideBottom {
    -webkit-animation: sb 1s ease-in-out;
    animation: sb 1s ease-in-out;
}

@-webkit-keyframes sb {
    0% {
        transform: translateZ(0)
    }
    100% {
        transform: translate3d(0, 200%, 0)
    }
}

@keyframes sb {
    0% {
        transform: translateZ(0)
    }
    100% {
        transform: translate3d(0, 200%, 0)
    }
}

/* Другие стили остались без изменений */
.swing {
    -webkit-animation: sw 2s ease-in-out alternate infinite;
    animation: sw 2s ease-in-out alternate infinite;
    transform-origin: 48% 4%;
}

@-webkit-keyframes sw {
    from { transform: rotate(-3deg); }
    to { transform: rotate(3deg); }
}

@keyframes sw {
    from { transform: rotate(-3deg); }
    to { transform: rotate(3deg); }
}

.modal .mask {
    background-color: #000;
    opacity: .6;
    position: fixed;
    height: 100%;
    width: 100%;
    top: 0;
    left: 0;
    overflow: hidden;
}

/* Остальные модальные стили остались такими же */

.modal .modal-content {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(90vw, calc(90vh * 640 / 1020), 640px) !important;
    width: min(90vw, calc(90dvh * 640 / 1020), 640px) !important;
    max-width: 100vw;
    max-height: 100vh;
    max-height: 100dvh;
    margin-top: 0;
}


.modal .main {
    width: 100%;
    margin: 0 auto;
}

.modal .container {
    position: relative;
    width: 100%;
    aspect-ratio: 640 / 1020;
}

.modal .bg {
    width: 100%;
    height: 100%;
    object-fit: fill;
    position: absolute;
    top: 0;
    left: 0;
}

.modal .modal-main {
    width: 100%;
    position: absolute;
    top: 0;
    left: 0;
    margin-top: 0;
}

.modal .over-img {
    width: 80%;
    margin: 12% auto 0;
}

.modal .over-title {
    width: 80%;
    margin: 17% auto 2%;
    color: #ffe444;
    font-family: wenxue, Impact, sans-serif;
    font-size: clamp(34px, 10vw, 70px);
    line-height: 1;
    text-transform: uppercase;
    text-shadow: 3px 3px 0 #111, -1px -1px 0 #111;
}

.modal .over-score {
    margin-top: -4%;
    font-size: clamp(34px, 10vw, 64px);
    color: #ff735c;
    text-shadow: -2px -2px 0 #fff, 2px -2px 0 #fff, -2px 2px 0 #fff, 2px 2px 0 #fff;
}

.modal .tip {
    font-size: clamp(15px, 4vw, 24px);
    color: #9b724e;
}

.modal .over-button-b {
    width: 70%;
    margin: 3% auto 0;
}

.modal-game-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .08rem;
    min-height: clamp(58px, 14vw, 92px);
    border: clamp(4px, 1vw, 7px) solid #fff4de;
    border-radius: .17rem;
    box-shadow: 0 .055rem 0 #a6967e, inset 0 .02rem 0 rgba(255, 255, 255, .6);
    color: #fff;
    font: 500 clamp(21px, .27rem, 36px)/1 "Helvetica Neue", Arial, sans-serif;
    text-transform: uppercase;
    cursor: pointer;
    touch-action: manipulation;
}

.modal-game-button-retry {
    background: linear-gradient(#5c9df1, #3274ce);
}

.modal-game-button-share {
    background: linear-gradient(#ff9a63, #ef6842);
}

.modal-game-button > span[aria-hidden="true"] {
    font-size: 1.35em;
    font-weight: 800;
}

@media (max-width: 600px), (max-height: 700px) {
    .modal .modal-content {
        top: 47%;
        width: min(92vw, calc(88dvh * 640 / 1020)) !important;
    }

    .modal .over-img {
        margin-top: 10%;
    }

    .modal .over-button-b {
        width: 66%;
        margin-top: 2%;
    }
}

.wxShare {
    background: #000;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 11;
    opacity: .9;
}

.wxShare img {
    width: 50%;
    float: right;
    margin: 10px 10px 0 0;
}

.share-hint {
    width: 80%;
    margin: 22% auto 0;
    padding: .16rem;
    border: 3px solid #ffe16b;
    border-radius: .12rem;
    color: #fff;
    font-size: clamp(20px, 5vw, 36px);
    line-height: 1.25;
}

@font-face {
    font-family: wenxue;
    src: url(../assets/wenxue.woff) format("woff");
    font-display: swap;
}

.font-wenxue {
    font-family: wenxue;
}

audio {
    display: none;
}
