:root {
    --bg: #fdf8f2;
    --surface: #ffffff;
    --border: #ecddd0;
    --brown: #7c5c3e;
    --brown-lt: #c8a882;
    --accent: #e8743b;
    --accent-lt: #fdf0e4;
    --green: #4caf74;
    --red: #e05c5c;
    --text: #2d2015;
    --muted: #8a7060;
    --radius: 16px;
    --shadow: 0 4px 20px rgba(0, 0, 0, .07);
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Nunito', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.5rem 1rem 3rem;
}

.btn-home {
    display: inline-flex;
    align-items: center;
    padding: .5rem 1rem;
    background: #ffffff;
    border: 1.5px solid #ecddd0;
    border-radius: 10px;
    font-size: .85rem;
    font-weight: 700;
    color: #7c5c3e;
    text-decoration: none;
    margin-bottom: .5rem;
    transition: border-color .2s, background .2s, transform .15s;
    align-self: flex-start;
}

.btn-home:hover {
    border-color: #c8a882;
    background: #fdf0e4;
    transform: translateX(-2px);
}

/* ── HEADER ── */
.app-header {
    text-align: center;
    margin-bottom: 1.75rem;
    animation: fadeDown .5s ease both;
}

.app-header .hat {
    font-size: 2.5rem;
}

.app-header h1 {
    font-size: clamp(1.8rem, 6vw, 2.4rem);
    font-weight: 900;
    color: var(--text);
    letter-spacing: -.02em;
}

.app-header p {
    font-size: .9rem;
    color: var(--muted);
    margin-top: .25rem;
}

/* ── CARD ── */
.card {
    width: 100%;
    max-width: 480px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    animation: fadeUp .45s ease both;
}

.card h2 {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--brown);
    margin-bottom: 1.1rem;
    display: flex;
    align-items: center;
    gap: .5rem;
}

/* ── FORM ELEMENTS ── */
label {
    display: block;
    font-size: .8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--muted);
    margin-bottom: .4rem;
}

select,
input[type="text"],
input[type="number"] {
    width: 100%;
    padding: .75rem 1rem;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-family: 'Nunito', sans-serif;
    font-size: .95rem;
    font-weight: 600;
    color: var(--text);
    background: var(--bg);
    outline: none;
    transition: border-color .2s, box-shadow .2s;
}

select:focus,
input:focus {
    border-color: var(--brown-lt);
    box-shadow: 0 0 0 3px rgba(200, 168, 130, .2);
}

.field {
    margin-bottom: 1rem;
}

/* Players */
#player-config {
    display: flex;
    flex-direction: column;
    gap: .5rem;
    margin-bottom: .75rem;
}

.player-row {
    display: flex;
    align-items: center;
    gap: .5rem;
    animation: fadeUp .3s ease both;
}

.player-num {
    width: 28px;
    height: 28px;
    background: var(--accent-lt);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .75rem;
    font-weight: 800;
    color: var(--accent);
    flex-shrink: 0;
}

.player-row input {
    margin: 0;
}

.btn-row {
    display: flex;
    gap: .5rem;
    margin-bottom: 1rem;
}

/* ── BUTTONS ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .7rem 1.2rem;
    border-radius: 10px;
    border: none;
    font-family: 'Nunito', sans-serif;
    font-size: .9rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform .15s, box-shadow .15s, filter .15s;
    text-decoration: none;
}

.btn:active {
    transform: scale(.96);
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 3px 12px rgba(232, 116, 59, .35);
}

.btn-primary:hover {
    filter: brightness(1.06);
    box-shadow: 0 5px 18px rgba(232, 116, 59, .4);
}

.btn-outline {
    background: transparent;
    border: 1.5px solid var(--border);
    color: var(--brown);
}

.btn-outline:hover {
    border-color: var(--brown-lt);
    background: var(--accent-lt);
}

.btn-success {
    background: var(--green);
    color: #fff;
    box-shadow: 0 3px 12px rgba(76, 175, 116, .35);
    flex: 1;
    padding: 1rem;
    font-size: 1.1rem;
}

.btn-pass {
    background: var(--surface);
    border: 1.5px solid var(--border);
    color: var(--muted);
    flex: 1;
    padding: 1rem;
    font-size: 1.1rem;
}

.btn-pass:hover {
    border-color: var(--red);
    color: var(--red);
    background: #fff5f5;
}

.btn-lg {
    width: 100%;
    padding: 1rem;
    font-size: 1rem;
}

.btn-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    padding: 0;
    background: var(--accent-lt);
    border: 1.5px solid var(--border);
    color: var(--accent);
    font-size: 1.1rem;
}

/* ── GAME SCREEN ── */
.game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.round-badge {
    background: var(--accent-lt);
    color: var(--accent);
    font-size: .75rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .08em;
    padding: .3rem .75rem;
    border-radius: 20px;
}

.current-player-label {
    font-size: .85rem;
    font-weight: 700;
    color: var(--muted);
}

.current-player-name {
    font-size: 1.1rem;
    font-weight: 900;
    color: var(--text);
}

/* Word display */
.word-box {
    background: var(--accent-lt);
    border: 2px solid var(--border);
    border-radius: 14px;
    padding: 2rem 1rem;
    text-align: center;
    margin: 1rem 0;
    min-height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.word-box::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 50% 0%, rgba(232, 116, 59, .07) 0%, transparent 70%);
}

#word {
    font-size: clamp(1.8rem, 8vw, 3rem);
    font-weight: 900;
    color: var(--text);
    line-height: 1.2;
    text-align: center;
    position: relative;
    transition: opacity .2s, transform .2s;
    word-break: break-word;
}

#word.changing {
    opacity: 0;
    transform: scale(.92);
}

/* Timer */
.timer-row {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-bottom: 1rem;
}

.timer-track {
    flex: 1;
    height: 10px;
    background: var(--border);
    border-radius: 5px;
    overflow: hidden;
}

.timer-bar {
    height: 100%;
    background: var(--green);
    border-radius: 5px;
    transition: width 1s linear, background .5s;
}

.timer-bar.warn {
    background: #f0a500;
}

.timer-bar.danger {
    background: var(--red);
}

#timer {
    font-size: 1.4rem;
    font-weight: 900;
    color: var(--text);
    min-width: 50px;
    text-align: right;
}

#timer.danger {
    color: var(--red);
    animation: tick .5s steps(1) infinite;
}

@keyframes tick {
    50% {
    opacity: .4;
    }
}

/* Action buttons */
.action-row {
    display: flex;
    gap: .75rem;
}

/* Live scores sidebar */
.live-scores {
    width: 100%;
    max-width: 480px;
    margin-top: .75rem;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    box-shadow: var(--shadow);
    animation: fadeUp .45s .1s ease both;
}

.live-scores h3 {
    font-size: .75rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: var(--muted);
    margin-bottom: .75rem;
}

.score-list {
    display: flex;
    flex-direction: column;
    gap: .4rem;
}

.score-row {
    display: flex;
    align-items: center;
    gap: .6rem;
}

.score-name {
    flex: 1;
    font-size: .9rem;
    font-weight: 700;
}

.score-bar-wrap {
    flex: 2;
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
}

.score-bar {
    height: 100%;
    background: var(--accent);
    border-radius: 4px;
    transition: width .6s ease;
}

.score-pts {
    font-size: .85rem;
    font-weight: 800;
    color: var(--accent);
    min-width: 28px;
    text-align: right;
}

.score-active .score-name {
    color: var(--accent);
}

.score-active .score-bar {
    background: var(--green);
}

/* ── SUMMARY ── */
.summary-scores {
    display: flex;
    flex-direction: column;
    gap: .5rem;
    margin-bottom: 1.25rem;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: .65rem 1rem;
    background: var(--bg);
    border-radius: 10px;
    border: 1px solid var(--border);
}

.summary-row .s-name {
    font-weight: 700;
}

.summary-row .s-pts {
    font-weight: 900;
    color: var(--accent);
}

.found-section {
    margin-bottom: 1rem;
}

.found-section h4 {
    font-size: .8rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--muted);
    margin-bottom: .5rem;
}

.word-chips {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
}

.chip {
    background: var(--accent-lt);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: .25rem .7rem;
    font-size: .8rem;
    font-weight: 700;
    color: var(--brown);
}

/* ── FINAL ── */
.podium {
    display: flex;
    flex-direction: column;
    gap: .5rem;
    margin-bottom: 1.5rem;
}

.podium-row {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .8rem 1rem;
    background: var(--bg);
    border-radius: 12px;
    border: 1.5px solid var(--border);
    transition: transform .2s;
}

.podium-row.first {
    background: #fff8ee;
    border-color: #f0c060;
    box-shadow: 0 2px 12px rgba(240, 192, 96, .2);
}

.rank {
    font-size: 1.3rem;
    width: 30px;
}

.podium-name {
    flex: 1;
    font-weight: 800;
    font-size: 1rem;
}

.podium-pts {
    font-weight: 900;
    font-size: 1.1rem;
    color: var(--accent);
}

/* ── OVERLAY ── */
#overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

#overlay img {
    width: 90%;
    max-width: 400px;
    border-radius: 12px;
}

/* ── UTILS ── */
.d-none {
    display: none !important;
}

.divider {
    height: 1px;
    background: var(--border);
    margin: 1rem 0;
}


/* Modals */
.modal-header { border-bottom: none; padding-bottom: 0; }
.modal-footer { border-top: none; }
.modal-title { font-weight: 800; font-size: 1.2rem; }
.modal-icon { font-size: 2.5rem; text-align: center; margin-bottom: .5rem; }


/* ── GROUPES ── */
.group-section {
    margin-top: 1rem;
}
.group-section h4 {
    font-size: .85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--color-muted, #888);
    margin-bottom: .5rem;
}
.player-row {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-bottom: .35rem;
}
/* Sélecteur de groupe inline dans chaque ligne joueur */
.player-row select.group-select {
    width: 120px;
    font-size: .8rem;
    padding: 2px 6px;
    border-radius: 6px;
    border: 1px solid #ccc;
    background: #fff;
}

/* Live scores par groupe */
.score-group-label {
    font-size: .7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--color-muted, #aaa);
    margin-top: .5rem;
    margin-bottom: .15rem;
    padding-left: 2px;
}

@keyframes fadeDown {
    from {
    opacity: 0;
    transform: translateY(-20px);
    }

    to {
    opacity: 1;
    transform: translateY(0);
    }
}

@keyframes fadeUp {
    from {
    opacity: 0;
    transform: translateY(20px);
    }

    to {
    opacity: 1;
    transform: translateY(0);
    }
}

@keyframes wordPop {
    0% {
    transform: scale(.85);
    opacity: 0;
    }

    70% {
    transform: scale(1.05);
    }

    100% {
    transform: scale(1);
    opacity: 1;
    }
}

.word-pop {
    animation: wordPop .3s ease both;
}
