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

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    background: #1a1a2e;
    color: #e0e0e0;
    font-family: 'Press Start 2P', monospace;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100dvh;
    overflow: hidden;
    padding: 0.5rem;
}

h1 {
    font-size: clamp(1rem, 5vw, 2rem);
    color: #e94560;
    margin-bottom: 0.3rem;
    text-shadow: 3px 3px 0 #0f3460;
}

.subtitle {
    font-size: 0.5rem;
    color: #888;
    margin-bottom: 1rem;
}

canvas {
    border: 4px solid #0f3460;
    border-radius: 4px;
    image-rendering: pixelated;
    background: #16213e;
    max-width: 100%;
    max-height: calc(100dvh - 120px);
    width: auto;
    height: auto;
}

#hud {
    display: flex;
    justify-content: space-between;
    width: 100%;
    max-width: 480px;
    padding: 0.5rem 0;
    font-size: 0.7rem;
}

#hud span {
    color: #e94560;
}

/* Character select screen */
#char-select {
    text-align: center;
}

#char-select h2 {
    font-size: 1rem;
    margin-bottom: 2rem;
    color: #e94560;
}

.char-options {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
}

.fruit-title {
    margin-top: 2rem !important;
}

.fruit-options {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.fruit-option {
    cursor: pointer;
    text-align: center;
    padding: 0.8rem;
    border: 3px solid #0f3460;
    border-radius: 8px;
    background: #16213e;
    transition: all 0.2s;
    opacity: 0.5;
}

.fruit-option:hover {
    border-color: #e94560;
    opacity: 0.8;
}

.fruit-option.active {
    border-color: #e94560;
    opacity: 1;
}

.char-option {
    cursor: pointer;
    text-align: center;
    padding: 1.5rem;
    border: 3px solid #0f3460;
    border-radius: 8px;
    background: #16213e;
    transition: all 0.2s;
}

.char-option:hover {
    border-color: #e94560;
    transform: scale(1.05);
}

.char-option canvas {
    border: none;
    margin-bottom: 0.5rem;
}

.char-option .name {
    font-size: 0.8rem;
    color: #e0e0e0;
    margin-top: 0.5rem;
}

/* Game over */
#game-over {
    display: none;
    text-align: center;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
}

#game-over h2 {
    font-size: 1.5rem;
    color: #e94560;
    margin-bottom: 1rem;
}

#game-over .score {
    font-size: 0.8rem;
    margin-bottom: 2rem;
}

#game-over button {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.7rem;
    padding: 0.8rem 1.5rem;
    background: #e94560;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    margin: 0.3rem;
}

#game-over button:hover {
    background: #c73652;
}

/* Name input */
#player-name {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.6rem;
    padding: 0.6rem 1rem;
    border: 2px solid #0f3460;
    border-radius: 4px;
    background: #16213e;
    color: #e0e0e0;
    outline: none;
    width: 180px;
    margin-bottom: 0.5rem;
}

#player-name:focus {
    border-color: #e94560;
}

#name-input-area {
    margin-bottom: 1rem;
}

#name-input-area button {
    font-size: 0.55rem;
    padding: 0.5rem 1rem;
}

.saved-msg {
    color: #2ecc71;
    font-size: 0.7rem;
    margin-bottom: 1rem;
}

/* Leaderboard */
#leaderboard {
    text-align: center;
    max-width: 400px;
    width: 90vw;
}

#leaderboard h2 {
    font-size: 1.2rem;
    color: #e94560;
    margin-bottom: 1rem;
}

.lb-tabs {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.lb-tab {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.6rem;
    padding: 0.5rem 1rem;
    border: 2px solid #0f3460;
    border-radius: 4px;
    background: transparent;
    color: #888;
    cursor: pointer;
}

.lb-tab.active {
    border-color: #e94560;
    color: #e94560;
}

#lb-list {
    margin-bottom: 1rem;
}

.lb-row {
    display: flex;
    justify-content: space-between;
    padding: 0.4rem 0.8rem;
    font-size: 0.6rem;
    border-bottom: 1px solid #0f3460;
}

.lb-row .lb-rank {
    color: #e94560;
    width: 2rem;
    text-align: left;
}

.lb-row .lb-name {
    flex: 1;
    text-align: left;
}

.lb-row .lb-score {
    color: #e94560;
    width: 4rem;
    text-align: right;
}

.lb-highlight {
    background: #0f3460;
    border-radius: 4px;
    color: #e94560;
}

.lb-highlight .lb-name {
    color: #e94560;
}

.lb-empty {
    color: #555;
    font-size: 0.6rem;
    padding: 2rem 0;
}

#leaderboard > button {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.6rem;
    padding: 0.6rem 1.2rem;
    background: #e94560;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

#leaderboard > button:hover {
    background: #c73652;
}

/* Mobile controls */
#mobile-controls {
    display: none;
    justify-content: center;
    gap: 2rem;
    padding: 0.5rem 0;
}

#mobile-controls button {
    font-size: 2rem;
    width: 70px;
    height: 50px;
    border: 3px solid #0f3460;
    border-radius: 8px;
    background: #16213e;
    color: #e0e0e0;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

#mobile-controls button:active {
    background: #e94560;
    border-color: #e94560;
}

@media (pointer: coarse) {
    #mobile-controls {
        display: flex;
    }
}

.leaderboard-btn {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.6rem;
    padding: 0.6rem 1.2rem;
    background: transparent;
    color: #888;
    border: 2px solid #0f3460;
    border-radius: 4px;
    cursor: pointer;
    margin-top: 1.5rem;
}

.leaderboard-btn:hover {
    border-color: #e94560;
    color: #e94560;
}

#game-screen {
    display: none;
    position: relative;
}
