

.bingo-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 10px;
    font-family: Arial, sans-serif;
    width: 100%;
    display: flex;
    flex-direction: column;
    height: auto; /* Auto height instead of fixed viewport height */
    min-height: 0; /* Allow container to shrink */
    box-sizing: border-box;
}

.bingo-title {
    text-align: center;
    font-size: clamp(18px, 4vh, 28px); /* Responsive font size */
    margin-bottom: 10px;
    width: 100%;
    flex-shrink: 0;
}

.bingo-board {
    border: 2px solid #333;
    border-radius: 5px;
    overflow: hidden;
    margin-bottom: 10px;
    background-color: #fff;
    width: 100%;
    display: grid;
    max-width: 100%;
    min-height: 0; /* Allow flex item to shrink below content size */
    aspect-ratio: 1 / 1; /* Make the board itself square */
    align-self: center; /* Center the board horizontally */
}


.bingo-board[data-size="3"] {
    grid-template-rows: repeat(3, 1fr);
    grid-template-columns: repeat(3, 1fr);
    aspect-ratio: 1 / 1;
}

.bingo-board[data-size="4"] {
    grid-template-rows: repeat(4, 1fr);
    grid-template-columns: repeat(4, 1fr);
    aspect-ratio: 1 / 1;
}

.bingo-board[data-size="5"] {
    grid-template-rows: repeat(5, 1fr);
    grid-template-columns: repeat(5, 1fr);
    aspect-ratio: 1 / 1;
}

.bingo-row {
    display: contents;
}

.bingo-cell {
    width: 100%;
    aspect-ratio: 1 / 1; /* Ensure cell is square */
    position: relative;
    border-right: 1px solid #ccc;
    border-bottom: 1px solid #ccc;
    text-align: center;
    cursor: pointer;
    transition: background-color 0.3s;
    box-sizing: border-box;
    overflow: hidden; /* Prevent text overflow */
}

/* We don't need the ::before pseudo-element anymore since we're using aspect-ratio */

.bingo-cell-content {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: min(5px, 1.5vmin);
    font-size: clamp(10px, 2vmin, 14px);
    line-height: 1.2;
    word-break: break-word;
    hyphens: auto;
}

.bingo-cell:last-child {
    border-right: none;
}

.bingo-board[data-size="3"] .bingo-cell:nth-child(3n) {
    border-right: none;
}

.bingo-board[data-size="3"] .bingo-cell:nth-child(n+7) {
    border-bottom: none;
}

.bingo-board[data-size="4"] .bingo-cell:nth-child(4n) {
    border-right: none;
}

.bingo-board[data-size="4"] .bingo-cell:nth-child(n+13) {
    border-bottom: none;
}

.bingo-board[data-size="5"] .bingo-cell:nth-child(5n) {
    border-right: none;
}

.bingo-board[data-size="5"] .bingo-cell:nth-child(n+21) {
    border-bottom: none;
}

.bingo-cell.selected {
    background-color: #ffeb3b;
}

.bingo-cell.winning-cell {
    background-color: #4CAF50 !important;
    color: white !important;
    border: 2px solid #2E7D32 !important;
}



.bingo-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-top: 10px;
    width: 100%;
    text-align: center;
    flex-wrap: wrap;
    flex-shrink: 0; /* Prevent controls from shrinking */
}

.bingo-size-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 0; /* Remove bottom margin to align with button */
    font-size: clamp(12px, 2vmin, 14px); /* Responsive font size */
}

.bingo-select {
    padding: 6px;
    border-radius: 4px;
    border: 1px solid #ccc;
    font-size: clamp(12px, 2vmin, 14px); /* Responsive font size */
    cursor: pointer;
}

.bingo-button {
    padding: 8px 16px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: clamp(12px, 2vmin, 14px); /* Responsive font size */
    transition: background-color 0.3s;
}

.bingo-button:hover {
    background-color: #45a049;
}


/* Media queries for different screen sizes */
@media (max-height: 600px) {
    .bingo-container {
        padding: 5px;
    }

    .bingo-title {
        margin-bottom: 5px;
        font-size: clamp(16px, 3vh, 22px);
    }

    .bingo-board {
        margin-bottom: 5px;
    }

    .bingo-controls {
        margin-top: 5px;
    }
}

@media (max-width: 600px) {
    .bingo-cell-content {
        font-size: clamp(10px, 2vmin, 13px); /* Adjusted font size for mobile */
        padding: min(4px, 1.5vmin);
    }

    /* Specific adjustments for 5x5 board on mobile */
    .bingo-board[data-size="5"] .bingo-cell-content {
        font-size: clamp(9px, 1.8vmin, 12px);
        line-height: 1.1;
    }

    /* Keep controls on same row on mobile */
    .bingo-controls {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        gap: 10px;
        padding: 0 5px;
    }

    .bingo-button {
        flex: 1;
        max-width: none;
        padding: 8px 10px;
    }

    .bingo-size-selector {
        flex-direction: row;
        margin-bottom: 0;
        flex: 1;
        white-space: nowrap;
    }
}

/* For very small screens */
@media (max-height: 500px) and (max-width: 500px) {
    .bingo-container {
        padding: 2px;
    }

    .bingo-title {
        font-size: clamp(14px, 2.5vh, 18px);
        margin-bottom: 2px;
    }

    /* Adjusted size for 5x5 on very small screens */
    .bingo-board[data-size="5"] .bingo-cell-content {
        font-size: clamp(8px, 1.6vmin, 11px);
        padding: 1px;
        line-height: 1.1;
    }
}

/* Specific adjustments for different board sizes */
@media (max-width: 480px) {
    /* 3x3 board can have slightly larger text */
    .bingo-board[data-size="3"] .bingo-cell-content {
        font-size: clamp(11px, 2.2vmin, 14px);
        padding: min(5px, 1.8vmin);
    }

    /* 4x4 board needs slightly smaller text */
    .bingo-board[data-size="4"] .bingo-cell-content {
        font-size: clamp(10px, 2vmin, 13px);
        padding: min(4px, 1.6vmin);
    }

    /* 5x5 board needs smaller text but still readable */
    .bingo-board[data-size="5"] .bingo-cell-content {
        font-size: clamp(8px, 1.7vmin, 11px);
        padding: min(2px, 1.2vmin);
        line-height: 1.1;
    }

    /* Keep controls on same row even on small screens */
    .bingo-controls {
        flex-direction: row;
        justify-content: space-between;
    }
}
