.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 1;
    font-family: 'Poppins', sans-serif;
}

.screen.active {
    opacity: 1;
    pointer-events: auto;
    z-index: 10;
}

.screen-content {
    text-align: center;
    color: #fff;
    /* allow the content area to expand up to the title image width so the image centers nicely */
    width: min(90vw, 1012px);
    max-width: 1012px;
    padding: 2rem;
    position: relative;
    z-index: 12;
}

/* Splash title image sizing and footer logo */
.splash-title {
    /* allow the title image to grow up to its native width on wide screens,
       but remain responsive on smaller viewports */
    width: min(90vw, 1012px);
    height: auto;
    display: block;
    margin: 0 auto 1rem;
}
.splash-footer { margin-top: 2rem; display:flex; justify-content:center; align-items:center; }
.sr-logo { width: 250px; height: auto; opacity: 0.95; }

.title {
    font-size: 4rem;
    font-weight: 700;
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    background: linear-gradient(45deg, #4ecdc4, #8e44ad);
    background-size: 200% 200%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: gradientShift 4s ease infinite;
    text-shadow: 0 0 15px rgba(78, 205, 200, 0.4);
}

@keyframes gradientShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.subtitle {
    font-size: 1.2rem;
    margin-bottom: 2rem;
    color: #aaa;
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.1);
}

.high-score { color:#fff; font-size:1.3rem; margin-bottom:0.5rem; text-shadow: 0 0 8px rgba(255, 255, 255, 0.2); }

.btn {
    position: relative;
    padding: 1rem 3rem 1rem 3.7rem;
    font-size: 1.2rem;
    font-family: 'Poppins', sans-serif;
    font-weight: 700;
    color: #fff;
    border: none;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    transition: all 0.3s ease;
    margin: 0.5rem 2rem;
    background: transparent;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* SVG snake body styling */
.btn svg {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    z-index: 0;
}

/* Snake body path */
.btn .snake-body {
    /* Use the SVG stroke (gradient) for body — stroke-width is controlled in SVG but adjust visual weight here */
    stroke-width: 6;
    stroke-linejoin: round;
    stroke-linecap: round;
    filter: drop-shadow(0 0 4px rgba(78, 205, 200, 0.3)) drop-shadow(0 0 5px rgba(142, 68, 173, 0.3));
    transform-origin: 25% 50%; /* Anchor near the head for tail jiggle */
    transition: filter 0.3s ease, transform 0.3s ease;
}

/* Tongue path */
.btn .snake-tongue {
    fill: none; /* Ensure no fill, it uses stroke */
    filter: drop-shadow(0 0 8px rgba(255, 118, 117, 0.7));
    opacity: 0;
    transform-origin: 30% 50%; /* Origin near the mouth */
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Text stays on top */
.btn span {
    position: relative;
    z-index: 1;
}

.btn:hover {
    transform: translateY(-3px) scale(1.02);
}

.btn:hover .snake-body {
    filter: drop-shadow(0 0 4px rgba(78, 205, 200, 0.5)) drop-shadow(0 0 5px rgba(142, 68, 173, 0.5));
    animation: snakeTailJiggle 0.5s ease-in-out infinite alternate;
}

.btn:hover .snake-tongue {
    opacity: 1;
    animation: tongueFlicker 3s steps(10) infinite alternate;
}

.btn:active {
    transform: translateY(0) scale(0.98);
}

/* Secondary button variant */
.btn-secondary .snake-body {
    stroke: #8e44ad;
    stroke-width: 2;
    fill: none;
    filter: drop-shadow(0 0 15px rgba(142, 68, 173, 0.4));
}

.btn-secondary:hover .snake-body {
    fill: rgba(142, 68, 173, 0.3);
    filter: drop-shadow(0 0 25px rgba(142, 68, 173, 0.6));
}

/* New button animations */
@keyframes snakeTailJiggle {
    0% { transform: rotate(-1.5deg); }
    100% { transform: rotate(1.5deg); }
}

@keyframes tongueFlicker {
    0% { transform: scaleX(0.9) scaleY(1) translateX(-4px); }
    50% { transform: scaleX(1.2) scaleY(1.5) translateX(5px); }
    100% { transform: scaleX(0.9) scaleY(1) translateX(-4px); }
}

.new-high-badge {
    margin-left:0.6rem; padding:0.2rem 0.6rem; 
    border:1px solid #fff; 
    border-radius:999px;
    font-size:0.9rem; 
    animation:pop 350ms ease; 
    box-shadow:0 0 12px rgba(255,255,255,0.35);
    background: rgba(255, 255, 255, 0.1);
}

@keyframes pop { 0%{transform:scale(0.6);opacity:0} 60%{transform:scale(1.1);opacity:1} 100%{transform:scale(1)} }

.prev-high { color:#888; font-size:0.95rem; margin-bottom:1.2rem; }

.score-display {
    font-size: 3rem;
    font-weight: 700;
    margin: 2rem 0;
    color: #fff;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

.game-over-content {
    display: flex;
    flex-direction: row;
    justify-content: space-around;
    align-items: flex-start;
    gap: 2rem;
    width: 100%;
    max-width: 100%;
}

.game-over-left {
    flex: 0 0 45%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.game-over-right {
    flex: 0 0 45%;
    max-width: none;
    padding: 1.5rem;
    background: rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.game-over-right .subtitle {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    text-align: center;
}

.high-scores-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 60vh;
    overflow-y: auto;
    padding-right: 1rem; /* for scrollbar */
}

.high-score-entry {
    display: grid;
    grid-template-columns: 3rem 1fr auto;
    gap: 1rem;
    align-items: center;
    font-size: 1.1rem;
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    background: rgba(255,255,255,0.05);
    transition: background 0.2s ease;
}
.high-score-entry:hover {
    background: rgba(255,255,255,0.1);
}

.high-score-entry .rank {
    font-weight: 700;
    color: #aaa;
    text-align: right;
}
.high-score-entry .username {
    font-weight: 400;
    color: #eee;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.high-score-entry .score {
    font-weight: 700;
    color: #4ecdc4;
}

.game-hud {
    position: absolute;
    top: 1.5rem;
    left: 1.5rem;
    right: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    pointer-events: none; /* Container doesn't block clicks */
}

.game-hud > * {
    pointer-events: auto; /* Children can be clicked */
}

.score-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.5rem 1.5rem;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 0 15px rgba(0,0,0,0.5);
}

.score-container span:first-child {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #aaa;
}

.score-container span:last-child {
    font-size: 1.8rem;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.3);
}

.btn-icon {
    padding: 0.8rem;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
}

.btn-icon svg {
    width: 48px;
    height: auto;
    stroke: #fff;
}

.screen-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(5px);
    z-index: 11;
}

.pause-menu-buttons {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 2rem;
}