:root {
    --primary-color: #4CAF50; /* Green apple */
    --secondary-color: #FFC107; /* Amber yellow */
    --background-color: #F5F5F5;
    --text-color: #333333;
    --white-color: #FFFFFF;
    --dark-color: #333333;
    --danger-color: #F44336;
    --font-family: 'Press Start 2P', cursive;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: var(--font-family);
    color: var(--text-color);
    -webkit-user-select: none;
    /* Safari */
    -ms-user-select: none; /* IE 10+ */
    user-select: none;
    background-color: #000;
}

#game-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    /* background-image removed for solid color */
}
#background-decorations {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: -1;
}
.background-emoji {
    position: absolute;
    opacity: 0.15;
    animation-name: float-background;
    animation-timing-function: linear;
    animation-iteration-count: infinite;
    width: auto;
    height: auto;
    max-width: 50px;
}

.screen {
    position: absolute;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 20px;
    box-sizing: border-box;
}

.screen.active {
    display: flex;
}

#game-screen {
    padding: 0;
}

#game-canvas {
    display: block;
}
.company-logo {
    width: 60%;
    max-width: 180px;
    margin-bottom: 1rem;
    image-rendering: pixelated;
}
.title {
    font-size: clamp(2.5rem, 8vw, 4rem);
    background: linear-gradient(to bottom, #FEEA3C, #F49D2D, #D65A28);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    text-shadow: none;
    margin-bottom: 0.2em;
}

.subtitle {
    font-size: clamp(0.8rem, 3vw, 1.2rem);
    color: #FEEA3C;
    margin-bottom: 0.8em;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}
#how-to-play {
    background: rgba(0, 0, 0, 0.75);
    border: 2px solid #FEEA3C;
    border-radius: 15px;
    padding: 15px;
    margin-bottom: 20px;
    width: 90%;
    max-width: 500px;
    max-height: 45vh; /* Increase height to fit title */
    display: flex;
    flex-direction: column;
}
.how-to-play-title {
    font-size: clamp(1rem, 4vw, 1.2rem);
    color: #FEEA3C;
    margin: 0 0 10px 0;
    padding-bottom: 5px;
    border-bottom: 2px solid rgba(255, 234, 60, 0.3);
}
.instructions {
    font-size: clamp(0.7rem, 2.5vw, 0.8rem);
    color: var(--white-color);
    margin: 0 0 10px 0;
    line-height: 1.4;
}
#start-screen, #end-screen, #game-screen {
    background: linear-gradient(rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.6)), url('https://play.rosebud.ai/assets/Basket Blitz Background.jpg?di9S') no-repeat center center / cover;
}
#legend-container {
    padding: 0;
    overflow-y: auto;
    flex-grow: 1; /* Allow it to take up remaining space */
}
.legend-section {
    margin-bottom: 15px;
}
.legend-section:last-child {
    margin-bottom: 0;
}
.legend-title {
    font-weight: 700;
    font-size: clamp(1rem, 4vw, 1.2rem);
    text-align: left;
    margin-bottom: 8px;
    padding-bottom: 4px;
    border-bottom: 2px solid rgba(255, 234, 60, 0.3);
    color: #FEEA3C;
}
.legend-item {
    display: flex;
    align-items: center;
    text-align: left;
    margin-bottom: 5px;
}
.legend-emoji {
    font-size: clamp(1.2rem, 5vw, 1.5rem);
    width: 40px;
    height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-right: 10px;
}
.legend-description {
    font-size: clamp(0.8rem, 3vw, 1rem);
    color: var(--white-color);
}

.btn {
    font-family: var(--font-family);
    font-size: clamp(1rem, 4vw, 1.2rem);
    padding: 12px 30px;
    border: none;
    border-radius: 50px;
    background-color: var(--white-color);
    color: var(--primary-color);
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    text-transform: uppercase;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    margin-top: 10px;
}

.btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.25);
}
#start-button:disabled {
    background: linear-gradient(to bottom, #999, #777);
    color: #ccc;
    cursor: not-allowed;
    text-shadow: 1px 1px 0 rgba(0,0,0,0.3);
    transform: none;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}
#start-button:disabled:hover {
    transform: none;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}
#leaderboard {
    background: rgba(0, 0, 0, 0.75);
    border: 2px solid #FEEA3C;
    border-radius: 15px;
    padding: 15px;
    margin-top: 20px;
    width: 90%;
    max-width: 500px;
    color: var(--white-color);
}
.leaderboard-title {
    font-size: clamp(1rem, 4vw, 1.2rem);
    color: #FEEA3C;
    margin: 0 0 10px 0;
    padding-bottom: 5px;
    border-bottom: 2px solid rgba(255, 234, 60, 0.3);
}
#leaderboard table {
    width: 100%;
    border-collapse: collapse;
    font-size: clamp(0.7rem, 2.5vw, 0.9rem);
}
#leaderboard th, #leaderboard td {
    padding: 6px;
    text-align: center;
}
#leaderboard th {
    color: #FEEA3C;
}
#leaderboard tbody tr:nth-child(odd) {
    background-color: rgba(255, 255, 255, 0.05);
}
#leaderboard tbody tr {
    opacity: 0;
    transform: translateX(-20px);
    animation: slideInRow 0.5s ease-out forwards;
}
/* Stagger the animation for each row */
#leaderboard tbody tr:nth-child(1) { animation-delay: 0.1s; background: rgba(255, 215, 0, 0.2); }
#leaderboard tbody tr:nth-child(2) { animation-delay: 0.2s; }
#leaderboard tbody tr:nth-child(3) { animation-delay: 0.3s; }
#leaderboard tbody tr:nth-child(4) { animation-delay: 0.4s; }
#leaderboard tbody tr:nth-child(5) { animation-delay: 0.5s; }
#leaderboard td:nth-child(2) {
    text-align: left;
    font-weight: bold;
    color: #fff;
    word-break: break-all;
}
#leaderboard td:last-child {
    text-align: right;
}
#leaderboard td:first-child {
    font-weight: bold;
    color: #FFD700;
}
#start-button {
    background: linear-gradient(to bottom, #FEEA3C, #F49D2D, #D65A28);
    color: var(--dark-color);
    text-shadow: 1px 1px 0 rgba(255,255,255,0.3);
}
.btn.alt {
    background: none;
    border: 2px solid var(--white-color);
    color: var(--white-color);
}
#ui-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: center; /* Center the timer */
    padding: 15px 20px;
    box-sizing: border-box;
    font-size: clamp(1rem, 4vw, 1.5rem);
    font-weight: 600;
    color: var(--white-color);
    pointer-events: none;
    text-shadow: 2px 2px 0 rgba(0,0,0,0.5);
    z-index: 10;
}
.ui-item {
    background: rgba(0, 0, 0, 0.4);
    padding: 5px 15px;
    border-radius: 10px;
    border: 2px solid #FEEA3C;
}
#timer-container {
    /* Make the timer visible */
    background: rgba(0, 0, 0, 0.4);
    padding: 5px 15px;
    border-radius: 10px;
    border: 2px solid #FEEA3C;
}
@keyframes score-pop {
    0% { transform: scale(1); }
    50% { transform: scale(1.25); color: #FEEA3C; }
    100% { transform: scale(1); }
}
#score.score-pop {
    display: inline-block; /* Needed for transform */
    animation: score-pop 0.3s ease-out;
}

.form-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 20px 0;
    width: 80%;
    max-width: 350px;
}

.form-group label {
    color: #FEEA3C;
    text-shadow: 1px 1px 0 rgba(0,0,0,0.3);
    margin-bottom: 10px;
    font-size: 0.8rem;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    border: 2px solid #FEEA3C;
    background: rgba(0, 0, 0, 0.2);
    color: var(--white-color);
    font-family: var(--font-family);
    font-size: 1rem;
    text-align: center;
}

.form-group input::placeholder {
    color: rgba(255, 255, 255, 0.5);
    color: rgba(255, 255, 255, 0.5);
}
.end-screen-logo {
    position: absolute;
    bottom: 20px;
    width: 25%;
    max-width: 120px;
    opacity: 0.6;
}
.device-played-on {
    margin: 15px 0;
    font-size: clamp(0.8rem, 2.5vw, 1rem);
    color: var(--white-color);
    background: rgba(0, 0, 0, 0.3);
    padding: 8px 15px;
    border-radius: 20px;
}
@keyframes float {
  0% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-10px);
  }
  100% {
    transform: translateY(0px);
  }
}
@keyframes float-background {
  from {
    transform: translateY(110vh) rotate(0deg);
  }
  to {
    transform: translateY(-10vh) rotate(360deg);
  }
}
@keyframes slideInRow {
  to {
    opacity: 1;
    transform: translateX(0);
  }
}