﻿body {
    background-color: #f9f9f9;
    font-family: "Poppins", sans-serif;
    text-align: center;
    margin: 0;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto; /* allows scrolling for entire page */
}

.container {
    max-width: 900px;
    margin: auto;
    padding: 0 10px; /* reduced padding */
    box-sizing: border-box;
    flex: 1 1 auto; /* allow container to shrink/grow */
    display: flex;
    flex-direction: column;
    justify-content: center;
}

h1 {
    margin-bottom: 10px;
}

/* Mode selection UI */
.mode-selection {
    margin-top: 90px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 70vh; /* vertically center content roughly */
}

.mode-selection button {
    font-size: 1.2em;
    padding: 10px 20px;
    margin: 10px;
    cursor: pointer;
    border: none;
    border-radius: 6px;
    background-color: indianred;
    color: white;
    transition: background-color 0.3s ease;
}

.mode-selection button:hover {
    background-color: #8bc34a;
}

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 40px 50px; /* more distance between grids (row | column) */
    justify-items: center;
    align-items: start;
    margin-top: 70px;
    width: 100%;
    max-width: 1200px;
}

/* Player card style */
.card {
    border: 2px solid #ccc;
    border-radius: 12px;
    padding: 15px;
    background-color: white;
    width: 280px; 
    box-sizing: border-box;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease;
}

.card:hover {
    transform: translateY(-4px);
}

.card h2 {
    margin-bottom: 10px;
    font-size: 1.1rem;
}

.grid {
    display: grid;
    grid-template-columns: repeat(5, 45px); /* reduced box size */
    grid-template-rows: repeat(5, 45px);
    justify-content: center;
    gap: 6px; /* spacing between boxes */
    margin: 0 auto;
}

/* Cells */
.cell {
    width: 48px; /* ✅ slightly smaller box */
    height: 48px;
    font-size: 22px;
    background-color: #eee;
    border-radius: 6px;
    cursor: pointer;
    line-height: 48px;
    user-select: none;
    border: 2px solid #ccc;
    transition: background-color 0.3s ease, transform 0.2s ease;
    position: relative;
}

.cell.marked {
    background-color: #8bc34a;
    color: white;
    font-weight: bold;
    pointer-events: none;
}

.cell.revealed {
    background-color: #ffffff;
    border-color: #999;
}

/* Strike through entire row */
.strike-row {
    text-decoration: line-through;
    color: #555;
}

.strike-row.cell {
    background-color: #a5d6a7; /* lighter green */
}

.top {
    font-size: 6.5em;
    margin-top: 50px;
    font-weight: bold;
    color: red;
}

.top span {
    display: inline-block;
    transition: transform 0.2s ease, color 0.2s ease, text-shadow 0.2s ease;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.4); /* added shadow */
}

        /* Individual letter fonts/colors */
.top span:nth-child(1) {
    font-family: "Luckiest Guy", cursive;
    color: #ff4d4d;
}

.top span:nth-child(2) {
    font-family: "Permanent Marker", cursive;
    color: #ff9800;
}

.top span:nth-child(3) {
    font-family: "Creepster", cursive;
    color: #4caf50;
}

.top span:nth-child(4) {
    font-family: "Fredoka One", cursive !important;
    color: #2196f3;
}

.top span:nth-child(5) {
    font-family: "Luckiest Guy", cursive;
    color: #9c27b0;
}

.top span:hover {
    transform: scale(1.2) rotate(-5deg);
    color: #8bc34a;
    text-shadow: 4px 4px 6px rgba(0, 0, 0, 0.6); /* stronger shadow on hover */
}

/* Turn and called number display */
.called-number {
    font-size: 1.2em;
    font-weight: bold;
    margin-top: 10px;
}

.winner {
    margin-top: 20px;
    font-size: 1.5em;
    color: #8bc34a;
}

.hidden {
    display: none;
}

.controls {
    margin-top: 50px;
    display: flex;
    flex-direction: column; /* ensures Play Again is on top */
    align-items: center;
    gap: 10px;
}

.controls button {
    font-size: 1.2em;
    padding: 16px 0; /* equal height, balanced padding */
    margin: 6px;
    width: 210px; /* ✅ fixed width so both buttons match */
    cursor: pointer;
    border: none;
    border-radius: 6px;
    background-color: indianred;
    color: white;
    font-weight: bold; /* make text bold */
    text-align: center;
    transition: background-color 0.3s ease;
}

.controls button:hover {
    background-color: #8bc34a;
}

/* BINGO letters container */
.bingo-letters {
    display: grid;
    grid-template-columns: repeat(5, 48px); /* match smaller box size */
    justify-content: center;
    margin-top: 18px;
    gap: 8px;
}

    /* Fancy Bingo letters */
.bingo-letters span {
    font-weight: bold;
    font-size: 30px;
    user-select: none;
    cursor: default;
    display: inline-block;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    transition: transform 0.3s ease, color 0.3s ease;
}

/* Individual letter fonts/colors */
.bingo-letters span:nth-child(1) { /* B */
    font-family: "Luckiest Guy", cursive;
    color: #ff4d4d;
}

.bingo-letters span:nth-child(2) { /* I */
    font-family: "Permanent Marker", cursive;
    color: #ff9800;
}

.bingo-letters span:nth-child(3) { /* N */
    font-family: "Creepster", cursive;
    color: #4caf50;
}

.bingo-letters span:nth-child(4) { /* G */
    font-family: "Fredoka One", cursive;
    color: #2196f3;
}

        .bingo-letters span:nth-child(5) { /* O */
            font-family: "Luckiest Guy", cursive;
            color: #9c27b0;
        }

        /* Hover effect */
        .bingo-letters span:hover {
            transform: scale(1.2) rotate(-5deg);
            color: #8bc34a;
            text-shadow: 3px 3px 6px rgba(0,0,0,0.5);
        }

        /* Struck letters */
        .bingo-letters span.struck {
            color: black;
            text-decoration: line-through;
        }


/* Optional: hover effect for cells */
.cell:hover:not(.marked):not(.revealed) {
    background-color: #d0f0c0;
    transform: scale(1.05);
}

/* For numbers shown after reveal */
.revealed-number {
    font-size: 1.2em;
    font-weight: bold;
    color: #000;
}

/* Responsive for multiple players */
@media (max-width: 1000px) {
    .cards {
        grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
        gap: 30px;
    }

    .card {
        width: 90vw;
        max-width: 280px;
    }
}

.home-image {
    display: block;
    max-width: 4020px;
    max-height: 400vh; /* limit height to half viewport */
    width: 100%;
    height: auto;
    margin: 0 auto 20px auto;
    border-radius: 12px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    object-fit: contain;
}

/* Mode buttons container */
.mode-buttons {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

footer {
    display: flex;
    justify-content: center;
    gap: 20px;
    padding: 20px 0;
    margin-top: 20px;
    background-color: #fafafa; /* removed background */
    flex-shrink: 0; /* don't shrink */
}

    footer p .copyright {
        font-family: 'Aharoni', monospace; /* example font */
        font-size: 11px; /* slightly larger */
        font-weight: bold; /* optional */
        color: #555; /* optional color */
    }

    footer p {
        display: flex;
        list-style-type: none;
        padding: 0;
        margin: 0;
        gap: 20px;
    }

        footer p a {
            text-decoration: none;
            color: #333;
            font-weight: normal;
            font-size: 9px;
            transition: color 0.3s ease;
        }

            footer p a:hover {
                color: #007bff;
            }

/* ===== Modal Styling ===== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
    transition: opacity 0.3s ease;
}

    .modal.hidden {
        display: none;
    }

.modal-content {
    background: #fff;
    border-radius: 12px;
    padding: 25px 35px;
    width: 420px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    position: relative;
    animation: fadeInUp 0.4s ease;
    text-align: center;
}

.close-modal {
    position: absolute;
    right: 15px;
    top: 12px;
    font-size: 24px;
    cursor: pointer;
    color: #777;
    transition: color 0.2s;
}

    .close-modal:hover {
        color: #000;
    }

.modal-content h2 {
    margin-top: 5px;
    margin-bottom: 20px;
    font-size: 22px;
    font-weight: 700;
}

.modal-body {
    text-align: left;
}

.player-count-label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
}

#player-count {
    width: 100%;
    padding: 8px 10px;
    margin-bottom: 18px;
    border-radius: 6px;
    border: 1px solid #ccc;
    font-size: 15px;
}

.player-inputs {
    margin-bottom: 18px;
}

.player-setup {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    gap: 10px;
}

    .player-setup label {
        font-weight: 600;
        flex-basis: 25%;
        text-align: right;
    }

    .player-setup input {
        flex: 1;
        padding: 6px 8px;
        border-radius: 6px;
        border: 1px solid #ccc;
        font-size: 14px;
    }

    .player-setup select {
        padding: 6px 8px;
        border-radius: 6px;
        border: 1px solid #ccc;
        font-size: 14px;
        min-width: 120px;
    }

.start-btn {
    width: 100%;
    padding: 10px;
    background: #3b82f6;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.2s;
}

    .start-btn:hover {
        background: #2563eb;
    }

@keyframes fadeInUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}
/* ==== PLAYER GRIDS CONTAINER ==== */
#player-boards {
    display: grid;
    gap: 30px; /* increased space between grids */
    justify-content: center;
    align-content: center;
    margin-top: 30px;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}
/* ==== PLAYER GRID ==== */
.player-card {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    padding: 15px;
    text-align: center;
    transition: transform 0.2s ease;
}

    .player-card:hover {
        transform: scale(1.02);
    }

/* ==== PLAYER NAME ==== */
.player-name {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 12px;
}

    .cell:hover {
        background-color: #eaeaea;
        transform: scale(1.05);
    }

/* ==== BINGO ROW ==== */
.bingo-row {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 12px;
    font-weight: bold;
    color: #bbb;
}
/* ==== RESPONSIVE LAYOUT ==== */
@media (min-width: 600px) {
    #player-boards {
        grid-template-columns: repeat(2, 1fr); /* 2 per row */
    }
}

/* Force 2x2 layout for 4 players */
.cards.four-players {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 40px 50px; /* keep existing spacing */
    justify-items: center;
}

#last-number-container.hidden {
    display: none;
}

@media (max-width: 600px) {
    .cards {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 20px;
    }

    .card {
        width: 90vw;
        max-width: 320px;
    }

    .grid {
        grid-template-columns: repeat(5, 42px);
        grid-template-rows: repeat(5, 42px);
        gap: 6px;
    }

    .cell {
        width: 42px;
        height: 42px;
        font-size: 16px;
    }

    .bingo-letters {
        grid-template-columns: repeat(5, 42px);
        gap: 6px;
    }

        .bingo-letters span {
            font-size: 18px;
        }

    #winner-message {
        font-size: 18px;
        padding: 8px 12px;
    }

    .top {
        font-size: 2em;
        text-align: center;
    }

    footer ul {
        flex-direction: column; /* stack links vertically */
        align-items: center;
        gap: 10px;
    }

        footer ul li a {
            font-size: 9px; /* smaller text size */
            line-height: 1.0;
            opacity: 0.85; /* slightly muted for cleaner look */
        }
}

#cards-container {
    display: grid;
    gap: 20px; /* gap between cards */
}

    /* For 2 players */
    #cards-container.two-players {
        grid-template-columns: repeat(2, 1fr);
    }

    /* For 3 players */
    #cards-container.three-players {
        grid-template-columns: repeat(3, 1fr);
    }

    /* For 4 players */
    #cards-container.four-players {
        grid-template-columns: repeat(2, 1fr); /* 2 columns */
        grid-auto-rows: auto; /* let rows adjust */
    }


/* Mobile responsiveness */
@media (max-width: 600px) {
    .cards.two-players,
    .cards.three-players,
    .cards.four-players {
        grid-template-columns: repeat(2, 1fr);
    }

    .card {
        width: 100%;
        max-width: none;
    }

    .grid {
        grid-template-columns: repeat(5, 40px);
        grid-template-rows: repeat(5, 40px);
        gap: 6px;
    }

    .cell {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
}
.card input[type="text"] {
    font-size: 14px;
    padding: 4px 6px;
    border-radius: 6px;
    border: 1px solid #ccc;
    text-align: center;
}

.card select {
    font-size: 14px;
    padding: 4px 6px;
    border-radius: 6px;
    border: 1px solid #ccc;
}

.card > .grid {
    margin-top: 10px; /* adjust value as needed */
}
.card input[type="text"] {
    font-weight: bold; /* make name bold */
}


/* Winner overlay for progressive Bingo */
.winner-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5em;
    font-weight: bold;
    color: indianred;
    text-align: center;
    border-radius: 12px;
    flex-direction: column;
    z-index: 10;
    animation: sparkle 1s infinite;
}

@keyframes sparkle {
    0%, 100% {
        text-shadow: 0 0 2px gold, 0 0 5px gold, 0 0 8px orange;
    }

    50% {
        text-shadow: 0 0 5px gold, 0 0 10px gold, 0 0 15px orange;
    }
}
/* 🎉 Emoji Confetti Styles */
.confetti-emoji {
    position: absolute;
    font-size: 1.5rem;
    animation: fall 1.2s ease-out forwards;
    opacity: 0.9;
    pointer-events: none;
    z-index: 999;
}

@keyframes fall {
    0% {
        transform: translateY(0) scale(1) rotate(0deg);
        opacity: 1;
    }

    100% {
        transform: translateY(200px) scale(0.6) rotate(360deg);
        opacity: 0;
    }
}
/* ===== MOBILE RESPONSIVENESS ===== */
@media (max-width: 600px) {
    /* Container adjustments */
    body {
        padding: 10px;
    }

    /* Cards container for small screens */
    #cards-container,
    .cards,
    #player-boards {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
        gap: 8px; /* tighter spacing between player cards */
        justify-items: center;
        align-items: start;
    }

    /* Card adjustments */
    .card,
    .player-card {
        width: 105%;
        max-width: 180px;
        padding: 8px 6px; /* slightly reduced padding */
    }

    /* Grid inside cards */
    .grid {
        grid-template-columns: repeat(5, 32px);
        grid-template-rows: repeat(5, 32px);
        gap: 0px; /* reduced inner cell gap */
    }

    /* Individual cells */
    .cell {
        width: 32px;
        height: 32px;
        font-size: 14px;
        line-height: 32px;
    }

    /* Bingo letters */
    .bingo-letters {
        grid-template-columns: repeat(5, 32px);
        gap: 2px; /* align neatly with grid gap */
        margin-top: 4px;
    }

        .bingo-letters span {
            font-size: 14px;
        }

    /* Mode selection and top text */
    .mode-selection {
        min-height: auto;
        margin-top: 20px;
    }

    .top {
        font-size: 2em;
    }

    footer p .copyright {
        font-size: 9px; /* slightly larger */
        color: #555; /* optional color */
    }

    footer p {
        flex-direction: column;
        list-style-type: none;
        padding: 0;
        margin: 0;
        gap: 10px;
    }

        footer p a {
            text-decoration: none;
            color: #333;
            font-weight: normal;
            font-size: 8px;
            transition: color 0.3s ease;
        }

    

    /* Winner message */
    #winner-message {
        font-size: 4px;
        padding: 2px 2px;
    }

    /* Modal adjustments */
    .modal-content {
        width: 90%;
        padding: 20px;
    }

    .start-btn {
        font-size: 14px;
        padding: 8px;
    }

    /* ===== BUTTON CLEANUP ===== */
    .controls {
        margin-top: 15px; /* less gap above buttons */
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 10px; /* consistent spacing between buttons */
    }

        .controls button {
            font-size: 14px;
            padding: 6px 14px;
            min-width: 140px;
            border-radius: 6px;
            margin: 0;
            background-color: indianred;
            color: white;
            transition: background-color 0.3s ease;
        }

            .controls button:hover {
                background-color: #8bc34a;
            }
}

/* Extra small devices (phones < 400px) */
@media (max-width: 400px) {
    #cards-container,
    .cards,
    #player-boards {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 15px; /* tighter gap for smaller phones */
    }

    .card,
    .player-card {
        max-width: 200px;
        padding:10px 6px;
    }

    .grid {
        grid-template-columns: repeat(5, 28px);
        grid-template-rows: repeat(5, 28px);
        gap:4px;
    }

    .cell {
        width: 30px;
        height: 32px;
        font-size: 18px;
        line-height: 28px;
    }

    .bingo-letters {
        grid-template-columns: repeat(5, 28px);
        gap: 3px;
        margin-top: 10px;
    }

        .bingo-letters span {
            font-size: 19px;
        }

    .top {
        font-size: 4.0em;
    }

    /* Compact button layout for very small screens */
    .controls {
        margin-top: 60px;
        gap: 8px;
    }

        .controls button {
            font-size: 14px;
            padding: 10px 10px;
            min-width: 120px;
        }

    footer p .copyright {
        font-size: 11px; /* slightly larger */
        color: #555; /* optional color */
    }

    footer p {
        flex-direction:column;
        list-style-type: none;
        padding: 0;
        margin: 0;
        gap: 13px;
        margin-top: 35px;
    }

        footer p a {
            text-decoration: none;
            color: #333;
            font-weight: normal;
            font-size: 10px;
            transition: color 0.3s ease;
        }
}

/* ===== 3-PLAYER FIX ===== */
#cards-container.three-players {
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* 2 equal columns */
    grid-auto-rows: auto;
    justify-content: center; /* center the whole grid container */
    gap: 15px; /* consistent spacing */
}

    /* Center the 3rd child to span both columns */
    #cards-container.three-players > :nth-child(3) {
        grid-column: 1 / span 2; /* span both columns */
        justify-self: center; /* center the 3rd grid horizontally */
    }

/* === Center Start Button in Modal === */
#player-setup-modal .modal-body {
    display: flex;
    flex-direction: column;
    align-items: center; /* center all elements inside */
    text-align: center; /* align text nicely */
    gap: 4px; /* even spacing */
}

/* Make sure the label and select stay centered but full width */
#player-setup-modal label,
#player-setup-modal select {
    width: 200%;
    max-width: 150px; /* prevent stretching too wide */
    text-align: left; /* keep label readable */
}

/* Center the Start Game button perfectly */
#player-setup-modal .start-btn {
    display: block;
    margin: 1px auto 0 auto; /* centers horizontally */
    width: 80%; /* consistent width */
    max-width: 200px; /* avoid being too wide */
}

/* ===== Home Screen Buttons (Robot / Multiplayer) ===== */
.mode-buttons {
    display: flex;
    flex-direction: column; /* stack buttons vertically */
    justify-content: center;
    align-items: center;
    gap: 4px; /* space between buttons */
    margin-top: 10px;
}

/* Make buttons uniform and centered */
.mode-selection button {
    font-size: 1.4em;
    font-weight: bold;
    padding: 16px 16px;
    width: 220px; /* keep buttons same width */
    text-align: center;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    background-color: indianred;
    color: white;
    transition: background-color 0.3s ease;
}
    /* On hover */
    .mode-selection button:hover {
        background-color: #8bc34a;
    }


/* ==== Make control buttons bold ==== */
.controls button {
    font-weight: bold;
    letter-spacing: 0.5px;
}

.cell.marked {
    background-color: #8bc34a;
    color: white;
    font-weight: bold;
    pointer-events: none;
}
