:root {
    --primary: #FF5300;
    --secondary: #FFF;
    --accent: #FFD700;
    --text: #2c3e50;
    --bg-overlay: rgba(0,0,0,0.5);
    --glass: rgba(255, 255, 255, 0.95);
    --shadow: 0 8px 20px rgba(0,0,0,0.15);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

body {
    font-family: 'Fredoka', sans-serif;
    background: linear-gradient(135deg, #FF9A9E 0%, #FECFEF 100%);
    height: 100vh;
    overflow: hidden;
    color: var(--text);
}

.app-container {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* --- GAME AREA --- */
#game-canvas-container {
    position: relative;
    box-shadow: var(--shadow);
    border-radius: 12px;
    background-color: rgba(255, 220, 174, 0.6);
    overflow: hidden; /* Clips the danger line */
}

/* The DANGER LINE */
#danger-line {
    position: absolute;
    /* This top value must match loseHeight in JS (approx 120px / 960px = 12.5%) */
    top: 12.5%; 
    left: 0;
    width: 100%;
    border-bottom: 3px dashed rgba(255, 0, 0, 0.5);
    z-index: 5;
    pointer-events: none;
    display: flex;
    justify-content: flex-end;
}

#danger-line span {
    font-size: 10px;
    color: rgba(255, 0, 0, 0.6);
    background: rgba(255,255,255,0.7);
    padding: 2px 5px;
    border-radius: 4px;
    margin-right: 5px;
    margin-top: -10px;
}

canvas { display: block; }

/* --- UI OVERLAY --- */
#ui-layer {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none;
    z-index: 10;
}

.screen {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: var(--bg-overlay);
    backdrop-filter: blur(5px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    pointer-events: auto;
    transition: opacity 0.2s;
}

.hidden { opacity: 0; pointer-events: none; visibility: hidden; }
.active { opacity: 1; pointer-events: auto; visibility: visible; }

/* --- MODALS --- */
.modal {
    background: var(--glass);
    padding: 2rem;
    border-radius: 24px;
    box-shadow: var(--shadow);
    text-align: center;
    width: 90%;
    max-width: 360px;
    animation: popIn 0.3s cubic-bezier(0.17, 0.67, 0.38, 1.25);
}

@keyframes popIn { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }

h1 { font-size: 4rem; color: var(--primary); line-height: 0.9; margin-bottom: 1.5rem; text-shadow: 3px 3px 0 #fff; transform: rotate(-5deg); }
h2 { font-size: 2rem; margin-bottom: 1.5rem; color: #333; }
p { margin-bottom: 1rem; line-height: 1.4; color: #555; }

/* --- BUTTONS --- */
.menu-buttons { display: flex; flex-direction: column; gap: 12px; width: 100%; align-items: center; }

button {
    font-family: 'Fredoka', sans-serif;
    border: none; cursor: pointer; outline: none;
    transition: transform 0.1s, filter 0.1s;
}
button:active { transform: scale(0.96); }

/* Center Buttons Fix */
.btn-primary, .btn-secondary, .btn-special, .btn-back, .btn-home {
    padding: 14px 20px;
    border-radius: 50px;
    font-size: 1.1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 85%; /* Not 100% width */
    max-width: 280px;
}

.btn-primary { background: var(--primary); color: white; box-shadow: 0 4px 0 #c94202; }
.btn-secondary { background: white; color: var(--text); box-shadow: 0 4px 0 #ccc; border: 1px solid #ddd; }
.btn-special { background: #0057B7; color: #FFD700; box-shadow: 0 4px 0 #003d80; }
.btn-back, .btn-home { margin-top: 15px; background: transparent; border: 2px solid #ccc; color: #777; width: 60%; margin-left: auto; margin-right: auto; }
.btn-link { text-decoration: none; margin-bottom: 10px; display: inline-flex; }

/* Settings Toggles */
.setting-list { width: 100%; text-align: left; }
.setting-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; font-weight: 600; font-size: 1.1rem; }
.btn-toggle { padding: 6px 16px; border-radius: 12px; font-weight: bold; width: 70px; }
.btn-toggle.on { background: #4CD964; color: white; }
.btn-toggle.off { background: #FF3B30; color: white; }

/* --- HUD --- */
#hud {
    position: absolute; top: 0; left: 0; width: 100%; padding: 15px;
    display: flex; justify-content: space-between; pointer-events: none;
}
.hud-left, .hud-right { display: flex; gap: 10px; pointer-events: auto; }

.score-box, .next-fruit-box {
    background: rgba(255,255,255,0.9);
    padding: 6px 14px;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    min-width: 70px;
}

.icon-btn {
    width: 44px; height: 44px;
    border-radius: 12px;
    background: white;
    color: var(--text);
    font-size: 1.2rem;
    display: flex; justify-content: center; align-items: center;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.label { font-size: 0.65rem; font-weight: 700; color: #999; text-transform: uppercase; letter-spacing: 1px; }
#game-score { font-size: 1.4rem; font-weight: 700; color: var(--primary); }
#game-next-fruit { width: 28px; height: 28px; object-fit: contain; margin-top: 2px; }

.highscore-display { margin-top: 20px; font-weight: 600; background: rgba(255,255,255,0.6); padding: 5px 15px; border-radius: 20px; }

#new-record-label { color: #FFD700; font-weight: 900; font-size: 1.2rem; margin: 10px 0; text-shadow: 1px 1px 0 #9e6403; animation: pulse 1s infinite; }
@keyframes pulse { 0% { transform: scale(1); } 50% { transform: scale(1.1); } 100% { transform: scale(1); } }