/* === ОСНОВНЫЕ ПЕРЕМЕННЫЕ === */
:root {
    --index: calc(1vw + 1.2vh);
    --transition: 1.5s cubic-bezier(.05, .5, 0, 1);
    --glass-bg: rgba(0, 0, 0, 0.55);
    --glass-border: rgba(255, 255, 255, 0.15);
    --text-color: #ffffff;
    --accent: #a5d8ff;
    --accent2: #4dabf7;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

@font-face {
    font-family: 'kamerik-3d';
    src: url('../fonts/kamerik205-heavy.woff2') format('woff2');
    font-weight: 900;
}
@font-face {
    font-family: 'merriweather-italic';
    src: url('../fonts/merriweather-regular-italic.woff2') format('woff2');
}

body {
    background-color: #000;
    color: var(--text-color);
    font-family: 'merriweather-italic', serif;
    overflow-x: hidden;
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
}

/* === 3D СЦЕНА (ФОН) === */
.layers {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: -1;
    perspective: 1000px;
    overflow: hidden;
}
.layers__container {
    height: 100vh;
    transform-style: preserve-3d;
    transform: rotateX(var(--move-y, 0deg)) rotateY(var(--move-x, 0deg));
    will-change: transform;
    transition: transform var(--transition);
}
.layers__item {
    position: absolute;
    inset: -5vw;
    background-size: cover;
    background-position: center;
    display: flex;
    align-items: center;
    justify-content: center;
}
.layer-1 { transform: translateZ(-55px) scale(1.06); }
.layer-2 { transform: translateZ(80px) scale(0.88); }
.layer-4 { transform: translateZ(190px) scale(0.9); }
.layer-5 { transform: translateZ(300px) scale(0.9); }
.layer-6 { transform: translateZ(380px); }

canvas.rain {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
}

/* === ИГРОВАЯ ОБОЛОЧКА === */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border-radius: calc(var(--index) * 1.8);
    border: 1px solid var(--glass-border);
    box-shadow: 0 20px 40px rgba(0,0,0,0.5);
    transition: transform 0.3s ease;
}

.game-container {
    width: 100%;
    max-width: 500px;
    z-index: 1;
}

.game-panel {
    padding: calc(var(--index) * 1.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: calc(var(--index) * 1.2);
}

.game-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.score-box {
    background: rgba(255,255,255,0.1);
    border-radius: 12px;
    padding: 0.5rem 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.score-label {
    font-size: calc(var(--index) * 0.5);
    opacity: 0.7;
    text-transform: uppercase;
}
.score-value {
    font-family: 'kamerik-3d', sans-serif;
    font-size: calc(var(--index) * 1.5);
    color: var(--accent);
    line-height: 1;
}

.leaderboard-btn {
    background: rgba(255,255,255,0.15);
    border: none;
    color: white;
    padding: 0.6rem 1.5rem;
    border-radius: 30px;
    font-size: calc(var(--index) * 0.65);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    transition: 0.3s;
    font-family: 'kamerik-3d', sans-serif;
}
.leaderboard-btn:hover {
    background: var(--accent);
    color: #000;
}

.canvas-wrapper {
    background: rgba(0,0,0,0.3);
    border-radius: 16px;
    padding: 10px;
    box-shadow: 0 0 25px rgba(0,0,0,0.5);
    border: 1px solid rgba(255,255,255,0.1);
}

#game-canvas {
    display: block;
    border-radius: 8px;
    background-color: #161618;
    background-image: url("data:image/svg+xml,%3Csvg width='16' height='16' viewBox='0 0 16 16' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cg opacity='0.2'%3E%3Ccircle cx='8' cy='8' r='4' fill='%23525053'/%3E%3C/g%3E%3C/svg%3E");
    width: 100%;
    height: auto;
    max-width: 320px;
}

.game-footer {
    width: 100%;
    text-align: center;
}
.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255,255,255,0.1);
    color: white;
    text-decoration: none;
    padding: 0.6rem 1.8rem;
    border-radius: 30px;
    font-weight: bold;
    font-size: calc(var(--index) * 0.7);
    transition: 0.3s;
    border: 1px solid rgba(255,255,255,0.2);
}
.back-btn:hover {
    background: rgba(255,255,255,0.25);
    transform: translateY(-2px);
}

/* === МОДАЛЬНОЕ ОКНО === */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0; top: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(6px);
    justify-content: center;
    align-items: center;
}
.modal.active { display: flex; }
.modal-content {
    width: 90%;
    max-width: 500px;
    padding: calc(var(--index) * 2);
    position: relative;
}
.modal-content h2 {
    font-family: 'kamerik-3d', sans-serif;
    text-align: center;
    margin-bottom: 1rem;
    color: var(--accent);
}
.close {
    position: absolute;
    top: 10px; right: 20px;
    font-size: 2rem;
    cursor: pointer;
    color: #aaa;
}
.close:hover { color: white; }

.leaderboard-table-container {
    max-height: 350px;
    overflow-y: auto;
}
#leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    font-size: calc(var(--index) * 0.6);
}
#leaderboard-table th {
    background: rgba(255,255,255,0.1);
    padding: 0.6rem;
    text-align: left;
    color: var(--accent);
}
#leaderboard-table td {
    padding: 0.5rem 0.6rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
#leaderboard-table tr:hover {
    background: rgba(255,255,255,0.05);
}
.player-row {
    background: rgba(165,216,255,0.15) !important;
    font-weight: bold;
}
.player-row td {
    color: var(--accent);
}

.player-tag {
    color: var(--accent);
    font-weight: bold;
    font-size: 0.9em;
    margin-left: 4px;
    background: rgba(0,0,0,0.3);
    padding: 2px 8px;
    border-radius: 12px;
}

.star-gold { color: gold; font-size: 1.2rem; }
.star-silver { color: silver; font-size: 1.2rem; }
.star-bronze { color: #cd7f32; font-size: 1.2rem; }

/* ========== АДАПТИВНОСТЬ ========== */
@media (max-width: 768px) {
    :root {
        --index: calc(0.7vw + 0.7vh);
    }

    html, body {
        height: 100%;
        overflow: hidden;
        margin: 0;
        padding: 0;
    }

    body {
        display: flex;
        align-items: center;
        justify-content: center;
        padding-top: 0;
        padding-bottom: 3rem;
        padding-left: 0.8rem;
        padding-right: 0.8rem;
        box-sizing: border-box;
    }

    .game-container {
        width: 100%;
        max-width: 420px;
        display: flex;
        flex-direction: column;
    }

    .game-panel {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: calc(var(--index) * 0.7);
        padding: calc(var(--index) * 1.2);
        border-radius: calc(var(--index) * 1.2);
        overflow: hidden;
    }

    .game-header {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.3rem;
        width: 100%;
    }

    .score-box {
        flex: 1 1 auto;
        padding: 0.3rem 0.8rem;
        border-radius: 8px;
    }

    .score-label {
        font-size: 12px;
    }

    .score-value {
        font-size: 20px;
    }

    .leaderboard-btn {
        flex: 1 1 auto;
        font-size: 12px;
        padding: 0.4rem 0.8rem;
    }

    .canvas-wrapper {
        display: flex;
        justify-content: center;
        align-items: center;
        width: 100%;
        max-height: 55vh;
        padding: 2px;
        background: rgba(0,0,0,0.3);
        border-radius: 12px;
        overflow: hidden;
    }

    #game-canvas {
        aspect-ratio: 4 / 5;
        height: auto;
        max-height: 100%;
        max-width: 100%;
        width: auto;
        border-radius: 8px;
    }

    .game-footer {
        width: 100%;
    }

    .back-btn {
        width: 100%;
        justify-content: center;
        font-size: 12px;
        padding: 0.5rem 0.8rem;
    }

    .modal-content {
        width: 95%;
        padding: 0.8rem;
    }

    .modal-content h2 {
        font-size: 1.2rem;
    }

    .close {
        font-size: 1.5rem;
    }

    .leaderboard-table-container {
        max-height: 60vh;
    }

    #leaderboard-table {
        font-size: 0.7rem;
    }

    #leaderboard-table th,
    #leaderboard-table td {
        padding: 0.4rem 0.3rem;
    }

    .player-tag {
        font-size: 0.8em;
    }
}