/* ==================== Base Styles ==================== */

body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #ffffff; /* Light background */
    color: #000000; /* Dark text */
}

h2 {
    text-align: center;
    margin: 20px 0 10px 0;
}

/* ==================== Bingo Caller Game Styles ==================== */

/* Top Display Container */
#caller-top-display {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    background-color: #f0f0f0;
    padding: 10px;
}

/* Adjusted called-number-display */
#caller-called-number-display {
    flex: 1;
    min-width: 300px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 10px;
}

#caller-called-number {
    font-size: 10em; /* Increased from 7em to 10em */
    color: #333333;
    font-weight: bold; /* Added bold for better visibility */
}

#caller-called-phrase {
    font-size: 2em; /* Increased from 1.5em to 2em */
    color: #555555;
    margin-top: 15px; /* Slightly increased spacing */
    text-align: center;
    padding: 0 10px;
}

#caller-last-five-called {
    margin-top: 10px;
    text-align: center;
}

#caller-last-five-called h3 {
    margin-bottom: 5px;
    font-size: 1em;
}

#caller-last-called-numbers {
    font-size: 1em;
    color: #333333;
}

/* Winning Numbers Styles */
#caller-winning-numbers {
    flex: 1;
    min-width: 300px;
    padding: 10px;
    background-color: #f0f0f0;
}

#caller-winning-numbers h3 {
    margin-bottom: 10px;
    font-size: 1.5em;
    text-align: center;
}

#caller-winning-numbers div {
    margin: 5px 0;
    font-size: 1em;
    text-align: center;
}

#caller-winning-numbers strong {
    display: inline-block;
    width: 120px;
    text-align: right;
    margin-right: 5px;
}

#caller-controls {
    display: flex;
    justify-content: center;
    margin: 10px 0;
    flex-wrap: wrap;
}

#caller-controls button {
    font-size: 1.2em;
    padding: 10px 20px;
    margin: 5px;
    background-color: #e0e0e0;
    color: #000000;
    border: none;
    cursor: pointer;
}

#caller-controls button:hover {
    background-color: #cccccc;
}

#caller-numbers-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    padding: 10px;
}

.caller-number-cell {
    width: calc(10% - 10px); /* 10 numbers per row */
    height: 40px;
    margin: 5px;
    text-align: center;
    line-height: 40px;
    font-size: 1em;
    color: #000000;
    border: 1px solid #cccccc;
    background-color: #ffffff;
    cursor: default;
}

.caller-number-cell.called {
    color: red;
    background-color: #ffe6e6;
}

#caller-winner-text {
    position: fixed;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 3em;
    color: gold;
    text-shadow: 2px 2px 5px #000000;
    text-align: center;
    padding: 0 10px;
    z-index: 1001;
}

#caller-confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 1000;
}

.caller-confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    background-color: red;
    opacity: 0.7;
    animation: fall linear infinite;
}

@keyframes fall {
    0% {
        transform: translateY(-10vh) rotate(0deg);
    }
    100% {
        transform: translateY(110vh) rotate(360deg);
    }
}

/* Caller Modal Styles */

.caller-modal {
    display: none; /* Hidden by default */
    position: fixed;
    z-index: 1002; /* Sit on top of confetti */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: hidden; /* Disable scroll */
    background-color: rgba(0, 0, 0, 0.7); /* Black background with opacity */
}

.caller-modal-content {
    background-color: #fefefe;
    margin: 10% auto; /* 10% from the top and centered */
    padding: 20px;
    border: 1px solid #888888;
    width: 90%; /* Adjusted for mobile screens */
    max-width: 400px;
    position: relative;
}

.caller-close-button {
    color: #aaaaaa;
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.caller-close-button:hover,
.caller-close-button:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}

#caller-player-numbers-input {
    width: 100%;
    height: 100px;
    margin-top: 10px;
    font-size: 1em;
}

#caller-submit-numbers-button {
    margin-top: 10px;
    padding: 10px 20px;
    font-size: 1em;
    width: 100%;
    background-color: #e0e0e0;
    color: #000000;
    border: none;
    cursor: pointer;
}

#caller-submit-numbers-button:hover {
    background-color: #cccccc;
}

/* ==================== Question Mark Container Styles ==================== */

#caller-question-mark-container {
    position: fixed; /* Position it relative to the viewport */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* Allow clicks to pass through */
    z-index: 1003; /* Ensure it's above the modal's z-index (assuming modal is 1002) */
}

/* ==================== Existing Question Mark Styles ==================== */

.caller-question-mark {
    position: absolute;
    font-size: 20px;
    animation: float 5s forwards;
}

@keyframes float {
    0% {
        opacity: 1;
        transform: translateY(0) rotate(0deg);
    }
    100% {
        opacity: 0;
        transform: translateY(+100px) rotate(360deg);
    }
}

/* ==================== Bingo Card Generator Styles ==================== */

#card-generator-section {
    padding: 20px;
    background-color: #fafafa;
}

#card-generator-section h2 {
    margin-bottom: 10px;
}

#card-generator-controls {
    text-align: center;
    margin-bottom: 20px;
}

#card-generator-controls input {
    padding: 10px;
    font-size: 16px;
    width: 200px;
    margin-right: 10px;
}

#card-generator-controls button {
    padding: 10px 20px;
    font-size: 16px;
    cursor: pointer;
    background-color: #e0e0e0;
    border: none;
    margin-right: 5px; /* Added margin for spacing */
}

#card-generator-controls button:hover {
    background-color: #cccccc;
}

#game-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    grid-gap: 10px;
    max-width: 210mm; /* A4 width */
    margin: 0 auto;
}

.player-card {
    border: 1px solid #000;
    padding: 10px;
    background-color: #ffffff;
}

.player-card h3 {
    text-align: center;
    margin-bottom: 10px;
}

.game-number {
    font-size: 12px;
    margin: 2px 0;
    text-align: center;
}

.bingo-card {
    width: 100%;
    margin-bottom: 5px;
    border: 1px solid #000;
    page-break-inside: avoid;
}

.bingo-grid {
    width: 100%;
    border-collapse: collapse;
}

.bingo-grid td {
    width: 11%;
    height: 15px;
    border: 1px solid #000;
    text-align: center;
    font-size: 10px;
    padding: 1px;
}

.blank {
    background-color: #f0f0f0;
}

/* ==================== Responsive Styles ==================== */

@media screen and (max-width: 800px) {
    /* Caller Game Responsive */
    #caller-top-display {
        flex-direction: column;
    }

    #caller-called-number-display,
    #caller-winning-numbers {
        width: 100%;
        min-width: auto;
    }

    #caller-called-number {
        font-size: 8em; /* Adjusted for medium screens */
    }

    #caller-called-phrase {
        font-size: 1.8em;
    }

    /* Card Generator Responsive */
    #game-cards {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    }
}

@media screen and (max-width: 600px) {
    /* Caller Game Responsive */
    #caller-called-number {
        font-size: 6em; /* Adjusted for smaller screens */
    }

    #caller-called-phrase {
        font-size: 1.5em;
    }

    #caller-controls button {
        font-size: 1em;
        padding: 8px 16px;
    }

    .caller-number-cell {
        width: calc(20% - 10px); /* 5 numbers per row */
    }

    /* Card Generator Responsive */
    #game-cards {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }
}

@media screen and (max-width: 400px) {
    /* Caller Game Responsive */
    #caller-called-number {
        font-size: 5em; /* Adjusted for very small screens */
    }

    #caller-called-phrase {
        font-size: 1.2em;
    }

    .caller-number-cell {
        width: calc(33.33% - 10px); /* 3 numbers per row */
    }

    /* Card Generator Responsive */
    #game-cards {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    }
}

/* ==================== Dark Mode Styles ==================== */

@media (prefers-color-scheme: dark) {
    body {
        background-color: #121212; /* Dark background */
        color: #ffffff; /* Light text */
    }

    /* Caller Game Dark Mode */
    #caller-top-display,
    #caller-winning-numbers {
        background-color: #1e1e1e;
    }

    #caller-called-number {
        color: #ffffff;
    }

    #caller-called-phrase {
        color: #cccccc;
    }

    #caller-last-called-numbers {
        color: #ffffff;
    }

    #caller-controls button {
        background-color: #333333;
        color: #ffffff;
    }

    #caller-controls button:hover {
        background-color: #444444;
    }

    #caller-numbers-grid {
        background-color: #1e1e1e;
    }

    .caller-number-cell {
        color: #ffffff;
        border: 1px solid #444444;
        background-color: #2e2e2e;
    }

    .caller-number-cell.called {
        color: #ff6666;
        background-color: #4e1e1e;
    }

    #caller-winner-text {
        color: gold;
        text-shadow: 2px 2px 5px #ffffff;
    }

    /* Modal Styles for Dark Mode */
    .caller-modal-content {
        background-color: #1e1e1e;
        color: #ffffff;
        border: 1px solid #888888;
    }

    .caller-close-button {
        color: #cccccc;
    }

    .caller-close-button:hover,
    .caller-close-button:focus {
        color: #ffffff;
    }

    #caller-player-numbers-input {
        background-color: #2e2e2e;
        color: #ffffff;
        border: 1px solid #444444;
    }

    #caller-submit-numbers-button {
        background-color: #333333;
        color: #ffffff;
        border: none;
    }

    #caller-submit-numbers-button:hover {
        background-color: #444444;
    }

    /* Card Generator Dark Mode */
    #card-generator-section {
        background-color: #1e1e1e;
        color: #ffffff;
    }

    #card-generator-controls button,
    #card-generator-controls input {
        background-color: #333333;
        color: #ffffff;
        border: 1px solid #ffffff;
    }

    .player-card {
        border-color: #ffffff;
        background-color: #2e2e2e;
    }

    .bingo-card {
        border-color: #ffffff;
        background-color: #2e2e2e;
    }

    .bingo-grid td {
        border-color: #ffffff;
        background-color: #3e3e3e;
        color: #ffffff;
    }

    .blank {
        background-color: #2e2e2e;
    }
}

/* ==================== Print Styles ==================== */

@media print {
    body * {
        visibility: hidden; /* Hide everything */
    }

    #game-cards, #game-cards * {
        visibility: visible; /* Show bingo cards */
    }

    #game-cards {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
    }

    /* Arrange bingo cards to fit 4 players per A4 page */
    .player-card {
        page-break-inside: avoid;
        margin-bottom: 20px;
    }

    /* Optionally, set size and layout */
    @page {
        size: A4;
        margin: 10mm;
    }
}