body {
    font-family: Arial, sans-serif;
    background-color: #121213;
    color: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh; /* Fallback for older browsers */
    height: -webkit-fill-available; /* Safari-specific fallback */
    height: calc(var(--vh, 1vh) * 100); /* Dynamic height from JavaScript */
    margin: 0;
    touch-action: manipulation; /* Prevent double-tap zoom on iOS */
}

#game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

header {
    text-align: center;
}

#category-display {
    background: linear-gradient(135deg, #2a2a2a 0%, #1e1e1e 100%);
    border: 2px solid #3a3a3c;
    border-radius: 12px;
    padding: 12px 24px;
    font-size: 1.1rem;
    font-weight: 600;
    color: #b59f3b;
    letter-spacing: 1px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    margin: 10px 0;
    display: inline-block;
    min-width: 200px;
}

.category-label {
    color: #818384;
    font-weight: 500;
    margin-right: 8px;
}

.revealed-letter {
    color: #fff;
    font-weight: 700;
    text-shadow: 0 0 8px rgba(181, 159, 59, 0.4);
}

.hidden-letter {
    color: #565758;
    font-weight: 400;
}

.title-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

.title-row h1 {
    margin: 0;
}

.header-buttons {
    display: flex;
    gap: 10px;
}

#privacy-button {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: #565758;
    border: none;
    color: #fff;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
    touch-action: manipulation; /* Prevent double-tap zoom on iOS */
}

#privacy-button:hover {
    background-color: #6e6f70;
}

#found-words {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin: 10px 0;
}

.found-word-slot {
    padding: 10px 20px;
    background-color: #2a2a2a;
    border: 2px solid #3a3a3c;
    border-radius: 6px;
    font-size: 1.2rem;
    font-weight: bold;
    letter-spacing: 2px;
    color: #818384;
    transition: all 0.3s ease;
}

.found-word-slot.revealed {
    background-color: #538d4e;
    border-color: #538d4e;
    color: #fff;
    transform: scale(1.05);
}

#grid-container {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 5px;
}

.tile {
    width: 60px;
    height: 60px;
    border: 2px solid #3a3a3c;
    display: flex;
    flex-direction: column; /* Stack letter and dots */
    justify-content: space-between; /* Position letter at top, dots at bottom */
    align-items: center;
    font-size: 2rem;
    font-weight: bold;
    text-transform: uppercase;
    position: relative;
    touch-action: manipulation; /* Prevent double-tap zoom on iOS */
}

.tile-letter {
    padding-top: 5px; /* Adjust as needed */
}

.feedback-dots {
    position: absolute;
    bottom: 5px;
    display: flex;
    gap: 3px;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #3a3a3c; /* Default color */
}

.dot.correct {
    background-color: #538d4e; /* Green */
}

.dot.present {
    background-color: #b59f3b; /* Yellow */
}

.dot.absent {
    background-color: #3a3a3c; /* Dark Gray */
}

#keyboard-container {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.keyboard-row {
    display: flex;
    justify-content: center;
    gap: 5px;
}

.key {
    padding: 15px 10px;
    border: none;
    border-radius: 4px;
    background-color: #818384;
    color: #fff;
    font-size: 1rem;
    cursor: pointer;
    touch-action: manipulation; /* Prevent double-tap zoom on iOS */
}

.key:disabled {
    background-color: #3a3a3c;
    cursor: not-allowed;
}

.key.unused {
    background-color: #3a3a3c;
    opacity: 0.5;
    cursor: not-allowed;
}

.key.special-key {
    font-size: 1.3rem;
    padding: 15px 12px;
}

.key.enter-key {
    font-size: 1.5rem;
    padding: 15px 18px;
    font-weight: bold;
}

.error-message {
    color: #ff4d4d;
    height: 20px;
}

#help-button {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: #565758;
    border: none;
    color: #fff;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
    touch-action: manipulation; /* Prevent double-tap zoom on iOS */
}

#help-button:hover {
    background-color: #6e6f70;
}

.modal {
    position: fixed;
    z-index: 1;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.4);
}

.modal-content {
    background-color: #1e1e1e;
    margin: 15% auto;
    padding: 20px;
    border: 1px solid #888;
    width: 80%;
    max-width: 500px;
    color: #fff;
    position: relative;
}

.close-button {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
}

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

.hidden {
    display: none;
}

ul {
    list-style-type: none;
    padding: 0;
}

li span {
    font-weight: bold;
}

.correct {
    color: #538d4e;
}

.present {
    color: #b59f3b;
}

.absent {
    color: #3a3a3c;
}

#stats-modal .modal-content {
    text-align: center;
}

#stats-title {
    margin-bottom: 20px;
}

#stats-content {
    margin: 20px 0;
    padding: 20px;
    background-color: #2a2a2a;
    border-radius: 8px;
}

.stats-result {
    font-size: 1.2rem;
    margin-bottom: 15px;
}

.stats-category {
    margin: 10px 0;
    font-size: 1.1rem;
}

.stats-words {
    margin: 10px 0;
    font-size: 1rem;
    color: #b59f3b;
}

.stats-streak {
    margin: 10px 0;
    font-size: 1.1rem;
    font-weight: bold;
    color: #ff9500;
}

.come-back {
    margin-top: 15px;
    font-style: italic;
    color: #818384;
}

.share-button {
    margin-top: 15px;
    padding: 12px 24px;
    background-color: #538d4e;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s ease;
    touch-action: manipulation; /* Prevent double-tap zoom on iOS */
}

.share-button:hover {
    background-color: #6aad64;
}

.share-button:active {
    transform: scale(0.98);
}

#comparison-stats {
    margin-top: 20px;
    padding: 20px;
    background-color: #1a1a1a;
    border-radius: 8px;
}

#comparison-stats h3 {
    margin-top: 0;
    margin-bottom: 20px;
    color: #fff;
    font-size: 1.1rem;
}

#comparison-stats h4 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #b59f3b;
    font-size: 1rem;
}

.stats-charts {
    display: flex;
    gap: 30px;
    justify-content: space-around;
    flex-wrap: wrap;
}

.chart-section {
    flex: 1;
    min-width: 250px;
}

/* Donut Chart Styles */
.donut-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.donut-chart {
    width: 150px;
    height: 150px;
}

.donut-legend {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    display: inline-block;
}

/* Bar Chart Styles */
.bar-chart {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.bar-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.bar-row.user-bar .bar-fill {
    background-color: #b59f3b;
}

.bar-label {
    width: 20px;
    text-align: center;
    font-weight: bold;
    color: #fff;
}

.bar-label-words {
    width: 60px;
    text-align: left;
    font-weight: bold;
    color: #fff;
    font-size: 0.9rem;
}

.bar-container {
    flex: 1;
    height: 30px;
    background-color: #2a2a2a;
    border-radius: 4px;
    position: relative;
    display: flex;
    align-items: center;
}

.bar-fill {
    height: 100%;
    background-color: #538d4e;
    border-radius: 4px;
    min-width: 30px;
    transition: width 0.3s ease;
}

.bar-count {
    position: absolute;
    right: 8px;
    color: #fff;
    font-size: 0.9rem;
    font-weight: bold;
}

/* Mobile Responsive Styles */
@media (max-width: 768px) {
    * {
        box-sizing: border-box;
    }

    body {
        height: 100vh; /* Fallback for older browsers */
        height: -webkit-fill-available; /* Safari-specific fallback */
        height: calc(var(--vh, 1vh) * 100); /* Dynamic height from JavaScript */
        overflow: hidden;
        overflow-x: hidden;
        padding: 0;
        margin: 0;
        align-items: flex-start;
    }

    #game-container {
        gap: 10px;
        padding: 8px 16px 10px 16px;
        max-height: 100vh; /* Fallback for older browsers */
        max-height: -webkit-fill-available; /* Safari-specific fallback */
        max-height: calc(var(--vh, 1vh) * 100); /* Dynamic height from JavaScript */
        overflow-y: auto;
        overflow-x: hidden;
        width: 100%;
        justify-content: flex-start;
        box-sizing: border-box;
    }

    header {
        margin-top: 0;
        padding-top: 0;
    }

    .title-row h1 {
        font-size: 1.5rem;
        margin: 5px 0 5px 0;
    }

    .title-row {
        gap: 12px;
    }

    #help-button {
        width: 32px;
        height: 32px;
        font-size: 1.05rem;
    }

    #category-display {
        font-size: 0.95rem;
        margin: 8px 0;
        padding: 10px 20px;
        min-width: 180px;
        letter-spacing: 0.8px;
    }

    #found-words {
        gap: 8px;
        margin: 8px 0;
    }

    .found-word-slot {
        padding: 8px 14px;
        font-size: 0.95rem;
        letter-spacing: 1.5px;
    }

    .tile {
        width: 64px;
        height: 64px;
        font-size: 1.8rem;
    }

    #grid-container {
        gap: 5px;
    }

    .dot {
        width: 7px;
        height: 7px;
    }

    .feedback-dots {
        gap: 2px;
        bottom: 4px;
    }

    .key {
        padding: 16px 2px;
        font-size: 1rem;
        min-width: 28px;
        flex: 1;
    }

    .key.special-key {
        padding: 12px 10px;
        font-size: 1.3rem;
        flex: 0 0 auto;
    }

    .key.enter-key {
        padding: 12px 14px;
        font-size: 1.5rem;
        flex: 0 0 auto;
    }

    .keyboard-row {
        gap: 3px;
        width: 100%;
        max-width: none;
        justify-content: stretch;
    }

    #keyboard-container {
        gap: 4px;
        width: 100%;
        padding: 0;
        box-sizing: border-box;
    }
}

/* Extra small phones */
@media (max-width: 400px) {
    #game-container {
        gap: 8px;
        padding: 6px 12px 8px 12px;
    }

    .title-row h1 {
        font-size: 1.3rem;
    }

    #category-display {
        font-size: 0.85rem;
        padding: 8px 16px;
        min-width: 160px;
        letter-spacing: 0.5px;
    }

    #help-button {
        width: 30px;
        height: 30px;
        font-size: 0.95rem;
    }

    .tile {
        width: 58px;
        height: 58px;
        font-size: 1.6rem;
    }

    #grid-container {
        gap: 4px;
    }

    .found-word-slot {
        padding: 6px 10px;
        font-size: 0.85rem;
    }

    .key {
        padding: 14px 3px;
        font-size: 0.9rem;
        min-width: 26px;
        flex: 1;
    }

    .key.special-key {
        padding: 11px 10px;
        font-size: 1.2rem;
        flex: 0 0 auto;
    }

    .key.enter-key {
        padding: 11px 14px;
        font-size: 1.4rem;
        flex: 0 0 auto;
    }

    #keyboard-container {
        padding: 0;
    }

    .keyboard-row {
        gap: 2px;
    }
}

/* Consent Banner */
.consent-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: #1e1e1e;
    border-top: 2px solid #538d4e;
    padding: 20px;
    z-index: 1000;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5);
}

.consent-content {
    max-width: 800px;
    margin: 0 auto;
    text-align: center;
}

.consent-content h3 {
    margin-top: 0;
    margin-bottom: 10px;
    color: #fff;
}

.consent-content p {
    margin: 10px 0;
    color: #d0d0d0;
    line-height: 1.5;
}

.consent-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 15px;
    flex-wrap: wrap;
}

.consent-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    touch-action: manipulation; /* Prevent double-tap zoom on iOS */
}

.consent-accept {
    background-color: #538d4e;
    color: #fff;
}

.consent-accept:hover {
    background-color: #6aad64;
}

.consent-customize {
    background-color: #b59f3b;
    color: #fff;
}

.consent-customize:hover {
    background-color: #d4b844;
}

.consent-reject {
    background-color: #818384;
    color: #fff;
}

.consent-reject:hover {
    background-color: #9a9b9c;
}

/* Privacy Modal Styles */
.privacy-content {
    max-height: 70vh;
    overflow-y: auto;
}

.privacy-content h3 {
    margin-top: 20px;
    margin-bottom: 10px;
    color: #b59f3b;
}

.privacy-content ul {
    list-style-type: disc;
    padding-left: 20px;
}

.privacy-content li {
    margin-bottom: 8px;
    line-height: 1.5;
}

/* Privacy Settings */
.privacy-option {
    margin-bottom: 25px;
    padding: 15px;
    background-color: #2a2a2a;
    border-radius: 8px;
}

.privacy-option-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 10px;
}

.privacy-option h3 {
    margin: 0;
    color: #fff;
    font-size: 1.1rem;
}

.privacy-option p {
    margin: 8px 0;
    color: #d0d0d0;
    line-height: 1.5;
}

.privacy-warning {
    color: #ff9500 !important;
    font-size: 0.95rem;
}

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 28px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #3a3a3c;
    transition: 0.3s;
    border-radius: 28px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background-color: #fff;
    transition: 0.3s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #538d4e;
}

input:checked + .slider:before {
    transform: translateX(22px);
}

/* Mobile adjustments for consent banner */
@media (max-width: 768px) {
    .consent-banner {
        padding: 15px 10px;
    }

    .consent-content h3 {
        font-size: 1.1rem;
    }

    .consent-content p {
        font-size: 0.9rem;
    }

    .consent-buttons {
        flex-direction: column;
        gap: 8px;
    }

    .consent-btn {
        width: 100%;
        padding: 12px 16px;
    }

    #privacy-button {
        width: 32px;
        height: 32px;
        font-size: 0.9rem;
    }

    .header-buttons {
        gap: 8px;
    }
}
