/* html, body {
    height: 100%;
    box-sizing: border-box;
    background: linear-gradient(324deg, #ffffff, #e0f7e0);
} */
body {
    font-family: 'Jockey One', sans-serif;
    margin: 0;
    background: linear-gradient(324deg, #ffffff, #e0f7e0);
    min-height: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    background-color: #1a1a1a;
    color: #ffffff;
    padding: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.header-left {
    display: flex;
    align-items: center;
}

header h1 {
    margin: 0;
    font-size: clamp(1.5rem, 5vw, 1.8rem);
    font-family: 'Bungee', cursive;
    color: #ffffff;
}

.region-selection {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
    padding: 0.5rem 0;
}

.region-selection-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    padding: 0.5rem 0;
    background: #e0f7e0;
    border-radius: 10px;
    border: 2px solid #28a745;
}

.toggle-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.toggle-group span {
    font-size: clamp(0.9rem, 2.5vw, 1rem);
    font-family: 'Jockey One', sans-serif;
    color: #ffffff;
}

.toggle-group-stats {
    display: flex;
    align-items: center;
    gap: 8px;
}

.toggle-group-stats span {
    font-size: clamp(0.9rem, 2.5vw, 1rem);
    font-family: 'Jockey One', sans-serif;
    color: #000000;
}

.toggle-switch {
    position: relative;
    width: 36px;
    height: 20px;
    background-color: #666;
    border-radius: 18px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.toggle-switch.active {
    background-color: #28a745;
}

.toggle-slider {
    position: absolute;
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background-color: #ffffff;
    border-radius: 50%;
    transition: transform 0.3s ease;
}

.toggle-switch.active .toggle-slider {
    transform: translateX(16px);
}

.game-container {
    max-width: 100%;
    padding: 0 30px;
    text-align: center;
    flex: 1;
    margin-left: auto;
    margin-right: auto;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.header {
    display: flex;
    justify-content: center;
    gap: 90px;
    flex-wrap: wrap;
    position: relative;
    margin-top: 4px;
    z-index: 700;
}

.turns-counter {
    font-size: clamp(1.3rem, 3.5vw, 1.4rem);
    margin-bottom: 12px;
    color: #333;
    font-family: 'Jockey One', sans-serif;
}

.turns-counter .value, .timer .value {
    font-size: clamp(1.5rem, 4vw, 1.6rem);
    font-weight: bold;
}

.timer {
    font-size: clamp(1.3rem, 3.5vw, 1.4rem);
    color: #333;
    font-family: 'Jockey One', sans-serif;
}

.sorting-game {
    display: none;
    position: relative;
    z-index: 500;
}

.sorting-category {
    margin-bottom: 15px;
    background: linear-gradient(44deg, #ffffff, #ebffeb);
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    box-sizing: border-box;
    min-height: 180px;
    width: 100%;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.category-header {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.category-title {
    font-size: clamp(1.4rem, 4vw, 1.6rem);
    font-weight: bold;
    color: #1a1a1a;
    font-family: 'Bungee', cursive;
}

.category-turns {
    font-size: clamp(1.1rem, 3vw, 1.2rem);
    color: #555;
    font-family: 'Jockey One', sans-serif;
}

.position-labels {
    display: grid;
    grid-template-columns: repeat(5, minmax(60px, 100px));
    gap: 8px;
    justify-content: center;
    margin-bottom: 8px;
    max-width: 540px;
    margin-left: auto;
    margin-right: auto;
}

.position-label {
    font-size: clamp(0.9rem, 2.5vw, 1rem);
    color: #666;
    font-family: 'Jockey One', sans-serif;
}

.least-greatest-labels {
    display: grid;
    grid-template-columns: repeat(5, minmax(60px, 100px));
    gap: 8px;
    justify-content: center;
    margin-top: 8px;
    max-width: 540px;
    margin-left: auto;
    margin-right: auto;
}

.least-greatest-label {
    font-size: clamp(0.8rem, 2.2vw, 0.9rem);
    color: #666;
    font-family: 'Jockey One', sans-serif;
    text-align: center;
}

.sorting-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(60px, 100px));
    gap: 8px;
    justify-content: center;
    margin: 0 auto;
    list-style: none;
    padding: 0;
    max-width: 540px;
}

.sortable-item {
    width: 100%;
    height: 88px;
    background-color: #ffffff;
    border: 2px solid #ddd;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    font-size: clamp(0.85rem, 2.2vw, 0.9rem);
    text-align: center;
    padding: 6px;
    margin: 0;
    box-sizing: border-box;
    user-select: none;
    touch-action: manipulation;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.sortable-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.sortable-item .flag {
    height: 24px;
    object-fit: contain;
    border-radius: 4px;
    margin-bottom: 2px;
    border: 1px solid #ffffff;
}

.sortable-item .country-name {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: 'Jockey One', sans-serif;
}

.sortable-item .country-value {
    font-size: clamp(0.75rem, 2vw, 0.8rem);
    margin-top: 4px;
    font-family: 'Jockey One', sans-serif;
}

.sortable-item.correct {
    background-color: #28a745;
    color: #ffffff;
    border: 2px solid #1e7e34;
    cursor: default;
    pointer-events: none;
}

.sortable-item.correct .country-name,
.sortable-item.correct .country-value {
    color: #ffffff;
}

.sortable-item.incorrect {
    background-color: #dc3545;
    color: #ffffff;
}

.sortable-item.incorrect .country-name,
.sortable-item.incorrect .country-value {
    color: #ffffff;
}

.sortable-item.neutral {
    background-color: #ffffff;
    color: #333;
}

.sortable-item.shake {
    animation: shake 0.5s;
}

.sortable-item.empty {
    background-color: #f5f5f5;
    border: 2px dashed #ccc;
    cursor: default;
    pointer-events: none;
}

.sortable-item.empty .flag,
.sortable-item.empty .country-name,
.sortable-item.empty .country-value {
    display: none;
}

.sortable-item.highlight {
    background-color: #e9ecef;
    border: 2px solid #555;
}

@keyframes shake {
    0% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    50% { transform: translateX(4px); }
    75% { transform: translateX(-4px); }
    100% { transform: translateX(0); }
}

.submit-btn-container {
    margin: 20px 0;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    z-index: 600;
}

#submitBtn {
    width: 180px;
    padding: 16px 32px;
    font-size: clamp(1.2rem, 3.2vw, 1.3rem);
}

#shareResultsBtn {
    background-color: #28a745;
    color: #ffffff;
    width: 140px;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: clamp(1rem, 2.8vw, 1.1rem);
    font-family: 'Bungee', cursive;
    transition: background-color 0.3s ease, transform 0.2s ease, box-shadow 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    z-index: 600;
    touch-action: manipulation;
    margin: auto;
}

#shareResultsBtn:hover {
    background-color: #218838;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

#newGameBtn {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 180px;
    padding: 14px 28px;
    font-size: clamp(1.2rem, 3.2vw, 1.3rem);
    margin: auto;
}

.btn.primary {
    background-color: #28a745;
    color: #ffffff;
    width: 140px;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: clamp(1rem, 2.8vw, 1.1rem);
    font-family: 'Bungee', cursive;
    transition: background-color 0.3s ease, transform 0.2s ease, box-shadow 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    z-index: 600;
}

.btn.primary:hover {
    background-color: #218838;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.status-message {
    font-size: clamp(1rem, 2.8vw, 1.2rem);
    margin: 20px 0;
    color: #333;
    font-family: 'Jockey One', sans-serif;
    max-width: 480px;
    margin-left: auto;
    margin-right: auto;
}

.copy-notification {
    display: none;
    position: fixed;
    top: 20%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: #28a745;
    color: #ffffff;
    padding: 10px 20px;
    border-radius: 6px;
    font-family: 'Jockey One', sans-serif;
    font-size: clamp(0.9rem, 2.5vw, 1rem);
    transition: opacity 0.5s ease;
    z-index: 1001;
}

.copy-notification.show {
    display: block;
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background: linear-gradient(135deg, #ffffff, #f0f9f0);
    margin: 5% auto;
    padding: 20px;
    border: none;
    width: 90%;
    max-width: 500px;
    border-radius: 12px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
    position: relative;
    transform: translateY(-20px);
    animation: slideIn 0.5s ease forwards;
}

.modal-content h2 {
    font-family: 'Bungee', cursive;
    color: #1a1a1a;
    margin: 0 0 15px 0;
    font-size: clamp(1.6rem, 4.5vw, 1.8rem);
    text-align: center;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

.modal-content h3 {
    font-family: 'Bungee', cursive;
    color: #1a1a1a;
    margin: 15px 0 10px;
    font-size: clamp(1.4rem, 4vw, 1.6rem);
    text-align: center;
}

.best-game-table {
    width: 100%;
    border-collapse: collapse;
    margin: 10px 0;
    font-family: 'Jockey One', sans-serif;
    background: #f9f9f9;
    border-radius: 8px;
    overflow: hidden;
}

.best-game-table th,
.best-game-table td {
    padding: 10px;
    text-align: center;
    font-size: clamp(0.9rem, 2.5vw, 1rem);
    color: #333;
}

.best-game-table th {
    background-color: #28a745;
    color: #ffffff;
    font-weight: normal;
}

.best-game-table td {
    border-top: 1px solid #ddd;
}

.best-game-table tr:hover {
    background-color: #e0f7e0;
}

@keyframes slideIn {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.close-modal {
    color: #666;
    float: right;
    font-size: clamp(1.5rem, 4vw, 1.8rem);
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s ease, transform 0.3s ease;
}

.close-modal:hover,
.close-modal:focus {
    color: #000;
    transform: scale(1.2);
}

.settings-option {
    margin: 10px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    accent-color: #00a707;
    background: #f9f9f9;
    padding: 6px;
    border-radius: 8px;
    transition: background 0.3s ease, transform 0.3s ease;
}

.settings-option:hover {
    background: #e0f7e0;
    transform: translateY(-2px);
}

.settings-option label {
    font-size: clamp(1rem, 2.8vw, 1.2rem);
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: 'Jockey One', sans-serif;
    color: #333;
}

.imperial-units-toggle {
    background: #e7f7e7;
    border-radius: 6px;
    padding: 5px;
    width: 140px;
    border: 2px solid #28a745;
    justify-content: space-between;
    margin-left: auto;
    margin-right: auto;
}

.settings-footer {
    display: flex;
    justify-content: center;
    margin-top: 20px;
}

#daysPlayed, #dailyStreak, #bestGame {
    font-size: clamp(1rem, 2.8vw, 1.2rem);
    margin: 15px 0;
    color: #333;
    font-family: 'Jockey One', sans-serif;
    background: #f9f9f9;
    padding: 10px;
    border-radius: 8px;
}

#daysPlayed:hover, #dailyStreak:hover {
    background: #e0f7e0;
    transform: translateY(-2px);
}

.how-to-play {
    background: linear-gradient(135deg, #ffffff, #e0f7e0);
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
    max-width: 600px;
    margin-top: 20px;
    margin-left: auto;
    margin-right: auto;
    transform: translateY(-10px);
    animation: fadeIn 0.5s ease forwards;
}

.how-to-play h2 {
    font-family: 'Bungee', cursive;
    color: #1a1a1a;
    font-size: clamp(1.6rem, 4.5vw, 1.8rem);
    margin: 0 0 15px 0;
    text-align: center;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

.how-to-play p {
    font-family: 'Jockey One', sans-serif;
    font-size: clamp(1.2rem, 3.2vw, 1.4rem);
    color: #333;
    margin: 15px 0;
    line-height: 1.6;
    transition: transform 0.3s ease;
    border-radius: 8px;
}

.how-to-play p:hover {
    /* transition: background 0.5s ease, transform 0.3s 
    ease; */
    /* background: #e0f7e062; */
    transform: translateY(-3px);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

footer {
    background-color: #1a1a1a;
    color: #ffffff;
    text-align: center;
    padding: 0.8rem;
    font-family: 'Jockey One', sans-serif;
    font-size: clamp(0.9rem, 2.5vw, 1rem);
    margin-top: auto;
}

/* Media Queries for Mobile Optimization */
@media (max-width: 768px) {
    header {
        flex-direction: column;
        align-items: center;
        padding: 0.5rem;
    }

    .header-left {
        margin-bottom: 0.5rem;
    }

    .region-selection {
        justify-content: center;
        gap: 6px;
    }

    .region-selection-stats {
        gap: 6px;
        justify-content: center;
    }

    .toggle-group {
        gap: 6px;
    }

    .game-container {
        padding: 0 5px;
    }

    .sorting-grid {
        grid-template-columns: repeat(5, minmax(50px, 80px));
        gap: 6px;
        max-width: 430px;
    }

    .position-labels {
        grid-template-columns: repeat(5, minmax(50px, 80px));
        gap: 6px;
        max-width: 430px;
    }

    .least-greatest-labels {
        grid-template-columns: repeat(5, minmax(50px, 80px));
        gap: 6px;
        max-width: 430px;
    }

    .sorting-category {
        padding: 12px;
        min-height: 160px;
        max-width: 450px;
    }

    .sortable-item {
        height: 70px;
        padding: 5px;
        font-size: clamp(0.8rem, 2vw, 0.85rem);
    }

    .sortable-item .flag {
        height: 20px;
    }

    .sortable-item .country-value {
        font-size: clamp(0.7rem, 1.8vw, 0.75rem);
    }

    .how-to-play {
        padding: 15px;
        margin-bottom: 15px;
        max-width: 95%;
    }

    .how-to-play h2 {
        font-size: clamp(1.4rem, 4vw, 1.6rem);
    }

    .how-to-play p {
        font-size: clamp(1rem, 2.8vw, 1.2rem);
    }

    #newGameBtn {
        width: 140px;
        padding: 10px 20px;
        font-size: clamp(1rem, 2.8vw, 1.1rem);
    }

    .btn.primary {
        padding: 8px 16px;
        width: 120px;
        font-size: clamp(0.9rem, 2.5vw, 1rem);
        z-index: 600;
    }

    #submitBtn {
        width: 140px;
        padding: 10px 20px;
        font-size: clamp(1rem, 2.8vw, 1.1rem);
    }

    .submit-btn-container {
        margin: 15px 0;
    }

    .modal-content {
        margin: 20% auto;
        padding: 15px;
        width: 95%;
    }

    .modal-content h2 {
        font-size: clamp(1.4rem, 4vw, 1.6rem);
    }

    .modal-content h3 {
        font-size: clamp(1.2rem, 3.5vw, 1.4rem);
    }

    .best-game-table th,
    .best-game-table td {
        padding: 8px;
        font-size: clamp(0.8rem, 2.2vw, 0.9rem);
    }

    .least-greatest-label {
        font-size: clamp(0.75rem, 2vw, 0.85rem);
    }

    .settings-option {
        align-items: flex-start;
    }

    .imperial-units-toggle {
        align-self: flex-end;
    }
}

@media (max-width: 480px) {
    .sorting-grid {
        grid-template-columns: repeat(5, minmax(45px, 70px));
        gap: 4px;
        max-width: 366px;
    }

    .position-labels {
        grid-template-columns: repeat(5, minmax(45px, 70px));
        gap: 4px;
        max-width: 366px;
    }

    .least-greatest-labels {
        grid-template-columns: repeat(5, minmax(45px, 70px));
        gap: 4px;
        max-width: 366px;
    }

    .sorting-category {
        padding: 10px;
        min-height: 140px;
        max-width: 380px;
    }

    .sortable-item {
        font-size: clamp(0.75rem, 1.8vw, 0.8rem);
    }

    .sortable-item .flag {
        height: 18px;
    }

    .category-title {
        font-size: clamp(1.2rem, 3.5vw, 1.4rem);
    }

    .category-turns {
        font-size: clamp(0.9rem, 2.5vw, 1rem);
    }

    .least-greatest-label {
        font-size: clamp(0.7rem, 1.8vw, 0.8rem);
    }

    .how-to-play {
        padding: 10px;
        margin-bottom: 10px;
        max-width: 95%;
    }

    .how-to-play h2 {
        font-size: clamp(1.2rem, 3.5vw, 1.4rem);
    }

    .how-to-play p {
        font-size: clamp(0.9rem, 2.5vw, 1rem);
    }

    .btn.primary {
        width: 100px;
        font-size: clamp(0.8rem, 2vw, 0.9rem);
    }

    .best-game-table th,
    .best-game-table td {
        padding: 6px;
        font-size: clamp(0.75rem, 1.8vw, 0.8rem);
    }

    #submitBtn {
        width: 120px;
        font-size: clamp(0.9rem, 2.3vw, 1rem);
    }

    .modal-content h2 {
        font-size: clamp(1.2rem, 3.5vw, 1.4rem);
    }

    .modal-content h3 {
        font-size: clamp(1rem, 3vw, 1.2rem);
    }

    .modal-content {
        margin: 25% auto;
        padding: 10px;
    }

    #newGameBtn {
        width: 120px;
        padding: 8px 16px;
        font-size: clamp(0.9rem, 2.3vw, 1rem);
    }
}