/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --green-dark:  #1e3d1e;
    --green-mid:   #2d5c2d;
    --green-light: #4a7a2a;
    --brown:       #7a4f2d;
    --beige:       #f5ede0;
    --accent:      #e8871a;
    --accent-dark: #c46b0a;
    --text:        #2a1f14;
}

html, body {
    font-family: 'Source Sans Pro', sans-serif;
    background: var(--green-dark);
    color: var(--text);
    width: 100%;
    height: 100%;
    overflow: hidden;
    position: fixed;
}

/* ===== SCREENS ===== */
.screen {
    display: none;
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.screen.active { display: flex; }

.screen-inner {
    background: var(--beige);
    border-radius: 20px;
    padding: 2.5rem 2rem;
    max-width: 480px;
    width: 95%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
    margin: 1rem auto;
}

/* ===== START SCREEN ===== */
#screen-start { background: radial-gradient(ellipse at center, #2d5c2d 0%, #0f2210 100%); }

.logo-top {
    font-size: 0.9rem;
    color: rgba(245,237,224,0.7);
    letter-spacing: 3px;
    text-transform: uppercase;
    margin-bottom: 1.2rem;
}

h1 {
    font-family: 'Playfair Display', serif;
    font-size: 2.8rem;
    line-height: 1.1;
    color: var(--green-dark);
    margin-bottom: 1rem;
    text-align: center;
}
h1 span { color: var(--accent); }

h2 {
    font-family: 'Playfair Display', serif;
    font-size: 1.8rem;
    color: var(--green-dark);
    margin-bottom: 0.5rem;
    text-align: center;
}

.subtitle {
    font-size: 1rem;
    color: var(--brown);
    line-height: 1.6;
    margin-bottom: 1.5rem;
    text-align: center;
}

.highscore-box {
    display: inline-block;
    background: var(--green-dark);
    color: var(--beige);
    border-radius: 10px;
    padding: 0.5rem 1.2rem;
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
    text-align: center;
}

.hint {
    margin-top: 1rem;
    font-size: 0.8rem;
    color: #999;
    text-align: center;
}

/* ===== BUTTONS ===== */
.btn-primary {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 12px;
    padding: 0.9rem 2.2rem;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    display: inline-block;
    text-decoration: none;
    margin: 0.3rem auto;
    width: 100%;
    text-align: center;
}
.btn-primary:hover  { background: var(--accent-dark); transform: translateY(-2px); }
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
    background: var(--green-dark);
    color: var(--beige);
    border: none;
    border-radius: 12px;
    padding: 0.8rem 1.8rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    display: inline-block;
    text-decoration: none;
    margin: 0.3rem auto;
    width: 100%;
    text-align: center;
}
.btn-secondary:hover { background: var(--green-mid); }

/* ===== GAME SCREEN ===== */
#screen-game {
    background: #1a3320;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    overflow: hidden;
    padding: 0;
}

#hud {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1.2rem;
    background: rgba(0,0,0,0.75);
    color: #fff;
    font-size: 1.05rem;
    font-weight: 700;
    height: 48px;
    flex-shrink: 0;
    z-index: 10;
    width: 100%;
}
#hud-center {
    font-size: 0.7rem;
    letter-spacing: 2px;
    opacity: 0.5;
    text-transform: uppercase;
    text-align: center;
    flex: 1;
}
#hud-score { min-width: 90px; }
#hud-timer { min-width: 70px; text-align: right; }

#gameCanvas {
    display: block;
    touch-action: none;
    flex-shrink: 0;
}

/* ===== COUNTDOWN OVERLAY ===== */
#countdown-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.45);
    z-index: 30;
    pointer-events: none;
}
#countdown-overlay.hidden { display: none; }

#countdown-text {
    font-family: 'Playfair Display', serif;
    font-size: 8rem;
    font-weight: 700;
    color: #fff;
    line-height: 1;
    text-shadow: 0 4px 30px rgba(0,0,0,0.5);
}
#countdown-text.go {
    color: var(--accent);
    font-size: 5rem;
}

/* ===== TOUCH CONTROLS ===== */
#touch-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px 0;
    background: rgba(0,0,0,0.6);
    flex-shrink: 0;
    width: 100%;
}
.touch-row {
    display: flex;
    gap: 6px;
    justify-content: center;
}
.touch-btn {
    width: 58px;
    height: 58px;
    background: rgba(255,255,255,0.18);
    border: 2px solid rgba(255,255,255,0.35);
    border-radius: 12px;
    font-size: 1.4rem;
    color: #fff;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
    display: flex;
    align-items: center;
    justify-content: center;
}
.touch-btn:active { background: rgba(255,255,255,0.45); }

/* ===== END SCREEN ===== */
#screen-end {
    background: radial-gradient(ellipse at center, #2d5c2d 0%, #0f2210 100%);
    overflow-y: auto;
    align-items: flex-start;
    padding: 1rem 0;
}

.score-emoji {
    font-size: 3rem;
    margin-bottom: 0.4rem;
    text-align: center;
}
.final-score {
    font-size: 4.5rem;
    font-weight: 900;
    color: var(--accent);
    font-family: 'Playfair Display', serif;
    line-height: 1;
    margin: 0.3rem 0;
    text-align: center;
}
.score-message { font-size: 1rem; color: var(--brown); margin-bottom: 0.8rem; text-align: center; }

/* ===== LEAD FORM ===== */
.lead-form-box {
    background: #fff;
    border-radius: 14px;
    padding: 1.4rem 1.6rem;
    margin-top: 1.2rem;
    text-align: left;
}
.lead-form-box h3 {
    font-size: 1.1rem;
    color: var(--green-dark);
    margin-bottom: 0.4rem;
    text-align: center;
    font-family: 'Playfair Display', serif;
}
.lead-form-box > p {
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 1.2rem;
    text-align: center;
    line-height: 1.5;
}

.form-group { margin-bottom: 1rem; }
.form-group label {
    display: block;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--green-dark);
    margin-bottom: 0.35rem;
}
.form-group input[type="text"],
.form-group input[type="email"] {
    width: 100%;
    padding: 0.7rem 0.9rem;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 0.95rem;
    transition: border-color 0.2s;
    color: var(--text);
}
.form-group input:focus { outline: none; border-color: var(--accent); }

.checkbox-group label {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    font-weight: 400;
    font-size: 0.82rem;
    color: #555;
    cursor: pointer;
    line-height: 1.5;
}
.checkbox-group input[type="checkbox"] {
    width: 17px; height: 17px;
    flex-shrink: 0;
    margin-top: 2px;
    accent-color: var(--accent);
    cursor: pointer;
}

/* ===== THANKS SCREEN ===== */
#screen-thanks {
    background: radial-gradient(ellipse at center, #2d5c2d 0%, #0f2210 100%);
    overflow-y: auto;
    align-items: flex-start;
    padding: 1rem 0;
}

/* ===== LEADERBOARD ===== */
.leaderboard {
    background: var(--green-dark);
    border-radius: 12px;
    padding: 1rem 1.2rem;
    margin: 1.2rem 0;
    text-align: left;
}
.leaderboard h3 {
    color: var(--beige);
    font-size: 0.8rem;
    text-align: center;
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-bottom: 0.9rem;
}
#leaderboard-list { list-style: none; }
#leaderboard-list li {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.8rem;
    border-radius: 8px;
    margin-bottom: 0.4rem;
    background: rgba(255,255,255,0.07);
    color: var(--beige);
    font-size: 0.9rem;
}
#leaderboard-list li:nth-child(1) { background: rgba(245,197,24,0.22); }
#leaderboard-list li:nth-child(2) { background: rgba(192,192,192,0.18); }
#leaderboard-list li:nth-child(3) { background: rgba(205,127,50,0.18);  }
#leaderboard-list li.me { outline: 2px solid var(--accent); border-radius: 8px; }

.lb-rank  { font-size: 1.1rem; min-width: 28px; text-align: center; }
.lb-name  { flex: 1; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-score { font-weight: 700; color: #f5c518; margin-left: auto; padding-left: 0.5rem; }
.lb-date  { font-size: 0.72rem; color: rgba(255,255,255,0.4); padding-left: 0.4rem; white-space: nowrap; }

/* ===== RESPONSIVE ===== */
@media (max-width: 480px) {
    h1 { font-size: 2rem; }
    .final-score { font-size: 3rem; }
    .screen-inner { padding: 1.2rem 1rem; border-radius: 14px; }
    .touch-btn { width: 52px; height: 52px; font-size: 1.2rem; }
    .highscore-box { font-size: 0.85rem; padding: 0.4rem 0.9rem; }
    .btn-primary, .btn-secondary { font-size: 1rem; padding: 0.8rem 1.5rem; }
    .lead-form-box { padding: 1rem; }
    .logo-top { font-size: 0.75rem; }
}

@media (max-width: 380px) {
    h1 { font-size: 1.7rem; }
    .touch-btn { width: 46px; height: 46px; font-size: 1.1rem; }
    .screen-inner { padding: 1rem 0.8rem; }
}

/* Desktop: verberg touch controls */
@media (min-width: 800px) {
    #touch-controls { display: none; }
}

/* Landscape op telefoon */
@media (max-height: 500px) and (orientation: landscape) {
    #screen-game {
        flex-direction: row;
        align-items: stretch;
    }
    #hud {
        position: absolute;
        top: 0; left: 0; right: 0;
        z-index: 10;
    }
    #touch-controls {
        flex-direction: column;
        padding: 4px 8px;
        width: auto;
        justify-content: center;
    }
    .touch-row { flex-direction: column; }
    .touch-btn { width: 44px; height: 44px; font-size: 1rem; }
}
