body {
    font-family: sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: #f0f0f0;
    padding: 10px; /* Reduced padding for mobile */
    font-size: 16px; /* Base font size */
}

h1 {
    font-size: 1.8rem; /* Relative font size */
    color: #333;
}

#game-info {
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap; /* Allow wrapping on small screens */
    width: 100%; /* Full width on mobile */
    max-width: 100%;
    margin-bottom: 15px; /* Reduced margin */
    background-color: #e0e0e0;
    padding: 10px;
    border-radius: 5px;
}

#difficulty-level-container {
    display: flex;
    align-items: center;
    justify-content: center; /* Center items horizontally */
    gap: 5px; /* Space between buttons and text */
}

.level-button {
    padding: 8px 12px; /* Increased padding */
    font-size: 1.4em; /* Increased font size */
    cursor: pointer;
    border: 1px solid #ccc;
    border-radius: 4px;
    background-color: #f0f0f0;
    color: #333;
    margin: 0; /* Remove default button margin */
    line-height: 1; /* Adjust line height for better alignment */
    min-width: 2.5rem; /* Minimum touch width */
    min-height: 2.5rem; /* Minimum touch height */
    display: inline-flex; /* Added for centering */
    align-items: center; /* Added for centering */
    justify-content: center; /* Added for centering */
}

.level-button:hover {
    background-color: #e0e0e0;
}

#game-area, #mcq-area, #game-summary {
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 15px; /* Reduced margin */
    width: 100%; /* Full width */
    max-width: 700px;
    box-sizing: border-box; /* Include padding in width */
    text-align: center;
}

#level-20-complete-screen { /* Styles for the new screen */
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 15px;
    width: 100%;
    max-width: 700px;
    box-sizing: border-box;
    text-align: center;
}

#level-20-complete-screen h2 {
    margin-top: 0;
    color: #28a745; /* Green color for congratulations */
}

#level-20-complete-screen p {
    font-size: 1.1em;
    margin-bottom: 15px;
}

#level-20-complete-screen div {
    margin-bottom: 10px;
    font-size: 1.1em;
}

#level-20-complete-screen button {
    /* Inherits general button styles, can add specifics if needed */
    margin-top: 20px;
}

/* Style for the xAPI Debug Panel Container */
.output-container {
    width: 100%; /* Take full available width */
    max-width: 700px; /* Match other content blocks */
    box-sizing: border-box; /* Include padding/border in width */
    min-height: 50px; /* Ensure it's visible even if empty */
    margin: 15px 0; /* Add some margin like other blocks */
    /* Inline styles from HTML are kept: padding, border, background, etc. */
}


.grid-container {
    display: grid;
    /* Responsive grid: Default to auto-fit */
    grid-template-columns: repeat(auto-fit, minmax(75px, 1fr));
    gap: 8px; /* Slightly reduced gap */
    margin: 15px auto;
    padding: 8px;
    background-color: #d3e9ff; /* Light blue background for grid */
    border-radius: 5px;
    max-width: 95%; /* Allow grid to use more width */
    box-sizing: border-box;
}

.ion-tile {
    border: 1px solid #ccc;
    padding: 10px 5px; /* Adjusted padding */
    text-align: center;
    cursor: pointer;
    border-radius: 5px;
    background-color: #fff;
    transition: background-color 0.2s, transform 0.1s, border 0.2s;
    border: 2px solid transparent; /* Add transparent border for layout consistency */
    font-weight: bold;
    font-size: 0.9rem; /* Slightly smaller font for tiles */
    min-height: 40px; /* Ensure minimum tap height */
    display: flex; /* Center content vertically */
    justify-content: center;
    align-items: center;
}

.ion-tile.cation {
    background-color: #ffdddd; /* Light red for cations */
    border-color: #ffaaaa;
}

.ion-tile.anion {
    background-color: #ddddff; /* Light blue for anions */
    border-color: #aaaaff;
}

.ion-tile.selected {
    border: 2px solid #333; /* Dark border for selected tiles */
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.3); /* Optional: Add a subtle shadow */
    transform: scale(1.05); /* Slightly larger when selected */
    background-color: rgba(255, 255, 153, 0.1); /* Semi-transparent yellow */
}

.ion-tile.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#selected-ions {
    margin-top: 15px;
    font-weight: bold;
}

button {
    padding: 10px 20px;
    font-size: 1em;
    cursor: pointer;
    border: none;
    border-radius: 5px;
    background-color: #007bff;
    color: white;
    margin-top: 15px;
    transition: background-color 0.2s;
    min-width: 120px; /* Ensure button is wide enough */
}

button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

button:hover:not(:disabled) {
    background-color: #0056b3;
}

.hidden {
    display: none;
}

#mcq-area h2, #game-summary h2 {
    margin-top: 0;
}

#mcq-options button {
    display: block;
    width: 95%; /* Wider buttons for easier tapping */
    margin: 8px auto; /* Reduced margin */
    background-color: #6c757d;
    padding: 12px; /* Larger padding */
}
#mcq-options button.correct {
    background-color: #28a745; /* Green for correct */
}
#mcq-options button.incorrect {
    background-color: #dc3545; /* Red for incorrect */
}
#mcq-options button:hover:not(:disabled) {
    background-color: #5a6268;
}
#mcq-options button.correct:hover:not(:disabled) {
    background-color: #218838;
}
#mcq-options button.incorrect:hover:not(:disabled) {
    background-color: #c82333;
}


#feedback-area {
    margin-top: 15px;
    padding: 10px;
    border-radius: 5px;
    min-height: 40px; /* Ensure space for feedback */
}

#feedback-area.correct {
    background-color: #d4edda; /* Light green */
    color: #155724;
    border: 1px solid #c3e6cb;
}

#feedback-area.incorrect {
    background-color: #f8d7da; /* Light red */
    color: #721c24;
    border: 1px solid #f5c6cb;
}

#tries-left {
    margin-top: 10px;
    font-style: italic;
    color: #666;
}

#summary-list {
    list-style: none;
    padding: 0;
    text-align: left;
    max-width: 400px;
    margin: 15px auto;
}

#summary-list li {
    background-color: #f8f9fa;
    margin-bottom: 5px;
    padding: 8px;
    border-radius: 3px;
    border: 1px solid #dee2e6;
    font-size: 0.9rem; /* Adjust font size */
}

#summary-list li.correct {
    border-left: 5px solid #28a745; /* Green border for correct */
}

#summary-list li.incorrect {
    border-left: 5px solid #dc3545; /* Red border for incorrect */
}

/* Media Queries for further adjustments */

/* Force 4 columns on typical mobile portrait */
@media (max-width: 599px) {
    .grid-container {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (min-width: 600px) {
    body {
        padding: 20px; /* Restore padding on larger screens */
    }
    #game-info {
        width: 80%;
        padding: 10px;
    }
     #game-area, #mcq-area, #game-summary {
        width: 90%;
        padding: 20px;
    }
    .grid-container {
        max-width: 400px; /* Limit grid width again */
        gap: 10px;
        padding: 10px;
         grid-template-columns: repeat(4, 1fr); /* Fixed 4 columns */
    }
    .ion-tile {
        padding: 15px;
        font-size: 1rem;
    }
    #mcq-options button {
        width: 80%;
        margin: 10px auto;
        padding: 10px 20px;
    }
     #summary-list {
        max-width: 400px;
    }
     #summary-list li {
        font-size: 1rem;
    }
}

@media (max-height: 500px) and (orientation: landscape) {
    /* Specific adjustments for short landscape screens */
    h1 {
        font-size: 1.5rem;
        margin-bottom: 5px;
    }
    #game-info {
        margin-bottom: 10px;
        font-size: 0.9rem;
        padding: 5px;
    }
     #game-area, #mcq-area, #game-summary {
        padding: 15px;
        margin-bottom: 10px;
    }
    .grid-container {
         margin: 10px auto;
         gap: 5px;
         padding: 5px;
    }
     .ion-tile {
        padding: 8px 4px;
        min-height: 35px;
    }
    button {
        margin-top: 10px;
        padding: 8px 15px;
    }
     #mcq-options button {
        margin: 5px auto;
        padding: 10px;
    }
}
