:root {
    --bg: #3b0f14;
    --bg-2: #5a1a20;
    --panel: #4d1a1f;
    --panel-2: #66262c;
    --text: #fff6e6;
    --muted: #e0c7b0;
    --gold: #f2c94c;
    --green: #2e7d4f;
    --paper: #fffaf0;
    --ink: #2b1b14;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: radial-gradient(circle at 50% 0%, var(--bg-2), var(--bg) 70%);
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 18px;
}

.hidden {
    display: none !important;
}

.top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    max-width: 1500px;
    margin: 0 auto;
    padding: 10px 16px 0;
}

.top h1 {
    margin: 0;
    font-size: 1.8rem;
    color: var(--gold);
}

.lang {
    display: flex;
    gap: 6px;
}

.lang-button {
    padding: 8px 14px;
    font-size: 1rem;
    color: var(--text);
    background: var(--panel-2);
    border: 2px solid transparent;
    border-radius: 999px;
    cursor: pointer;
}

.lang-button.active {
    border-color: var(--gold);
    color: var(--gold);
}

/* ---------- Réglages ---------- */

.setup {
    max-width: 600px;
    margin: 12px auto;
    padding: 16px;
}

.setup h2 {
    margin: 0 0 6px;
    font-size: 1.6rem;
}

.setup-hint {
    margin: 0 0 16px;
    color: var(--muted);
}

.setup-rows {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.setup-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: var(--panel);
    border-radius: 14px;
}

.setup-row .num {
    flex: none;
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    font-weight: 700;
    color: var(--ink);
    background: var(--gold);
    border-radius: 50%;
}

.setup-row input,
.setup-row select {
    min-width: 0;
    padding: 10px 12px;
    font-size: 1rem;
    color: var(--text);
    background: var(--bg);
    border: 2px solid var(--panel-2);
    border-radius: 10px;
}

.setup-row input {
    flex: 1;
}

.setup-error {
    min-height: 1.4em;
    margin: 10px 0 0;
    color: #ffb4a8;
}

.big-button {
    display: block;
    width: 100%;
    margin-top: 8px;
    padding: 16px;
    font-size: 1.3rem;
    font-weight: 700;
    color: #3a2a00;
    background: var(--gold);
    border: 0;
    border-radius: 14px;
    cursor: pointer;
}

.big-button:hover {
    filter: brightness(1.08);
}

.big-button:disabled {
    cursor: default;
    opacity: 0.6;
}

.small-button {
    padding: 10px 14px;
    font-size: 1rem;
    color: var(--text);
    background: var(--panel-2);
    border: 0;
    border-radius: 10px;
    cursor: pointer;
}

.small-button:hover {
    background: #7a3239;
}

.small-button[aria-pressed="false"] {
    opacity: 0.5;
}

/* ---------- Partie ---------- */

.game {
    display: grid;
    grid-template-columns: 460px minmax(0, 1fr);
    gap: 18px;
    align-items: start;
    max-width: 1500px;
    margin: 0 auto;
    padding: 10px 16px 28px;
}

.caller {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
    background: var(--panel);
    border-radius: 18px;
}

.ball-row {
    display: flex;
    align-items: center;
    gap: 16px;
    min-height: 130px;
}

.ball {
    flex: none;
    display: grid;
    place-items: center;
    width: 120px;
    height: 120px;
    font-size: 3.4rem;
    font-weight: 800;
    color: var(--ink);
    background: radial-gradient(circle at 35% 30%, #fff7c9, var(--gold) 60%, #c9962a);
    border-radius: 50%;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.ball.empty {
    opacity: 0.35;
}

.ball.pop {
    animation: pop 0.5s ease-out;
}

@keyframes pop {
    0% { transform: scale(0.3) rotate(-20deg); }
    70% { transform: scale(1.12); }
    100% { transform: scale(1); }
}

.ball-text {
    min-width: 0;
}

.ball-nap {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gold);
    overflow-wrap: anywhere;
}

.ball-tr {
    margin-top: 4px;
    color: var(--muted);
    overflow-wrap: anywhere;
}

.draw {
    margin-top: 0;
}

.options {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.option {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.option input {
    width: 20px;
    height: 20px;
}

.options select {
    padding: 8px;
    font-size: 1rem;
    color: var(--text);
    background: var(--bg);
    border: 2px solid var(--panel-2);
    border-radius: 8px;
}

.prizes {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.prize {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 6px 10px;
    background: var(--panel-2);
    border-radius: 10px;
}

.prize .pname {
    flex: none;
    min-width: 92px;
    font-weight: 700;
}

.prize .pdesc {
    flex: 1;
    font-size: 0.85rem;
    color: var(--muted);
}

.prize .pwin {
    font-weight: 700;
    color: var(--gold);
}

.prize.won {
    border: 2px solid var(--gold);
}

.mini-title {
    margin: 4px 0 0;
    font-size: 1rem;
    color: var(--muted);
}

.tabellone {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 3px;
}

.tabellone span {
    display: grid;
    place-items: center;
    padding: 5px 0;
    font-size: 0.95rem;
    color: #9c7f6e;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 6px;
}

.tabellone span.out {
    font-weight: 700;
    color: var(--ink);
    background: var(--gold);
}

.tabellone span.latest {
    outline: 3px solid #fff;
}

.actions {
    display: flex;
    justify-content: flex-end;
}

.rules {
    color: var(--muted);
    font-size: 0.95rem;
}

.rules summary {
    cursor: pointer;
    color: var(--text);
}

.rules ul {
    margin: 8px 0 0;
    padding-left: 20px;
}

.rules li {
    margin-bottom: 6px;
}

/* ---------- Joueurs et cartelle ---------- */

.players {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.player {
    padding: 12px;
    background: var(--panel);
    border-radius: 16px;
    border: 3px solid transparent;
}

.player.flash {
    border-color: var(--gold);
}

.player-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.player-name {
    font-size: 1.25rem;
    font-weight: 700;
}

.badge {
    padding: 2px 10px;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--ink);
    background: var(--gold);
    border-radius: 999px;
}

.cards {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.card {
    flex: 1 1 330px;
    max-width: 480px;
    padding: 6px;
    background: #b5472f;
    border-radius: 10px;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: 2px;
}

.cell {
    display: grid;
    place-items: center;
    aspect-ratio: 1 / 0.95;
    font-size: clamp(0.8rem, 1.2vw, 1.15rem);
    font-weight: 700;
    color: var(--ink);
    background: var(--paper);
    border-radius: 4px;
}

.cell.blank {
    background: #d9a27a;
}

.cell.hit {
    color: #fff;
    background: var(--green);
    box-shadow: inset 0 0 0 3px #bff0cf;
}

.cell.latest {
    animation: blink 0.7s ease-in-out 4;
}

@keyframes blink {
    50% { filter: brightness(1.8); transform: scale(1.12); }
}

/* ---------- Annonces ---------- */

.toast {
    position: fixed;
    top: 14px;
    left: 50%;
    z-index: 20;
    max-width: min(92vw, 640px);
    padding: 14px 24px;
    font-size: 1.4rem;
    font-weight: 800;
    text-align: center;
    color: var(--ink);
    background: var(--gold);
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    transform: translateX(-50%);
    animation: toast-in 0.35s ease-out;
}

@keyframes toast-in {
    from { opacity: 0; transform: translate(-50%, -30px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

.win {
    position: fixed;
    inset: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(0, 0, 0, 0.65);
}

.win-box {
    width: 100%;
    max-width: 440px;
    padding: 28px 22px;
    text-align: center;
    background: var(--panel);
    border: 3px solid var(--gold);
    border-radius: 20px;
}

.win-box h2 {
    margin: 0 0 8px;
    font-size: 2.2rem;
    color: var(--gold);
}

.win-box .small-button {
    margin-top: 12px;
}

.confetti {
    position: fixed;
    top: -20px;
    z-index: 30;
    width: 10px;
    height: 16px;
    pointer-events: none;
    animation: fall linear forwards;
}

@keyframes fall {
    to { transform: translateY(110vh) rotate(720deg); }
}

/* ---------- Petits écrans ---------- */

@media (max-width: 980px) {
    .game {
        grid-template-columns: minmax(0, 1fr);
    }

    .card {
        flex-basis: 300px;
    }
}
