/* ===========================
   IMPORTS & GOOGLE FONTS
   =========================== */

@import url('https://fonts.googleapis.com/css2?family=Rubik:wght@400;600;700;800&family=Poppins:wght@600;700;800&display=swap');

/* ===========================
   VARIABLES & RESET
   =========================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary-color: #ec4899;
    --accent-color: #f59e0b;
    --success-color: #10b981;
    --warning-color: #f97316;
    --danger-color: #ef4444;
    
    --bg-dark: #0f172a;
    --bg-light: #f8fafc;
    --surface-dark: #1e293b;
    --surface-light: #ffffff;
    --text-dark: #0f172a;
    --text-light: #ffffff;
    --text-muted: #64748b;
    
    --border-radius: 12px;
    --border-radius-lg: 20px;
    --transition: all 0.3s ease;
}

/* ===========================
   GLOBAL STYLES
   =========================== */

body {
    font-family: 'Poppins', 'Inter', sans-serif;
    background: linear-gradient(135deg, var(--bg-dark) 0%, #1a1f3a 100%);
    color: var(--text-light);
    line-height: 1.6;
    min-height: 100vh;
    padding: 20px;
}

html {
    scroll-behavior: smooth;
}

/* ===========================
   TYPOGRAPHY
   =========================== */

h1 {
    font-size: 3rem;
    font-weight: 800;
    font-family: 'Rubik', sans-serif;
    background: linear-gradient(135deg, var(--primary-light), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 10px;
    text-align: center;
    text-shadow: none;
    animation: slideDown 0.6s ease;
}

h4 {
    font-size: 1.3rem;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 30px;
    font-weight: 400;
    animation: fadeIn 0.8s ease 0.2s both;
}

label {
    font-weight: 600;
    display: block;
    margin-bottom: 8px;
    color: var(--text-light);
    font-family: 'Poppins', sans-serif;
    font-size: 1rem;
}

/* ===========================
   LAYOUT - MAIN CONTAINER
   =========================== */

main {
    max-width: 900px;
    margin: 0 auto;
    padding: 40px 20px;
    animation: fadeIn 0.6s ease;
}

/* ===========================
   FORMS & INPUTS
   =========================== */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.form {
    background: var(--surface-dark);
    border-radius: var(--border-radius-lg);
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
}

.player-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    justify-content: center;
    margin-bottom: 35px;
}

.player-controls label {
    margin-bottom: 0;
    white-space: nowrap;
}

.player-controls-inputs {
    display: flex;
    align-items: center;
    gap: 15px;
}

#amountplayers {
    width: 170px;
    padding: 14px;
    border-radius: var(--border-radius);
    border: 2px solid var(--primary-color);
    background-color: rgba(99, 102, 241, 0.1);
    color: var(--text-light);
    font-size: 1.1rem;
    font-weight: 600;
    text-align: center;
    transition: var(--transition);
}

#amountplayers:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(236, 72, 153, 0.2);
    background-color: rgba(236, 72, 153, 0.1);
}

input[type="text"] {
    padding: 12px;
    border-radius: var(--border-radius);
    border: 2px solid var(--primary-color);
    background-color: rgba(99, 102, 241, 0.1);
    color: var(--text-light);
    font-size: 1rem;
    transition: var(--transition);
    margin-bottom: 0;
}

input[type="text"]:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(236, 72, 153, 0.2);
}

input[type="text"]::placeholder {
    color: var(--text-muted);
}

.player-names {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 12px 20px;
    margin-bottom: 35px;
    padding-bottom: 20px;
}

.player-names br {
    display: none;
}

.player-names label {
    margin-bottom: 0;
    white-space: nowrap;
}

.player-names input {
    width: 100%;
}

/* ===========================
   BUTTONS
   =========================== */

button {
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    border-radius: var(--border-radius);
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form > button[type="submit"],
.form > button {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: var(--text-light);
    padding: 16px 40px;
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    display: block;
    box-shadow: 0 10px 30px rgba(99, 102, 241, 0.3);
    position: relative;
    overflow: hidden;
}

.form > button[type="submit"]:hover,
.form > button:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 40px rgba(99, 102, 241, 0.4);
    background: linear-gradient(135deg, var(--primary-light), var(--primary-color));
}

.form > button[type="submit"]:active,
.form > button:active {
    transform: translateY(0);
}

button#decrease-players,
button#increase-players {
    background: linear-gradient(135deg, var(--accent-color), #f97316);
    color: var(--text-light);
    padding: 0;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1;
    box-shadow: 0 5px 15px rgba(245, 158, 11, 0.3);
}

button#decrease-players:hover,
button#increase-players:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 20px rgba(245, 158, 11, 0.4);
}

button#decrease-players:active,
button#increase-players:active {
    transform: scale(0.95);
}

/* Game page buttons */
.game-container button {
    padding: 16px 30px;
    margin: 10px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

.game-container button:not(.secondary) {
    background: linear-gradient(135deg, var(--secondary-color), #db2777);
    color: var(--text-light);
}

.game-container button:not(.secondary):hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 35px rgba(236, 72, 153, 0.4);
}

.game-container button.secondary {
    background: linear-gradient(135deg, var(--text-muted), #475569);
    color: var(--text-light);
}

.game-container button.secondary:hover {
    background: linear-gradient(135deg, #64748b, #334155);
    transform: translateY(-2px);
    box-shadow: 0 15px 35px rgba(100, 116, 139, 0.4);
}

/* ===========================
   GAME CONTAINER
   =========================== */

.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 40px;
    animation: fadeIn 0.6s ease;
}

/* ===========================
   CARD DISPLAY
   =========================== */

.card-display {
    background: linear-gradient(135deg, var(--primary-dark), var(--secondary-color));
    border-radius: var(--border-radius-lg);
    padding: 60px 40px;
    width: 100%;
    max-width: 600px;
    box-shadow: 0 30px 80px rgba(99, 102, 241, 0.4), 0 0 40px rgba(236, 72, 153, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.1);
    text-align: center;
    min-height: 300px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    animation: cardFlip 0.6s ease;
    position: relative;
    overflow: hidden;
    transition: all 0.4s ease;
}

.card-display::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
    animation: shimmer 3s infinite;
}

/* Colorisation par catégorie */
.card-display.category-boisson {
    background: linear-gradient(135deg, #c7253e 0%, #ef4444 100%);
    box-shadow: 0 30px 80px rgba(239, 68, 68, 0.4), 0 0 40px rgba(239, 68, 68, 0.2);
}

.card-display.category-boisson::before {
    background: radial-gradient(circle, rgba(255, 255, 255, 0.15) 0%, transparent 70%);
}

.card-display.category-défi {
    background: linear-gradient(135deg, #0369a1 0%, #0ea5e9 100%);
    box-shadow: 0 30px 80px rgba(14, 165, 233, 0.4), 0 0 40px rgba(14, 165, 233, 0.2);
}

.card-display.category-défi::before {
    background: radial-gradient(circle, rgba(255, 255, 255, 0.12) 0%, transparent 70%);
}

.card-display.category-divers {
    background: linear-gradient(135deg, #7c3aed 0%, #a855f7 100%);
    box-shadow: 0 30px 80px rgba(168, 85, 247, 0.4), 0 0 40px rgba(168, 85, 247, 0.2);
}

.card-display.category-divers::before {
    background: radial-gradient(circle, rgba(255, 255, 255, 0.12) 0%, transparent 70%);
}

.card-display.category-parler {
    background: linear-gradient(135deg, #059669 0%, #10b981 100%);
    box-shadow: 0 30px 80px rgba(16, 185, 129, 0.4), 0 0 40px rgba(16, 185, 129, 0.2);
}

.card-display.category-parler::before {
    background: radial-gradient(circle, rgba(255, 255, 255, 0.12) 0%, transparent 70%);
}

.card-category {
    font-size: 0.9rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 15px;
    background: rgba(255, 255, 255, 0.15);
    padding: 8px 16px;
    border-radius: 20px;
    display: inline-block;
    position: relative;
    z-index: 1;
}

.card-text {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-light);
    line-height: 1.4;
    position: relative;
    z-index: 1;
    max-width: 500px;
}

/* ===========================
   PLAYERS INFO
   =========================== */

.players-info {
    width: 100%;
    max-width: 600px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 12px;
}

.player-badge {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    padding: 16px 14px;
    border-radius: 60px;
    text-align: center;
    font-weight: 600;
    font-size: 0.9rem;
    box-shadow: 0 5px 15px rgba(99, 102, 241, 0.3);
    border: 2px solid rgba(99, 102, 241, 0.5);
    transition: var(--transition);
    color: var(--text-light);
    width: 140px;
    min-height: 80px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    word-break: break-word;
    overflow: hidden;
    flex-shrink: 0;
}

.player-badge:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.4);
}

.player-badge.active {
    background: linear-gradient(135deg, var(--secondary-color), #db2777);
    box-shadow: 0 0 0 3px rgba(236, 72, 153, 0.3), 0 8px 30px rgba(236, 72, 153, 0.5);
    transform: scale(1.08) translateY(-5px);
    border-color: var(--secondary-color);
    animation: playerActivePulse 0.6s ease;
}

@keyframes playerActivePulse {
    0% {
        transform: scale(0.95) translateY(0);
        box-shadow: 0 0 0 0px rgba(236, 72, 153, 0.6), 0 8px 30px rgba(236, 72, 153, 0.5);
    }
    50% {
        transform: scale(1.12) translateY(-5px);
        box-shadow: 0 0 0 8px rgba(236, 72, 153, 0.2), 0 8px 30px rgba(236, 72, 153, 0.5);
    }
    100% {
        transform: scale(1.08) translateY(-5px);
        box-shadow: 0 0 0 3px rgba(236, 72, 153, 0.3), 0 8px 30px rgba(236, 72, 153, 0.5);
    }
}

/* ===========================
   GAME CONTROLS
   =========================== */

.game-controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
    width: 100%;
    max-width: 600px;
}

/* ===========================
   RESPONSIVE DESIGN
   =========================== */

@media (max-width: 768px) {
    h1 {
        font-size: 2rem;
    }

    h4 {
        font-size: 1.1rem;
    }

    main {
        padding: 20px 10px;
    }

    .form {
        padding: 30px 20px;
    }

    .card-display {
        padding: 40px 20px;
        min-height: 250px;
    }

    .card-text {
        font-size: 1.3rem;
    }

    .player-names {
        grid-template-columns: auto 1fr;
    }

    .form > button[type="submit"],
    .form > button {
        max-width: 100%;
    }

    button#decrease-players,
    button#increase-players {
        width: 45px;
        height: 45px;
    }

    .player-controls-inputs {
        width: 100%;
    }

    #amountplayers {
        width: 120px;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 1.5rem;
    }

    h4 {
        font-size: 0.95rem;
    }

    body {
        padding: 10px;
    }

    main {
        padding: 15px 5px;
    }

    .form {
        padding: 20px;
        border-radius: var(--border-radius);
    }

    .card-display {
        padding: 30px 15px;
        max-width: 100%;
    }

    .card-text {
        font-size: 1rem;
    }

    .card-category {
        font-size: 0.75rem;
        padding: 6px 12px;
    }

    .player-controls-wrapper {
        width: 100%;
        gap: 12px;
    }

    .player-controls {
        gap: 10px;
        margin-bottom: 12px;
    }

    .player-controls-inputs {
        gap: 10px;
        width: 100%;
        justify-content: center;
    }

    button#decrease-players,
    button#increase-players {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }

    #amountplayers {
        width: 120px;
        font-size: 1.1rem;
        padding: 14px;
    }

    .game-container button {
        padding: 14px 20px;
        font-size: 0.9rem;
        margin: 8px 5px;
    }

    .player-names {
        grid-template-columns: auto 1fr;
        gap: 8px 12px;
    }
}

/* ===========================
   ACCESSIBILITY
   =========================== */

button:focus {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

input:focus {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

/* ===========================
   UTILITY CLASSES
   =========================== */

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.text-center {
    text-align: center;
}

.text-muted {
    color: var(--text-muted);
}

/* ===========================
   ENDGAME EFFECT
   =========================== */

.card-display.endgame {
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 50%, #ec4899 100%);
    box-shadow: 0 30px 100px rgba(245, 158, 11, 0.6), 0 0 60px rgba(236, 72, 153, 0.4), inset 0 0 30px rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    animation: endgamePulse 0.8s ease-in-out, endgameGlow 2s ease-in-out infinite;
}

.card-display.endgame .card-category {
    font-size: 1.3rem;
    animation: bounce 0.6s ease;
}

.card-display.endgame .card-text {
    font-size: 2rem;
    animation: slideUp 0.6s ease 0.2s both;
}

.endgame-subtitle {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.95);
    margin-top: 20px;
    position: relative;
    z-index: 1;
    animation: fadeIn 0.8s ease 0.4s both;
}

.endgame-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
}

.confetti {
    position: fixed;
    width: 10px;
    height: 10px;
    background: radial-gradient(circle at 30% 30%, #fbbf24, #f59e0b);
    opacity: 0.8;
    animation: confettiFall linear forwards;
    top: -10px;
    border-radius: 50%;
    z-index: 10;
}

.confetti:nth-child(odd) {
    background: radial-gradient(circle at 30% 30%, #ec4899, #db2777);
}

.confetti:nth-child(3n) {
    background: radial-gradient(circle at 30% 30%, #a855f7, #7c3aed);
}

.confetti:nth-child(5n) {
    background: radial-gradient(circle at 30% 30%, #06b6d4, #0891b2);
}

@keyframes endgamePulse {
    0% {
        transform: scale(0.9);
        opacity: 0;
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes endgameGlow {
    0%, 100% {
        box-shadow: 0 30px 100px rgba(245, 158, 11, 0.6), 0 0 60px rgba(236, 72, 153, 0.4), inset 0 0 30px rgba(255, 255, 255, 0.2);
    }
    50% {
        box-shadow: 0 30px 120px rgba(245, 158, 11, 0.8), 0 0 80px rgba(236, 72, 153, 0.6), inset 0 0 40px rgba(255, 255, 255, 0.3);
    }
}

@keyframes confettiFall {
    to {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}
