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

body {
    font-family: Arial, sans-serif;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    color: white;
    overflow-y: auto;
    overflow-x: hidden;
    margin: 0;
    padding: 0;
}

#game-container {
    width: 100%;
    min-height: 100vh;
    position: relative;
}

.screen {
    display: none;
    width: 100%;
    height: 100%;
}

.screen.active {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
}

#menu-screen.active {
    justify-content: center;
}

#menu-screen {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
}

#menu-screen h1 {
    font-size: 3em;
    margin-bottom: 2em;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 1em;
}

.menu-btn, .control-btn {
    padding: 1em 2em;
    font-size: 1.2em;
    background: #4a90e2;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.menu-btn:hover, .control-btn:hover {
    background: #357abd;
    transform: scale(1.05);
}

#game-screen {
    display: none;
    padding: 0;
    background: #1a1a2e;
    width: 100%;
    height: 100vh;
    box-sizing: border-box;
    overflow: hidden; /* Убираем скролл с экрана */
}

#game-screen.active {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100vh;
    box-sizing: border-box;
    overflow: hidden;
}

#game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    background: rgba(0,0,0,0.9);
    border-radius: 0;
    margin: 0;
    min-height: 120px;
    flex-shrink: 0;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
}

.player-info {
    flex: 1;
    min-width: 200px;
}

#player1-info {
    text-align: right; /* Выравнивание по правому краю для первого игрока */
}

#player2-info {
    text-align: left; /* Выравнивание по левому краю для второго игрока */
}

.player-info h3 {
    margin-bottom: 10px;
    font-size: 1.3em;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.7);
}

.resource {
    margin: 8px 0;
    font-size: 1.1em;
    font-weight: 500;
    line-height: 1.5;
}

#game-controls {
    display: flex;
    gap: 10px;
}

#game-board-container {
    padding-bottom: 50px; /* Отступ снизу для предотвращения обрезания поля */
    flex: 1 1 auto;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    background: rgba(0,0,0,0.3);
    border-radius: 8px;
    overflow: auto; /* Скролл только внутри контейнера игрового поля */
    min-height: 400px;
    min-width: 0;
    position: relative;
    margin-top: 140px; /* Отступ для закреплённой шапки */
    margin-bottom: 220px; /* Отступ для закреплённой панели */
    max-height: calc(100vh - 360px);
}

#game-board-container canvas {
    display: block;
}

#game-canvas {
    background: #0f3460;
    border: 2px solid #4a90e2;
    border-radius: 4px;
    display: block;
    /* Не ограничиваем размер - будет скролл */
}

#game-panel {
    display: flex;
    gap: 20px;
    padding: 15px;
    background: rgba(0,0,0,0.9);
    border-radius: 0;
    max-height: 200px;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    overflow-x: auto;
}

.panel-section {
    flex: 1;
    padding: 10px;
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
}

.panel-section h4 {
    margin-bottom: 10px;
    font-size: 1em;
}

.tower-options, .soldier-options {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 10px;
}

.tower-btn, .soldier-btn, .obstacle-btn {
    padding: 8px;
    font-size: 0.9em;
    background: #4a90e2;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.tower-btn:hover, .soldier-btn:hover, .obstacle-btn:hover {
    background: #357abd;
}

.tower-btn:disabled, .soldier-btn:disabled, .obstacle-btn:disabled {
    background: #666;
    cursor: not-allowed;
}

.upgrade-btn {
    padding: 8px;
    font-size: 0.9em;
    background: #e2a84a;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    width: 100%;
    margin-top: 5px;
}

.upgrade-btn:hover:not(:disabled) {
    background: #bd8a35;
}

.upgrade-btn:disabled {
    background: #666;
    cursor: not-allowed;
}

.info-panel {
    font-size: 0.8em;
    color: #ccc;
    margin-top: 10px;
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    height: 5px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 5px;
    outline: none;
    margin: 5px 0;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 15px;
    height: 15px;
    background: #4a90e2;
    border-radius: 50%;
    cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
    width: 15px;
    height: 15px;
    background: #4a90e2;
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

#victory-screen {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
}

#victory-screen h1 {
    font-size: 3em;
    margin-bottom: 2em;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

