@import url("https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Fraunces:opsz,wght@9..144,700;9..144,800&display=swap");

:root {
    --ink: #10182b;
    --muted: #687086;
    --paper: #f4f0e8;
    --card: #fffdf8;
    --line: #ddd7cc;
    --bulgaria: #198754;
    --bulgaria-soft: #e5f3ec;
    --france: #2457c5;
    --france-soft: #e8eefc;
    --red: #d93845;
    --gold: #f2bd48;
    --shadow: 0 24px 70px rgba(22, 28, 45, 0.13);
}

* {
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    background:
        radial-gradient(circle at 10% 10%, rgba(25, 135, 84, 0.14), transparent 28%),
        radial-gradient(circle at 90% 85%, rgba(36, 87, 197, 0.14), transparent 30%),
        var(--paper);
    font-family: "DM Sans", sans-serif;
}

button,
select,
input {
    font: inherit;
}

button {
    color: inherit;
}

.game-shell {
    width: min(920px, calc(100% - 32px));
    margin: 0 auto;
    padding: 22px 0 48px;
}

.topbar {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    margin-bottom: 20px;
}

.brand {
    text-align: center;
}

.brand-kicker,
.eyebrow {
    display: block;
    color: var(--muted);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

.brand h1 {
    margin: 2px 0 0;
    font-family: "Fraunces", serif;
    font-size: clamp(1.45rem, 4vw, 2rem);
}

.back-link {
    justify-self: start;
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
}

.back-link:hover {
    color: var(--ink);
}

.icon-button {
    width: 42px;
    height: 42px;
    justify-self: end;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: rgba(255, 253, 248, 0.75);
    cursor: pointer;
}

.icon-button[aria-pressed="true"] {
    color: var(--muted);
    text-decoration: line-through;
}

.scoreboard {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    overflow: hidden;
    margin-bottom: 18px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--card);
    box-shadow: 0 8px 30px rgba(22, 28, 45, 0.07);
}

.team {
    display: flex;
    gap: 14px;
    align-items: center;
    padding: 17px 22px;
    transition: background 180ms ease;
}

.team-france {
    justify-content: flex-end;
    text-align: right;
}

.team.active.team-bulgaria {
    background: var(--bulgaria-soft);
}

.team.active.team-france {
    background: var(--france-soft);
}

.flag {
    font-size: 2rem;
    filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.12));
}

.team-name {
    display: block;
    color: var(--muted);
    font-size: 0.77rem;
    font-weight: 700;
    text-transform: uppercase;
}

.score {
    display: block;
    margin-top: -3px;
    font-family: "Fraunces", serif;
    font-size: 2rem;
    line-height: 1;
}

.match-status {
    display: flex;
    min-width: 100px;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 10px 18px;
    border-right: 1px solid var(--line);
    border-left: 1px solid var(--line);
    color: var(--muted);
    font-size: 0.72rem;
}

.match-status strong {
    color: var(--ink);
    font-size: 0.95rem;
}

.panel {
    position: relative;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 26px;
    background: rgba(255, 253, 248, 0.94);
    box-shadow: var(--shadow);
}

.setup {
    padding: clamp(28px, 6vw, 56px);
}

.setup-heading {
    max-width: 550px;
    margin-bottom: 34px;
}

.setup-heading h2,
.results h2 {
    margin: 6px 0 8px;
    font-family: "Fraunces", serif;
    font-size: clamp(2rem, 6vw, 3.35rem);
    line-height: 1.05;
}

.setup-heading p,
.results p {
    margin: 0;
    color: var(--muted);
    line-height: 1.6;
}

.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    margin-bottom: 30px;
}

.setting {
    display: flex;
    min-width: 0;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 12px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fff;
    font-size: 0.9rem;
    font-weight: 700;
}

.setting output {
    color: var(--france);
}

.setting input[type="range"] {
    width: 100%;
    accent-color: var(--france);
}

.setting select {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: var(--card);
}

.direction-setting {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    margin: 0;
}

.direction-setting legend {
    padding: 0 6px;
}

.direction-setting label {
    color: var(--muted);
    font-weight: 500;
}

.direction-setting input {
    accent-color: var(--bulgaria);
}

.primary-button,
.reveal-button {
    display: flex;
    width: 100%;
    justify-content: center;
    align-items: center;
    gap: 12px;
    padding: 16px 22px;
    border: 0;
    border-radius: 13px;
    color: #fff;
    background: var(--ink);
    font-weight: 700;
    cursor: pointer;
    transition: transform 150ms ease, box-shadow 150ms ease;
}

.primary-button:hover,
.reveal-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(16, 24, 43, 0.22);
}

.primary-button span {
    font-size: 1.2rem;
}

.setup-error {
    min-height: 1.4em;
    margin: 10px 0 0;
    color: var(--red);
    font-size: 0.85rem;
    text-align: center;
}

.play-area {
    min-height: 590px;
    padding: 36px clamp(22px, 6vw, 60px) 24px;
    text-align: center;
}

.progress-track {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 6px;
    background: var(--line);
}

.progress-fill {
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, var(--bulgaria), var(--gold), var(--france));
    transition: width 300ms ease;
}

.turn-banner {
    display: flex;
    max-width: 460px;
    align-items: center;
    gap: 10px;
    margin: 0 auto 20px;
    padding: 10px 12px;
    border-radius: 12px;
    background: var(--paper);
    text-align: left;
}

.turn-banner > span:first-child {
    font-size: 1.7rem;
}

.turn-banner div span {
    display: block;
    color: var(--muted);
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
}

.turn-banner strong {
    font-size: 0.9rem;
}

.difficulty {
    margin-left: auto;
    padding: 6px 9px;
    border-radius: 30px;
    color: #765407;
    background: #fff0c9;
    font-size: 0.72rem;
    font-weight: 700;
}

.match-commentary {
    min-height: 1.4em;
    margin: -8px 0 12px;
    color: var(--muted);
    font-family: "Fraunces", serif;
    font-size: 0.88rem;
    font-style: italic;
}

.match-commentary.celebrate {
    color: var(--bulgaria);
    font-style: normal;
    font-weight: 700;
    animation: commentary-pop 420ms ease-out;
}

.match-commentary.oops {
    color: var(--red);
    animation: commentary-wobble 360ms ease-out;
}

.timer {
    position: relative;
    width: 104px;
    height: 104px;
    margin: 0 auto 17px;
}

.timer svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.timer circle {
    fill: none;
    stroke-width: 7;
}

.timer-track {
    stroke: var(--line);
}

.timer-progress {
    stroke: var(--bulgaria);
    stroke-linecap: round;
    transition: stroke-dashoffset 100ms linear, stroke 200ms ease;
}

.timer.urgent .timer-progress {
    stroke: var(--red);
}

.timer.urgent .timer-number strong {
    color: var(--red);
}

.timer.tick {
    animation: timer-tick 240ms ease-out;
}

.timer-number {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.timer-number strong {
    font-family: "Fraunces", serif;
    font-size: 2rem;
    line-height: 0.85;
}

.timer-number span {
    color: var(--muted);
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
}

.word-card {
    min-height: 198px;
    max-width: 560px;
    margin: 0 auto 18px;
    padding: 27px 24px 22px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 10px 30px rgba(22, 28, 45, 0.07);
}

.route {
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.word {
    overflow-wrap: anywhere;
    margin: 16px 0 2px;
    font-family: "Fraunces", serif;
    font-size: clamp(2.25rem, 8vw, 4rem);
    font-weight: 800;
    line-height: 1;
}

.pronunciation {
    min-height: 1.3em;
    color: var(--muted);
    font-size: 0.84rem;
    font-style: italic;
}

.answer {
    margin-top: 18px;
    padding-top: 15px;
    border-top: 1px dashed var(--line);
}

.answer span {
    display: block;
    color: var(--muted);
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
}

.answer strong {
    font-size: 1.35rem;
}

.reveal-button {
    max-width: 560px;
    margin: 0 auto;
    background: var(--france);
}

.judge-actions {
    display: grid;
    max-width: 560px;
    grid-template-columns: 1fr 1.3fr;
    gap: 12px;
    margin: 0 auto;
}

.judge-button {
    padding: 15px 13px;
    border: 1px solid;
    border-radius: 13px;
    font-weight: 700;
    cursor: pointer;
}

.judge-button span {
    margin-right: 6px;
}

.missed {
    border-color: #ebc2c6;
    color: #9c2630;
    background: #fff0f1;
}

.correct {
    border-color: #afd6c0;
    color: #11653c;
    background: var(--bulgaria-soft);
}

.judge-button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.keyboard-hint {
    margin: 14px 0 0;
    color: var(--muted);
    font-size: 0.72rem;
}

.results {
    padding: clamp(40px, 8vw, 72px);
    text-align: center;
}

.trophy {
    margin-bottom: 13px;
    font-size: 4rem;
}

.final-score {
    display: grid;
    max-width: 480px;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 20px;
    margin: 34px auto;
}

.final-score div {
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fff;
}

.final-score div span {
    display: block;
    color: var(--muted);
    font-size: 0.8rem;
}

.final-score strong {
    font-family: "Fraunces", serif;
    font-size: 2.8rem;
}

.text-button {
    margin-top: 15px;
    border: 0;
    color: var(--muted);
    background: none;
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
}

@keyframes timer-tick {
    0% { transform: scale(1); }
    45% { transform: scale(1.12) rotate(-2deg); }
    100% { transform: scale(1); }
}

@keyframes commentary-pop {
    0% { opacity: 0; transform: translateY(5px) scale(0.96); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes commentary-wobble {
    0%, 100% { transform: translateX(0); }
    30% { transform: translateX(-5px); }
    60% { transform: translateX(4px); }
}

.hidden {
    display: none !important;
}

@media (max-width: 620px) {
    .game-shell {
        width: min(100% - 20px, 920px);
        padding-top: 12px;
    }

    .topbar {
        margin-bottom: 12px;
    }

    .brand-kicker,
    .keyboard-hint {
        display: none;
    }

    .scoreboard {
        border-radius: 14px;
    }

    .team {
        gap: 8px;
        padding: 12px 10px;
    }

    .flag {
        font-size: 1.45rem;
    }

    .team-name {
        font-size: 0.62rem;
    }

    .score {
        font-size: 1.55rem;
    }

    .match-status {
        min-width: 72px;
        padding: 8px;
    }

    .match-status > span {
        display: none;
    }

    .settings-grid,
    .direction-setting {
        grid-template-columns: 1fr;
    }

    .direction-setting {
        grid-column: auto;
    }

    .play-area {
        min-height: 0;
        padding-top: 28px;
    }

    .timer {
        width: 88px;
        height: 88px;
        margin-bottom: 12px;
    }

    .word-card {
        min-height: 180px;
    }

    .judge-actions {
        grid-template-columns: 1fr 1.2fr;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition: none !important;
    }
}
