body {
    margin: 0;
    padding: 0;
    overflow: hidden;
    touch-action: none;
    background-color: #000;
    font-family: 'Press Start 2P', monospace;
    height: 100vh;
    display: flex;
    flex-direction: column;
    font-weight: 700;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background: linear-gradient(to bottom, #000 80%, #5a0b0f);
    font-size: 1rem;
}

#game-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    position: relative;
    background: transparent;
    max-width: 320px;
    margin: 0 auto;
    width: 100%;
}

.game-border {
    position: absolute;
    top: auto;
    border: none;
    left: 0;
    width: 320px; /* Fixed width to match canvas */
    height: 560px; /* Fixed height to match canvas */
    z-index: 5;
    pointer-events: none; /* Allow interaction through the image */
}

canvas {
    background-color: transparent !important;
    border-radius: 0;
    image-rendering: optimizeQuality;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    position: relative;
    margin-top: 0;
    width: 100%;
    max-width: 320px;
    max-height: 560px;
    z-index: 1;
}

.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    font-family: 'Press Start 2P', monospace;
    text-transform: uppercase;
    text-align: center;
    z-index: 10;
    background: rgba(0, 0, 0, 0.85);
}

#pause-menu.overlay {
    background: rgb(0, 0, 0); /* Pure black background for pause menu */
}

#menu-screen.overlay {
    padding: 0 24px;
    box-sizing: border-box;
    width: 100%;
    padding-bottom: 40px;
    background: rgb(0, 0, 0); /* Pure black background */
}

.game-over-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 20px;
}

.game-over-text .game,
.game-over-text .over {
    font-size: 4.5em;
    font-weight: 700;
    line-height: 0.8;
}

.game-over-text .over {
    margin-top: 15px;
}

.overlay img {
    max-width: 80%;
    height: auto;
    margin-bottom: 20px;
}

.hidden {
    display: none !important;
}

.score-display {
    font-size: 1.5em;
    margin: 10px 0;
}

.score-box .score-label {
    font-weight: 400;
}

.score-box span {
    font-weight: 700;
}

.score-box {
    background-color: rgba(255, 255, 255, 0.1);
    padding: 10px 20px;
    margin: 5px 0;
    border-radius: 5px;
    width: 200px;
    text-align: center;
}

.button-icon {
    margin-right: 8px;
    vertical-align: middle;
    font-size: 1.5em;
}

.overlay .score-display {
    font-weight: 400;
}

/* UI Control Buttons */
.game-controls {
    position: absolute;
    bottom: 40px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    padding: 0;
    max-width: 320px;
    margin: 0 auto;
    width: 100%;
    z-index: 6;
}

.control-btn {
    background: transparent;
    border: none;
    color: white;
    font-family: 'Press Start 2P', monospace;
    font-size: 1rem;
    cursor: pointer;
    padding: 10px 0;
    text-transform: uppercase;
}

.control-btn:first-child {
    text-align: left;
    padding-left: 0;
}

.control-btn:last-child {
    text-align: right;
    padding-right: 0;
}

/* Game UI elements */
.game-ui {
    position: absolute;
    top: 40px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    padding: 0;
    color: white;
    font-family: 'Press Start 2P', monospace;
    font-size: 1rem;
    text-transform: uppercase;
    max-width: 320px;
    margin: 0 auto;
    width: 100%;
    z-index: 6;
}

.lives {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
}

.star {
    font-size: 24px;
    color: white;
    margin-top: 8px;
}

.heart {
    font-size: 24px;
    color: white;
    margin-top: 8px;
}

/* Pause Menu */
#pause-menu {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
}

#pause-menu .btn-menu {
    background: transparent;
    border: none;
    color: white;
    font-family: 'Press Start 2P', monospace;
    font-size: 16px;
    cursor: pointer;
    padding: 10px;
    text-transform: uppercase;
    width: 200px;
    text-align: center;
}

#pause-menu .btn-menu:hover {
    color: #f82b44;
}

#game-over-screen.overlay {
    background: linear-gradient(to bottom, #000 80%, #5a0b0f);
    font-family: 'Press Start 2P', monospace;
    text-transform: uppercase;
    color: white;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    z-index: 10;
}

/* Make sure the game over screen doesn't hide the border */
#game-over-screen.overlay ~ .game-border {
    opacity: 1 !important;
    z-index: 5 !important;
    visibility: visible !important;
}

#game-over-screen h1 {
    font-size: 3.5rem;
    margin-bottom: 2rem;
    line-height: 1.2;
    font-family: 'Press Start 2P', monospace;
}

#game-over-screen .score-box {
    background-color: #000;
    border-radius: 999px;
    padding: 1rem 2rem;
    margin-bottom: 1rem;
    font-size: 1.1rem;
    font-weight: bold;
    color: white;
    text-align: center;
    font-family: 'Press Start 2P', monospace;
    text-transform: uppercase;
    width: fit-content;
    min-width: 200px;
}

.btn-restart {
    font-family: 'Press Start 2P', monospace;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    background-color: #EE2737;
    color: white;
    border: none;
    border-radius: 999px;
    padding: 0;
    font-size: 1rem;
    font-weight: bold;
    text-transform: uppercase;
    cursor: pointer;
    transition: background-color 0.2s ease;
    width: 100%;
    height: 44px;
    white-space: nowrap;
}

.btn-restart:hover {
    background-color: #EE2737;
}

.btn-restart svg {
    height: 1em;
    width: auto;
    fill: white;
}

.high-score {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    color: white;
    text-align: right;
}

#ui-high-score {
    color: #FFB600;
    margin-top: 8px;
    display: block;
}

/* Game Over Screen with new styling */
#game-over-screen {
    text-align: center;
}

#game-over-screen h1 {
    font-size: 3rem;
    color: #f82b44;
    margin-bottom: 40px;
}

.score-container {
    margin: 20px 0 40px 0;
}

.score-container .score-box {
    background-color: transparent;
    border: none;
    padding: 10px 0;
    font-size: 1.2rem;
}

.score-value {
    color: #FFD700;
    font-size: 2rem;
    display: block;
    margin-top: 5px;
}

.btn-menu {
    background: transparent;
    border: none;
    color: white;
    font-family: 'Press Start 2P', monospace;
    font-size: 16px;
    cursor: pointer;
    padding: 10px;
    text-transform: uppercase;
    width: 200px;
    text-align: center;
}

.footer-branding {
    position: absolute;
    bottom: 30px;
    text-align: center;
    width: 100%;
    left: 0;
}

.footer-branding h2 {
    font-size: 2rem;
    color: white;
    margin: 0;
    line-height: 1.2;
}

/* Hide game UI when an overlay is visible */
body:has(.overlay:not(.hidden)) .game-ui,
body:has(.overlay:not(.hidden)) .game-controls {
    display: none;
}

/* For browsers that don't support :has, use a class-based approach */
.menu-visible .game-ui,
.menu-visible .game-controls {
    display: none;
}

/* Keep the border visible on game over screen */
body:has(#game-over-screen:not(.hidden)) .game-border {
    opacity: 1 !important;
    z-index: 5 !important;
    visibility: visible !important;
}

/* Game Over Screen Styling */
.game-over-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
}

#game-over-screen h1 {
    font-size: 2.5rem;
    color: white;
    text-align: center;
    margin-bottom: 40px;
    line-height: 1.2;
}

.final-score {
    font-size: 2.5rem;
    color: white;
    margin-bottom: 50px;
}

.game-over-buttons {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    width: 100%;
}

.btn-menu {
    background: transparent;
    border: none;
    color: white;
    font-family: 'Press Start 2P', monospace;
    font-size: 1rem;
    cursor: pointer;
    padding: 10px;
    text-transform: uppercase;
    width: 200px;
    text-align: center;
}

.arrow {
    color: #f82b44;
    margin-right: 10px;
}

.heart-icon {
    width: 20px;
    height: 20px;
    margin-top: 8px;
}

.cover-image-container {
    display: flex;
    justify-content: center;
    width: 100%;
}

.cover-image {
    max-width: 100%;
    height: auto;
}

/* Hide the game canvas and border when on main menu */
body:has(#menu-screen:not(.hidden)) .game-border,
body:has(#menu-screen:not(.hidden)) #gameCanvas {
    opacity: 0;
}

/* Show the game canvas and border when the menu is hidden */
body:has(#menu-screen.hidden) .game-border,
body:has(#menu-screen.hidden) #gameCanvas {
    opacity: 1;
    transition: opacity 0.3s ease;
}

/* Secondary button styling */
.btn-secondary {
    font-family: 'Press Start 2P', monospace;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    background-color: transparent;
    color: white;
    border: 2px solid white;
    border-radius: 999px;
    padding: 0;
    font-size: 0.9rem;
    font-weight: bold;
    text-transform: uppercase;
    cursor: pointer;
    width: 100%;
    height: 44px;
    white-space: nowrap;
    margin-top: 15px;
}

/* Updated menu screen button spacing */
#menu-screen .btn-restart,
#menu-screen .btn-secondary {
    margin-bottom: 15px;
    max-width: 375px;
    width: 100%;
}

#menu-screen .cover-image-container {
    width: 100%;
    padding-bottom: 40px;
}

#menu-screen .cover-image {
    max-width: 375px;
    width: 100%;
}

/* Instruction Screen Styling */
#instructions-screen.overlay {
    justify-content: center;
    background: rgb(0, 0, 0); /* Pure black background */
}

#instructions-screen .instruction-content {
    padding: 48px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.instruction-title {
    font-size: 2.5rem;
    color: white;
    margin-bottom: 80px;
    text-align: center;
}

.static-snake-container {
    width: 100%;
    height: 150px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 50px;
    position: relative;
    pointer-events: none;
    z-index: 20;
}

/* Head - rightmost piece */
.static-snake-container::before {
    content: '';
    position: absolute;
    width: 40px;
    height: 40px;
    background-image: url('assets/images/head.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    left: calc(50% + 40px);
    z-index: 21;
}

/* Body 1 - right of center */
.static-snake-container::after {
    content: '';
    position: absolute;
    width: 40px;
    height: 40px;
    background-image: url('assets/images/body_straight.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    left: 50%;
    z-index: 21;
}

/* Body 2 - left of center */
.static-snake-container .body2 {
    content: '';
    position: absolute;
    width: 40px;
    height: 40px;
    background-image: url('assets/images/body_straight.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    left: calc(50% - 40px);
    display: block;
    z-index: 21;
}

/* Tail - leftmost piece */
.static-snake-container .tail {
    content: '';
    position: absolute;
    width: 40px;
    height: 40px;
    background-image: url('assets/images/tail.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    transform: scaleX(-1); /* Flip horizontally */
    left: calc(50% - 80px);
    display: block;
    z-index: 21;
}

.instruction-text {
    font-size: 1.2rem;
    color: white;
    margin-bottom: 40px;
    text-align: center;
    max-width: 300px;
    line-height: 1.5;
    margin-top: 80px;
}

/* Removed swipe indicator styles */

/* Show game UI when instructions screen is visible */
body:has(#instructions-screen:not(.hidden)) .game-ui,
body:has(#instructions-screen:not(.hidden)) .game-controls {
    display: flex;
}

body:has(#instructions-screen:not(.hidden)) .game-border {
    opacity: 1;
}

body:has(#instructions-screen:not(.hidden)) #gameCanvas {
    opacity: 0.1; /* Make the canvas almost invisible to hide any leftover content */
} 