[hidden] {
    display: none !important;
}

:root {
    --rated-flag-width: 3.3rem;
    --rated-flag-gap: 0.45rem;
}

@media (max-width: 23rem) {
    :root {
        --rated-flag-width: 2.6rem;
        --rated-flag-gap: 0.3rem;
    }
}

body {
    font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    color: #1f2937;
    line-height: 1.5;
}

h1 {
    margin: 1.25rem 0 0.75rem;
    text-align: center;
    font-size: clamp(2rem, 4vw, 2.6rem);
    font-weight: 800;
    letter-spacing: -0.04em;
    color: #172554;
}

p {
    margin: 0.5rem auto;
    text-align: center;
    max-width: 42rem;
    color: #334155;
    font-size: 1rem;
}

#answer {
    width: 100%;
    min-width: 0;
    font-size: 1.25rem;
    height: 2.9rem;
    padding: 0 1rem;
    box-sizing: border-box;
    background: #fff;
    border: 2px solid #cbd5e1;
    border-radius: 0.85rem;
    box-shadow: inset 0 3px 6px rgba(15, 23, 42, 0.16), inset 0 -2px 0 rgba(255, 255, 255, 0.9), 0 1px 2px rgba(15, 23, 42, 0.06);
}

#answer:focus {
    outline: none;
    border-color: #4f46e5;
    box-shadow: inset 0 3px 6px rgba(15, 23, 42, 0.12), 0 0 0 3px rgba(79, 70, 229, 0.25);
}

#answer-wrapper {
    position: relative;
    display: inline-flex;
    width: 100%;
    flex: 1 1 auto;
}

.answer-suggestions {
    position: absolute;
    left: 0;
    top: 100%;
    width: 100%;
    background: white;
    border: 1px solid #d1d5db;
    border-top: 0;
    border-radius: 0 0 0.75rem 0.75rem;
    box-shadow: 0 10px 20px rgba(15, 23, 42, 0.12);
    z-index: 30;
    max-height: 12rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.answer-suggestions[hidden] {
    display: none;
}

.country-suggestion {
    width: 100%;
    border: 0;
    background: transparent;
    padding: 0.55rem 0.75rem;
    text-align: left;
    font-size: 0.95rem;
    cursor: pointer;
    color: #111827;
}

.country-suggestion.active,
.country-suggestion:hover,
.country-suggestion:focus {
    background: #eef2ff;
    outline: none;
}

#submit,
#skip,
#replay,
#share {
    cursor: pointer;
    height: 2.25rem;
    color: white;
    width: 100%;
    max-width: none;
    flex: none;
    border: none;
    border-radius: 0.85rem;
    font-weight: 700;
    box-shadow: 0 6px 14px rgba(20, 35, 90, 0.18);
}

#submit {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
}

#skip {
    background: linear-gradient(135deg, #64748b, #94a3b8);
}

#replay {
    background: linear-gradient(135deg, #0ea5e9, #2563eb);
}

#buttons-div {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin: 1rem 0;
}

#buttons-div > button {
    width: 100%;
    max-width: none;
}

@media (min-width: 700px) {
    #buttons-div {
        flex-direction: row;
        justify-content: center;
        max-width: 34rem;
        margin: 1rem auto;
    }

    #buttons-div > button {
        width: min(14rem, 50%);
        max-width: 14rem;
    }

    #buttons-div > button#replay {
        width: 20rem;
        max-width: calc(100vw - 9rem);
        margin: 0 auto;
    }
}

#study-controls {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.75rem;
    margin: 1rem 0;
}

#study-controls > button,
.mode-toggle-btn {
    height: 2.5rem;
    cursor: pointer;
    border: none;
    border-radius: 0.85rem;
    font-weight: 700;
    box-shadow: 0 6px 14px rgba(20, 35, 90, 0.18);
}

#study-prev,
#study-next {
    width: 5rem;
    max-width: none;
    flex: 0 0 5rem;
    color: white;
    background: linear-gradient(135deg, #0ea5e9, #2563eb);
}

.mode-toggle {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.5rem;
    margin-top: 1.5rem;
}

.mode-toggle-btn {
    width: 100%;
    max-width: none;
    background: linear-gradient(135deg, #fdf2f8, #ede9fe);
    color: #1f2937;
    border: 2px solid rgba(79, 70, 229, 0.15);
    border-radius: 0.9rem;
    font-weight: 700;
    box-shadow: 0 4px 10px rgba(79, 70, 229, 0.08);
}

.rating-buttons {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.5rem;
    width: min(100%, 30rem);
    margin: 1rem auto;
}

.rating-tier {
    height: 2.6rem;
    border: none;
    border-radius: 0.85rem;
    font-weight: 800;
    cursor: pointer;
    background: linear-gradient(135deg, #f8fafc, #e2e8f0);
    color: #1f2937;
    box-shadow: 0 6px 14px rgba(20, 35, 90, 0.12);
}

.rating-tier:hover,
.rating-tier:focus {
    transform: translateY(-1px);
}

.mode-toggle-btn.active {
    background: linear-gradient(135deg, #22c55e, #14b8a6);
    color: white;
    border-color: rgba(20, 184, 166, 0.3);
    box-shadow: 0 8px 18px rgba(34, 197, 94, 0.25);
}

#continent-buttons {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    margin: 1rem 0 1.25rem;
}

.continent-btn {
    margin: 0;
    padding: 0.6rem 1rem;
    font-size: 0.96rem;
    font-weight: 700;
    color: #1f2937;
    background: linear-gradient(135deg, #f8fafc, #e2e8f0);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: 0.85rem;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.continent-btn:hover,
.continent-btn:focus {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.12);
}

.continent-btn.active {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
    border-color: rgba(37, 99, 235, 0.35);
    box-shadow: 0 8px 18px rgba(37, 99, 235, 0.2);
}

.continent-btn:disabled {
    opacity: 0.45;
    box-shadow: none;
    cursor: not-allowed;
}

.continent-btn:disabled:hover,
.continent-btn:disabled:focus {
    transform: none;
    box-shadow: none;
}

#country[hidden],
#score[hidden],
#progress[hidden] {
    display: none !important;
}

#flag-container {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: center;
    min-height: 12rem;
    margin: 0 auto;
    padding: 0;
    width: min(100%, 20rem);
    background: linear-gradient(135deg, #f8fafc, #e2e8f0);
    border: 1px solid rgba(59, 130, 246, 0.18);
    border-radius: 1.1rem;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7), 0 10px 22px rgba(15, 23, 42, 0.08);
    overflow: hidden;
}

/* The flag is the whole question here, so it gets far more room than the
   thumbnail-sized hint flag in the capitals game. */
#country-flag {
    width: 100%;
    height: auto;
    object-fit: contain;
    border-radius: 0;
    box-shadow: none;
    display: block;
    margin: 0;
}

#country-flag[hidden], #flag-missing[hidden] {
    display: none;
}

#flag-missing {
    font-style: italic;
    color: #555;
}

#input-div {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin: 1rem auto;
    flex-wrap: nowrap;
}

/* two 14rem buttons and the 0.75rem gap between them */
@media (min-width: 700px) {
    #input-div {
        width: min(100%, 28.75rem);
    }
}

#input-div > #country {
    min-width: 0;
}

#input-div[data-mode="study"] #answer-wrapper {
    width: auto !important;
    max-width: none !important;
}

#countries-list {
    width: 20rem;
    max-width: calc(100vw - 9rem);
}

#country {
    margin: 0;
    font-weight: bold;
    font-size: 1rem;
    color: #111;
}

#input-div[data-mode="rate"] > #country {
    font-size: 1.35rem;
}

#reveal-answer {
    height: 2.5rem;
    min-width: 8.5rem;
    padding: 0 1rem;
    cursor: pointer;
    background: linear-gradient(135deg, #fef3c7, #fcd34d);
    color: #1f2937;
    border: none;
    border-radius: 0.85rem;
    font-weight: 700;
    box-shadow: 0 6px 14px rgba(20, 35, 90, 0.18);
}

#reveal-answer.revealed {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: white;
}

#answers-table {
    margin-top: 1rem;
    border-collapse: collapse;
}

#answers-table tr {
    border: 1px solid black;
}

#answers-table tr th, #answers-table tr td {
    border: 1px solid black;
    padding: 0.5rem;
}

.answer-flag {
    width: 3rem;
    height: 2rem;
    object-fit: contain;
    display: block;
}

#feedback {
    margin: 0.5rem auto 0;
    font-size: 1.2rem;
    font-weight: bold;
    text-align: center;
    white-space: pre-line;
}

#feedback:empty {
    margin: 0;
}

#score, #progress {
    width: 100%;
    display: flex;
    justify-content: center;
    /* the flex container collapses the whitespace around the <span>s, so the
       gap puts the spacing back between "Progress:" and "1 / 201" */
    gap: 0.35rem;
    margin: 0.5rem auto;
}

#answers-table {
    margin-left: auto;
    margin-right: auto;
}

#share {
    display: block;
    width: 20rem;
    max-width: calc(100vw - 9rem);
    height: 2.25rem;
    margin: 1rem auto;
    padding: 0 1.5rem;
    color: white;
    background: linear-gradient(135deg, #67e8f9, #22d3ee, #0891b2);
    cursor: pointer;
}

#rate-own-flag {
    display: block;
    width: 20rem;
    max-width: calc(100vw - 9rem);
    height: 2.25rem;
    margin: 0.5rem auto 1rem;
    padding: 0 1.5rem;
    color: #1f2937;
    background: linear-gradient(135deg, #fef3c7, #fcd34d);
    border: none;
    border-radius: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 6px 14px rgba(20, 35, 90, 0.12);
}

#replay {
    display: block;
    width: 20rem;
    max-width: calc(100vw - 9rem);
    margin: 1rem auto;
}

#share[hidden],
#replay[hidden] {
    display: none !important;
}

.ratings-table {
    margin: 1.1rem auto 0;
    border-collapse: collapse;
    font-size: 1.5rem;
}

.ratings-table th {
    width: 3rem;
    padding: 0.45rem 1.1rem 0.45rem 0;
    text-align: right;
    vertical-align: middle;
    color: #1f2937;
}

.ratings-table td {
    padding: 0.45rem 0;
    text-align: left;
    vertical-align: middle;
}

.ratings-table tr + tr th,
.ratings-table tr + tr td {
    border-top: 1px solid rgba(15, 23, 42, 0.14);
}

.rated-flags {
    display: grid;
    grid-template-columns: repeat(5, var(--rated-flag-width));
    gap: var(--rated-flag-gap);
    justify-items: center;
    align-items: center;
}

.rated-flags-empty {
    display: block;
    color: #94a3b8;
}

.rated-flag {
    width: var(--rated-flag-width);
    height: calc(var(--rated-flag-width) / 1.571);
    object-fit: cover;
    border-radius: 0.3rem;
    margin: 0;
    border: 1px solid rgba(15, 23, 42, 0.12);
    vertical-align: middle;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.08);
}
