body {
    margin: 0px;
    padding: 0px;
    font-family: Helvetica, sans-serif;
    text-align: center;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.main-content {
    flex: 1;
}

h1 {
    color: rgb(0, 0, 0);  
    font-size: 50px; 
}

h2 {
    color: rgb(0, 0, 0);  
    font-size: 40px; 
    text-align: center;
}

a {
    color: rgb(0, 42, 255); 
    font-size: 40px; 
    text-align: center;
}

h3 {
    color: rgb(0, 0, 0);  
    font-size: 30px; 
}

.list-container {
    text-align: center;
}

ul {
    text-align: left;
    display: inline-block;
    width: 100%;
    box-sizing: border-box;
    padding-left: 30px;
}

li {
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    white-space: normal;
    max-width: calc(100% - 20px);
    box-sizing: border-box;
    margin: 0 10px;
}

.header-container {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 20px;
    gap: 1%
}

.header-image {
    height: 50px; 
    width: auto;
}

.clue-help-icon {
    height: 1em;
    width: auto;
    margin-left: 15px;
    vertical-align: middle;
    cursor: pointer;
    transition: opacity 0.2s;
}

.clue-help-icon:hover {
    opacity: 0.7;
}

.mob {
    display: none;
}

.mob a {
    text-decoration: none;
    color: rgb(0, 0, 0);
}

.desk {
    display: block;
}

.popup-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100vw;
    height: 100vh;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.4);
}

.popup-content {
    background-color: #fff;
    margin: 0 auto; /* Center horizontally */
    padding: 25px;
    border: 5px solid #000000;
    width: 90%; /* Use percentage width for better responsiveness */
    max-width: 900px;
    border-radius: 12px;
    box-shadow: 0 2px 16px rgba(0,0,0,0.25);
    position: fixed; /* Change to fixed positioning */
    top: 50%; /* Position at 50% from top */
    left: 50%; /* Position at 50% from left */
    transform: translate(-50%, -50%); /* Center perfectly */
    text-align: center;
    font-size: 1.5em;
    line-height: 1.5;
    /* Ensure popup stays within viewport */
    box-sizing: border-box;
}

.close-btn {
    color: #000000;
    float: right;
    font-size: 32px;
    font-weight: bold;
    position: absolute;
    top: 18px;
    right: 24px;
    cursor: pointer;
}

.close-btn:hover,
.close-btn:focus {
    color: #000;
    text-decoration: none;
    cursor: pointer;
}

.main-container {
    margin: 2.5% auto 8% auto; 
    padding: 25px;
    border: 5px solid #000000;
    width: 60%;
    max-width: 900px;
    border-radius: 12px;
    box-shadow: 0 2px 16px rgba(0,0,0,0.25);
    position: relative;
    text-align: center;
    font-size: 1.5em;
    line-height: 1.5;
    margin-bottom: 50px;
}

input {
    width: 50%;
    height: 2em;
    font-family: Helvetica, sans-serif;
    font-size: 0.7em;
    border: 3px solid #000;
    border-radius: 5px;
}

/* Custom dropdown container */
.datalist-container {
    position: relative;
    display: inline-block;
    width: 50%;
}

/* Custom dropdown styling */
.custom-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    /* border: 3px solid #000;
    border-radius: 5px; */
    max-height: 250px; /* Approximately 6 items */
    overflow-y: auto;
    z-index: 1000;
    display: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    scrollbar-width: thin;
    scrollbar-color: #888 #f1f1f1;
}

/* Dropdown content container */
.dropdown-content {
    width: 100%;
}

/* Webkit scrollbar styling for better appearance */
.custom-dropdown::-webkit-scrollbar {
    width: 8px;
}

.custom-dropdown::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.custom-dropdown::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.custom-dropdown::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.custom-dropdown.show {
    display: block;
}

/* Style individual dropdown options */
.dropdown-option {
    padding: 8px 12px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
    font-family: Helvetica, sans-serif;
    font-size: 0.7em;
    transition: background-color 0.2s;
}

.dropdown-option:hover {
    background-color: #f0f0f0;
}

.dropdown-option:last-child {
    border-bottom: none;
}

.dropdown-option.selected {
    background-color: #e0e0e0;
}

.submit-button button {
    border: 3px solid #000;
    border-radius: 5px;
    background-color: #fff;
    font-family: Helvetica, sans-serif;
    font-size: 0.7em;
    /* Ensure "Submit" text is always visible */
    white-space: nowrap;
    overflow: visible;
    text-overflow: clip;
    min-height: 0.8em;
    min-width: 80px;
    padding: 8px 12px;
    margin-top: 2.5px;
}

.welldone-popup .popup-content {
    background-color: #85e884;
}

.error-popup .popup-content {
    background-color: #ea7b7b;
}

.clue-help-popup .popup-content {
    background-color: #e8f4fd;
    border-color: #0066cc;
}

.clue-help-popup .close-btn {
    color: #0066cc;
}

.clue-help-popup h2 {
    color: #0066cc;
    margin-top: 0;
}

/* Mobile Optimization Styles */
@media (max-width: 768px) {
    .mob {
        display: block !important;
    }
    
    .desk {
        display: none !important;
    }
    
    .header-container {
        flex-direction: row;
        text-align: center;
        margin: 15px;
        gap: 10px;
        align-items: center;
        justify-content: center;
    }
    
    .header-image {
        margin-top: 10px;
        height: 40px;
        text-align: center;
    }

    .mobheader {
        text-align: center;
        display: inline-block;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
    }

    /* Mobile typography */
    h1 {
        font-size: 32px;
        margin: 10px 0;
        white-space: normal; /* Allow text wrapping */
        overflow: visible; /* Show all text */
        text-overflow: clip; /* Don't truncate text */
        word-wrap: break-word; /* Break long words if needed */
        hyphens: auto; /* Add hyphens for better text flow */
    }
    h4 {
        font-size: 50px;
        margin: 10px 0;
        white-space: normal; /* Allow text wrapping */
        overflow: visible; /* Show all text */
        text-overflow: clip; /* Don't truncate text */
        word-wrap: break-word; /* Break long words if needed */
        hyphens: auto; /* Add hyphens for better text flow */
    }
    
    /* Main page title specific styling */
    .header-container h1 {
        margin: 0;
        display: inline-block;
        vertical-align: middle;
    }
    
    h2 {
        font-size: 28px;
    }
    
    h3 {
        font-size: 22px;
    }
    
    a {
        font-size: 28px;
    }
    .header-image {
        float: right;
    }
    
    /* Mobile container adjustments */
    .main-container {
        width: auto;
        max-width: 90%;
        margin: 15px auto;
        padding: 20px 15px;
        font-size: 1.2em;
        line-height: 1.4;
        display: inline-block;
    }
    
    /* Mobile form adjustments */
    input {
        width: 80%;
        height: 2.5em;
        font-size: 16px; /* Prevents zoom on iOS */
        -webkit-appearance: none;
        border-radius: 8px;
    }
    
    .datalist-container {
        width: 80%;
    }
    
    /* Mobile popup adjustments */
    .popup-content {
        width: 95%;
        margin: 0 auto;
        padding: 20px 15px;
        font-size: 1.2em;
        line-height: 1.4;
        /* Keep the fixed positioning and centering from desktop */
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        /* Ensure popup stays within viewport */
        box-sizing: border-box;
    }
    
    .close-btn {
        font-size: 28px;
        top: 15px;
        right: 20px;
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Mobile dropdown adjustments */
    .custom-dropdown {
        max-height: 200px;
        border-radius: 8px;
    }
    
    .dropdown-option {
        padding: 8px 10px;
        font-size: 18px;
        min-height: 30px;
        display: flex;
        align-items: center;
        border-bottom: 1px solid #eee;
    }
    
    /* Mobile button adjustments */
    .submit-button button {
        font-size: 16px;
        padding: 12px 20px;
        min-height: 50px; /* Increased height to ensure text fits */
        width: 40%; /* About 1/2 the width of input box (80% / 2) */
        min-width: 120px; /* Minimum width to ensure "Submit" text fits */
        border-radius: 8px;
        -webkit-appearance: none;
        cursor: pointer;
        margin: 2.5px auto 0 auto; /* Center the button and keep top margin */
        white-space: nowrap; /* Prevent text wrapping */
        overflow: visible; /* Ensure text is never hidden */
        text-overflow: clip; /* Don't truncate text */
        line-height: 1.2; /* Ensure proper line height for text */
        display: flex;
        align-items: center;
        justify-content: center;
        color: #000; /* Ensure text is visible */
    }
    
    /* Mobile list adjustments */
    .list-container ul {
        text-align: center;
        padding-left: 30px;
        display: inline-block;
    }
    
    .list-container li {
        margin: 8px 10px;
        padding: 5px 0;
        font-size: 0.9em;
        text-align: left;
        word-wrap: break-word;
        overflow-wrap: break-word;
        hyphens: auto;
        white-space: normal;
        max-width: calc(100% - 20px);
        box-sizing: border-box;
    }
    
    /* Mobile help icon adjustments */
    .clue-help-icon {
        height: 0.8em;
        margin-left: 0.3em; /* Width of approximately one space */
        min-width: 24px;
        min-height: 24px;
        display: inline-block;
        vertical-align: middle;
    }
    
    /* Ensure title and help icon stay on same line */
    .main-container h1 {
        /* Allow text wrapping for clue titles */
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
        word-wrap: break-word;
        hyphens: auto;
        /* Use inline layout to keep help icon with text */
        display: inline;
        text-align: center;
    }
    
    /* Position help icon inline with the text */
    .main-container h1 .clue-help-icon {
        display: inline;
        vertical-align: middle;
        margin-left: 0.3em; /* Width of approximately one space */
    }
    
    /* Mobile spacing adjustments */
    .main-container + .main-container {
        margin-top: 20px;
    }
    
    /* Touch-friendly improvements */
    .clue-help-icon,
    .header-image,
    .dropdown-option,
    .submit-button button {
        -webkit-tap-highlight-color: transparent;
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        user-select: none;
    }
    
    /* Better mobile scrolling */
    .custom-dropdown {
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    
    .custom-dropdown::-webkit-scrollbar {
        display: none;
    }
}

/* Small mobile devices */
@media (max-width: 480px) {
    h1 {
        font-size: 28px;
        white-space: normal; /* Allow text wrapping */
        overflow: visible; /* Show all text */
        text-overflow: clip; /* Don't truncate text */
        word-wrap: break-word; /* Break long words if needed */
        hyphens: auto; /* Add hyphens for better text flow */
    }
    
    h2 {
        font-size: 24px;
    }
    
    h3 {
        font-size: 20px;
    }
    
    .main-container {
        width: auto;
        max-width: 90%;
        padding: 15px 10px;
        font-size: 1.1em;
        display: inline-block;
        margin: 0 auto;    
    }
    
    .popup-content {
        width: 98%;
        margin: 0 auto;
        padding: 15px 10px;
        /* Keep the fixed positioning and centering from desktop */
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        /* Ensure popup stays within viewport */
        box-sizing: border-box;
    }
    
    input {
        width: 90%;
    }
    
    .datalist-container {
        width: 90%;
    }
    
    .submit-button button {
        width: 45%; /* About 1/2 the width of input box (90% / 2) */
        margin: 10px auto 0 auto; /* Center the button and keep top margin */
        min-width: 120px; /* Consistent with main mobile breakpoint */
        min-height: 50px; /* Consistent with main mobile breakpoint */
        white-space: nowrap; /* Prevent text wrapping */
        overflow: visible; /* Ensure text is never hidden */
        text-overflow: clip; /* Don't truncate text */
        line-height: 1.2; /* Ensure proper line height for text */
        display: flex;
        align-items: center;
        justify-content: center;
        color: #000; /* Ensure text is visible */
    }
    
    .clue-help-icon {
        height: 0.7em;
        margin-left: 8px;
        min-width: 20px;
        min-height: 20px;
    }
}

/* Desktop styles (screens larger than 768px) */
@media (min-width: 769px) {
    .mob {
        display: none !important;
    }
    
    .desk {
        display: block !important;
    }
}

/* Medium tablets */
@media (min-width: 769px) and (max-width: 1024px) {
    .mob {
        display: none !important;
    }
    
    .desk {
        display: block !important;
    }
    
    .main-container {
        width: 75%;
        padding: 30px 25px;
    }
    
    .popup-content {
        width: 85%;
        margin: 0 auto;
        /* Keep the fixed positioning and centering from desktop */
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        /* Ensure popup stays within viewport */
        box-sizing: border-box;
    }
    
    input {
        width: 60%;
    }
    
    .datalist-container {
        width: 60%;
    }
}

/* Landscape mobile optimization */
@media (max-width: 768px) and (orientation: landscape) {
    .popup-content {
        width: 95%;
        margin: 0 auto;
        max-height: 80vh;
        overflow-y: auto;
        /* Keep the fixed positioning and centering from desktop */
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        /* Ensure popup stays within viewport */
        box-sizing: border-box;
    }
    
    .main-container {
        margin: 10px auto;
        padding: 15px 20px;
    }
    
    h1 {
        font-size: 28px;
        margin: 5px 0;
        white-space: normal; /* Allow text wrapping */
        overflow: visible; /* Show all text */
        text-overflow: clip; /* Don't truncate text */
        word-wrap: break-word; /* Break long words if needed */
        hyphens: auto; /* Add hyphens for better text flow */
    }
}
