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

html, body {
    /* Pas de pull-to-refresh, pas de bounce iOS */
    overscroll-behavior: none;
    /* Pas de double-tap-zoom */
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
    /* Hauteur fiable mobile (gere les barres dynamiques) */
    height: 100%;
}

body {
    background: #1a1a2e;
    color: white;
    font-family: Arial, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    min-height: 100dvh;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.ecran {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 20px;
    width: 100%;
    max-width: 480px;
}

h1 {
    font-size: 3rem;
    color: #2ecc71;
    text-shadow: 0 0 20px #2ecc71;
    margin-bottom: 10px;
}

h2 {
    font-size: 1.6rem;
    color: #2ecc71;
}

h2 span {
    color: white;
    background: #2ecc71;
    padding: 4px 12px;
    border-radius: 6px;
    font-family: monospace;
    font-size: 1.8rem;
    letter-spacing: 4px;
}

button {
    padding: 14px 28px;
    min-height: 48px;        /* taille tactile minimale */
    font-size: 1rem;
    font-weight: bold;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.1s, opacity 0.1s;
    touch-action: manipulation;
}

button:hover {
    opacity: 0.85;
    transform: scale(1.03);
}

button:active {
    transform: scale(0.97);
}

#btn-copier {
    background: #34495e;
    color: white;
    font-size: 0.95rem;
}

#btn-copier.copie {
    background: #2ecc71;
}

#btn-creer {
    background: #2ecc71;
    color: #1a1a2e;
    font-size: 1.1rem;
    padding: 14px 36px;
}

#btn-rejoindre {
    background: #9b59b6;
    color: white;
}

#btn-demarrer {
    background: #2ecc71;
    color: #1a1a2e;
    font-size: 1.1rem;
    margin-top: 10px;
}

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

input {
    padding: 12px 16px;
    font-size: 1.1rem;
    border-radius: 8px;
    border: 2px solid #333;
    background: #16213e;
    color: white;
    text-transform: uppercase;
    letter-spacing: 3px;
    width: 160px;
    text-align: center;
}

input:focus {
    outline: none;
    border-color: #9b59b6;
}

#liste-joueurs {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 10px 0;
    min-height: 80px;
}

#liste-joueurs div {
    font-size: 1.1rem;
    font-weight: bold;
}

#attente-msg {
    color: #888;
    font-size: 0.9rem;
}

#jeu {
    flex-direction: column;
    gap: 10px;
    padding: 10px;
}

canvas {
    border: 2px solid #333;
    display: block;
    /* Responsive : on remplit la largeur dispo en gardant le ratio 18:32,
       sans depasser la hauteur du viewport (laisse de la place au score). */
    width: min(100vw - 20px, (100vh - 140px) * 18 / 32, 480px);
    width: min(100vw - 20px, (100dvh - 140px) * 18 / 32, 480px);
    height: auto;
    aspect-ratio: 18 / 32;
    /* Aucun geste navigateur sur le canvas — on capte les swipes nous-memes */
    touch-action: none;
}

#scores {
    display: flex;
    gap: 14px;
    font-size: 0.9rem;
    font-family: monospace;
    background: #11111b;
    padding: 8px 16px;
    border-radius: 8px;
    max-width: 100%;
    flex-wrap: wrap;
    justify-content: center;
}

#hint-swipe {
    color: #888;
    font-size: 0.8rem;
    text-align: center;
}

/* ── Overlay rotation (mobile en paysage) ───────────────────────── */
#rotation-msg {
    display: none;
    position: fixed;
    inset: 0;
    background: #1a1a2e;
    z-index: 1000;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    text-align: center;
    padding: 20px;
}

#rotation-msg > div:first-child {
    font-size: 4rem;
    animation: tourne 1.6s ease-in-out infinite;
}

#rotation-msg .sub {
    color: #888;
    font-size: 0.9rem;
}

@keyframes tourne {
    0%, 100% { transform: rotate(0deg); }
    50%      { transform: rotate(-90deg); }
}

/* Affiche l'overlay seulement quand l'ecran est en paysage ET petit
   (i.e. probablement un telephone, pas un grand ecran de bureau). */
@media (orientation: landscape) and (max-height: 500px) {
    #rotation-msg { display: flex; }
}