:root {
    --bg-color: #05050a;
    --accent-primary: #00f2ff;
    --accent-secondary: #ff00ea;
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --font-main: 'Outfit', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-main);
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    width: 100vw;
}

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: radial-gradient(circle at center, #0a0a1f 0%, #05050a 100%);
}

#gameCanvas {
    display: block;
    /* Cursor controlled by JS */
}

#ui-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
    padding: 0 !important;
    /* Ensure Bootstrap container-fluid doesn't add padding */
}

.overlay-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(5, 5, 10, 0.85);
    backdrop-filter: blur(8px);
    pointer-events: all;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

/* Default screens are columns, but rows should stay rows */
.overlay-screen:not(.row) {
    flex-direction: column;
}

#start-screen {
    background: transparent;
    backdrop-filter: none;
    width: 100%;
    height: 100%;
    padding: 1.5rem;
    /* Normalized padding */
    overflow-y: hidden !important;
    /* Hide unwanted scrollbar */
    display: flex;
    flex-direction: row;
    pointer-events: all;
}

#start-screen.row {
    --bs-gutter-x: 3rem;
    /* Increase horizontal gap between columns */
}

.start-side-placeholder {
    width: 280px;
    /* Match leaderboard width to keep center perfect */
}

.start-center-content {
    display: flex;
    flex-direction: column;
    align-items: center;
}

#leaderboard-container {
    width: 280px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(8px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
}

.leaderboard-header {
    cursor: pointer;
    position: relative;
    padding-right: 25px;
    /* Space for chevron */
    user-select: none;
}

.leaderboard-header::after {
    content: '▾';
    position: absolute;
    right: 0;
    top: 0;
    font-size: 0.8rem;
    color: var(--text-secondary);
    transition: transform 0.3s ease;
}

#leaderboard-container.collapsed .leaderboard-header::after {
    transform: rotate(-90deg);
}

.leaderboard-header:hover h3 {
    color: var(--accent-primary);
    text-shadow: 0 0 10px var(--accent-primary);
}

.leaderboard-header h3 {
    font-size: 0.8rem;
    letter-spacing: 0.3rem;
    color: var(--text-primary);
    text-align: center;
    margin-bottom: 0.4rem;
    text-transform: uppercase;
    transition: color 0.3s ease;
}

.leaderboard-tabs {
    display: flex;
    justify-content: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 0.5rem;
    margin-bottom: 0.5rem;
}

.leaderboard-tabs span {
    font-size: 0.6rem;
    letter-spacing: 1px;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.leaderboard-body {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    max-height: 300px;
    overflow-y: auto;
    padding-right: 4px;
    transition: max-height 0.4s cubic-bezier(0.165, 0.84, 0.44, 1), opacity 0.3s ease;
    opacity: 1;
}

#leaderboard-container.collapsed .leaderboard-body {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
}

/* Custom Scrollbar for Leaderboard */
.leaderboard-body::-webkit-scrollbar {
    width: 3px;
}

.leaderboard-body::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02);
}

.leaderboard-body::-webkit-scrollbar-thumb {
    background: var(--accent-primary);
    border-radius: 10px;
}

.leaderboard-row {
    display: flex;
    align-items: center;
    padding: 0.4rem 0.6rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.03);
    border-radius: 6px;
    transition: all 0.2s ease;
}

.leaderboard-row:hover {
    background: rgba(0, 242, 255, 0.05);
    border-color: rgba(0, 242, 255, 0.3);
}

.leaderboard-rank {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-secondary);
    width: 25px;
}

.leaderboard-name {
    font-size: 0.8rem;
    color: var(--text-primary);
    flex-grow: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right: 10px;
}

.leaderboard-score {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-primary);
}

.leaderboard-entry.placeholder {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.3);
    text-align: center;
    letter-spacing: 0.1rem;
    padding: 2rem 0;
}

.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* Leaderboard Tooltip (Speech Bubble) */
.leaderboard-row {
    position: relative;
    /* Anchor for tooltip */
}

#pw-global-tooltip {
    position: fixed;
    /* Fixed relative to viewport to avoid any parent clipping */
    background: rgba(10, 10, 20, 0.75);
    /* Increased transparency slightly more */
    border: 1px solid rgba(255, 255, 255, 0.4);
    /* White/Silver border */
    border-radius: 8px;
    padding: 0.4rem 0.5rem;
    /* Ultra-compact padding */
    width: 220px;
    /* Adjusted for 4 columns */
    z-index: 10000;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.23, 1, 0.32, 1);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
    max-height: 80vh;
    overflow-y: auto;
}

#pw-global-tooltip.visible {
    opacity: 1;
    visibility: visible;
}

.tooltip-header {
    font-size: 0.55rem;
    /* Slightly smaller */
    letter-spacing: 1px;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 0.2rem;
    text-transform: uppercase;
}

.tooltip-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    /* 4 columns layout */
    gap: 0.3rem;
    /* Tighter gap */
    margin-bottom: 0.4rem;
}

.tooltip-kill-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.1rem;
}

.tooltip-kill-icon {
    width: 14px;
    /* Smaller icons for 4-column layout */
    height: 14px;
    object-fit: contain;
}

.tooltip-kill-count {
    font-size: 0.65rem;
    /* Sharper font */
    font-weight: 700;
    color: #fff;
}

.tooltip-footer {
    font-size: 0.6rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.8);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 0.4rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.tooltip-mode {
    font-size: 0.55rem;
    padding: 1px 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.6);
}

/* Tooltip Arrow (Bubble Tail) */
.tooltip-arrow {
    position: absolute;
    bottom: -6px;
    /* Default: Arrow at the bottom center */
    left: 50%;
    transform: translateX(-50%) rotate(45deg);
    width: 10px;
    height: 10px;
    background: rgba(10, 10, 20, 0.75);
    border-right: 1px solid rgba(255, 255, 255, 0.4);
    border-bottom: 1px solid rgba(255, 255, 255, 0.4);
    transition: all 0.2s ease;
}

/* Flipped State (When tooltip is below the row) */
#pw-global-tooltip.flipped .tooltip-arrow {
    bottom: auto;
    top: -6px;
    /* Arrow at the top center */
    border-right: none;
    border-bottom: none;
    border-left: 1px solid rgba(255, 255, 255, 0.4);
    border-top: 1px solid rgba(255, 255, 255, 0.4);
}


/* Typography styles */
h1 {
    font-size: clamp(2.8rem, 8vw, 5rem) !important;
    font-weight: 700 !important;
    letter-spacing: 0.1rem !important;
    line-height: 0.85 !important;
    margin-bottom: 0.8rem !important;
    /* Slightly more space */
    color: #ffffff !important;
    text-align: center !important;
    font-family: var(--font-main) !important;
}

.subtitle {
    font-size: clamp(0.7rem, 2vw, 1.2rem) !important;
    font-weight: 300 !important;
    letter-spacing: 0.3rem !important;
    color: var(--text-secondary) !important;
    margin-bottom: 2.5rem !important;
    text-transform: uppercase !important;
    font-family: var(--font-main) !important;
    white-space: nowrap !important;
}

.icon-box {
    width: 35px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
}

.elements-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    /* Tighter gap since icon-box has its own width */
    text-decoration: none !important;
    transition: all 0.3s ease;
}

.elements-link {
    color: #ffffff !important;
    font-size: 0.7rem !important;
    letter-spacing: 0.1rem !important;
    text-decoration: none !important;
    margin-top: 0 !important;
    opacity: 0.6 !important;
    transition: all 0.3s ease !important;
    font-family: var(--font-main) !important;
    white-space: nowrap;
    line-height: normal;
    /* Force normal line height for flex centering */
}

.elements-icon {
    width: 24px !important;
    height: 24px !important;
    display: block;
    opacity: 0.8;
    transition: all 0.3s ease;
}

.elements-group:hover .elements-link {
    opacity: 1;
    text-decoration: none !important;
    text-shadow: 0 0 10px var(--accent-primary);
}

.elements-group:hover .elements-icon {
    opacity: 1;
    transform: scale(1.1);
    /* Vibrant Yellow Filter (#ffff00 roughly) */
    filter: invert(93%) sepia(93%) saturate(5435%) hue-rotate(357deg) brightness(106%) contrast(106%);
}



.beta-notice {
    font-size: 0.6rem;
    letter-spacing: 0.1rem;
    color: rgba(255, 255, 255, 0.3);
    text-transform: uppercase;
    padding: 1rem;
    font-family: 'Outfit', sans-serif;
}

.credits-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    opacity: 1;
    pointer-events: none;
    padding: 0.5rem 0;
    line-height: 1.1;
    z-index: 20;
}

@media (min-width: 992px) {
    .credits-container {
        align-items: flex-end;
    }
}


@media (max-width: 991px) {
    .credits-container {
        margin-bottom: 1.5rem;
    }

    .start-center-content {
        margin-top: 2rem !important;
    }
}

.credit-line {
    font-size: 0.65rem !important;
    /* Slightly larger as requested */
    letter-spacing: 0.15rem !important;
    line-height: 1.1 !important;
    color: var(--text-secondary) !important;
    font-family: var(--font-main) !important;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    text-transform: uppercase;
    margin: 0 !important;
    padding: 0 !important;
}

.credit-icon {
    width: 10px;
    height: 10px;
    object-fit: contain;
}

.credit-logo {
    height: 18px !important;
    /* Further reduced */
    width: auto !important;
    object-fit: contain;
    margin: 0 !important;
    padding: 0 !important;
}

.start-ship-3d-wrapper {
    width: 100px;
    height: 100px;
    aspect-ratio: 1/1;
    flex-shrink: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 0.5rem !important;
    /* Tighter spacing */
}

#start-ship-3d-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.controls-hint {
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-align: center;
    line-height: 1.8;
    margin-bottom: 3rem;
    letter-spacing: 0.1rem;
}

/* UI Elements */
#game-ui {
    position: absolute;
    bottom: 1.5rem;
    left: 2rem;
    right: 2rem;
    display: flex;
    justify-content: center;
    pointer-events: none;
}

.stats-container {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.stat-box {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.8rem;
}

.label {
    display: block;
    font-size: 0.5rem;
    letter-spacing: 0.1rem;
    color: var(--text-secondary);
}

#score-value {
    font-size: 1rem;
    font-weight: 700;
    color: #ff931e;
    /* Changed to orange as requested */
}

.kills-list-hud {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
    align-items: center;
    min-width: 50px;
}

.kill-item-hud {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--accent-primary);
}

.kill-icon-hud {
    width: 16px;
    height: 16px;
    object-fit: contain;
}

#time-value {
    font-size: 1rem;
    font-weight: 700;
    color: #ffffff;
}

.stats-summary {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 1.5rem;
    margin-bottom: 0.8rem;
    width: 100%;
}

.final-score,
.final-time {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    width: auto;
}

.final-score .label,
.final-time .label {
    margin-bottom: 0.2rem;
    font-size: 0.7rem !important;
    letter-spacing: 0.2rem !important;
    color: var(--text-secondary) !important;
    font-family: var(--font-main) !important;
}

#final-score-value {
    font-size: 2.8rem;
    font-weight: 700;
    line-height: 1;
    color: #ff931e;
}

#final-time-value {
    font-size: 2.8rem;
    font-weight: 700;
    line-height: 1;
    color: #ffffff;
}

.lives-display {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.life-icon {
    width: 14px;
    height: 14px;
    filter: drop-shadow(0 0 5px #ff3366);
}

#lives-value {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* Buttons */
button {
    background: transparent;
    border: 1px solid var(--accent-primary);
    color: var(--accent-primary);
    padding: 1.2rem 3rem;
    font-size: 1rem;
    font-family: var(--font-main);
    letter-spacing: 0.3rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    border-radius: 4px;
    text-transform: uppercase;
}

button:hover {
    background: var(--accent-primary);
    color: var(--bg-color);
    box-shadow: 0 0 30px rgba(0, 242, 255, 0.6);
}

/* Difficulty Selection */
.difficulty-selection {
    display: flex;
    gap: 10px;
    justify-content: center;
    width: 100%;
}

.diff-btn {
    padding: 0.4rem 0.8rem !important;
    font-size: 0.6rem !important;
    letter-spacing: 0.1rem !important;
    background: rgba(0, 0, 0, 0.3) !important;
    min-width: 80px;
    border-width: 1px !important;
    border-style: solid !important;
    border-color: #ffffff !important;
    /* Default white stroke */
    color: #ffffff !important;
    /* Default white text */
    transition: all 0.3s ease !important;
}

/* Easy (Green) */
.diff-btn[data-difficulty="EASY"]:hover {
    border-color: #00ff88 !important;
    color: #00ff88 !important;
    background: rgba(0, 255, 136, 0.1) !important;
    box-shadow: 0 0 15px rgba(0, 255, 136, 0.4) !important;
}

.diff-btn[data-difficulty="EASY"].active {
    background: #00ff88 !important;
    color: #000000 !important;
    border-color: #00ff88 !important;
    box-shadow: 0 0 20px rgba(0, 255, 136, 0.6) !important;
    opacity: 1 !important;
}

/* Normal (White) */
.diff-btn[data-difficulty="NORMAL"]:hover {
    background: rgba(255, 255, 255, 0.1) !important;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.4) !important;
}

.diff-btn[data-difficulty="NORMAL"].active {
    background: #ffffff !important;
    color: #000000 !important;
    border-color: #ffffff !important;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.6) !important;
    opacity: 1 !important;
}

/* Hard (Red) */
.diff-btn[data-difficulty="HARD"]:hover {
    border-color: #ff0033 !important;
    color: #ff0033 !important;
    background: rgba(255, 0, 51, 0.1) !important;
    box-shadow: 0 0 15px rgba(255, 0, 51, 0.4) !important;
}

.diff-btn[data-difficulty="HARD"].active {
    background: #ff0033 !important;
    color: #ffffff !important;
    border-color: #ff0033 !important;
    box-shadow: 0 0 20px rgba(255, 0, 51, 0.6) !important;
    opacity: 1 !important;
}

button:disabled,
button:disabled:hover,
#save-button:disabled,
#save-button:disabled:hover,
#v-save-button:disabled,
#v-save-button:disabled:hover {
    pointer-events: none !important;
    transform: none !important;
    box-shadow: none !important;
}

/* Game Over Styles */
#game-over-screen {
    overflow-y: auto !important;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    padding: 1rem 1.5rem !important;
    gap: 0.5rem !important;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
}

.end-screen-logo {
    width: 45px;
    height: 45px;
    margin-bottom: 0.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.end-screen-logo:hover {
    transform: scale(1.1);
    filter: drop-shadow(0 0 20px #ffcc00);
    /* Yellow glow on hover */
}

.game-over-title {
    font-size: 2.8rem !important;
    font-weight: 700 !important;
    color: #ffffff !important;
    margin-bottom: 0.4rem !important;
    font-family: var(--font-main) !important;
    text-align: center !important;
    letter-spacing: normal !important;
}

#kill-summary {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.6rem;
    max-width: 600px;
    margin-bottom: 0.6rem !important;
    padding: 0.4rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
}

.kill-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.2rem 0.4rem;
}

.kill-icon {
    width: 22px;
    height: 22px;
    object-fit: contain;
    filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.2));
}

.kill-count {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-secondary);
    letter-spacing: 0.05rem;
}

#name-entry-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    width: 100%;
}

#name-entry-container p {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 0.5rem;
    letter-spacing: 1px;
}

.go-input-group {
    display: flex;
    gap: 10px;
    justify-content: center;
    width: 100%;
    flex-wrap: wrap;
    /* allow wrapping on tiny screens */
}

#player-name {
    background: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    padding: 0.8rem 1.2rem !important;
    border-radius: 8px !important;
    color: #fff !important;
    font-family: var(--font-main) !important;
    font-size: 0.9rem !important;
    letter-spacing: 2px !important;
    width: 200px !important;
    outline: none !important;
    transition: all 0.3s ease !important;
    text-align: left !important;
    /* Match victory alignment */
}

#player-name:focus {
    border-color: #00FFF8 !important;
    box-shadow: 0 0 15px rgba(0, 255, 248, 0.2) !important;
}

#save-button {
    background: #00FFF8;
    color: #000;
    border: none;
    padding: 0 1.5rem;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.3s;
    text-transform: uppercase;
}

#save-button:hover:not(:disabled) {
    background: #fff;
    color: #000;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 255, 248, 0.4);
}

#go-leaderboard-list {
    margin-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    width: 100%;
    max-width: 450px;
    min-height: 250px;
    /* Force visibility */
    max-height: 400px;
    flex-shrink: 0;
    /* Prevent squashing */
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 1rem;
}

#go-leaderboard-list.hidden {
    display: none !important;
}

#v-leaderboard-list.hidden {
    display: none !important;
}


@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 0.8;
    }

    50% {
        transform: scale(1.05);
        opacity: 1;
    }

    100% {
        transform: scale(1);
        opacity: 0.8;
    }
}

/* Victory HUD Styling */
#victory-screen {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 95%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto !important;
    z-index: 1000;
    pointer-events: auto;
    /* Re-enable for clicks */
    display: flex;
    flex-direction: column;
    align-items: center;
    color: #fff;
    font-family: 'Outfit', sans-serif;
    text-align: center;
    animation: victoryHudFadeIn 1s cubic-bezier(0.23, 1, 0.32, 1) forwards;
    text-shadow: 0 0 20px rgba(0, 0, 0, 1), 0 0 5px rgba(0, 0, 0, 1);
}

@keyframes victoryHudFadeIn {
    from {
        opacity: 0;
        transform: translate(-50%, -40%) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

.victory-badge {
    color: #00FFF8;
    letter-spacing: 3px;
    font-size: 0.75rem;
    font-weight: 700;
    display: block;
    margin-bottom: 0.25rem;
    text-shadow: 0 0 10px rgba(0, 255, 248, 0.5);
}

.victory-header h2 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 1.2rem !important;
    letter-spacing: 1px;
}

.victory-stats-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.v-stat,
.v-time {
    display: flex;
    flex-direction: column;
}

.v-label {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.9);
    letter-spacing: 2px;
    margin-bottom: 0.5rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 1);
}

#v-score-value,
#v-time-value {
    font-size: 1.8rem;
    font-weight: 700;
    text-shadow: 0 0 15px rgba(0, 255, 248, 0.6);
}

#v-name-container p {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 0.8rem;
    letter-spacing: 1px;
}

.v-input-group {
    display: flex;
    gap: 10px;
    margin-bottom: 1.5rem;
    justify-content: center;
}

#v-leaderboard-list {
    margin-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    max-height: 400px;
    overflow-y: auto;
}

#v-player-name {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 0.8rem 1.2rem;
    border-radius: 8px;
    color: #fff;
    font-size: 0.9rem;
    width: 200px;
    transition: all 0.3s;
}

#v-player-name:focus {
    border-color: #00FFF8;
    box-shadow: 0 0 15px rgba(0, 255, 248, 0.2);
    outline: none;
}

#v-save-button {
    background: #00FFF8;
    color: #000;
    border: none;
    padding: 0 1.5rem;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.3s;
}

#v-save-button:hover {
    background: #fff;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 255, 248, 0.4);
}

#v-kill-summary {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1.5rem;
    margin-bottom: 2.5rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
}

.v-footer {
    display: flex;
    justify-content: center;
    width: 100%;
    margin-top: 1.5rem;
}

#v-restart-button,
#restart-button {
    background: transparent;
    border: 2px solid #fff;
    color: #fff;
    padding: 1rem 2.5rem;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
    text-transform: uppercase;
}

#v-restart-button:hover,
#restart-button:hover {
    background: #fff;
    color: #000;
}

/* --- Mobile Optimizations --- */
@media (max-width: 768px) {
    body {
        /* Prevent bounce and scroll on mobile browsers */
        position: fixed;
        overflow: hidden;
    }

    #start-screen {
        overflow-y: auto !important;
        align-items: flex-start !important;
        padding-top: 2rem !important;
        padding-bottom: 2rem !important;
    }

    h1 {
        font-size: 3.6rem !important;
        margin-bottom: 0.3rem !important;
    }

    .subtitle {
        font-size: 0.8rem !important;
        letter-spacing: 0.15rem !important;
        margin-bottom: 1.5rem !important;
    }

    .start-ship-icon {
        width: 32px !important;
        height: 32px !important;
        margin-bottom: 1rem !important;
    }

    button {
        padding: 1rem 2rem !important;
        font-size: 0.9rem !important;
        letter-spacing: 0.2rem !important;
    }

    #start-button {
        margin-bottom: 1.5rem !important;
    }

    .elements-link {
        font-size: 0.7rem !important;
        margin-top: 1rem !important;
    }

    .credits-container {
        margin-top: 1.5rem !important;
    }

    .game-over-title {
        font-size: 2.2rem !important;
    }

    .stats-summary {
        gap: 1.5rem !important;
        margin-bottom: 1rem !important;
    }

    #final-score-value,
    #final-time-value {
        font-size: 2.2rem !important;
    }

    .stat-box {
        padding: 0.3rem 0.6rem !important;
        gap: 0.5rem !important;
    }

    #kill-summary {
        gap: 0.8rem !important;
        margin-bottom: 1rem !important;
    }

    #player-name {
        width: 200px !important;
        padding: 0.6rem 1rem !important;
    }

    #game-over-buttons {
        margin-top: 0.5rem !important;
    }

    #game-ui {
        bottom: 0.8rem !important;
        left: 0.8rem !important;
        right: 0.8rem !important;
    }
}

/* Ensure side elements center correctly on portrait/stacked view */
@media (max-width: 991px) {

    .start-side-placeholder,
    #leaderboard-placeholder {
        margin-left: auto !important;
        margin-right: auto !important;
    }
}

/* Mini Leaderboard */
.mini-leaderboard {
    width: 100%;
    max-width: 450px;
    margin: 1rem auto;
    min-height: 250px;
    /* Force visibility */
    max-height: 400px;
    flex-shrink: 0;
    /* Prevent squashing */
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    padding-right: 5px;
}

.mini-leaderboard::-webkit-scrollbar {
    width: 3px;
}

.mini-leaderboard::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02);
}

.mini-leaderboard::-webkit-scrollbar-thumb {
    background: var(--accent-primary);
    border-radius: 10px;
}

.leaderboard-row.mini {
    padding: 0.4rem 0.6rem;
    border-radius: 4px;
}

.leaderboard-name-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.diff-indicator {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.victory-star-icon {
    width: 12px;
    height: 12px;
    vertical-align: middle;
    margin-left: 4px;
    filter: drop-shadow(0 0 3px rgba(255, 255, 255, 0.5));
}


/* --- Validation Styling --- */
#player-name.input-error,
#v-player-name.input-error,
#player-name.input-error:focus,
#v-player-name.input-error:focus {
    border: 2px solid #ff0000 !important;
    box-shadow: 0 0 20px rgba(255, 0, 0, 0.6) !important;
    animation: shake 0.4s ease-in-out;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    50% {
        transform: translateX(5px);
    }

    75% {
        transform: translateX(-5px);
    }
}