body {
    font-family: 'Helvetica Neue', sans-serif;
    margin: 0;
    background: #1a1a1a;
    color: #ecf0f1;
    overflow: hidden; /* Prevent body from scrolling */
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh; /* Full viewport height */
}

.game-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 500px; /* Max width for larger screens */
    height: 100%;
    /* max-height: 900px; /* This was causing issues on tall screens */
    background: #2c3e50;
    border-radius: 15px;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    overflow: hidden; /* Important to contain the panes */
}

.top-pane {
    flex-shrink: 0; /* Prevent the top pane from shrinking */
    min-height: 320px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end; /* Align content to the bottom */
    background: linear-gradient(to bottom, #2c3e50, #466368);
    position: relative;
    padding: 10px 10px 20px 10px;
    overflow: hidden; /* Hide overflowing parallax layers */
}

.bottom-pane {
    flex-grow: 1; /* Allow this pane to grow and fill remaining space */
    overflow-y: auto; /* Allow ONLY this pane to scroll if needed */
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 10px;
    background: #34495e;
    box-shadow: 0 -5px 15px rgba(0,0,0,0.3);
    position: relative;
}

/* Hide scrollbar for a cleaner look */
.bottom-pane::-webkit-scrollbar {
    width: 0;
    background: transparent;
}

#level-display {
    font-size: 1.2em;
    font-weight: bold;
    color: #ecf0f1;
    background: rgba(0,0,0,0.3);
    padding: 5px 15px;
    border-radius: 10px;
    margin-bottom: 10px;
    z-index: 10;
    position: relative;
}

#parallax-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 110%; /* Slightly larger to allow for movement */
    height: 110%;
    background-image: url('assets/img/backgrounds/forest-bg.png');
    background-size: cover;
    background-position: center;
    animation: slow-pan 40s linear infinite alternate;
    z-index: 1;
}

@keyframes slow-pan {
    from { transform: translateX(-5%) translateY(-5%); }
    to { transform: translateX(5%) translateY(0%); }
}

.top-pane::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle, transparent 50%, rgba(0,0,0,0.7) 100%);
    z-index: 2;
}

.combat-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px;
    background: rgba(0,0,0,0.2);
    border-radius: 10px;
    width: 300px;
    z-index: 10;
    transition: all 0.3s ease;
}

.combat-area.boss {
    border: 2px solid #f1c40f;
    box-shadow: 0 0 20px #f1c40f;
}

#monster-name {
    margin: 0 0 10px 0;
    font-size: 1.5em;
    font-weight: bold;
}

.monster-image-container {
    width: 140px; /* Увеличим размер для рамки */
    height: 140px;
    margin-bottom: 15px;
    background: #1a2531;
    border-radius: 15px; /* Скругляем углы */
    border: 5px solid #1a2531;
    box-shadow: 0 0 15px rgba(0,0,0,0.5), inset 0 0 10px rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden; /* Скрываем то, что выходит за рамки */
    padding: 5px; /* Отступ для внутреннего изображения */
}

#monster-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 10px; /* Скругляем углы самого изображения */
    filter: saturate(1.2) contrast(1.1); /* Делаем цвета ярче */
}

.health-bar-container {
    width: 80%;
    height: 20px;
    background-color: #1a2531;
    border-radius: 10px;
    border: 1px solid #4a627a;
    overflow: hidden;
}

.health-bar {
    width: 100%;
    height: 100%;
    background-color: #e74c3c;
    border-radius: 8px;
    transition: width 0.3s ease-in-out;
}

#board-container {
    width: 100%;
    max-width: 420px; /* A reasonable max size for the board */
    margin: 0 auto 15px auto; /* Centering and providing space below */
    aspect-ratio: 1 / 1;
    position: relative;
}

#game-board {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-template-rows: repeat(7, 1fr);
    gap: 4px;
    background-color: #2c3e50;
    border: 3px solid #2c3e50;
    padding: 5px;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

.gem {
    /* Width and height are now controlled by the grid */
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s ease-in-out;
    background-color: rgba(0, 0, 0, 0.3);
    background-size: 80%;
    background-repeat: no-repeat;
    background-position: center;
    box-shadow: inset 0 -3px 5px rgba(0,0,0,0.2), 0 2px 3px rgba(0,0,0,0.2);
}

.player-stats-container {
    display: flex;
    align-items: center;
    width: 100%;
    max-width: 400px;
    padding: 10px;
    background: rgba(0,0,0,0.2);
    border-radius: 10px;
    border: 2px solid #4a627a;
    margin-bottom: 15px; /* Space between stats and skills */
}

.player-avatar {
    width: 60px; /* Smaller avatar */
    height: 60px;
    border-radius: 8px; /* Делаем квадратным */
    border: 3px solid #ecf0f1;
    background-color: #2c3e50;
    margin-right: 15px;
    flex-shrink: 0;
    overflow: hidden; /* Обрезаем изображение по рамке */
}

.player-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* Масштабируем изображение */
}

.player-info {
    flex-grow: 1;
}

.player-stat {
    font-size: 1em;
    margin-bottom: 5px;
}

.player-health {
    display: flex;
    align-items: center;
    font-size: 1em;
}

.player-hb-container {
    width: 100%;
    /* margin-left: 10px; /* This was causing the misalignment */
}

.skills-container {
    display: flex;
    justify-content: center;
    gap: 10px;
    width: 100%;
    max-width: 400px;
    margin-bottom: 15px; /* Add space below the skills bar */
}

.skill-slot {
    position: relative;
    width: 45px;
    height: 45px;
    background-color: rgba(0,0,0,0.3);
    background-size: 70%;
    background-position: center;
    background-repeat: no-repeat;
    border: 2px solid #4a627a;
    border-radius: 10px;
    cursor: pointer;
    filter: grayscale(1);
    opacity: 0.6;
    transition: all 0.3s ease;
}

/* --- Re-pasting all other utility and animation classes --- */
#board-notification { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); background: rgba(0, 0, 0, 0.8); color: white; padding: 15px 25px; border-radius: 10px; z-index: 100; font-size: 1.2em; text-align: center; opacity: 1; transition: opacity 0.3s ease-in-out; }
#board-notification.hidden { opacity: 0; pointer-events: none; }
#combat-text-container { position: fixed; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 999; }
.floating-text { position: absolute; font-size: 2em; font-weight: bold; color: white; text-shadow: 2px 2px 4px black; animation: float-up 1.5s ease-out forwards; }
.floating-text.super-hit { font-size: 3em; color: #f1c40f; }
.floating-text.crit-hit { font-size: 2.5em; color: #e74c3c; transform: rotate(-5deg); }
.floating-text.heal-text { color: #2ecc71; }
#game-board.targeting .gem:hover { cursor: crosshair; box-shadow: 0 0 20px #fff; }
@keyframes float-up { to { transform: translateY(-100px); opacity: 0; } }
@keyframes screen-flash-and-shake { 0% { transform: translate(0, 0); box-shadow: 0 5px 15px rgba(0,0,0,0.3), inset 0 0 0 0 rgba(255, 255, 150, 0); } 25% { transform: translate(5px, -5px) rotate(1deg); box-shadow: 0 5px 15px rgba(0,0,0,0.3), inset 0 0 100px 50px rgba(255, 255, 150, 0.7); } 50% { transform: translate(-5px, 5px) rotate(-1deg); } 75% { transform: translate(5px, 5px) rotate(1deg); } 100% { transform: translate(0, 0); box-shadow: 0 5px 15px rgba(0,0,0,0.3), inset 0 0 0 0 rgba(255, 255, 150, 0); } }
.super-attack-effect { animation: screen-flash-and-shake 0.4s ease-in-out; }
.mob-projectile { position: fixed; width: 20px; height: 20px; background: radial-gradient(circle, #ff9933, #e74c3c); border-radius: 50%; box-shadow: 0 0 10px #ff9933; z-index: 200; transition: transform 0.5s ease-in; }
.skill-slot.ready { filter: grayscale(0); opacity: 1; border-color: #f1c40f; box-shadow: 0 0 15px #f1c40f; }
.charge-counter { position: absolute; bottom: -2px; right: -2px; background: #1a2531; color: #ecf0f1; font-size: 0.8em; font-weight: bold; padding: 2px 5px; border-radius: 5px; border: 1px solid #4a627a; }
.gem.selected { transform: scale(1.1); box-shadow: 0 0 10px rgba(255, 255, 255, 0.8); }
.gem.hint { animation: hint-pulse 0.7s ease-in-out infinite alternate; }
@keyframes hint-pulse { from { transform: scale(1); } to { transform: scale(1.1); box-shadow: 0 0 15px #fff; } }
.monster-hit { animation: hit-flash 0.3s ease-out; }
@keyframes hit-flash { 0% { transform: scale(1); filter: brightness(1); } 50% { transform: scale(1.05) translateX(-5px) rotate(-2deg); filter: brightness(2) drop-shadow(0 0 5px #fff); } 100% { transform: scale(1); filter: brightness(1); } }
.monster-defeat { animation: defeat-animation 0.5s ease-in forwards; }
@keyframes defeat-animation { to { transform: scale(0); opacity: 0; filter: blur(5px); } }
/* .new-gem animation is now handled in JavaScript */
.flying-out { position: relative; z-index: 10; animation-duration: 0.5s; animation-fill-mode: forwards; animation-timing-function: cubic-bezier(0.6, -0.28, 0.735, 0.045); }
@keyframes fly-out-1 { to { transform: translate(-100px, -150px) rotate(-45deg) scale(0.5); opacity: 0; } }
@keyframes fly-out-2 { to { transform: translate(100px, -120px) rotate(45deg) scale(0.5); opacity: 0; } }
@keyframes fly-out-3 { to { transform: translate(-120px, 100px) rotate(-30deg) scale(0.5); opacity: 0; } }
@keyframes fly-out-4 { to { transform: translate(150px, 80px) rotate(60deg) scale(0.5); opacity: 0; } }
.fly-1 { animation-name: fly-out-1; }
.fly-2 { animation-name: fly-out-2; }
.fly-3 { animation-name: fly-out-3; }
.fly-4 { animation-name: fly-out-4; }
.particle { position: absolute; width: 8px; height: 8px; border-radius: 50%; pointer-events: none; z-index: 20; animation: burst 0.7s ease-out forwards; }
@keyframes burst { 0% { transform: translate(0, 0) scale(1); opacity: 1; } 100% { transform: var(--transform-end); opacity: 0; } }
.gem-0 { background-image: url('assets/img/tiles/skull.svg'); background-color: #e74c3c; }
.gem-1 { background-image: url('assets/img/tiles/sword.svg'); background-color: #3498db; }
.gem-2 { background-image: url('assets/img/tiles/shield.svg'); background-color: #2ecc71; }
.gem-3 { background-image: url('assets/img/tiles/potion.svg'); background-color: #f1c40f; }
.gem-4 { background-image: url('assets/img/tiles/coin.svg'); background-color: #9b59b6; }

@media (max-height: 740px) {
    .top-pane {
        min-height: 280px; /* A bit smaller */
        padding-bottom: 10px;
    }

    .monster-image-container {
        width: 100px;
        height: 100px;
        margin-bottom: 10px;
    }

    #monster-name {
        font-size: 1.3em;
        margin-bottom: 5px;
    }

    .bottom-pane {
        padding: 10px;
    }

    #board-container, .player-stats-container {
        margin-bottom: 10px; /* Reduce space between elements */
    }

    .player-stats-container {
        padding: 8px;
    }

    .player-avatar {
        width: 50px;
        height: 50px;
    }

    .player-stat, .player-health {
        font-size: 0.9em;
    }

    .skills-container {
        gap: 8px;
        margin-bottom: 10px;
    }

    .skill-slot {
        width: 40px;
        height: 40px;
    }
}

@media (max-height: 680px) {
    .top-pane {
        min-height: 240px; /* Even smaller */
    }

    .monster-image-container {
        width: 90px;
        height: 90px;
    }

    #monster-name {
        font-size: 1.2em;
    }

    .player-avatar {
        width: 45px;
        height: 45px;
    }

    .player-stat, .player-health {
        font-size: 0.85em;
        margin-bottom: 3px;
    }

    .player-stats-container {
        margin-bottom: 10px;
    }

    .skills-container {
        gap: 5px;
        margin-bottom: 10px; /* Use margin-bottom for spacing */
    }

    .skill-slot {
        width: 38px;
        height: 38px;
    }
}

/* --- New Projectile Styles --- */

.fireball {
    width: 30px;
    height: 30px;
    background: radial-gradient(circle, white, yellow, orange, red);
    border-radius: 50%;
    box-shadow: 0 0 15px orange, 0 0 25px red;
    border: none;
}

.player-projectile {
    position: fixed;
    width: 35px;
    height: 35px;
    z-index: 200;
    /* transition is no longer needed as animation is handled by JS */
}

.spinning-disc {
    background-color: #ecf0f1;
    border-radius: 50%;
    border: 3px solid #95a5a6;
    box-shadow: 0 0 10px #fff, inset 0 0 5px #7f8c8d;
    animation: spin 0.3s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

@keyframes gem-flash {
    0% { transform: scale(1); box-shadow: 0 0 10px rgba(255, 255, 255, 0.8); }
    50% { transform: scale(1.15); box-shadow: 0 0 25px #fff; filter: brightness(1.5); }
    100% { transform: scale(1); box-shadow: 0 0 10px rgba(255, 255, 255, 0.8); }
}

.gem-flash-effect {
    animation: gem-flash 0.3s ease-out;
}

/* --- Start Screen Styles --- */

#start-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 500px;
    height: 100%;
    background: #2c3e50;
    padding: 20px;
    box-sizing: border-box;
    text-align: center;
    color: #ecf0f1;
}

#start-screen h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

#start-screen p {
    font-size: 1.1em;
    margin-bottom: 20px;
}

#player-name-input {
    width: 80%;
    padding: 12px;
    margin-bottom: 20px;
    border-radius: 8px;
    border: 2px solid #4a627a;
    background: #1a2531;
    color: #ecf0f1;
    font-size: 1em;
    text-align: center;
}

#player-name-input::placeholder {
    color: #95a5a6;
}

#avatar-selection-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-bottom: 25px;
    max-width: 300px;
}

.avatar-option {
    width: 80px;
    height: 80px;
    border-radius: 10px; /* Делаем квадратным */
    border: 3px solid #4a627a;
    background-color: #1a2531;
    cursor: pointer;
    transition: all 0.2s ease;
    object-fit: cover;
    overflow: hidden;
}

.avatar-option:hover {
    border-color: #f1c40f;
}

.avatar-option.selected {
    border-color: #2ecc71;
    box-shadow: 0 0 15px #2ecc71;
    transform: scale(1.1);
}

#start-game-button {
    padding: 12px 30px;
    border-radius: 10px;
    border: none;
    background: #27ae60;
    color: white;
    font-size: 1.2em;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

#start-game-button:hover {
    background: #2ecc71;
}

#start-game-button:disabled {
    background: #95a5a6;
    cursor: not-allowed;
}

/* --- Utility Classes --- */
.hidden {
    display: none !important; /* Use !important to ensure it overrides other display properties */
}

/* --- New Monster Dialog Styles --- */
.dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.dialog-box {
    background: linear-gradient(145deg, #4a5a6a, #2c3e50);
    padding: 30px;
    border-radius: 20px;
    border: 3px solid #6a7a8a;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    text-align: center;
    color: #ecf0f1;
    width: 90%;
    max-width: 350px;
    animation: dialog-appear 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes dialog-appear {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.dialog-box h2 {
    font-size: 2em;
    margin-top: 0;
    margin-bottom: 15px;
    color: #f1c40f;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.5);
}

.dialog-box img {
    width: 150px;
    height: 150px;
    border-radius: 15px;
    border: 4px solid #1a2531;
    box-shadow: 0 0 15px rgba(0,0,0,0.5);
    margin-bottom: 15px;
    background: #1a2531;
    object-fit: cover;
}

.dialog-box h3 {
    font-size: 1.5em;
    margin: 0 0 10px 0;
}

.dialog-box p {
    font-size: 1em;
    margin-bottom: 25px;
}

.dialog-box button {
    padding: 12px 30px;
    border-radius: 10px;
    border: none;
    background: #27ae60;
    color: white;
    font-size: 1.2em;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.dialog-box button:hover {
    background: #2ecc71;
}

/* --- Start Screen Styles --- */

#start-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 500px;
    height: 100%;
    background: #2c3e50;
    padding: 20px;
    box-sizing: border-box;
    text-align: center;
    color: #ecf0f1;
}

#start-screen h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

#start-screen p {
    font-size: 1.1em;
    margin-bottom: 20px;
}

#player-name-input {
    width: 80%;
    padding: 12px;
    margin-bottom: 20px;
    border-radius: 8px;
    border: 2px solid #4a627a;
    background: #1a2531;
    color: #ecf0f1;
    font-size: 1em;
    text-align: center;
}

#player-name-input::placeholder {
    color: #95a5a6;
}

#avatar-selection-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-bottom: 25px;
    max-width: 300px;
}

.avatar-option {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 3px solid #4a627a;
    background-color: #1a2531;
    cursor: pointer;
    transition: all 0.2s ease;
    object-fit: cover; /* This makes sure the image fills the circle */
    overflow: hidden; /* This clips the image to the circle */
}

.avatar-option:hover {
    border-color: #f1c40f;
}

.avatar-option.selected {
    border-color: #2ecc71;
    box-shadow: 0 0 15px #2ecc71;
    transform: scale(1.1);
}

#start-game-button {
    padding: 12px 30px;
    border-radius: 10px;
    border: none;
    background: #27ae60;
    color: white;
    font-size: 1.2em;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

#start-game-button:hover {
    background: #2ecc71;
}

#start-game-button:disabled {
    background: #95a5a6;
    cursor: not-allowed;
}

/* --- Utility Classes --- */
.hidden {
    display: none !important; /* Use !important to ensure it overrides other display properties */
}
