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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    height: 100vh;
    overflow: hidden;
    padding: 1rem;
    display: flex;
    flex-direction: column;
}

.header {
    text-align: center;
    margin-bottom: 1rem;
    flex-shrink: 0;
}

.wine-name {
    font-size: clamp(1.5rem, 4vh, 3rem);
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    margin-bottom: 0.3rem;
}

.subtitle {
    font-size: clamp(0.8rem, 2vh, 1.2rem);
    opacity: 0.9;
}

.votes-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
}

.votes-grid {
    display: grid;
    gap: min(1rem, 2vh);
    width: 100%;
    height: 100%;
    max-height: calc(100vh - 8rem);
}

/* Calcul automatique des colonnes selon le nombre d'éléments */
.votes-grid[data-count="1"] { grid-template-columns: 1fr; }
.votes-grid[data-count="2"] { grid-template-columns: repeat(2, 1fr); }
.votes-grid[data-count="3"] { grid-template-columns: repeat(3, 1fr); }
.votes-grid[data-count="4"] { grid-template-columns: repeat(2, 1fr); }
.votes-grid[data-count="5"], .votes-grid[data-count="6"] { grid-template-columns: repeat(3, 1fr); }
.votes-grid[data-count="7"], .votes-grid[data-count="8"], .votes-grid[data-count="9"] { grid-template-columns: repeat(3, 1fr); }
.votes-grid[data-count="10"], .votes-grid[data-count="11"], .votes-grid[data-count="12"] { grid-template-columns: repeat(4, 1fr); }

/* Pour plus de 12 participants */
.votes-grid:not([data-count="1"]):not([data-count="2"]):not([data-count="3"]):not([data-count="4"]):not([data-count="5"]):not([data-count="6"]):not([data-count="7"]):not([data-count="8"]):not([data-count="9"]):not([data-count="10"]):not([data-count="11"]):not([data-count="12"]) {
    grid-template-columns: repeat(auto-fit, minmax(min(200px, 20vw), 1fr));
}

.voter-card {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border-radius: min(15px, 3vh);
    padding: min(1.5rem, 3vh);
    text-align: center;
    transition: transform 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    min-height: 0;
    position: relative;
    container-type: inline-size;
}

.voter-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
}

.voter-result {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-height: min(80px, 10vh);
}

.voter-card:hover {
    transform: scale(1.05);
}

.voter-photo {
    width: max(4vw, min(8vw, 100px));
    height: max(4vw, min(8vw, 100px));
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: min(0.8rem, 1.5vh);
    border: 2px solid rgba(255, 255, 255, 0.3);
    flex-shrink: 0;
}

/* Photos adaptées selon le nombre de participants */
.votes-grid[data-count="1"] .voter-photo,
.votes-grid[data-count="2"] .voter-photo {
    width: max(8vw, min(12vw, 140px));
    height: max(8vw, min(12vw, 140px));
}

.votes-grid[data-count="3"] .voter-photo {
    width: max(6vw, min(10vw, 120px));
    height: max(6vw, min(10vw, 120px));
}

.votes-grid[data-count="4"] .voter-photo,
.votes-grid[data-count="5"] .voter-photo,
.votes-grid[data-count="6"] .voter-photo {
    width: max(5vw, min(9vw, 110px));
    height: max(5vw, min(9vw, 110px));
}

/* Photos moyennes pour 7-12 participants */
.votes-grid[data-count="7"] .voter-photo,
.votes-grid[data-count="8"] .voter-photo,
.votes-grid[data-count="9"] .voter-photo,
.votes-grid[data-count="10"] .voter-photo,
.votes-grid[data-count="11"] .voter-photo,
.votes-grid[data-count="12"] .voter-photo {
    width: max(4vw, min(7vw, 90px));
    height: max(4vw, min(7vw, 90px));
}

.voter-name {
    font-size: max(1.2vw, min(2.5vw, 1.8rem));
    font-weight: 600;
    margin-bottom: 0.3em;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.2);
    line-height: 1.1;
}

.vote-score {
    font-size: max(4vw, min(8vw, 5rem));
    font-weight: bold;
    margin-bottom: 0.1em;
    line-height: 1;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

/* Code couleur selon la note */
.vote-score.excellent {
    color: #4ade80;
}

.vote-score.good {
    color: #fbbf24;
}

.vote-score.average {
    color: #fb923c;
}

.vote-score.poor {
    color: #ef4444;
}

/* États des votes */
.voter-card.voting {
    border-left: 4px solid #3b82f6;
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.4);
    animation: pulse 2s infinite;
    background: rgba(59, 130, 246, 0.1);
}

.voter-card.voted {
    border-left: 4px solid #10b981;
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.3);
    background: rgba(16, 185, 129, 0.1);
}

.voting-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.voting-spinner {
    width: min(35px, 4.5vh);
    height: min(35px, 4.5vh);
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top: 3px solid #ffffff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: min(0.5rem, 1vh);
}

.voted-check {
    width: min(40px, 5vh);
    height: min(40px, 5vh);
    background: #10b981;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: min(0.5rem, 1vh);
    position: relative;
}

.voted-check::after {
    content: '✓';
    color: white;
    font-size: min(20px, 2.5vh);
    font-weight: bold;
}

.status-text.voting {
    color: #ffffff;
}

.status-text.voted {
    color: #34d399;
}

/* Animations */
@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Mode compact pour les indicateurs */
.votes-grid[data-large="true"] .voter-result {
    min-height: min(60px, 8vh);
}

.votes-grid[data-large="true"] .voting-spinner {
    width: min(25px, 3.5vh);
    height: min(25px, 3.5vh);
    margin-bottom: min(0.3rem, 0.5vh);
}

.votes-grid[data-large="true"] .voted-check {
    width: min(30px, 4vh);
    height: min(30px, 4vh);
    margin-bottom: min(0.3rem, 0.5vh);
}

.votes-grid[data-large="true"] .voted-check::after {
    font-size: min(16px, 2vh);
}

/* Bordure colorée pour les notes publiées */
.voter-card.published.excellent {
    border-left: 4px solid #4ade80;
    box-shadow: 0 0 20px rgba(74, 222, 128, 0.2);
}

.voter-card.published.good {
    border-left: 4px solid #fbbf24;
    box-shadow: 0 0 20px rgba(251, 191, 36, 0.2);
}

.voter-card.published.average {
    border-left: 4px solid #fb923c;
    box-shadow: 0 0 20px rgba(251, 146, 60, 0.2);
}

.voter-card.published.poor {
    border-left: 4px solid #ef4444;
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.2);
}

.score-label {
    font-size: max(1.2vw, min(2.5vw, 1.8rem));
    opacity: 0.8;
}

.status-text {
    font-size: max(1.5vw, min(3vw, 2rem));
    font-weight: 600;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}

/* Animation d'apparition */
@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.voter-card {
    animation: fadeInScale 0.5s ease forwards;
}

/* Ajustements spéciaux selon le nombre de participants */
.votes-grid[data-count="1"] .voter-name {
    font-size: max(2vw, min(3.5vw, 2.5rem));
}

.votes-grid[data-count="1"] .vote-score {
    font-size: max(8vw, min(12vw, 8rem));
}

.votes-grid[data-count="2"] .voter-name {
    font-size: max(1.8vw, min(3vw, 2.2rem));
}

.votes-grid[data-count="2"] .vote-score {
    font-size: max(6vw, min(10vw, 7rem));
}

.votes-grid[data-count="3"] .voter-name {
    font-size: max(1.5vw, min(2.5vw, 2rem));
}

.votes-grid[data-count="3"] .vote-score {
    font-size: max(5vw, min(8vw, 6rem));
}

/* Pour 4-6 participants */
.votes-grid[data-count="4"] .voter-name,
.votes-grid[data-count="5"] .voter-name,
.votes-grid[data-count="6"] .voter-name {
    font-size: max(1.3vw, min(2.2vw, 1.8rem));
}

.votes-grid[data-count="4"] .vote-score,
.votes-grid[data-count="5"] .vote-score,
.votes-grid[data-count="6"] .vote-score {
    font-size: max(4vw, min(7vw, 5.5rem));
}

/* Indicateur d'état de connexion */
.connection-status {
    font-size: clamp(0.7rem, 1.5vh, 1rem);
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-weight: 500;
    text-shadow: none;
    margin-top: 0.5rem;
    display: inline-block;
    transition: all 0.3s ease;
}

.connection-status.connected {
    background-color: rgba(16, 185, 129, 0.2);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.connection-status.disconnected {
    background-color: rgba(239, 68, 68, 0.2);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.connection-status.reconnecting {
    background-color: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.3);
    animation: pulse 1.5s infinite;
}

.connection-status.error {
    background-color: rgba(239, 68, 68, 0.3);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.4);
}

.connection-status.failed {
    background-color: rgba(127, 29, 29, 0.3);
    color: #fca5a5;
    border: 1px solid rgba(127, 29, 29, 0.4);
}

/* QR Code Overlay */
.qr-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

.qr-overlay.hidden {
    display: none;
}

.qr-container {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 2rem;
    text-align: center;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.3);
    animation: scaleIn 0.3s ease;
}

.qr-container h2 {
    color: #1f2937;
    font-size: clamp(1.5rem, 4vh, 2.5rem);
    font-weight: bold;
    margin-bottom: 1.5rem;
    text-shadow: none;
}

.qr-container p {
    color: #6b7280;
    font-size: clamp(1rem, 2.5vh, 1.3rem);
    margin-top: 1.5rem;
    font-weight: 500;
}

#qrcode {
    margin: 0 auto;
    background: white;
    border-radius: 10px;
    padding: 1rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

#qrcode canvas, #qrcode img {
    display: block;
    margin: 0 auto;
    border-radius: 5px;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}