:root {
    --bg: #100e1c;
    --bg-alt: #1c1636;
    --card: #211c3a;
    --card-border: #3a3364;
    --text: #f5f3ff;
    --text-muted: #a8a2c9;
    --primary: #a855f7;
    --primary-dark: #7c3aed;
    --accent: #22d3ee;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --civil: #38bdf8;
    --undercover: #ef4444;
    --proletaire: #c084fc;
    --radius: 20px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Nunito', "Segoe UI", Roboto, system-ui, sans-serif;
    color: var(--text);
    min-height: 100vh;
    background:
        radial-gradient(circle at 15% 0%, rgba(168, 85, 247, 0.35), transparent 45%),
        radial-gradient(circle at 85% 15%, rgba(34, 211, 238, 0.28), transparent 45%),
        radial-gradient(circle at 50% 100%, rgba(236, 72, 153, 0.18), transparent 55%),
        linear-gradient(180deg, var(--bg-alt), var(--bg) 40%);
    background-attachment: fixed;
}

.page {
    max-width: 720px;
    margin: 0 auto;
    padding: 24px 16px 64px;
    position: relative;
}

a {
    color: var(--primary);
}

.back-link {
    display: inline-block;
    margin-bottom: 12px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.95rem;
}

h1 {
    font-family: 'Baloo 2', 'Nunito', sans-serif;
    font-size: 1.6rem;
    margin: 0.4em 0;
}

h2 {
    font-family: 'Baloo 2', 'Nunito', sans-serif;
    font-size: 1.15rem;
    margin-top: 0;
}

.fun-title {
    text-align: center;
    font-weight: 800;
    letter-spacing: 0.3px;
}

.hint {
    color: var(--text-muted);
    font-size: 0.92rem;
    text-align: center;
}

/* Hero / home page */
.hero {
    position: relative;
    overflow: hidden;
    text-align: center;
    padding: 44px 12px 28px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}

.hero-badge {
    display: inline-block;
    background: rgba(34, 211, 238, 0.14);
    border: 1px solid rgba(34, 211, 238, 0.4);
    color: var(--accent);
    font-family: 'Baloo 2', sans-serif;
    font-weight: 700;
    font-size: 0.82rem;
    padding: 6px 16px;
    border-radius: 999px;
    animation: bounce-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.hero-float {
    position: absolute;
    font-size: 1.8rem;
    opacity: 0.32;
    pointer-events: none;
    animation: hero-float 6s ease-in-out infinite;
    filter: blur(0.2px);
}

.hero-float-1 { top: 6%; left: 6%; font-size: 2.1rem; animation-delay: 0s; }
.hero-float-2 { top: 12%; right: 8%; font-size: 1.7rem; animation-delay: 0.8s; }
.hero-float-3 { bottom: 18%; left: 12%; font-size: 1.9rem; animation-delay: 1.6s; }
.hero-float-4 { bottom: 8%; right: 14%; font-size: 1.6rem; animation-delay: 2.4s; }
.hero-float-5 { top: 46%; left: 2%; font-size: 1.5rem; animation-delay: 1.1s; }
.hero-float-6 { top: 42%; right: 3%; font-size: 1.7rem; animation-delay: 3s; }

@keyframes hero-float {
    0%, 100% { transform: translateY(0) rotate(-4deg); }
    50% { transform: translateY(-14px) rotate(6deg); }
}

.logo {
    position: relative;
    font-family: 'Baloo 2', sans-serif;
    font-size: 2.8rem;
    margin: 0;
    text-shadow: 0 6px 24px rgba(168, 85, 247, 0.5);
    animation: logo-wobble 4s ease-in-out infinite;
}

@keyframes logo-wobble {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-2deg); }
    75% { transform: rotate(2deg); }
}

.subtitle {
    position: relative;
    color: var(--text-muted);
    max-width: 480px;
}

.btn-glow {
    box-shadow: 0 10px 24px -8px rgba(168, 85, 247, 0.7), 0 0 0 0 rgba(168, 85, 247, 0.6);
    animation: btn-glow-pulse 2.4s ease-in-out infinite;
}

@keyframes btn-glow-pulse {
    0%, 100% { box-shadow: 0 10px 24px -8px rgba(168, 85, 247, 0.7), 0 0 0 0 rgba(168, 85, 247, 0.45); }
    50% { box-shadow: 0 10px 24px -8px rgba(168, 85, 247, 0.7), 0 0 0 10px rgba(168, 85, 247, 0); }
}

.panel {
    padding: 22px;
    margin-bottom: 20px;
}

.card {
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    box-shadow: 0 12px 32px -12px rgba(0, 0, 0, 0.5);
}

.rules-list {
    padding-left: 20px;
    line-height: 1.6;
    color: var(--text-muted);
}

.rules-list strong {
    color: var(--text);
}

/* Rôles (page d'accueil) */
.roles-showcase {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.role-chip {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 6px;
    background: var(--bg);
    border: 1px solid var(--card-border);
    border-top: 3px solid var(--card-border);
    border-radius: 16px;
    padding: 16px 10px;
    transition: transform 0.15s ease;
}

.role-chip:hover {
    transform: translateY(-3px);
}

.role-chip-icon {
    font-size: 1.9rem;
    line-height: 1;
    flex-shrink: 0;
}

.role-chip-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.role-chip-name {
    font-family: 'Baloo 2', sans-serif;
    font-weight: 800;
    font-size: 0.95rem;
}

.role-chip-desc {
    color: var(--text-muted);
    font-size: 0.78rem;
    line-height: 1.4;
}

.role-chip-civil { border-top-color: var(--civil); }
.role-chip-civil .role-chip-name { color: var(--civil); }
.role-chip-undercover { border-top-color: var(--undercover); }
.role-chip-undercover .role-chip-name { color: var(--undercover); }
.role-chip-proletaire { border-top-color: var(--proletaire); }
.role-chip-proletaire .role-chip-name { color: var(--proletaire); }

/* Déroulement d'une partie (page d'accueil) */
.steps-list {
    list-style: none;
    padding: 0;
    margin: 0 0 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.steps-list li {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    color: var(--text-muted);
    line-height: 1.45;
    font-size: 0.94rem;
}

.step-num {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--primary));
    color: #0b0620;
    font-family: 'Baloo 2', sans-serif;
    font-weight: 800;
    font-size: 0.85rem;
}

.win-conditions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.win-chip {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    border-radius: 16px;
    padding: 14px;
    border: 1px solid var(--card-border);
}

.win-chip-icon {
    font-size: 1.5rem;
    line-height: 1;
}

.win-chip strong {
    display: block;
    font-family: 'Baloo 2', sans-serif;
    font-size: 0.88rem;
    margin-bottom: 2px;
}

.win-chip p {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.78rem;
    line-height: 1.4;
}

.win-chip-civils {
    background: rgba(56, 189, 248, 0.1);
    border-color: rgba(56, 189, 248, 0.35);
}

.win-chip-imposteurs {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.35);
}

/* Buttons */
.btn {
    display: inline-block;
    border: none;
    border-radius: 16px;
    padding: 13px 24px;
    font-family: 'Baloo 2', 'Nunito', sans-serif;
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: transform 0.12s ease, filter 0.15s ease, box-shadow 0.15s ease;
}

.btn:active {
    transform: scale(0.96);
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    box-shadow: 0 10px 24px -8px rgba(168, 85, 247, 0.7);
}

.btn-primary:hover:not(:disabled) {
    filter: brightness(1.1);
    transform: translateY(-1px) scale(1.01);
}

.btn-secondary {
    background: var(--card);
    border: 1px solid var(--card-border);
    color: var(--text);
}

.btn-ghost {
    background: transparent;
    border: 1px solid var(--card-border);
    color: var(--text-muted);
}

.btn-lg {
    display: block;
    width: 100%;
    padding: 17px;
    font-size: 1.15rem;
    margin-top: 8px;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
    border-radius: 10px;
}

/* Setup form */
label {
    display: block;
    margin-bottom: 6px;
    font-weight: 700;
    color: var(--text-muted);
    font-size: 0.9rem;
}

input[type="number"],
input[type="text"],
select {
    background: var(--bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    color: var(--text);
    padding: 11px 14px;
    font-size: 1rem;
    width: 100%;
    font-family: inherit;
}

input[type="number"]:focus,
input[type="text"]:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.25);
}

.stepper {
    display: flex;
    gap: 10px;
}

.stepper input {
    flex: 1;
}

.roles-config {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 8px;
}

.civil-count {
    display: block;
    background: var(--bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 11px 12px;
    text-align: center;
    font-weight: 800;
    color: var(--civil);
}

.alert {
    padding: 14px 16px;
    border-radius: 14px;
    margin-bottom: 16px;
    font-weight: 700;
    text-align: center;
}

.alert-error {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid var(--danger);
    color: #fecaca;
}

.alert-warning {
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid var(--warning);
    color: #fde68a;
}

.alert-success {
    background: rgba(34, 197, 94, 0.15);
    border: 1px solid var(--success);
    color: #bbf7d0;
}

/* Game top bar */
.game-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.round-badge {
    background: var(--card);
    border: 1px solid var(--card-border);
    padding: 6px 16px;
    border-radius: 999px;
    font-weight: 800;
    font-size: 0.9rem;
    font-family: 'Baloo 2', sans-serif;
}

/* Cards grid (reveal + voting) */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 12px;
    margin: 16px 0 24px;
}

.player-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    padding: 18px 10px;
    color: var(--text);
    cursor: pointer;
    width: 100%;
    transition: transform 0.12s ease, border-color 0.15s ease, box-shadow 0.15s ease;
    font-family: inherit;
}

.player-card:hover:not(:disabled) {
    border-color: var(--primary);
    transform: translateY(-3px);
}

.card-icon {
    font-size: 1.8rem;
}

.card-name {
    font-weight: 800;
    text-align: center;
    word-break: break-word;
}

.card-status {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.vote-card:hover:not(:disabled) {
    border-color: var(--danger);
    box-shadow: 0 0 20px -8px var(--danger);
}

.dead-title {
    margin-top: 8px;
    color: var(--text-muted);
    font-size: 1rem;
    text-align: center;
}

/* Cartes des joueurs éliminés : rayées, grisées */
.eliminated-card {
    opacity: 0.45;
    filter: grayscale(0.8);
    cursor: default;
    position: relative;
}

.eliminated-card .card-name {
    text-decoration: line-through;
}

.eliminated-card::after {
    content: '❌';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    pointer-events: none;
}

/* Mélange de l'ordre de parole */
.shuffle-grid {
    margin-top: 20px;
}

.shuffle-card {
    position: relative;
    animation: shuffle-in 0.7s ease-out both;
    animation-delay: var(--delay);
}

@keyframes shuffle-in {
    0% {
        transform: translate(var(--dx), var(--dy)) rotate(var(--rot)) scale(0.55);
        opacity: 0;
    }
    60% {
        transform: translate(calc(var(--dx) * -0.12), calc(var(--dy) * -0.12)) rotate(calc(var(--rot) * -0.25)) scale(1.06);
        opacity: 1;
    }
    100% {
        transform: translate(0, 0) rotate(0deg) scale(1);
        opacity: 1;
    }
}

.order-badge {
    position: absolute;
    top: -10px;
    left: -10px;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--primary));
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Baloo 2', sans-serif;
    font-weight: 800;
    font-size: 0.9rem;
    color: #0b0620;
    border: 2px solid var(--card);
    z-index: 2;
    opacity: 0;
    animation: badge-pop 0.4s ease-out both;
    animation-delay: var(--badge-delay, 0s);
}

.order-badge-static {
    opacity: 1;
    animation: none;
    position: absolute;
    top: -10px;
    left: -10px;
}

@keyframes badge-pop {
    0% { transform: scale(0); opacity: 0; }
    70% { transform: scale(1.25); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

.shuffle-continue {
    animation: fade-in-late 0.5s ease-out both;
    animation-delay: 1s;
}

@keyframes fade-in-late {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Mystery / claimed cards (distribution des rôles) */
.mystery-card {
    aspect-ratio: 3 / 4;
    justify-content: center;
    background: linear-gradient(160deg, #4c2f9e, #26184f);
    border-color: #5a3fae;
    animation: pulse-glow 2.6s ease-in-out infinite;
}

.mystery-card .card-icon {
    font-size: 2.4rem;
}

.mystery-card:hover:not(:disabled) {
    border-color: var(--accent);
    box-shadow: 0 0 26px -6px var(--accent);
    animation-play-state: paused;
}

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 0 rgba(168, 85, 247, 0); }
    50% { box-shadow: 0 0 22px -4px rgba(168, 85, 247, 0.55); }
}

.claimed-card {
    aspect-ratio: 3 / 4;
    justify-content: center;
    background: rgba(34, 197, 94, 0.08);
    border-color: rgba(34, 197, 94, 0.4);
    cursor: default;
    position: relative;
}

.claimed-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--success);
    color: #06280f;
    font-size: 0.65rem;
    font-weight: 800;
    padding: 2px 7px;
    border-radius: 999px;
}

/* Avatars */
.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    font-family: 'Baloo 2', sans-serif;
    font-weight: 800;
    font-size: 1.5rem;
    color: white;
    overflow: hidden;
    flex-shrink: 0;
    border: 2px solid rgba(255, 255, 255, 0.15);
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-xl {
    width: 96px;
    height: 96px;
    font-size: 2.4rem;
}

.avatar-lg {
    width: 72px;
    height: 72px;
    font-size: 1.9rem;
}

.avatar-sm {
    width: 34px;
    height: 34px;
    font-size: 0.95rem;
}

.avatar-placeholder {
    background: rgba(255, 255, 255, 0.08) !important;
    border: 2px dashed var(--card-border);
}

.avatar-placeholder.has-photo {
    border-style: solid;
    background-size: cover;
    background-position: center;
}

.avatar-picker {
    position: relative;
    display: inline-block;
    cursor: pointer;
    margin: 0 auto;
}

.avatar-camera {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    border: 2px solid var(--card);
}

/* Modals (intro / naming / word reveal) */
.modal-overlay {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px 0 40px;
}

.modal-card {
    width: 100%;
    max-width: 360px;
    background: var(--card);
    border: 2px solid var(--card-border);
    border-radius: 26px;
    padding: 34px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    text-align: center;
    box-shadow: 0 20px 60px -20px rgba(0, 0, 0, 0.7);
}

.modal-card form {
    width: 100%;
}

.modal-kicker {
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-size: 0.72rem;
    font-weight: 800;
    color: var(--accent);
    background: rgba(34, 211, 238, 0.12);
    padding: 4px 12px;
    border-radius: 999px;
    margin: 0;
}

@keyframes bounce-in {
    0% { opacity: 0; transform: scale(0.82); }
    70% { opacity: 1; transform: scale(1.03); }
    100% { transform: scale(1); }
}

.bounce-in {
    animation: bounce-in 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.naming-form {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}

.name-input {
    text-align: center;
    font-size: 1.1rem;
    font-weight: 700;
    border-radius: 999px !important;
    padding: 13px 18px !important;
}

.reveal-box {
    width: 100%;
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.18), rgba(34, 211, 238, 0.12));
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 18px 14px;
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.proletaire-box {
    background: linear-gradient(135deg, rgba(192, 132, 252, 0.28), rgba(168, 85, 247, 0.16));
    color: var(--proletaire);
}

/* Reveal focus screen (résultat de vote) */
.reveal-focus {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 20px 0;
}

.reveal-card {
    width: 100%;
    max-width: 340px;
    background: var(--card);
    border: 2px solid var(--card-border);
    border-radius: 22px;
    padding: 30px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.reveal-card.role-civil {
    border-color: var(--civil);
    box-shadow: 0 0 30px -8px var(--civil);
}

.reveal-card.role-undercover {
    border-color: var(--undercover);
    box-shadow: 0 0 30px -8px var(--undercover);
}

.reveal-card.role-proletaire {
    border-color: var(--proletaire);
    box-shadow: 0 0 30px -8px var(--proletaire);
}

.reveal-name {
    font-size: 1.2rem;
    font-weight: 800;
    margin: 0;
}

.reveal-role {
    font-size: 1.6rem;
    font-weight: 800;
    margin: 0;
}

.reveal-role-label {
    margin: 0;
    color: var(--text-muted);
}

.warning-text {
    color: var(--warning);
    font-weight: 700;
    max-width: 340px;
    font-size: 0.9rem;
}

/* End screen */
.end-banner {
    text-align: center;
    padding: 30px 16px;
    border-radius: var(--radius);
    margin-bottom: 20px;
}

.win-civils {
    background: rgba(56, 189, 248, 0.12);
    border: 1px solid var(--civil);
}

.win-imposteurs {
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid var(--undercover);
}

.win-proletaire {
    background: rgba(192, 132, 252, 0.14);
    border: 1px solid var(--proletaire);
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 24px;
    background: var(--card);
    border-radius: var(--radius);
    overflow: hidden;
}

.results-table th,
.results-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--card-border);
    font-size: 0.9rem;
}

.results-table th {
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
}

.results-table tr.role-civil td:nth-child(3) { color: var(--civil); }
.results-table tr.role-undercover td:nth-child(3) { color: var(--undercover); }
.results-table tr.role-proletaire td:nth-child(3) { color: var(--proletaire); }

.end-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Bottom bar (reset + revoir un mot), visible pendant toute la partie */
.bottom-actions {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 32px;
    padding-top: 16px;
    border-top: 1px dashed var(--card-border);
}

.bottom-actions form {
    margin: 0;
}

/* Responsive tweaks */
@media (max-width: 480px) {
    .roles-config {
        grid-template-columns: 1fr;
    }

    .cards-grid {
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    }

    .logo {
        font-size: 2.1rem;
    }

    .modal-card {
        padding: 28px 18px;
    }

    .hero {
        padding: 32px 8px 22px;
    }

    .hero-float {
        font-size: 1.3rem;
        opacity: 0.22;
    }

    .roles-showcase {
        grid-template-columns: 1fr;
    }

    .role-chip {
        flex-direction: row;
        text-align: left;
        align-items: center;
        padding: 12px 14px;
    }

    .role-chip-desc {
        font-size: 0.8rem;
    }

    .win-conditions {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 360px) {
    .hero-badge {
        font-size: 0.72rem;
        padding: 5px 12px;
    }
}
