@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@700;900&display=swap');

body {
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: #1a1a2e;
    background-image: radial-gradient(circle at center, #16213e 0%, #0f3460 100%);
    font-family: 'Nunito', sans-serif;
    touch-action: none;
    overflow: hidden;
}

#game-container {
    position: relative;
    width: 540px;
    height: 810px;
    border: 8px solid #cbd5e1;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(0,0,0,0.6), inset 0 0 20px rgba(0,0,0,0.2);
    background-color: #87CEEB;
}

#game-container::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    background: linear-gradient(135deg, rgba(255,255,255,0.3) 0%, rgba(255,255,255,0) 40%);
    z-index: 20;
}

canvas {
    display: block;
    transition: transform 0.05s ease;
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    transition: all 0.1s ease;
}

#score {
    position: absolute;
    top: 30px;
    width: 100%;
    text-align: center;
    color: white;
    font-size: 50px;
    font-weight: 900;
    margin: 0;
    text-shadow: 0px 4px 0px #e67e22, 0px 6px 15px rgba(0,0,0,0.4);
    z-index: 10;
    letter-spacing: 2px;
    transition: transform 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#start-screen, #game-over-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: white;
    text-align: center;
    pointer-events: auto;
    z-index: 15;
    transition: opacity 0.3s ease;
}

.hidden {
    opacity: 0;
    pointer-events: none !important;
}

h2 {
    font-size: 40px;
    font-weight: 900;
    margin-bottom: 5px;
    color: #fff;
    text-shadow: 0px 4px 0px #e67e22, 0px 8px 20px rgba(0,0,0,0.5);
    background: -webkit-linear-gradient(#ffeaa7, #fdcb6e);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0px 4px 2px rgba(0,0,0,0.3));
}

.panel {
    background: rgba(255, 255, 255, 0.15);
    border: 2px solid rgba(255,255,255,0.4);
    border-radius: 15px;
    padding: 20px 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.4);
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: float 3s ease-in-out infinite;
    max-width: 80%;
}

@keyframes float {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
    100% { transform: translateY(0px); }
}

p {
    font-size: 18px;
    font-weight: 700;
    margin: 10px 0;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.8);
}

.pulse {
    animation: pulseText 1.5s infinite;
    color: #f1c40f;
    margin-top: 15px;
}

@keyframes pulseText {
    0% { opacity: 0.6; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.05); }
    100% { opacity: 0.6; transform: scale(1); }
}

#final-score {
    font-size: 54px;
    font-weight: 900;
    color: #f1c40f;
    display: block;
    margin: 5px 0;
    text-shadow: 0px 4px 0px #d35400, 0px 2px 10px rgba(0,0,0,0.5);
}

.leaderboard {
    margin-top: 20px;
    background: rgba(0,0,0,0.4);
    border-radius: 10px;
    padding: 15px;
    width: 100%;
    box-sizing: border-box;
}

.leaderboard h3 {
    margin: 0 0 10px 0;
    font-size: 20px;
    color: #f1c40f;
    text-shadow: 1px 1px 3px #000;
}

.leaderboard ul {
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 18px;
    text-align: left;
    width: 100%;
}

.leaderboard li {
    display: flex;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255,255,255,0.2);
    padding: 5px 0;
}

.leaderboard li:last-child {
    border-bottom: none;
}

#name-input-section {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(0,0,0,0.4);
    padding: 15px;
    border-radius: 10px;
}

#player-name {
    padding: 10px;
    border-radius: 5px;
    border: none;
    outline: none;
    font-family: inherit;
    font-weight: bold;
    text-align: center;
    margin-bottom: 10px;
    font-size: 16px;
    width: 200px;
}

#save-score-btn {
    padding: 10px 20px;
    border-radius: 5px;
    border: none;
    background-color: #f1c40f;
    color: #000;
    font-weight: 900;
    font-size: 16px;
    cursor: pointer;
    font-family: inherit;
    transition: transform 0.1s;
}

#save-score-btn:active {
    transform: scale(0.95);
}
