html, body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden !important;
    background-color: #0d0d0d;
    color: #fff;
    font-family: 'Tahoma', sans-serif;
    text-align: center;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

/* Обёртка, которая будет пропорционально масштабироваться */
#game-wrapper {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 800px;
    height: 550px;
    transform: translate(-50%, -50%) scale(1);
    transform-origin: center center;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-sizing: border-box;
}

#game-wrapper h1 {
    margin: 0 0 10px 0;
    height: 40px;
    line-height: 40px;
    font-size: 32px;
    color: #fff;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.9);
}

#game-card {
    width: 800px;
    height: 480px;
    margin: 0 auto;
    background: #2b1d14 url('images/bar_bg.png') no-repeat center/cover;
    border: 4px solid #5a3d28;
    position: relative;
    overflow: hidden;
    box-shadow: 0 0 25px rgba(0,0,0,0.8);
    box-sizing: border-box;
}

#top-bar {
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 45px;
    background: rgba(0,0,0,0.85);
    display: flex;
    justify-content: space-around;
    align-items: center;
    font-size: 16px;
    font-weight: bold;
    z-index: 5;
    border-bottom: 2px solid #5a3d28;
}

#sanych {
    position: absolute;
    left: 20px;
    bottom: 15px;
    width: 170px;
    height: 280px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: bottom center;
    filter: drop-shadow(2px 4px 6px rgba(0,0,0,0.7));
}

.sanych-away { background-image: url('images/sanych_away.png'); }
.sanych-warn { background-image: url('images/sanych_warn.png'); }
.sanych-look { background-image: url('images/sanych_look.png'); }

.sleep-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 26px;
    font-weight: bold;
    color: #81d4fa;
    text-shadow: 0 0 8px #0288d1;
    animation: pulseSleep 1s infinite alternate;
}

@keyframes pulseSleep {
    from { transform: scale(1) translateY(0); opacity: 0.6; }
    to { transform: scale(1.3) translateY(-10px); opacity: 1; }
}

#cocktail {
    position: absolute;
    left: 175px;
    bottom: 20px;
    width: 50px;
    height: 65px;
    background: url('images/cocktail.png') no-repeat center/contain;
    cursor: pointer;
    z-index: 6;
    filter: drop-shadow(0 0 6px #e91e63);
    display: none;
    transition: transform 0.2s ease;
}

#cocktail:hover { transform: scale(1.15); }

#cocktail-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #e91e63;
    color: #fff;
    font-size: 12px;
    font-weight: bold;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    line-height: 20px;
    text-align: center;
    box-shadow: 0 0 5px rgba(0,0,0,0.5);
}

#shelves {
    position: absolute;
    right: 20px;
    top: 60px;
    width: 550px;
    height: 395px;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-auto-rows: 105px;
    row-gap: 20px;
    justify-items: center;
    align-items: end;
    padding: 10px 0;
    box-sizing: border-box;
    overflow: hidden;
    border: 8px solid #4a2e1b;
    border-radius: 4px;
    box-shadow: inset 0 0 25px rgba(0,0,0,0.85), 0 5px 15px rgba(0,0,0,0.5);

    background-image: 
        linear-gradient(to right, 
            transparent calc(100% - 6px), 
            #5c3a21 calc(100% - 5px), 
            #8c5731 calc(100% - 3px), 
            #1a0f08 100%
        ),
        linear-gradient(to bottom, 
            transparent 105px, 
            #5c3a21 105px, 
            #8c5731 109px, 
            #3b2313 117px, 
            #1a0f08 125px, 
            transparent 125px
        );
    background-size: 20% 100%, 100% 125px;
    background-color: #1c120b;
}

.bottle.portveyn {
    background-image: url('images/portveyn777.png') !important;
}

.bottle {
    width: 58px;
    height: 100px;
    background: url('images/vodka.png') no-repeat center/contain;
    cursor: pointer;
    filter: drop-shadow(0px 4px 4px rgba(0,0,0,0.6));
    opacity: 1;
    transform: scale(1) translateY(0);
    transition: opacity 0.4s ease-out, transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.27);
}
.bottle:hover { transform: scale(1.08) translateY(-4px); }
.bottle.stolen { 
    opacity: 0; 
    transform: scale(0.3) translateY(20px); 
    pointer-events: none; 
}

.bonus {
    position: absolute;
    width: 80px;
    height: 80px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    cursor: pointer;
    z-index: 4;
    animation: bonusPop 0.3s ease-out, bonusFloat 2s infinite ease-in-out alternate;
}
.bonus.dollar { 
    background-image: url('images/dollar.png'); 
    background-color: rgba(255, 215, 0, 0.25); 
    border: 2px solid #ffd700;
    border-radius: 8px; 
    box-shadow: 0 0 12px #ffd700;
}
.bonus.pahom { 
    background-image: url('images/pahom.png'); 
    background-color: rgba(0, 255, 255, 0.25); 
    border: 2px solid #00ffff;
    border-radius: 50%; 
    box-shadow: 0 0 12px #00ffff;
}

@keyframes bonusPop {
    from { transform: scale(0); }
    to { transform: scale(1); }
}
@keyframes bonusFloat {
    from { transform: translateY(0px); }
    to { transform: translateY(-8px); }
}

#modal-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    z-index: 8;
    display: block;
    transition: opacity 0.3s ease;
}

/* Шапка модального окна */
.modal-header {
    display: grid;
    grid-template-columns: 1fr auto 1fr; /* Делит шапку на 3 части */
    align-items: center;
    margin-bottom: 15px;
    width: 100%;
}

.modal-header h2 {
    grid-column: 2; /* Заголовок ровно по центру */
    margin: 0 !important;
    color: #ffaa00;
    font-size: 20px;
    font-weight: bold;
    text-align: center;
    line-height: 1;
    white-space: nowrap;
}

/* Кнопка настроек прижата к правому краю */
#btn-settings {
    grid-column: 3;
    justify-self: end; /* Прижимает кнопку в самый правый бок */
    width: 36px;
    height: 36px;
    padding: 0;
    margin: 0;
    background: #2a1a0e;
    border: 2px solid #ffaa00;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s, transform 0.1s;
}

#btn-settings:hover {
    background: #442812;
}

#btn-settings:active {
    transform: scale(0.95);
}

.icon-btn {
    width: 20px;
    height: 20px;
    display: block;
}

.setting-icon {
    width: 28px;
    height: 28px;
    vertical-align: middle;
    margin-right: 10px;
}

.settings-list {
    margin: 20px 0;
    text-align: left;
}

.setting-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid rgba(255, 170, 0, 0.2);
}

.setting-item:last-child {
    border-bottom: none;
}

.setting-info {
    display: flex;
    align-items: center;
    color: #fff;
    font-size: 16px;
}

.btn-danger {
    background: #8b0000 !important;
    color: #fff !important;
    border-color: #ff4444 !important;
}

.btn-danger:hover {
    background: #b30000 !important;
}

.modal {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    background: #3e2723;
    border: 3px solid #ffb300;
    padding: 20px;
    width: 450px;
    display: none;
    z-index: 10;
    box-shadow: 0 0 35px rgba(0,0,0,0.9);
    border-radius: 8px;
    max-height: 440px;
    overflow-y: auto;
}

button {
    padding: 10px 18px;
    font-weight: bold;
    background: #ffb300;
    border: none;
    cursor: pointer;
    margin: 5px;
    border-radius: 4px;
    font-family: inherit;
    transition: transform 0.1s ease, background-color 0.15s ease, box-shadow 0.15s ease;
    outline: none;
}
button:hover { 
    background: #ffa000; 
}
button:active {
    transform: scale(0.92);
    background: #e68900;
}
button:disabled {
    background: #555 !important;
    color: #888 !important;
    cursor: not-allowed;
    transform: none !important;
}

.btn-clicked {
    animation: btnSuccessAnim 0.35s ease-out;
}

@keyframes btnSuccessAnim {
    0% {
        background-color: #4caf50;
        box-shadow: 0 0 14px #4caf50;
        transform: scale(1.08);
    }
    50% {
        background-color: #81c784;
        transform: scale(0.95);
    }
    100% {
        background-color: #ffb300;
        box-shadow: none;
        transform: scale(1);
    }
}

#start-modal { text-align: left; }
#start-modal h2 { text-align: center; color: #ffb300; margin-top: 0; }
.instructions {
    font-size: 13px;
    line-height: 1.5;
    background: rgba(0,0,0,0.4);
    padding: 12px 15px;
    border-radius: 6px;
    border: 1px solid #5a3d28;
    margin-bottom: 15px;
}
.instructions ul { padding-left: 18px; margin: 6px 0; }

#loader-container {
    width: 100%;
    height: 18px;
    background: #1a0f08;
    border: 2px solid #5a3d28;
    border-radius: 9px;
    overflow: hidden;
    margin-top: 10px;
}
#loader-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #ff8f00, #ffc107);
    transition: width 0.2s ease;
}
#loader-status {
    text-align: center;
    font-size: 12px;
    margin: 6px 0 12px 0;
    color: #ccc;
}

html, body, button, .bottle, .bonus, #modal-overlay, .modal {
    touch-action: manipulation;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.modal, #start-modal, #game-over-modal, #shop-modal {
    overflow-x: hidden !important;
    box-sizing: border-box !important;
}

.modal *, #start-modal * {
    box-sizing: border-box;
    max-width: 100%;
}

/* --- ЭФФЕКТЫ ПОБЕДЫ --- */

/* RGB переливание контура модального окна победы */
@keyframes rgbGlow {
    0%   { border-color: #ff0000; box-shadow: 0 0 30px rgba(255, 0, 0, 0.9), inset 0 0 15px rgba(255, 0, 0, 0.5); }
    17%  { border-color: #ff00ff; box-shadow: 0 0 30px rgba(255, 0, 255, 0.9), inset 0 0 15px rgba(255, 0, 255, 0.5); }
    33%  { border-color: #0000ff; box-shadow: 0 0 30px rgba(0, 0, 255, 0.9), inset 0 0 15px rgba(0, 0, 255, 0.5); }
    50%  { border-color: #00ffff; box-shadow: 0 0 30px rgba(0, 255, 255, 0.9), inset 0 0 15px rgba(0, 255, 255, 0.5); }
    67%  { border-color: #00ff00; box-shadow: 0 0 30px rgba(0, 255, 0, 0.9), inset 0 0 15px rgba(0, 255, 0, 0.5); }
    83%  { border-color: #ffff00; box-shadow: 0 0 30px rgba(255, 255, 0, 0.9), inset 0 0 15px rgba(255, 255, 0, 0.5); }
    100% { border-color: #ff0000; box-shadow: 0 0 30px rgba(255, 0, 0, 0.9), inset 0 0 15px rgba(255, 0, 0, 0.5); }
}

#victory-modal {
    border: 4px solid #ff0000 !important;
    animation: rgbGlow 3s linear infinite !important;
}

/* RGB пульсация и переливание кнопки "НАЧАТЬ ЗАНОВО" */
@keyframes rgbButton {
    0%   { background-color: #ff0055; box-shadow: 0 0 20px #ff0055; transform: scale(1); }
    20%  { background-color: #9900ff; box-shadow: 0 0 20px #9900ff; transform: scale(1.03); }
    40%  { background-color: #0066ff; box-shadow: 0 0 20px #0066ff; transform: scale(1); }
    60%  { background-color: #00cc66; box-shadow: 0 0 20px #00cc66; transform: scale(1.03); }
    80%  { background-color: #ff9900; box-shadow: 0 0 20px #ff9900; transform: scale(1); }
    100% { background-color: #ff0055; box-shadow: 0 0 20px #ff0055; transform: scale(1); }
}

#victory-modal .btn-primary {
    animation: rgbButton 2.5s ease-in-out infinite !important;
    border: 2px solid #ffffff !important;
    font-weight: bold;
    color: #ffffff !important;
    text-shadow: 0 0 5px #000;
}

/* Частицы CSS-фейерверка */
.firework-particle {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    pointer-events: none;
    z-index: 9999;
    animation: fireworkExplode 1s ease-out forwards;
}

@keyframes fireworkExplode {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(var(--dx), var(--dy)) scale(0.2);
        opacity: 0;
    }
}