:root {
    --bg: #121212;
    --surface: #282829;
    --text: #e8e8e8;
    --correct: #6a994e;
    --wrong: #bc4749;
}

body.light {
    --bg: #e9e9e9;
    --surface: #ffffff;
    --text: #222;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: "Inter Tight", sans-serif;
}

body {
    background: var(--bg);
    padding: 32px;
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

::selection {
    background: var(--text);
    color: var(--bg);
}

/* Top bar */
.topbar {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    font-family: "Inter Tight", sans-serif;
    font-size: 22px;
    font-weight: 800;
    letter-spacing: 0.06em;
}

.topbar-right {
    display: flex;
    align-items: stretch;
    gap: 8px;
}

.theme-toggle {
    background: var(--surface);
    border-radius: 8px;
    padding: 4px;
}

.theme-btn {
    padding: 5px 10px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--text);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}

.theme-btn:hover {
    background: var(--bg);
}

.lang-dropdown {
    background: var(--surface);
    border-radius: 8px;
    position: relative;
    padding: 4px;
}

.lang-selected {
    display: flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    padding: 5px 12px;
    border: none;
    border-radius: 8px;
    color: var(--text);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.1em;
    cursor: pointer;
    transition: border-color 0.15s;
}

.lang-selected:hover {
    background: var(--bg);
}

.lang-options {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: var(--surface);
    border-radius: 8px;
    overflow: hidden;
    z-index: 100;
    min-width: 120px;
    padding: 4px;
}

.lang-options > .lang-option:not(:last-of-type) {
    margin-bottom: 4px;
}

.lang-dropdown.open .lang-options {
    display: block;
}

.lang-option {
    display: block;
    width: 100%;
    padding: 8px 14px;
    border: none;
    border-radius: 6px;
    background: transparent;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: var(--text);
    cursor: pointer;
    text-align: left;
    transition: background 0.1s, color 0.1s;
}

.lang-option:hover {
    background: var(--bg);
}

.lang-option.active {
    background: var(--bg);
}

/* Region toggle */
.region-toggle {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    justify-content: center;
    background: var(--surface);
    border-radius: 8px;
    padding: 4px;
}

.region-btn {
    padding: 5px 12px;
    border: none;
    background: transparent;
    color: var(--text);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.06em;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.15s;
}

.region-btn:hover {
    background: var(--bg);
}

.region-btn.active {
    background: var(--bg);
}

/* Stats bar */
.stats {
    display: flex;
    gap: 8px;
}

.stat-pill {
    background: var(--surface);
    border-radius: 8px;
    padding: 5px 14px;
    font-size: 12px;
    letter-spacing: 0.04em;
}

.stat-pill span {
    font-weight: 700;
}

/* Card */
.card {
    background: var(--surface);
    border-radius: 16px;
    padding: 28px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    position: relative;
    overflow: hidden;
}

.flag-container img.emoji {
    width: 140px;
    height: auto;
    display: block;
}

.flag-container {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 128px;
    line-height: 1;
    filter: drop-shadow(0 8px 24px rgba(0,0,0,0.5));
    transition: transform 0.3s cubic-bezier(.34,1.56,.64,1), opacity 0.2s;
}

.flag-container.hide {
    opacity: 0;
    transform: scale(0.7) translateY(-10px);
}

.flag-container.show {
    animation: flagIn 0.4s cubic-bezier(.34,1.56,.64,1) forwards;
}

@keyframes flagIn {
    from { opacity: 0; transform: scale(0.7) translateY(-10px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* Input row */
.input-row {
    position: relative;
    display: flex;
    gap: 8px;
}

.guess-input {
    background: var(--bg);
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 13px 16px;
    color: var(--text);
    font-size: 14px;
    letter-spacing: 0.1em;
    transition: border-color 0.15s;
}

.guess-input:focus {
    outline: none;
}

.guess-input.correct {
    border-color: var(--correct);
    background: rgba(0,255,136,0.06);
}

.guess-input.wrong {
    border-color: var(--wrong);
    background: rgba(255,68,102,0.06);
}

/* Skip & Hint */
.bottom-options {
    display: flex;
    gap: 16px;
}

.small-btn {
    background: none;
    border: none;
    color: var(--text);
    font-size: 12px;
    cursor: pointer;
    letter-spacing: 0.1em;
    transition: color 0.15s;
    text-decoration: underline;
    text-underline-offset: 3px;
    padding: 0;
    position: relative;
}

.small-btn:hover { color: var(--text); }

.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 7px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg);
    color: var(--text);
    font-size: 11px;
    letter-spacing: 0.1em;
    padding: 3px 8px;
    border-radius: 5px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s;
}

.tooltip:hover::after {
    opacity: 1;
}

/* Progress bar */
.progress-wrap {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 16px;
}

.progress-bar-bg {
    width: 100%;
    height: 3px;
    background: var(--surface);
    border-radius: 2px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--text);
    border-radius: 2px;
    transition: width 0.4s cubic-bezier(.4,0,.2,1);
}

.progress-label {
    font-size: 12px;
    color: var(--text);
    letter-spacing: 0.1em;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Guessed grid */
.flag-grid {
    width: 100%;
    display: grid;
    justify-content: center;
    grid-template-columns: repeat(auto-fill, 72px);
    gap: 12px;
    max-height: 40vh;
    overflow-y: auto;
    padding-top: 12px;
    scrollbar-color: var(--surface) transparent;
    scrollbar-gutter: stable;
}

.flag-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: flagIn 0.35s cubic-bezier(.34,1.56,.64,1) forwards;
}

.flag-item .small-flag {
    font-size: 36px;
    transition: transform 0.2s;
    filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.4));

}

.small-flag:hover {
    transform: scale(1.6);
}

.small-flag img.emoji {
    width: 36px;
    height: auto;
}

.guessed-name {
    font-size: 12px;
    color: var(--text);
    text-align: center;
    letter-spacing: 0.1em;
}

.flag-item .skipped-name {
    font-size: 12px;
    color: var(--text);
    text-align: center;
    letter-spacing: 0.1em;
}



/* Finish screen */
.finish-screen {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    animation: flagIn 0.5s ease forwards;
}

.finish-screen.visible { display: flex; }

.finish-emoji { font-size: 64px; }

.finish-title {
    font-family: "Inter Tight", sans-serif;
    font-size: 32px;
    font-weight: 800;
}

.finish-sub {
    width: 100%;
    font-size: 16px;
    letter-spacing: 0.1em;
    display: flex;
    align-items: center;
    justify-content: space-around;
}

.restart-btn {
    margin-top: 8px;
    background: var(--text);
    color: var(--bg);
    border: none;
    border-radius: 10px;
    padding: 13px 32px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    letter-spacing: 0.1em;
    transition: opacity 0.15s, transform 0.15s;
}

.restart-btn:hover { opacity: 0.85; transform: scale(1.03); }

.content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}