@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@400;600&display=swap');

body {
    font-family: 'Fredoka', sans-serif;
    text-align: center;
    background: linear-gradient(135deg, #1e1e1e, #2c2c2c);
    color: white;
    margin: 0;
}

/* TITLE */
h1 {
    margin-bottom: 5px;
    font-size: 2.8rem;
    font-weight: 600;
    letter-spacing: 1px;
}

/* MENU */
#menu {
    margin-bottom: 15px;
}

#menuTop {
    margin-bottom: 6px;
}

#menuCoop {
    margin-bottom: 4px;
}

/* SELECT */
select {
    padding: 8px 12px;
    margin: 5px;
    font-size: 14px;
    cursor: pointer;
    border-radius: 8px;
    border: none;
    background-color: #3a3a3a;
    color: white;
    transition: transform 0.1s ease;
}

select:hover {
    transform: scale(1.05);
}

/* TITLE GRID */
#title {
    margin-top: 10px;
    font-size: 1.2rem;
}

/* COUNTER */
#counter {
    margin-bottom: 10px;
    font-size: 42px;
    font-weight: bold;
}

/* GRID */
#grid {
    display: grid;
    grid-template-columns: repeat(var(--grid-cols, 8), 80px);
    grid-gap: 8px;
    justify-content: center;
}

/* CELL */
.cell {
    width: 80px;
    height: 80px;
    background-color: #2c2c2c;
    border: 2px solid #444;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
    position: relative;
}

.cell img {
    width: 70px;
    height: 70px;
}

.cell:hover:not(.caught-bugs):not(.caught-fish) {
    transform: scale(1.1);
    background-color: #3a3a3a;
    box-shadow: 0 0 8px rgba(255,255,255,0.2);
}

.caught-bugs:hover,
.caught-fish:hover {
    transform: scale(1.1);
}

.caught-bugs {
    background-color: #2ecc71 !important;
    border-color: #27ae60;
    box-shadow: 0 0 10px rgba(46, 204, 113, 0.6);
}

.caught-fish {
    background-color: #3498db !important;
    border-color: #2980b9;
    box-shadow: 0 0 10px rgba(52, 152, 219, 0.6);
}

/* BUTTONS */
button {
    margin-top: 8px;
    margin-left: 5px;
    padding: 10px 18px;
    font-size: 15px;
    cursor: pointer;
    border-radius: 10px;
    border: none;
    background-color: #3a3a3a;
    color: white;
    transition: transform 0.1s ease, background-color 0.2s ease;
}

button:hover {
    transform: scale(1.08);
    background-color: #4a4a4a;
}

#toggleCoop.active {
    background-color: #e67e22;
    box-shadow: 0 0 10px rgba(230, 126, 34, 0.5);
}

/* NAMES */
.name {
    position: absolute;
    bottom: 3px;
    font-size: 10px;
    background: rgba(0,0,0,0.7);
    padding: 2px 5px;
    border-radius: 6px;
    display: none;
}

.show-names .name {
    display: block;
}

/* ── COOP MENU ─────────────────────────────────────────────── */
#coopMenu {
    display: none;
    margin-bottom: 15px;
    padding: 12px 16px;
    border: 2px solid #e67e22;
    border-radius: 12px;
    background-color: rgba(230, 126, 34, 0.08);
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
}

#coopMenu.visible {
    display: block;
}

#modeSelector {
    margin-bottom: 10px;
}

.mode-btn {
    margin: 4px;
    padding: 8px 20px;
    font-size: 14px;
    border-radius: 20px;
    border: 2px solid transparent;
    background-color: #3a3a3a;
    color: #aaa;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mode-btn:hover {
    background-color: #4a4a4a;
    color: white;
    transform: scale(1.05);
}

.mode-btn.active {
    background-color: #e67e22;
    color: white;
    border-color: #d35400;
    box-shadow: 0 0 8px rgba(230, 126, 34, 0.5);
}

#coopMenu input {
    padding: 8px;
    border-radius: 8px;
    border: none;
    margin: 4px;
    background-color: #3a3a3a;
    color: white;
    font-family: 'Fredoka', sans-serif;
    font-size: 14px;
    width: 130px;
}

#coopMenu button {
    margin: 4px;
}

/* ── RACE SCOREBOARD ───────────────────────────────────────── */
#scoreboard {
    display: none;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 14px;
}

#scoreboard.visible {
    display: flex;
}

.score-card {
    background-color: #2c2c2c;
    border: 2px solid #555;
    border-radius: 12px;
    padding: 8px 14px;
    min-width: 110px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.player-name {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
}

.player-score {
    font-size: 15px;
    font-weight: 600;
    color: white;
    line-height: 1.4;
}

.score-bugs { color: #2ecc71; }
.score-fish { color: #3498db; }

/* ── PLAYER COLORS ─────────────────────────────────────────── */
/* Each player gets a distinct color for their card border and name */
.player-color-0 { border-color: #e67e22; box-shadow: 0 0 8px rgba(230,126,34,0.4); }
.player-color-0 .player-name { color: #e67e22; }

.player-color-1 { border-color: #3daee9; box-shadow: 0 0 8px rgba(61,174,233,0.4); }
.player-color-1 .player-name { color: #3daee9; }

.player-color-2 { border-color: #9b59b6; box-shadow: 0 0 8px rgba(155,89,182,0.4); }
.player-color-2 .player-name { color: #9b59b6; }

.player-color-3 { border-color: #f1c40f; box-shadow: 0 0 8px rgba(241,196,15,0.4); }
.player-color-3 .player-name { color: #f1c40f; }

.player-color-4 { border-color: #e91e8c; box-shadow: 0 0 8px rgba(233,30,140,0.4); }
.player-color-4 .player-name { color: #e91e8c; }

.player-color-5 { border-color: #1abc9c; box-shadow: 0 0 8px rgba(26,188,156,0.4); }
.player-color-5 .player-name { color: #1abc9c; }

/* ── MOBILE ELEMENTS — hidden on desktop ──────────────────── */
#mobileNav, .mobile-drawer, #drawerOverlay { display: none; }

/* ═══════════════════════════════════════════════════════════════
   MOBILE  ≤ 768px
═══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {

    #menu, #coopMenu { display: none !important; }
    body { padding-bottom: 80px; }

    h1 { font-size: 1.6rem; margin: 12px 0 4px; }
    #title { font-size: 1rem; margin-top: 6px; }
    #counter { font-size: 28px; margin-bottom: 8px; }

    #reset {
        display: block;
        width: calc(100% - 32px);
        margin: 12px auto;
        padding: 12px;
        font-size: 16px;
        border-radius: 12px;
    }

    #grid {
        grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
        grid-gap: 6px;
        padding: 0 8px;
        width: 100%;
    }
    .cell {
        width: 100%;
        height: auto;
        aspect-ratio: 1;
        border-radius: 8px;
    }
    .cell img { width: 80%; height: 80%; object-fit: contain; }

    #scoreboard { padding: 0 8px; gap: 6px; }
    .score-card { min-width: 80px; padding: 6px 10px; flex: 1; }
    .player-name { font-size: 11px; max-width: 100%; }
    .player-score { font-size: 13px; }

    /* Bottom nav */
    #mobileNav {
        display: flex;
        position: fixed;
        bottom: 0; left: 0; right: 0;
        height: 64px;
        background-color: #1a1a1a;
        border-top: 1px solid #333;
        z-index: 100;
        align-items: stretch;
    }
    .nav-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        gap: 2px;
        padding: 6px 4px;
        transition: background-color 0.15s ease;
        -webkit-tap-highlight-color: transparent;
    }
    .nav-item:active { background-color: #2a2a2a; }
    .nav-item.active { background-color: rgba(230,126,34,0.15); }
    .nav-icon { font-size: 20px; line-height: 1; }
    .nav-label {
        font-size: 10px;
        color: #aaa;
        font-family: 'Fredoka', sans-serif;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 62px;
        text-align: center;
    }
    .nav-item.active .nav-label { color: #e67e22; }

    /* Overlay */
    #drawerOverlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.55);
        z-index: 150;
    }
    #drawerOverlay.visible { display: block; }

    /* Drawers */
    .mobile-drawer {
        display: block;
        position: fixed;
        bottom: 0; left: 0; right: 0;
        background-color: #242424;
        border-top: 2px solid #444;
        border-radius: 20px 20px 0 0;
        z-index: 200;
        padding: 12px 16px 80px;
        transform: translateY(100%);
        transition: transform 0.28s ease;
        max-height: 75vh;
        overflow-y: auto;
    }
    .mobile-drawer.open { transform: translateY(0); }

    .drawer-handle {
        width: 40px; height: 4px;
        background-color: #555;
        border-radius: 2px;
        margin: 0 auto 14px;
    }
    .drawer-title {
        font-size: 16px; font-weight: 600;
        color: #ccc;
        margin-bottom: 14px;
        text-align: center;
    }

    .drawer-options { display: flex; flex-direction: column; gap: 8px; }
    .drawer-option {
        padding: 14px 16px;
        background-color: #2c2c2c;
        border: 2px solid #444;
        border-radius: 12px;
        font-size: 15px;
        font-family: 'Fredoka', sans-serif;
        cursor: pointer;
        transition: all 0.15s ease;
        text-align: left;
        color: white;
        -webkit-tap-highlight-color: transparent;
    }
    .drawer-option:active { background-color: #3a3a3a; }
    .drawer-option.active {
        border-color: #e67e22;
        background-color: rgba(230,126,34,0.12);
        color: #e67e22;
        font-weight: 600;
    }

    /* Multiplayer drawer */
    .drawer-multi-content { display: flex; flex-direction: column; gap: 12px; }
    #mobileModeSelector { display: flex; gap: 8px; justify-content: center; }
    #mobileModeSelector .mode-btn { flex: 1; margin: 0; padding: 10px; font-size: 14px; }

    .drawer-multi-content input {
        width: 100%;
        padding: 12px 16px;
        border-radius: 10px;
        border: 2px solid #444;
        background-color: #2c2c2c;
        color: white;
        font-family: 'Fredoka', sans-serif;
        font-size: 15px;
    }
    .drawer-multi-content input:focus { outline: none; border-color: #e67e22; }

    .drawer-btn-row { display: flex; gap: 8px; }
    .drawer-btn-row button {
        flex: 1; margin: 0;
        padding: 12px;
        font-size: 15px;
        font-family: 'Fredoka', sans-serif;
        border-radius: 10px;
        border: none;
        background-color: #3a3a3a;
        color: white;
        cursor: pointer;
    }
    .drawer-btn-row button:active { background-color: #e67e22; }

} /* end @media */
