@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

body {
    margin: 0;
    overflow: hidden;
    background-color: #87CEEB;
    /* Sky blue */
    font-family: 'Press Start 2P', monospace;
    user-select: none;
    -webkit-user-select: none;
}

canvas {
    display: block;
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-shadow: 2px 2px 0 #000;
    z-index: 1000;
    pointer-events: none;
    /* Let clicks pass unless explicitly captured by children */
}

#hud {
    position: absolute;
    top: 20px;
    left: 20px;
    font-size: 24px;
    color: white;
    text-shadow: 2px 2px 0 #000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

#start-screen,
#game-over {
    text-align: center;
    background: rgba(0, 0, 0, 0.7);
    padding: 30px;
    border-radius: 20px;
    backdrop-filter: blur(5px);
    pointer-events: auto;
    transition: opacity 0.3s;
    border: 4px solid white;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.5);
    max-width: 80%;
    max-height: 80%;
    overflow-y: auto;
}

h1 {
    font-size: 36px;
    margin-bottom: 20px;
    color: #FFD700;
    /* Gold */
    text-shadow: 4px 4px 0 #B8860B;
}

button {
    font-family: 'Press Start 2P', monospace;
    font-size: 16px;
    padding: 15px 20px;
    background: linear-gradient(135deg, #FF1493 0%, #C71585 100%);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 0 6px 15px rgba(255, 20, 147, 0.4);
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: block;
    margin: 0 auto;
    text-shadow: 1px 1px 0px rgba(0, 0, 0, 0.5);
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(255, 20, 147, 0.6);
}

button:active {
    transform: translateY(2px);
    box-shadow: 0 2px 5px rgba(255, 20, 147, 0.4);
}

#btn-shop-start,
#btn-shop-go,
#btn-open-shop {
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
    box-shadow: 0 6px 15px rgba(255, 215, 0, 0.4);
    color: #333;
    text-shadow: none;
}

#btn-shop-start:hover,
#btn-shop-go:hover,
#btn-open-shop:hover {
    box-shadow: 0 8px 20px rgba(255, 215, 0, 0.6);
}

/* Premium Left Sidebar Shop */
#shop-screen {
    position: fixed;
    left: -400px;
    /* Initially hidden off-screen */
    top: 0;
    width: 350px;
    height: 100vh;
    background: rgba(20, 20, 30, 0.85);
    /* Dark blueish premium background */
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 20px 0 50px rgba(0, 0, 0, 0.5);
    z-index: 10000;
    transition: left 0.4s cubic-bezier(0.19, 1, 0.22, 1);
    display: flex;
    flex-direction: column;
    padding: 40px 20px;
    box-sizing: border-box;
    pointer-events: auto;
    /* Ensure clicks register on shop */
}

#shop-screen.open {
    left: 0;
}

#shop-screen h1 {
    font-size: 28px;
    text-align: left;
    margin-bottom: 5px;
    background: linear-gradient(to right, #FFD700, #FFF);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: none;
}

.shop-subtitle {
    text-align: left;
    color: #AAA;
    font-size: 10px;
    margin-bottom: 30px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

#shop-stars-container {
    display: flex;
    align-items: center;
    background: rgba(255, 215, 0, 0.1);
    border: 1px solid rgba(255, 215, 0, 0.3);
    padding: 10px 15px;
    border-radius: 12px;
    margin-bottom: 25px;
    font-size: 14px;
    color: #FFD700;
}

#shop-stars-container span {
    margin-left: auto;
    font-size: 18px;
    font-weight: bold;
}

#character-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
    overflow-y: auto;
    flex-grow: 1;
    padding-right: 5px;
}

/* Scrollbar styling */
#character-list::-webkit-scrollbar {
    width: 6px;
}

#character-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}

#character-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
}

.char-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 15px;
    display: flex;
    align-items: center;
    gap: 15px;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.char-card:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateX(5px);
}

.char-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: #666;
    transition: background 0.3s ease;
}

.char-card.unlocked::before {
    background: #82c846;
    /* Green */
}

.char-card.selected {
    background: rgba(255, 215, 0, 0.15);
    border-color: rgba(255, 215, 0, 0.4);
}

.char-card.selected::before {
    background: #FFD700;
    /* Gold */
}

.char-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: #333;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.char-info {
    flex-grow: 1;
    text-align: left;
}

.char-card h3 {
    font-size: 12px;
    margin: 0 0 5px 0;
    color: #FFF;
}

.char-card .price {
    font-size: 10px;
    color: #AAA;
    margin: 0;
}

.char-card.unlocked .price {
    color: #82c846;
}

.char-btn {
    font-size: 10px;
    padding: 8px 12px;
    margin: 0;
    width: auto;
    border-radius: 6px;
    box-shadow: none;
}

.char-btn.buy-btn {
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
    color: #000;
}

.char-btn.select-btn {
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
}

.char-btn.selected-btn {
    background: rgba(255, 255, 255, 0.1);
    color: #888;
    cursor: default;
}

.char-btn.selected-btn:hover {
    transform: none;
}

#btn-close-shop {
    margin-top: 20px;
    width: 100%;
    background: rgba(255, 255, 255, 0.1);
    box-shadow: none;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

#btn-close-shop:hover {
    background: rgba(255, 255, 255, 0.2);
}

#btn-open-shop-corner {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    border-radius: 25px;
    padding: 0;
    display: flex;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid #FFD700;
    color: #FFD700;
    cursor: pointer;
}

#btn-open-shop-corner:hover {
    background: rgba(255, 215, 0, 0.2);
}

#btn-restart-corner {
    position: absolute;
    top: 80px; /* Below the shop button */
    right: 20px;
    width: 50px;
    height: 50px;
    border-radius: 25px;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid #FFD700;
    color: #FFD700;
    cursor: pointer;
    font-size: 24px;
}

#btn-restart-corner:hover {
    background: rgba(255, 215, 0, 0.2);
}

.hidden {
    display: none !important;
}