* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
}

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #1a1a1a;
    font-family: 'Arial', sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
}

#game-container {
    position: relative;
    width: min(100%, calc(100vh * 9 / 16));
    height: 100%;
    max-height: 100%;
    aspect-ratio: 9 / 16;
    margin: 0 auto;
    background: #2c3e50;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

@media (max-aspect-ratio: 9/16) {
    #game-container {
        width: 100%;
        height: auto;
        max-height: 100%;
    }
}

#ui-overlay {
    position: absolute;
    top: 15px;
    left: 15px;
    right: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
    pointer-events: none;
}

#score-container {
    background: rgba(0, 0, 0, 0.75);
    padding: 8px 18px;
    border-radius: 20px;
    color: #fff;
    font-weight: bold;
    font-size: 16px;
    border: 2px solid #f39c12;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

#ui-controls {
    display: flex;
    gap: 10px;
    pointer-events: auto;
}

.ui-btn {
    background: rgba(0, 0, 0, 0.75);
    border: 2px solid #f39c12;
    border-radius: 50%;
    color: white;
    width: 44px;
    height: 44px;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.1s ease;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.ui-btn:active {
    transform: scale(0.9);
}

#game-canvas {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain; 
    background: linear-gradient(to bottom, #34495e, #2c3e50);
}

/* Эмулятор рекламы (для Live Server) */
#mock-ad-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #0f172a;
    z-index: 100; /* Перекрывает абсолютно все */
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
}

#mock-ad-overlay.hidden {
    display: none;
}

.mock-ad-content {
    text-align: center;
    padding: 30px;
    background: #1e293b;
    border: 3px solid #f1c40f;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.6);
    max-width: 80%;
}

.mock-ad-content h3 {
    color: #f1c40f;
    margin-top: 15px;
    margin-bottom: 10px;
    font-size: 20px;
}

.mock-ad-content p {
    font-size: 15px;
    color: #94a3b8;
}

#mock-ad-timer {
    font-weight: bold;
    color: #e67e22;
    font-size: 18px;
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.08); opacity: 0.7; }
    100% { transform: scale(1); opacity: 1; }
}

.pulse {
    animation: pulse 1.5s infinite;
}

/* Экраны оверлеев (Game Over / Revive / Leaderboard / Shake) */
#game-over-screen, #revive-screen, #leaderboard-screen, #shake-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.88);
    z-index: 20;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    text-align: center;
    padding: 24px;
}

#game-over-screen.hidden, #revive-screen.hidden, #leaderboard-screen.hidden, #shake-screen.hidden {
    display: none;
}

#game-over-title, #revive-title, #leaderboard-title, #shake-title {
    font-size: 34px;
    color: #e74c3c;
    margin-bottom: 15px;
    text-shadow: 0 2px 10px rgba(0,0,0,0.5);
}

#revive-title, #leaderboard-title, #shake-title {
    color: #f1c40f; 
}

#game-over-score-text, #revive-desc, #shake-desc {
    font-size: 18px;
    line-height: 1.5;
    margin-bottom: 30px;
}

#revive-desc, #shake-desc {
    color: #cbd5e0;
}

/* Карточка диалога для меню встряски */
.modal-card {
    background: #1e293b;
    border: 3px solid #f39c12;
    border-radius: 20px;
    padding: 30px 24px;
    max-width: 85%;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.modal-card p {
    font-size: 16px;
    margin-bottom: 25px;
}

/* Элементы таблицы рекордов */
#leaderboard-table-container {
    width: 100%;
    max-height: 55vh;
    overflow-y: auto;
    background: rgba(26, 36, 59, 0.75);
    border: 2px solid #f39c12;
    border-radius: 15px;
    margin-bottom: 25px;
    padding: 10px;
    box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.5);
}

#leaderboard-table-container::-webkit-scrollbar {
    width: 8px;
}

#leaderboard-table-container::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
}

#leaderboard-table-container::-webkit-scrollbar-thumb {
    background: #f39c12;
    border-radius: 10px;
}

#leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 16px;
}

#leaderboard-table th, #leaderboard-table td {
    padding: 12px 8px;
    text-align: center;
}

#leaderboard-table th {
    color: #f1c40f;
    border-bottom: 2px solid #f39c12;
    font-weight: bold;
    font-size: 14px;
    text-transform: uppercase;
}

#leaderboard-table tr {
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

#leaderboard-table tr:last-child {
    border-bottom: none;
}

#leaderboard-table tr.player-row {
    background: rgba(243, 156, 18, 0.22);
    color: #f1c40f;
    font-weight: bold;
}

/* Кнопки меню */
.menu-btn {
    background: #27ae60;
    color: white;
    border: none;
    padding: 15px 35px;
    font-size: 18px;
    font-weight: bold;
    border-radius: 30px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(39, 174, 96, 0.45);
    transition: transform 0.1s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.menu-btn:active {
    transform: scale(0.95);
}

/* Кнопка просмотра рекламы */
.video-btn {
    background: #e67e22; 
    box-shadow: 0 4px 15px rgba(230, 126, 34, 0.45);
}

/* Иконка ТВ */
.tv-icon {
    flex-shrink: 0;
    color: #ffffff;
}

/* Кнопка сдачи / пропуска */
.skip-btn {
    background: transparent;
    border: none;
    color: #a0aec0;
    font-size: 16px;
    text-decoration: underline;
    margin-top: 20px;
    cursor: pointer;
    padding: 10px;
    transition: color 0.1s ease;
}

.skip-btn:active {
    color: #ffffff;
}