/* General Container */
.numbers-game-container {
    border: 1px solid #ccc;
    padding: 15px;
    margin-bottom: 20px;
    background-color: #f9f9f9;
    position: relative;
}

/* Setup Area (Category + Selected List) */
.ng-setup {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
    gap: 20px;
}
.ng-category-selector {
    flex-basis: 50%;
    min-width: 200px;
}
.ng-category-selector label {
    margin-right: 10px;
    font-weight: bold;
}
#ng-category-select {
    padding: 5px;
    width: 100%;
    max-width: 250px;
}
#ng-selected-numbers-area {
    flex-basis: 40%;
    min-width: 180px;
    border: 1px solid #e0e0e0;
    padding: 10px;
    background-color: #fff;
    max-height: 150px;
    overflow-y: auto;
}
#ng-selected-numbers-area h4 {
    margin-top: 0;
    margin-bottom: 8px;
    font-size: 0.9em;
    color: #555;
}
#ng-selected-list {
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 0.9em;
}
#ng-selected-list li {
    padding: 2px 0;
    border-bottom: 1px dotted #eee;
}
#ng-selected-list li:last-child { border-bottom: none; }
#ng-selected-list .ng-list-placeholder { font-style: italic; color: #888; }
#ng-selected-list .click-state-1::before { content: "\25CF"; color: orange; margin-right: 5px; font-size: 0.8em; }
#ng-selected-list .click-state-2::before { content: "\2713"; color: green; margin-right: 5px; font-weight: bold; }

/* Grid */
.ng-grid {
    display: grid;
    /* Default columns, overridden by media queries */
    grid-template-columns: repeat(var(--grid-columns, 10), 1fr);
    gap: 5px; /* Keep gap relatively small on mobile */
    margin-bottom: 20px;
    max-width: 100%;
}
.ng-select-prompt {
    grid-column: 1 / -1;
    text-align: center;
    padding: 20px;
    color: #666;
    font-style: italic;
}

/* Grid Number Cells */
.ng-number-cell {
    display: flex; /* Crucial for centering text */
    justify-content: center; /* Center text horizontally */
    align-items: center; /* Center text vertically */
    aspect-ratio: 1 / 1; /* Keep cells square */
    padding: 2px; /* Reduce padding slightly to give text more room */
    border: 1px solid #b4b9be;
    background-color: #e0e0e0;
    color: #333;
    font-weight: bold;
    /* Base font size, overridden in media queries */
    font-size: 1.1em; /* Start slightly larger */
    cursor: pointer;
    transition: background-color 0.3s ease, color 0.3s ease, transform 0.1s ease;
    text-align: center;
    /* min-height: 35px; removed, aspect-ratio handles height */
    position: relative;
    overflow: hidden; /* Prevent text overflow issues */
    line-height: 1.1; /* Adjust line height for better vertical centering if needed */
}
.ng-number-cell:hover:not(:disabled) { background-color: #d0d0d0; }
.ng-number-cell:active:not(:disabled) { transform: scale(0.95); }
.ng-number-cell.clicked-once { background-color: #ffa500; color: #fff; border-color: #cc8400; }
.ng-number-cell.clicked-twice { background-color: #28a745; color: #fff; border-color: #1e7e34; cursor: not-allowed; opacity: 0.8; }
.ng-number-cell.disabled:not(.clicked-twice) { background-color: #cccccc; color: #777; cursor: not-allowed; opacity: 0.7; }

/* Spinner for loading */
.ng-number-cell .spinner { border: 3px solid #f3f3f3; border-top: 3px solid #3498db; border-radius: 50%; width: 16px; height: 16px; animation: spin 1s linear infinite; display: inline-block; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* Modal Popup Styles */
.ng-modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.6); z-index: 1000; display: none; }
.ng-modal { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); background-color: #fff; padding: 25px; border-radius: 5px; box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3); z-index: 1001; display: none; max-width: 90%; width: 500px; max-height: 80vh; overflow-y: auto; }
.ng-modal-close { position: absolute; top: 10px; right: 15px; background: none; border: none; font-size: 24px; font-weight: bold; color: #888; cursor: pointer; padding: 0; line-height: 1; }
.ng-modal-close:hover { color: #000; }

/* Modal Content Styling */
#ng-question-display h3 { margin-top: 0; color: #333; margin-bottom: 15px; }
#ng-question-text { margin-bottom: 15px; line-height: 1.6; }

/* Answer Section Styling */
#ng-answer-text { margin-top: 15px; padding-top: 10px; border-top: 1px solid #eee; display: none; }
#ng-reveal-answer-btn { padding: 8px 15px; cursor: pointer; margin-bottom: 10px; display: none; background-color: #0073aa; color: white; border: 1px solid #0073aa; border-radius: 3px; transition: background-color 0.2s ease; }
#ng-reveal-answer-btn:hover { background-color: #005a87; }
#ng-answer-content { display: none; }
#ng-answer-content h4 { margin: 0 0 8px 0; color: #4CAF50; font-size: 1.1em; }
#ng-answer-content p { margin: 0; line-height: 1.6; }


/* --- === MOBILE FRIENDLINESS ADJUSTMENTS === --- */

/* Medium Screens (Tablets / Large Phones) */
@media (max-width: 768px) {
    .ng-grid {
        /* Reduce columns significantly for tablets */
        --grid-columns: 5; /* <--- Fewer columns */
        gap: 4px; /* Slightly smaller gap */
    }
    .ng-number-cell {
        /* Maintain or slightly increase font size */
        font-size: 1.2em; /* <--- Increased font size */
    }
    .ng-modal {
        width: 85%;
    }
     .ng-setup {
        flex-direction: column;
        align-items: stretch;
    }
    .ng-category-selector, #ng-selected-numbers-area {
        flex-basis: auto;
        width: 100%;
    }
    #ng-selected-numbers-area {
         max-height: 100px;
    }
}

/* Small Screens (Typical Phones) */
@media (max-width: 480px) {
    .ng-grid {
        /* Further reduce columns for small phones */
        --grid-columns: 4; /* <--- Even fewer columns */
        gap: 3px; /* Smallest gap */
    }
     .ng-number-cell {
        /* Make font larger relative to the cell size */
        font-size: 1.3em; /* <--- Increased font size further */
        font-weight: 600; /* Slightly less bold if needed */
    }
    .ng-modal {
        width: 90%;
        padding: 15px;
    }
    .ng-modal-close {
        top: 5px;
        right: 10px;
        font-size: 20px;
    }
    #ng-question-display h3 {
         font-size: 1.2em;
    }
     #ng-reveal-answer-btn {
        padding: 6px 12px;
     }
     #ng-selected-numbers-area h4 {
        font-size: 0.85em;
     }
     #ng-selected-list {
        font-size: 0.85em;
     }
}

/* Optional: Very Small Screens (if needed) */
@media (max-width: 360px) {
    .ng-grid {
        /* Potentially reduce columns even more if 4 is still too small */
        /* --grid-columns: 3; */ /* Uncomment if needed */
        gap: 2px;
    }
     .ng-number-cell {
        font-size: 1.2em; /* May need slight reduction if columns decrease further */
     }
}