/* Universal Box Sizing */
* {
    box-sizing: border-box;
    user-select: none;
}

html, body {
    width: 100%;
    margin: 0;
    padding: 0;
    user-select: none; /* Prevent text selection */
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    min-height: 100vh;
    margin: 0;
    background-color: #f0f0f0;
    display: flex;  
    flex-direction: column;   
    align-items: center; 
}

.header-controls {
    margin-top: 20px;
}

.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    border: 2px solid #333;
    background-color: #c0c0c0;
    padding: 10px;
    border-radius: 5px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    position: relative; /* Added for positioning of absolute children */
    margin: 40px auto 20px auto;
    
}

.difficulty-selector {
    margin-bottom: 10px;
}

.difficulty-selector button {
    padding: 5px 10px;
    margin: 0 5px;
    cursor: pointer;
    border: 2px outset #c0c0c0;
    border-radius: 3px;
    background-color: #bdbdbd;
    color : #000;
}

.difficulty-selector button:active {
    border-style: inset;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 5px;
    background-color: #bdbdbd;
    border: 2px solid #808080;
    margin-bottom: 10px;
}

.timer-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.timer-box {
    background-color: #333;
    color: #ff0000;
    font-family: "DSEG7 Modern", "DSEG7", "Segment7", "Digital-7", "Digital", sans-serif;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 1.5em;
    letter-spacing: 2px;
    border: 2px inset #808080;
    min-width: 70px;
    text-align: center;
    font-weight: 500;
}

#reset-button {
    font-size: 1.5em; /* Make smiley bigger */
    padding: 0 10px;
    cursor: pointer;
    border: 2px outset #c0c0c0;
    background-color: #bdbdbd;
}

#reset-button:active {
    border-style: inset;
}

.toggle-container {
    margin-top: 10px;
    margin-bottom: 10px;
}

#toggle-mode-button {
    position: relative;
    width: 100px; /* Adjust width as needed */
    height: 40px; /* Adjust height as needed */
    background-color: #bdbdbd;
    border: 2px solid #808080;
    border-radius: 20px; /* Half of height for pill shape */
    cursor: pointer;
    overflow: hidden; /* Hide overflow for slider */
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 0 5px;
}

#toggle-mode-button .mode-icon {
    font-size: 1.5em;
    transition: opacity 0.3s ease;
    z-index: 1; /* Ensure icons are above slider */
}

#toggle-mode-button .bomb-icon {
    opacity: 1; /* Default active */
}

#toggle-mode-button .flag-icon {
    opacity: 0.5; /* Default inactive */
}

#toggle-mode-button .slider {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 46px; /* Half of button width - 2*border */
    height: 32px; /* Button height - 2*border */
    background-color: #e0e0e0;
    border: 1px solid #a0a0a0;
    border-radius: 16px; /* Half of slider height */
    transition: transform 0.3s ease;
    z-index: 0;
}

#toggle-mode-button.flag-mode .slider {
    transform: translateX(46px); /* Move to the right */
}

#toggle-mode-button.flag-mode .bomb-icon {
    opacity: 0.5;
}

#toggle-mode-button.flag-mode .flag-icon {
    opacity: 1;
}



#game-board {
    display: grid;
    border: 3px solid #808080;
}

.cell {
    width: 30px;
    height: 30px;
    border: 1px solid #808080;
    background-color: #bdbdbd;
    text-align: center;
    line-height: 30px;
    font-weight: bold;
    cursor: pointer;
    font-size: 1.2em;
    user-select: none; /* Prevent text selection */
}

.cell:active:not(.revealed) {
    background-color: #a0a0a0; /* Darker shade when pressed */
    border-style: inset;
}

.cell.revealed {
    background-color: #e0e0e0;
    border: 1px solid #a0a0a0;
    cursor: default;
}

.cell.mine {
    background-color: #ff0000;
}


/* Number Colors */
.c1 { color: #0000ff; }
.c2 { color: #008000; }
.c3 { color: #ff0000; }
.c4 { color: #000080; }
.c5 { color: #800000; }
.c6 { color: #008080; }
.c7 { color: #000000; }
.c8 { color: #808080; }

/* Styles for Game Stats */
.game-stats-container {
    background-color: #c0c0c0;
    border: 2px solid #333;
    padding: 15px;
    margin-top: 20px;
    margin-bottom: 20px;
    width: 60%;
    border-radius: 5px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    text-align: center;
}

.game-stats-container h2 {
    margin-top: 0;
    color: #333;
    border-bottom: 1px solid #888;
    padding-bottom: 10px;
    margin-bottom: 15px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 15px;
}

.stat-item {
    background-color: #bdbdbd;
    border: 1px solid #808080;
    padding: 10px;
    border-radius: 3px;
}

.stat-item h3 {
    margin-top: 0;
    margin-bottom: 5px;
    color: #555;
    font-size: 0.9em;
}

.stat-item p {
    margin: 0;
    font-size: 1.2em;
    font-weight: bold;
    color: #333;
}

@media (max-width: 600px) {
    .game-stats-container {
        width: 95%;
    }
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

footer {
    text-align: center;
    width: 100%;
    font-size: 0.8em;
    color: #888;
    padding: 10px 0; /* Add some padding */
}

footer a {
    color: #888; /* Dark grey color for links */
    text-decoration: none; /* Remove underline */
}

footer a:hover {
    text-decoration: underline; /* Add underline on hover for better UX */
}

#help-button {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 1px solid #888;
    background-color: #e0e0e0;
    color: #000;
    font-size: 1.2em;
    font-weight: bold;
    cursor: pointer;
    align-items: center;
}

/* The Modal (background) */
.modal {
    display: none; /* Hidden by default */
    position: fixed; /* Stay in place */
    z-index: 1; /* Sit on top */
    left: 0;
    top: 0;
    width: 100%; /* Full width */
    height: 100%; /* Full height */
    overflow: auto; /* Enable scroll if needed */
    background-color: rgb(0,0,0); /* Fallback color */
    background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
}

/* Modal Content/Box */
.modal-content {
    background-color: #fefefe;
    margin: 15% auto; /* 15% from the top and centered */
    padding: 20px;
    border: 1px solid #888;
    width: 80%; /* Could be more or less, depending on screen size */
    max-width: 500px;
    border-radius: 5px;
}

/* The Close Button */
.close-button {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
}

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

/* Back to Main Button for content pages */
.back-to-main-button {
    position: absolute;
    top: 20px; /* Adjust as needed */
    left: 20px; /* Adjust as needed */
    padding: 8px 15px;
    background-color: #f0f0f0;
    color: #333;
    text-decoration: none;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 0.9em;
    transition: background-color 0.3s, color 0.3s, border-color 0.3s;
    z-index: 100;
}

.back-to-main-button:hover {
    background-color: #e0e0e0;
    color: #000;
    border-color: #a0a0a0;
}

@media (max-width: 768px) {
    .back-to-main-button {
        top: 10px;
        left: 10px;
        padding: 6px 12px;
        font-size: 0.8em;
    }
}

/* Styles for Terms and Privacy pages */
.content-page-body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    background-color: #f0f0f0;
    margin: 0;
    padding: 0; /* Removed padding to prevent horizontal scrollbar */
    min-height: 100vh; /* Ensure it takes full viewport height */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
}

#explosion-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 0, 0, 0); /* Start fully transparent */
    z-index: 9999; /* Ensure it's on top */
    pointer-events: none; /* Allow clicks to pass through */
    opacity: 0;
    transition: opacity 0.1s ease-in-out; /* Smooth transition for fade */
}

#explosion-overlay.active {
    animation: explodeFade 0.8s ease-out forwards;
}

@keyframes explodeFade {
    0% { opacity: 0; background-color: rgba(255, 0, 0, 0); }
    20% { opacity: 0.4; background-color: rgba(255, 0, 0, 0.4); }
    80% { opacity: 0.4; background-color: rgba(255, 0, 0, 0.4); }
    100% { opacity: 0; background-color: rgba(255, 0, 0, 0); }
}

.content-container {
    background-color: #ffffff;
    margin: 40px auto; /* Center the container with top/bottom margin */
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    max-width: 900px; /* Max width for readability */
    border: 1px solid #ddd; /* Subtle border */
}

.content-container h1 {
    color: #333;
    text-align: center;
    margin-bottom: 30px;
    padding-bottom: 10px;
    border-bottom: 2px solid #eee; /* Underline for main title */
}

.content-container h2 {
    color: #555;
    margin-top: 25px;
    margin-bottom: 15px;
    padding-bottom: 5px;
}

.content-container p {
    margin-bottom: 10px;
}

.content-container ul {
    list-style-type: disc;
    margin-left: 20px;
    margin-bottom: 15px;
}

.content-container li {
    margin-bottom: 5px;
}

.back-button {
    display: inline-block;
    margin-top: 30px;
    padding: 10px 20px;
    background-color: #888;
    color: white;
    text-decoration: none;
    border-radius: 5px;
    transition: background-color 0.3s ease;
}

.back-button:hover {
    background-color: #aaa;
}

@media (max-width: 768px) {
    .content-container {
        margin: 20px auto;
        padding: 20px;
    }
}

/* Toast Message Styling */
#toast-message {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 25px;
    border-radius: 25px;
    font-size: 1.1em;
    font-weight: bold;
    z-index: 10000;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.5s, bottom 0.5s, background-color 0.5s;
    white-space: nowrap;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
}

#toast-message.show {
    visibility: visible;
    opacity: 1;
    bottom: 50px;
}

#toast-message.toast-success {
    background-color: #2ecc71; /* Green */
    color: white;
}

#toast-message.toast-failure {
    background-color: #e74c3c; /* Red */
    color: white;
}

.hidden {
    display: none !important;
}

@media screen and (max-width: 1023px) {
    .pc-only-side-ad {
        display: none !important; 
    }
}

@media screen and (min-width: 1024px) {
    .pc-only-side-ad {
        display: block !important;
        position: fixed !important;
        top: 80px;  
        right: 50px; 
        z-index: 92; 
    }
}

/* Navbar Styles */
.navbar {
    width: 100%;
    background-color: #f0f0f0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    padding: 10px 20px;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.navbar-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
}

.navbar-brand {
    font-size: 1.5em;
    font-weight: bold;
    color: #333;
    text-decoration: none;
}

.navbar-nav {
    list-style: none;
    display: flex;
    gap: 20px;
    margin: 0;
    padding: 0;
}

.navbar-nav a {
    color: #555;
    text-decoration: none;
    font-size: 1em;
    padding: 5px 10px;
    border-radius: 5px;
    transition: background-color 0.3s, color 0.3s;
}

.navbar-nav a:hover {
    background-color: #f0f0f0;
    color: #000;
}

.navbar-toggler {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}

.navbar-toggler-icon {
    display: block;
    width: 24px;
    height: 2px;
    background-color: #333;
    position: relative;
}

.navbar-toggler-icon::before,
.navbar-toggler-icon::after {
    content: '';
    position: absolute;
    width: 24px;
    height: 2px;
    background-color: #333;
    left: 0;
    transition: transform 0.3s, top 0.3s;
}

.navbar-toggler-icon::before {
    top: -7px;
}

.navbar-toggler-icon::after {
    top: 7px;
}

/* Responsive Drawer Menu */
@media (max-width: 768px) {
    .navbar-nav {
        display: none;
    }

    .navbar-toggler {
        display: block;
        z-index: 1050; /* Ensure it's above the drawer */
    }

    /* Animate hamburger to X */
    .navbar-toggler.is-active .navbar-toggler-icon {
        background-color: transparent;
    }
    .navbar-toggler.is-active .navbar-toggler-icon::before {
        transform: rotate(45deg);
        top: 0;
    }
    .navbar-toggler.is-active .navbar-toggler-icon::after {
        transform: rotate(-45deg);
        top: 0;
    }

    .navbar-collapse {
        position: fixed;
        top: 0;
        right: -280px; /* Start off-screen */
        width: 280px;
        height: 100%;
        background-color: #f0f0f0; /* Lighter gray background */
        box-shadow: -2px 0 5px rgba(0,0,0,0.1);
        transition: right 0.3s ease-in-out;
        padding-top: 80px; /* More padding top */
        z-index: 1040;
    }

    .navbar-collapse.is-open {
        right: 0; /* Slide in */
    }

    .navbar-collapse .navbar-nav {
        display: flex;
        flex-direction: column;
        align-items: flex-start; /* Align items to the left */
        gap: 0; /* Remove gap to use borders */
        width: 100%;
    }

    .navbar-collapse .navbar-nav a {
        font-size: 1.2em;
        width: 100%;
        text-align: left;
        padding: 15px 20px; /* Adjust padding */
    }

    .navbar-collapse .navbar-nav li:first-child a {
        border-top: 1px solid #e0e0e0; /* Top border for the first item */
    }

    .drawer-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 1030; /* Below drawer but above content */
    }

    .drawer-overlay.is-active {
        display: block;
    }
}

/* Language Selector Styling */
#language-selector {
    padding: 5px 8px;
    border-radius: 5px;
    border: 1px solid #ccc;
    background-color: #fff;
    cursor: pointer;
}

/* Ad container styling */
.ad-container {
    margin: 20px auto;
    text-align: center;
    width: 100%;
    max-width: 728px; /* Example max-width for a banner ad */
}

/* Responsive adjustments for ads */
@media (max-width: 768px) {
    .ad-container {
        padding: 0 10px;
    }
}

/* Specific styling for the top ad banner */
.top-ad-banner {
    width: 100%;
    background-color: #f0f0f0; /* Match body background */
    padding: 10px 0;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

/* Specific styling for the bottom ad banner */
.bottom-ad-banner {
    margin-top: auto; /* Pushes the footer and this banner to the bottom */
    padding: 10px 0;
    width: 100%;
    background-color: #f0f0f0;
}

/* Ensure main content takes up available space */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    align-items: center;
}

/* Body flex container to push footer down */
body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Contact Form Styling */
.contact-form {
    display: flex;
    flex-direction: column;
    gap: 20px; /* Increased gap for better spacing */
    background-color: #ffffff; /* White background for the form */
    padding: 30px; /* Increased padding */
    border-radius: 10px; /* Rounded corners */
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1); /* Softer shadow */
    border: 1px solid #e0e0e0; /* Light border */
    max-width: 600px; /* Max width for the form */
    margin: 20px auto; /* Centering the form */
}

.contact-form .form-group {
    display: flex;
    flex-direction: column;
}

.contact-form label {
    margin-bottom: 8px; /* Increased margin */
    font-weight: 600; /* Bolder labels */
    color: #333; /* Darker label color */
    font-size: 0.95em;
}

.contact-form input,
.contact-form textarea {
    padding: 12px 15px; /* Increased padding */
    border: 1px solid #ccc;
    border-radius: 6px; /* More rounded corners */
    font-size: 1em;
    font-family: inherit;
    background-color: #f9f9f9; /* Light background for inputs */
    transition: border-color 0.3s, box-shadow 0.3s; /* Smooth transitions */
}

.contact-form input:focus,
.contact-form textarea:focus {
    outline: none;
    border-color: #007bff; /* Highlight color on focus */
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1); /* Glow effect */
}

.contact-form textarea {
    resize: vertical;
    min-height: 140px; /* Increased min-height */
}

.contact-form button {
    padding: 15px 20px; /* Increased padding */
    background: linear-gradient(45deg, #007bff, #0056b3); /* Gradient background */
    color: white;
    border: none;
    border-radius: 6px; /* Rounded corners */
    cursor: pointer;
    font-size: 1.1em;
    font-weight: 600; /* Bolder text */
    transition: transform 0.2s, box-shadow 0.2s; /* Transitions for interaction */
    box-shadow: 0 4px 15px rgba(0, 123, 255, 0.2); /* Button shadow */
}

.contact-form button:hover {
    transform: translateY(-2px); /* Lift effect on hover */
    box-shadow: 0 6px 20px rgba(0, 123, 255, 0.3); /* Enhanced shadow on hover */
}

.contact-form button:active {
    transform: translateY(0); /* Reset lift on click */
    box-shadow: 0 4px 15px rgba(0, 123, 255, 0.2); /* Reset shadow on click */
}


#contact-form-status {
    margin-top: 15px;
    padding: 12px; /* Increased padding */
    border-radius: 6px; /* Rounded corners */
    text-align: center;
    font-weight: 500; /* Medium weight */
    display: none; /* Hidden by default */
    font-size: 1.05em;
}

#contact-form-status.success {
    background-color: #d1e7dd; /* Softer green */
    color: #0f5132; /* Darker green text */
    border: 1px solid #badbcc; /* Green border */
    display: block;
}

#contact-form-status.error {
    background-color: #f8d7da; /* Softer red */
    color: #842029; /* Darker red text */
    border: 1px solid #f5c2c7; /* Red border */
    display: block;
}