/* =========================================
   2. ИГРОВОЙ МОДУЛЬ (RUNNER)
   ========================================= */

#runner-screen {
    position: absolute;
    background: #81d4fa;
    z-index: 40;
    touch-action: none;
}

#game-area {
    position: absolute;
    top: 0;
    height: 100%;
    width: 100%;
    overflow: hidden;
    z-index: 10;
    background-color: #ffffff;
}

.track-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #ffffff;
    background-image:
        linear-gradient(90deg, rgba(179, 229, 252, 0.3) 0%, rgba(255, 255, 255, 0) 15%, rgba(255, 255, 255, 0) 85%, rgba(179, 229, 252, 0.3) 100%),
        radial-gradient(circle at 20% 30%, rgba(230, 245, 255, 0.6) 0%, transparent 40%),
        radial-gradient(circle at 80% 70%, rgba(230, 245, 255, 0.6) 0%, transparent 40%),
        radial-gradient(circle at 40% 80%, rgba(225, 240, 255, 0.5) 0%, transparent 35%),
        radial-gradient(circle at 70% 20%, rgba(225, 240, 255, 0.5) 0%, transparent 30%);
    background-size: 100% 100%;
    background-position: center top;
    z-index: 1;
    pointer-events: none;
}

/* ОБЪЕКТЫ */
#objects-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 20;
}

.game-object {
    position: absolute;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center bottom;
    z-index: 25;
    will-change: transform;
    transform: translate3d(-9999px, -9999px, 0);
}

/* ПЕРСОНАЖ: ПИНГВИН */
#penguin {
    position: absolute;
    width: 75px;
    height: 75px;
    z-index: 100;
    transform-origin: center bottom;
    will-change: transform;
}

.penguin-body {
    width: 100%;
    height: 100%;
    position: relative;
    transform-origin: center bottom;
}

.penguin-body.jumping {
    animation: jumpAnim 0.6s ease-out;
}

@keyframes jumpAnim {
    0% {
        transform: scale(1) translateY(0);
    }

    50% {
        transform: scale(1.1) translateY(-120px);
    }

    100% {
        transform: scale(1) translateY(0);
    }
}

.p-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center bottom;
    display: none;
    will-change: transform, opacity;
}

.p-layer.active {
    display: block !important;
}

#p-sprite-center {
    background-image: url('../../assets/images/penguin.png');
}

#p-sprite-left {
    background-image: url('../../assets/images/penguin_left.png');
}

#p-sprite-right {
    background-image: url('../../assets/images/penguin_right.png');
}

/* ЭФФЕКТЫ */
#trail-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
    pointer-events: none;
    opacity: 0.5;
}

#snow-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 150;
    pointer-events: none;
    background-image:
        radial-gradient(2px 2px at 20px 30px, #fff, transparent),
        radial-gradient(2px 2px at 40px 70px, #fff, transparent),
        radial-gradient(2px 2px at 50px 160px, #fff, transparent),
        radial-gradient(2px 2px at 90px 40px, #fff, transparent),
        radial-gradient(2px 2px at 130px 80px, #fff, transparent);
    background-size: 200px 200px;
    opacity: 0.8;
}

.damage-flash {
    animation: flashScreen 0.3s ease-out;
}

@keyframes flashScreen {
    0% {
        box-shadow: inset 0 0 0 0 rgba(255, 0, 0, 0);
    }

    30% {
        box-shadow: inset 0 0 100px 50px rgba(255, 0, 0, 0.5);
    }

    100% {
        box-shadow: inset 0 0 0 0 rgba(255, 0, 0, 0);
    }
}

.shake-element {
    animation: shakeAnim 0.4s cubic-bezier(.36, .07, .19, .97) both;
}

@keyframes shakeAnim {

    10%,
    90% {
        transform: translateX(-3px);
    }

    20%,
    80% {
        transform: translateX(3px);
    }

    30%,
    50%,
    70% {
        transform: translateX(-5px);
    }

    40%,
    60% {
        transform: translateX(5px);
    }
}

/* ТИПЫ ОБЪЕКТОВ (КОНКРЕТИКА) */
.obj-tree {
    width: 80px;
    height: 90px;
    background-image: url('../../assets/images/tree_simple.png');
}

.obj-coin {
    width: 45px;
    height: 45px;
    background-image: url('../../assets/images/coin.png');
}

.obj-obstacle {
    width: 80px;
    height: 80px;
    background-image: url('../../assets/images/obstacle.png');
}

.obj-hurdle {
    width: 130px;
    height: 50px;
    background-image: url('../../assets/images/hurdle.png');
}

.obj-ramp {
    width: 100px;
    height: 80px;
    background-image: url('../../assets/images/ramp.png');
}

.obj-snowman {
    width: 70px;
    height: 80px;
    background-image: url('../../assets/images/snowman.png');
}

.obj-skip {
    width: 50px;
    height: 50px;
    background-image: url('../../assets/images/ski_pass.png');
}

.obj-gate-easy {
    width: 120px;
    height: 80px;
    background-image: url('../../assets/images/gate_easy.png');
}

.obj-gate-medium {
    width: 120px;
    height: 80px;
    background-image: url('../../assets/images/gate_medium.png');
}

.obj-gate-hard {
    width: 120px;
    height: 80px;
    background-image: url('../../assets/images/gate_hard.png');
}

.obj-bear {
    width: 90px;
    height: 90px;
}

.obj-tiger {
    width: 90px;
    height: 90px;
}

.obj-bear.face-left {
    background-image: url('../../assets/images/bear_left.png');
}

.obj-bear.face-right {
    background-image: url('../../assets/images/bear_right.png');
}

.obj-tiger.face-left {
    background-image: url('../../assets/images/tiger_left.png');
}

.obj-tiger.face-right {
    background-image: url('../../assets/images/tiger_right.png');
}

/* HUD (ИГРОВОЙ ИНТЕРФЕЙС) */
#ui-top {
    position: absolute;
    /* Safe area logic */
    top: 0;
    padding-top: max(20px, env(safe-area-inset-top, 20px));
    left: 0;
    width: 100%;
    padding-left: 20px;
    padding-right: 20px;
    padding-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    z-index: 200;
    pointer-events: none;
}

.hud-left,
.hud-right {
    display: flex;
    gap: 10px;
    align-items: center;
    pointer-events: auto;
}

.hud-circle-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: none;
    background: white;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.15);
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hud-stat {
    background: rgba(255, 255, 255, 0.95);
    padding: 4px 10px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 3px 5px rgba(0, 0, 0, 0.1);
    font-weight: bold;
    color: #333;
    font-size: 1.1rem;
    min-height: 36px;
}

#score-display {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 2.8rem;
    font-weight: 900;
    color: #ffca28;
    text-shadow: 2px 2px 0 #5d4037;
    z-index: 190;
}

.stat-icon {
    width: 24px;
    height: 24px;
    object-fit: contain;
    display: block;
}

/* ООВЕРЛЕИ (СТАРТ/КОНЕЦ) */
#start-runner-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(38, 50, 56, 0.85);
    backdrop-filter: blur(5px);
}

#start-runner-overlay:not(.active) {
    display: none !important;
}

.overlay-content {
    background: white;
    width: 90%;
    max-width: 360px;
    padding: 30px;
    border-radius: 24px;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    z-index: 2001;
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* MODALS */
#question-modal .modal-content {
    background: #ffffff !important;
    border-top: 10px solid var(--accent-color);
    padding: 30px;
}

#q-diff-label {
    display: inline-block;
    padding: 5px 15px;
    background: #e3f2fd;
    color: #1976d2;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: bold;
    margin-bottom: 10px;
}