body {
    font-family: 'Arial', sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    margin: 0;
    background-color: #f0f8ff;
    color: #333;
}

h1 {
    color: #005a9c;
    margin: 10px 0;
}

#game-container {
    width: 95vw;
    aspect-ratio: 4 / 3;
    max-width: 800px;
    max-height: 600px;
    border: 5px solid #005a9c;
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(0,0,0,0.2);
    position: relative;
    overflow: hidden;
    background-color: #fff;
    touch-action: none; /* Prevent scrolling on mobile */
}

#game-area {
    width: 100%;
    height: calc(100% - 80px); /* Adjust for UI bar height */
    position: relative;
    background-image: url('background.png');
    background-size: cover;
    cursor: none;
}

#player {
    width: 15%; /* Responsive size */
    height: 15%;
    background-image: url('player.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    position: absolute;
    bottom: 2%; /* Position relative to game area */
    /* left is set by JS */
    transition: none; /* Remove transition for smoother direct control */
}

.letter {
    position: absolute;
    font-size: 4vmin; /* Responsive font size */
    font-weight: bold;
    color: #fff;
    background-color: #ff4500;
    width: 6.25%; /* 50px / 800px */
    aspect-ratio: 1 / 1;
    height: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    text-shadow: 2px 2px 3px rgba(0,0,0,0.5);
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    user-select: none;
}

#ui-bar {
    width: 100%;
    height: 13.33%; /* 80px / 600px */
    background-color: #005a9c;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: absolute;
    bottom: 0;
    left: 0;
    border-top: 3px solid #003f6b;
    padding: 0 10px;
    box-sizing: border-box;
}

.ui-element {
    text-align: center;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 0 5px;
}

.word-ui {
    flex: 2;
    padding-left: 10px; /* Add some padding */
}
.score-ui {
    flex: 1;
}
.lives-ui {
    flex: 1;
    padding-right: 10px; /* Add some padding */
}

.ui-element h2 {
    margin: 0 0 5px 0;
    font-size: 3vmin; /* Responsive font size */
    letter-spacing: 2px;
}

#word-area {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    height: 100%;
    width: 100%;
}

#word-display-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

#word-image-container {
    width: auto;
    height: 100%; /* Increased from 60% */
    aspect-ratio: 1 / 1;
    background-color: rgba(255, 255, 255, 0.3);
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5px;
    box-sizing: border-box;
}

#word-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

#word-display, #score, #lives {
    font-size: 4vmin; /* Responsive font size */
    font-weight: bold;
}

#word-display {
    display: flex;
    gap: 5px; /* Reduced gap slightly for better fit */
}

.letter-placeholder {
    width: 4.5vmin; /* Using vmin for better responsive scaling */
    height: 4.5vmin; /* Using vmin for better responsive scaling */
    aspect-ratio: 1 / 1;
    background-color: rgba(255,255,255,0.3);
    border-bottom: 4px solid #fff;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 4vmin; /* Adjusted font size */
    color: #fff;
}

#lives {
    font-size: 4vmin; /* Responsive font size */
    font-weight: bold;
    display: flex;
    gap: 5px;
    align-items: center;
    justify-content: center;
    margin-top: 5px; /* Added margin for spacing */
}

.life-heart {
    width: 4vmin; /* Increased size using vmin */
    height: 4vmin; /* Increased size using vmin */
    aspect-ratio: 1 / 1;
    background-image: url('heart.png');
    background-size: contain;
    background-repeat: no-repeat;
}

.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    text-align: center;
}

.overlay-content {
    background: #005a9c;
    padding: 5vmin;
    border-radius: 15px;
    border: 5px solid #fff;
    box-shadow: 0 0 30px rgba(0,0,0,0.5);
    width: 80%;
    max-width: 500px;
}

.overlay button {
    padding: 2vmin 4vmin;
    font-size: 3vmin;
    cursor: pointer;
    border: none;
    border-radius: 10px;
    background-color: #ff4500;
    color: white;
    font-weight: bold;
    margin-top: 20px;
    transition: background-color 0.3s ease;
}

.overlay button:hover {
    background-color: #e03d00;
}

/* Specific adjustments for very small screens if needed */
@media (max-width: 480px) {
    h1 {
        font-size: 6vw;
    }
    .ui-element h2 {
       font-size: 3vw;
    }
    #word-display, #score, #lives {
        font-size: 3.5vw;
    }
}