:root {
    /* France Saucisson palette */
    --bg: #fdf6e3;
    --bg-alt: #f5e6c8;
    --paper: #fff8e7;
    --kraft: #c8a878;
    --wood: #5b3a1f;
    --ink: #2b1810;
    --ink-soft: #6b5544;
    --tricolor-blue: #002395;
    --tricolor-red: #ed2939;
    --burgundy: #7a1f2b;
    --gold: #d4a017;
    --gold-deep: #b8860b;
    --vichy: #d52b1e;
    --green-leaf: #4a7c2a;

    --marked: #ed2939;
    --marked-text: #fff8e7;

    --radius: 16px;
    --radius-lg: 24px;
    --shadow-sm: 0 2px 6px rgba(91, 58, 31, 0.18);
    --shadow: 0 8px 24px rgba(91, 58, 31, 0.22);
    --shadow-lg: 0 16px 40px rgba(91, 58, 31, 0.28);
    --transition: 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    color: var(--ink);
    font-family: "Georgia", "Iowan Old Style", "Palatino Linotype", "Times New Roman", serif;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    overflow-x: hidden;
}

body {
    background-color: var(--bg);
    background-image:
        radial-gradient(circle at 20% 10%, rgba(212, 160, 23, 0.08), transparent 40%),
        radial-gradient(circle at 80% 90%, rgba(237, 41, 57, 0.08), transparent 45%),
        repeating-conic-gradient(
            from 45deg,
            rgba(213, 43, 30, 0.10) 0deg 90deg,
            transparent 90deg 180deg
        );
    background-size: auto, auto, 32px 32px;
    background-attachment: fixed;
}

button {
    font-family: inherit;
}

a {
    color: inherit;
    text-decoration: none;
}

/* ---------- Tricolor decorative strip ---------- */

.tricolor-strip {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 6px;
    z-index: 20;
    background: linear-gradient(
        to right,
        var(--tricolor-blue) 0%,
        var(--tricolor-blue) 33.33%,
        #fff 33.33%,
        #fff 66.66%,
        var(--tricolor-red) 66.66%,
        var(--tricolor-red) 100%
    );
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

/* ---------- Back link ---------- */

.back-link {
    position: fixed;
    top: 20px;
    left: 16px;
    z-index: 10;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--paper);
    border: 2px solid var(--burgundy);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: var(--burgundy);
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition), background var(--transition);
}

.back-link:hover {
    transform: translateX(-2px) scale(1.05);
    background: var(--bg-alt);
}

/* ---------- Home ---------- */

.home {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 48px 24px;
    gap: 40px;
    position: relative;
}

.home::before {
    content: "🥖 🧀 🍷 🥩 🍇";
    position: absolute;
    top: 28px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 22px;
    letter-spacing: 14px;
    opacity: 0.55;
    pointer-events: none;
}

.home__header {
    text-align: center;
    position: relative;
}

.home__ribbon {
    display: inline-block;
    padding: 8px 28px;
    margin-bottom: 14px;
    background: var(--tricolor-red);
    color: #fff;
    font-size: 13px;
    letter-spacing: 0.35em;
    text-transform: uppercase;
    font-weight: 700;
    border-radius: 4px;
    box-shadow: var(--shadow-sm);
    position: relative;
}

.home__ribbon::before,
.home__ribbon::after {
    content: "";
    position: absolute;
    top: 0;
    width: 0;
    height: 0;
    border-style: solid;
}

.home__ribbon::before {
    left: -10px;
    border-width: 0 10px 32px 0;
    border-color: transparent var(--burgundy) transparent transparent;
}

.home__ribbon::after {
    right: -10px;
    border-width: 32px 10px 0 0;
    border-color: var(--burgundy) transparent transparent transparent;
}

.home__title {
    font-size: clamp(56px, 12vw, 120px);
    margin: 0;
    letter-spacing: -0.03em;
    font-weight: 900;
    font-family: "Georgia", "Times New Roman", serif;
    color: var(--burgundy);
    text-shadow:
        2px 2px 0 var(--gold),
        4px 4px 0 var(--ink),
        6px 6px 14px rgba(0, 0, 0, 0.18);
    line-height: 0.95;
    transform: rotate(-2deg);
}

.home__subtitle {
    margin: 18px 0 0;
    font-size: 18px;
    color: var(--ink-soft);
    font-style: italic;
}

.role-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    width: 100%;
    max-width: 680px;
}

.role-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 12px;
    padding: 28px 26px;
    min-height: 200px;
    background: var(--paper);
    border: 2px solid var(--ink);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    transition: transform var(--transition), box-shadow var(--transition);
    position: relative;
    overflow: hidden;
}

.role-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 8px;
}

.role-card--presenter::before {
    background: linear-gradient(to right, var(--tricolor-red), var(--gold));
}

.role-card--player::before {
    background: linear-gradient(to right, var(--tricolor-blue), var(--green-leaf));
}

.role-card:hover {
    transform: translateY(-4px) rotate(-0.5deg);
    box-shadow: var(--shadow-lg);
}

.role-card__icon {
    font-size: 44px;
    line-height: 1;
}

.role-card__label {
    font-size: 30px;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--ink);
}

.role-card__hint {
    font-size: 14px;
    color: var(--ink-soft);
    font-style: italic;
}

.role-card--presenter .role-card__label {
    color: var(--tricolor-red);
}

.role-card--player .role-card__label {
    color: var(--tricolor-blue);
}

/* ---------- Presenter ---------- */

.presenter {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 24px 180px;
    gap: 24px;
    cursor: pointer;
    user-select: none;
    position: relative;
}

.presenter:focus {
    outline: none;
}

.presenter__count {
    font-variant-numeric: tabular-nums;
    font-size: 14px;
    color: var(--ink-soft);
    letter-spacing: 0.16em;
    text-transform: uppercase;
    font-weight: 700;
    background: var(--paper);
    padding: 8px 18px;
    border-radius: 999px;
    border: 2px solid var(--burgundy);
    box-shadow: var(--shadow-sm);
}

.presenter__count strong {
    color: var(--tricolor-red);
    font-size: 16px;
}

/* Bingo ball */
.presenter__ball {
    width: clamp(220px, 50vw, 380px);
    height: clamp(220px, 50vw, 380px);
    border-radius: 50%;
    background:
        radial-gradient(circle at 32% 30%, #ffffff 0%, #fff8e7 25%, #f0d896 65%, #c89a3a 100%);
    box-shadow:
        inset -10px -14px 28px rgba(0, 0, 0, 0.22),
        inset 10px 12px 24px rgba(255, 255, 255, 0.7),
        0 18px 42px rgba(91, 58, 31, 0.35),
        0 4px 8px rgba(0, 0, 0, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: transform 320ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.presenter__ball::before {
    /* inner white circle holding the number */
    content: "";
    position: absolute;
    inset: 18%;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #ffffff, #faf3e0);
    box-shadow: inset 0 4px 10px rgba(0, 0, 0, 0.12);
}

.presenter__ball.is-empty {
    background:
        radial-gradient(circle at 32% 30%, #ffffff 0%, #fff8e7 25%, #d8c39a 65%, #a88b58 100%);
    opacity: 0.7;
}

.presenter__ball.is-rolling {
    animation: ball-roll 480ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.presenter__ball.is-pop {
    animation: ball-pop 600ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes ball-roll {
    0%   { transform: translateX(-40px) rotate(-180deg) scale(0.92); }
    60%  { transform: translateX(8px) rotate(40deg) scale(1.05); }
    100% { transform: translateX(0) rotate(0deg) scale(1); }
}

@keyframes ball-pop {
    0%   { transform: scale(1); }
    35%  { transform: scale(1.10); }
    65%  { transform: scale(0.97); }
    100% { transform: scale(1); }
}

.presenter__number {
    position: relative;
    z-index: 1;
    font-size: clamp(80px, 22vw, 180px);
    font-weight: 900;
    letter-spacing: -0.04em;
    line-height: 1;
    color: var(--tricolor-red);
    font-variant-numeric: tabular-nums;
    text-shadow:
        2px 2px 0 rgba(0, 0, 0, 0.10),
        0 4px 8px rgba(0, 0, 0, 0.08);
}

.presenter__number.is-empty {
    color: var(--ink-soft);
    font-size: clamp(60px, 16vw, 120px);
}

.presenter__hint {
    margin: 0;
    color: var(--ink-soft);
    font-size: 16px;
    font-style: italic;
    letter-spacing: 0.02em;
    text-align: center;
}

.presenter__history {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
    max-height: 26vh;
    overflow-y: auto;
    padding: 12px;
    background: rgba(255, 248, 231, 0.94);
    border: 2px solid var(--burgundy);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    backdrop-filter: blur(4px);
}

.presenter__history:empty {
    display: none;
}

.history-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 8px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #fff, #fbe7a3 60%, #c9962e 100%);
    color: var(--ink);
    font-size: 14px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    border: 2px solid var(--gold-deep);
    box-shadow: var(--shadow-sm);
}

.history-chip--last {
    background: radial-gradient(circle at 35% 30%, #fff, #ffb3ba 50%, var(--tricolor-red) 100%);
    color: #fff;
    border-color: var(--burgundy);
    transform: scale(1.12);
    animation: chip-pulse 1.2s ease-in-out infinite;
}

@keyframes chip-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(237, 41, 57, 0.55); }
    50%      { box-shadow: 0 0 0 8px rgba(237, 41, 57, 0); }
}

.presenter__reset {
    position: fixed;
    top: 20px;
    right: 16px;
    height: 44px;
    padding: 0 20px;
    background: var(--paper);
    border: 2px solid var(--burgundy);
    border-radius: 999px;
    color: var(--burgundy);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition), background var(--transition);
}

.presenter__reset:hover {
    transform: translateY(-1px);
    background: var(--bg-alt);
}

/* ---------- Player ---------- */

.player {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 80px 16px 40px;
    gap: 22px;
}

.player__header {
    text-align: center;
}

.player__title {
    margin: 0;
    font-size: 36px;
    font-weight: 900;
    letter-spacing: -0.02em;
    color: var(--burgundy);
    text-shadow: 2px 2px 0 var(--gold);
}

.player__subtitle {
    margin: 8px 0 0;
    color: var(--ink-soft);
    font-size: 14px;
    font-style: italic;
}

/* Progress badges row */
.player__progress {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    max-width: 100%;
}

.progress-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--paper);
    border: 2px solid var(--ink);
    border-radius: 999px;
    font-size: 13px;
    font-weight: 700;
    color: var(--ink-soft);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition);
}

.progress-badge.is-achieved {
    background: var(--tricolor-red);
    color: #fff;
    border-color: var(--burgundy);
    transform: scale(1.05);
}

.progress-badge.is-bingo.is-achieved {
    background: linear-gradient(135deg, var(--gold), var(--tricolor-red));
    animation: badge-shine 1.6s ease-in-out infinite;
}

@keyframes badge-shine {
    0%, 100% { box-shadow: 0 0 0 0 rgba(212, 160, 23, 0.6); }
    50%      { box-shadow: 0 0 0 8px rgba(212, 160, 23, 0); }
}

.player__grid {
    display: grid;
    grid-template-columns: repeat(var(--grid-size), 1fr);
    gap: 8px;
    width: min(94vw, 580px);
    aspect-ratio: 1 / 1;
    padding: 14px;
    background: var(--paper);
    border: 3px solid var(--burgundy);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    position: relative;
}

.player__grid::before,
.player__grid::after {
    content: "";
    position: absolute;
    width: 28px;
    height: 28px;
    background: radial-gradient(circle at 35% 30%, #fff, #fbe7a3 60%, #c9962e 100%);
    border: 2px solid var(--gold-deep);
    border-radius: 50%;
    box-shadow: var(--shadow-sm);
}

.player__grid::before { top: -14px; left: -14px; }
.player__grid::after  { bottom: -14px; right: -14px; }

.cell {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-alt);
    border: 2px solid var(--kraft);
    border-radius: 12px;
    color: var(--ink);
    font-size: clamp(16px, 4.5vw, 28px);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    cursor: pointer;
    user-select: none;
    transition: background var(--transition), color var(--transition), transform var(--transition), border-color var(--transition);
    -webkit-tap-highlight-color: transparent;
    position: relative;
    overflow: hidden;
    font-family: "Georgia", serif;
}

.cell:hover {
    background: var(--paper);
    border-color: var(--burgundy);
}

.cell:active {
    transform: scale(0.92);
}

.cell.is-marked {
    background: var(--marked);
    color: var(--marked-text);
    border-color: var(--burgundy);
    transform: scale(0.96);
    animation: cell-stamp 320ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.cell.is-marked::after {
    /* stamp effect */
    content: "";
    position: absolute;
    inset: 0;
    border: 2px dashed rgba(255, 255, 255, 0.45);
    border-radius: 9px;
    margin: 4px;
    pointer-events: none;
}

@keyframes cell-stamp {
    0%   { transform: scale(1.18) rotate(-8deg); }
    60%  { transform: scale(0.90) rotate(2deg); }
    100% { transform: scale(0.96) rotate(0deg); }
}

.cell.is-celebrating {
    animation: cell-celebrate 800ms ease-in-out;
}

@keyframes cell-celebrate {
    0%, 100% { transform: scale(0.96); box-shadow: 0 0 0 0 rgba(212, 160, 23, 0); }
    50%      { transform: scale(1.06); box-shadow: 0 0 0 6px rgba(212, 160, 23, 0.55); }
}

.player__reset {
    height: 44px;
    padding: 0 22px;
    background: var(--paper);
    border: 2px solid var(--burgundy);
    border-radius: 999px;
    color: var(--burgundy);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition), background var(--transition);
}

.player__reset:hover {
    transform: translateY(-1px);
    background: var(--bg-alt);
}

/* ---------- Toast / Reward popup ---------- */

.toast-stack {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 50;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
    width: min(92vw, 420px);
}

.toast {
    background: var(--paper);
    border: 2px solid var(--burgundy);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 14px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    animation: toast-in 360ms cubic-bezier(0.2, 0.8, 0.2, 1) both,
               toast-out 320ms ease 2600ms forwards;
}

.toast__icon {
    font-size: 32px;
    line-height: 1;
}

.toast__text {
    flex: 1;
}

.toast__title {
    font-size: 16px;
    font-weight: 800;
    color: var(--burgundy);
    margin: 0;
}

.toast__sub {
    font-size: 13px;
    color: var(--ink-soft);
    margin: 2px 0 0;
    font-style: italic;
}

.toast--bingo {
    background: linear-gradient(135deg, #fff8e7, #ffe4b5);
    border-color: var(--tricolor-red);
}

.toast--bingo .toast__title {
    color: var(--tricolor-red);
    font-size: 22px;
    letter-spacing: 0.05em;
}

@keyframes toast-in {
    0%   { opacity: 0; transform: translateY(-20px) scale(0.92); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toast-out {
    0%   { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-12px); }
}

/* ---------- Bingo overlay (fullscreen celebration) ---------- */

.bingo-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at center, rgba(255, 248, 231, 0.92), rgba(122, 31, 43, 0.85));
    animation: overlay-fade 360ms ease both;
    pointer-events: auto;
}

.bingo-overlay__card {
    background: var(--paper);
    border: 4px solid var(--tricolor-red);
    border-radius: var(--radius-lg);
    padding: 36px 44px;
    text-align: center;
    box-shadow: var(--shadow-lg);
    transform: rotate(-2deg);
    animation: bingo-card 600ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.bingo-overlay__title {
    margin: 0;
    font-size: clamp(54px, 14vw, 120px);
    font-weight: 900;
    letter-spacing: -0.02em;
    color: var(--tricolor-red);
    text-shadow:
        3px 3px 0 var(--gold),
        6px 6px 0 var(--ink);
    line-height: 0.95;
}

.bingo-overlay__sub {
    margin: 16px 0 0;
    font-size: 18px;
    color: var(--ink-soft);
    font-style: italic;
}

.bingo-overlay__prize {
    font-size: 64px;
    margin-top: 12px;
    letter-spacing: 8px;
}

.bingo-overlay__close {
    margin-top: 22px;
    padding: 10px 24px;
    background: var(--tricolor-red);
    color: #fff;
    border: none;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition);
}

.bingo-overlay__close:hover {
    transform: translateY(-2px);
}

@keyframes overlay-fade {
    0%   { opacity: 0; }
    100% { opacity: 1; }
}

@keyframes bingo-card {
    0%   { opacity: 0; transform: rotate(-12deg) scale(0.4); }
    60%  { opacity: 1; transform: rotate(2deg) scale(1.06); }
    100% { transform: rotate(-2deg) scale(1); }
}

/* ---------- Confetti ---------- */

.confetti-layer {
    position: fixed;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 90;
}

.confetti {
    position: absolute;
    top: -10vh;
    width: 10px;
    height: 14px;
    opacity: 0.95;
    will-change: transform;
    animation: confetti-fall linear forwards;
}

@keyframes confetti-fall {
    0%   { transform: translate3d(0, -10vh, 0) rotate(0deg); }
    100% { transform: translate3d(var(--dx, 20px), 110vh, 0) rotate(var(--rot, 720deg)); }
}

/* ---------- Modal dialog ---------- */

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: radial-gradient(circle at center, rgba(43, 24, 16, 0.55), rgba(43, 24, 16, 0.78));
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    animation: modal-backdrop-in 220ms ease both;
}

.modal-backdrop.is-closing {
    animation: modal-backdrop-out 180ms ease both;
}

.modal {
    background: var(--paper);
    border: 3px solid var(--burgundy);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 28px 28px 22px;
    width: min(92vw, 420px);
    text-align: center;
    animation: modal-pop-in 320ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
    position: relative;
}

.modal::before {
    content: "";
    position: absolute;
    inset: 6px;
    border: 1px dashed rgba(122, 31, 43, 0.35);
    border-radius: calc(var(--radius-lg) - 6px);
    pointer-events: none;
}

.is-closing .modal {
    animation: modal-pop-out 180ms ease both;
}

.modal__icon {
    font-size: 38px;
    line-height: 1;
    margin-bottom: 8px;
}

.modal__title {
    font-size: 22px;
    font-weight: 800;
    color: var(--burgundy);
    margin: 0 0 8px;
    letter-spacing: 0.02em;
}

.modal__message {
    margin: 0 0 22px;
    color: var(--ink-soft);
    font-size: 15px;
    line-height: 1.45;
    font-style: italic;
}

.modal__actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.modal__btn {
    appearance: none;
    border: 2px solid var(--burgundy);
    background: var(--paper);
    color: var(--burgundy);
    font-family: inherit;
    font-size: 15px;
    font-weight: 700;
    padding: 10px 20px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: transform var(--transition), background var(--transition), color var(--transition);
    min-width: 110px;
}

.modal__btn:hover {
    background: var(--bg-alt);
    transform: translateY(-1px);
}

.modal__btn:focus-visible {
    outline: 3px solid var(--gold);
    outline-offset: 2px;
}

.modal__btn--primary {
    background: var(--burgundy);
    color: var(--paper);
}

.modal__btn--primary:hover {
    background: var(--tricolor-red);
    color: var(--paper);
}

@keyframes modal-backdrop-in {
    0%   { opacity: 0; }
    100% { opacity: 1; }
}

@keyframes modal-backdrop-out {
    0%   { opacity: 1; }
    100% { opacity: 0; }
}

@keyframes modal-pop-in {
    0%   { opacity: 0; transform: scale(0.85) translateY(10px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes modal-pop-out {
    0%   { opacity: 1; transform: scale(1); }
    100% { opacity: 0; transform: scale(0.92); }
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
}
