body {
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: #f0f0f0;
    font-family: 'Arial', sans-serif;
    touch-action: none; /* Prevent pull-to-refresh on mobile */
    overflow: hidden; /* Prevent scrolling */
}

#main-wrapper {
    position: relative;
    width: 100%;
    max-width: 450px; /* Limit max width for tablets/desktop */
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

#ui-layer {
    width: 100%;
    padding: 10px;
    box-sizing: border-box;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255,255,255,0.8);
    position: absolute;
    top: 0;
    z-index: 10;
    border-bottom: 1px solid #ccc;
}

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

canvas {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain; /* Maintain aspect ratio */
}

#score-display, #next-fruit-display {
    font-size: 1.2rem;
    font-weight: bold;
}

/* Next fruit preview */
#next-fruits-container {
    display: flex;
    gap: 5px;
}

.next-fruit-slot {
    width: 30px;
    height: 30px;
    background: rgba(255,255,255,0.5);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
}
.next-fruit-slot canvas {
    width: 100% !important;
    height: 100% !important;
}

#game-over-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    z-index: 20;
}

.hidden {
    display: none !important;
}

button {
    padding: 10px 20px;
    font-size: 16px;
    cursor: pointer;
    background-color: #ff6b6b;
    color: white;
    border: none;
    border-radius: 5px;
    margin-top: 10px;
}

button:hover {
    background-color: #ff5252;
}

/* High Score Styles */
#high-score-section {
    margin-top: 20px;
    width: 80%;
    text-align: center;
}

#score-form {
    margin-bottom: 20px;
}

#player-name {
    padding: 8px;
    font-size: 16px;
    border-radius: 4px;
    border: 1px solid #ccc;
    width: 150px;
}

#ranking-container {
    background-color: rgba(255, 255, 255, 0.9);
    border-radius: 8px;
    padding: 10px;
    color: #333;
    max-height: 200px;
    overflow-y: auto;
}

#ranking-container h3 {
    margin: 0 0 10px 0;
    font-size: 18px;
    color: #333;
}

#ranking-list {
    list-style: none;
    padding: 0;
    margin: 0;
    text-align: left;
}

#ranking-list li {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    border-bottom: 1px solid #eee;
    font-size: 14px;
}

#ranking-list li:last-child {
    border-bottom: none;
}

#ranking-list span.rank {
    font-weight: bold;
    margin-right: 10px;
    width: 20px;
    display: inline-block;
}

#ranking-list span.name {
    flex-grow: 1;
}

#ranking-list span.score {
    font-weight: bold;
    color: #ff6b6b;
}