:root {
    --bg: #14171c;
    --surface: #1e2229;
    --buzz-red: #e8432f;
    --buzz-red-dark: #a82e1f;
    --gold: #e8b547;
    --text-primary: #f2f0ea;
    --text-secondary: #8b93a1;
    --green: #4fae7a;
    --locked-gray: #3a3f47;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    margin: 0;
    height: 100%;
    background: var(--bg);
    color: var(--text-primary);
    font-family: "Inter", sans-serif;
    overscroll-behavior: none;
    user-select: none;
}

/* ==========================================================================
   Éléments partagés (utilisés sur plusieurs écrans)
   ========================================================================== */

.app {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    padding: env(safe-area-inset-top) env(safe-area-inset-right)
        env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.statusbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px 12px;
}

.badge {
    font-family: "JetBrains Mono", monospace;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--surface);
    padding: 6px 12px;
    border-radius: 20px;
    letter-spacing: 0.02em;
}

.status-dot {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.status-dot::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--green);
    transition: background 0.2s ease;
}

.status-dot.locked::before {
    background: var(--buzz-red);
}

.banner {
    position: relative;
    margin: 0 20px;
    background: var(--gold);
    color: #3d2a05;
    border-radius: 14px;
    padding: 14px 18px;
    font-family: "Archivo Black", sans-serif;
    font-size: 15px;
    text-transform: uppercase;
    letter-spacing: 0.01em;
    text-align: center;
    transform: translateY(-140%);
    opacity: 0;
    transition:
        transform 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.2),
        opacity 0.25s ease;
    pointer-events: none;
}

.banner.show {
    transform: translateY(0);
    opacity: 1;
}

.stage {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

/* ==========================================================================
   Écran joueur (index.html)
   ========================================================================== */

.ring {
    position: absolute;
    width: clamp(220px, 66vw, 300px);
    height: clamp(220px, 66vw, 300px);
    border-radius: 50%;
    border: 2px solid var(--buzz-red);
    opacity: 0;
}

.ring.pulse {
    animation: pulse 1.4s ease-out infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 0.6;
    }
    100% {
        transform: scale(1.35);
        opacity: 0;
    }
}

.buzz {
    position: relative;
    width: clamp(200px, 58vw, 280px);
    height: clamp(200px, 58vw, 280px);
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(
        circle at 32% 28%,
        #ff6a52 0%,
        var(--buzz-red) 55%,
        var(--buzz-red-dark) 100%
    );
    box-shadow:
        0 10px 0 var(--buzz-red-dark),
        0 14px 24px rgba(232, 67, 47, 0.35),
        inset 0 -6px 12px rgba(0, 0, 0, 0.15);
    color: white;
    font-family: "Archivo Black", sans-serif;
    font-size: clamp(28px, 8vw, 36px);
    letter-spacing: 0.04em;
    cursor: pointer;
    transition:
        transform 0.08s ease,
        box-shadow 0.08s ease,
        background 0.3s ease,
        filter 0.3s ease;
}

.buzz-label {
    order: 2;
    text-align: center;
}

.buzz:active:not(.locked) {
    transform: translateY(8px);
    box-shadow:
        0 2px 0 var(--buzz-red-dark),
        0 4px 10px rgba(232, 67, 47, 0.3),
        inset 0 -6px 12px rgba(0, 0, 0, 0.2);
}

.buzz.locked {
    background: radial-gradient(
        circle at 32% 28%,
        #4a4f58 0%,
        var(--locked-gray) 55%,
        #2a2e34 100%
    );
    box-shadow:
        0 10px 0 #23262b,
        inset 0 -6px 12px rgba(0, 0, 0, 0.25);
    color: var(--text-secondary);
    cursor: not-allowed;
    filter: saturate(0.5);
}

.lock-icon {
    display: none;
    width: 34px;
    height: 34px;
    flex-shrink: 0;
}

.lock-icon.left {
    order: 1;
}

.lock-icon.right {
    order: 3;
}

.buzz.locked .lock-icon {
    display: block;
}

.playerinfo {
    text-align: center;
    padding: 4px 20px 22px;
    font-size: 13px;
    color: var(--text-secondary);
}

.playerinfo strong {
    color: var(--text-primary);
    font-weight: 500;
}

/* ==========================================================================
   Écran host (host.html)
   ========================================================================== */

.host-app {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
    padding: env(safe-area-inset-top) env(safe-area-inset-right)
        env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* Lobby */
.lobby {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 28px;
    padding: 24px;
    text-align: center;
}

.room-code-label {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin: 0 0 8px;
}

.room-code {
    font-family: "JetBrains Mono", monospace;
    font-size: 40px;
    font-weight: 500;
    letter-spacing: 0.1em;
    background: var(--surface);
    padding: 16px 28px;
    border-radius: 16px;
    margin: 0;
    user-select: text;
}

.lobby-players {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    max-width: 340px;
}

.player-chip {
    background: var(--surface);
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 13px;
}

.mode-select {
    position: relative;
    display: flex;
    gap: 6px;
    background: var(--surface);
    padding: 4px;
    border-radius: 14px;
    width: 100%;
    max-width: 340px;
}

.mode-indicator {
    position: absolute;
    top: 4px;
    bottom: 4px;
    left: 0;
    background: var(--gold);
    border-radius: 10px;
    transition:
        transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
        width 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 0;
}

.mode-option {
    position: relative;
    z-index: 1;
    flex: 1;
    padding: 10px 8px;
    border-radius: 10px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    font-family: "Inter", sans-serif;
    cursor: pointer;
    transition: color 0.35s ease;
}

.mode-option.active {
    color: #3d2a05;
}

.start-btn {
    background: var(--buzz-red);
    color: white;
    border: none;
    padding: 16px 32px;
    border-radius: 16px;
    font-family: "Archivo Black", sans-serif;
    font-size: 16px;
    letter-spacing: 0.03em;
    cursor: pointer;
    width: 100%;
    max-width: 320px;
}

/* Partie en cours */
.game {
    display: flex;
    flex-direction: column;
    flex: 1;
    padding-top: 12px;
}

.meta-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 0 20px 16px;
    font-size: 13px;
    color: var(--text-secondary);
}

.stop-btn {
    background: transparent;
    border: 1px solid var(--buzz-red);
    color: var(--buzz-red);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-family: "Inter", sans-serif;
    cursor: pointer;
}

.host-banner {
    margin: 0 20px 16px;
    background: var(--gold);
    color: #3d2a05;
    border-radius: 16px;
    padding: 18px 20px;
    transform: translateY(-160%);
    opacity: 0;
    transition:
        transform 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.2),
        opacity 0.25s ease;
}

.host-banner.show {
    transform: translateY(0);
    opacity: 1;
}

.banner-title {
    font-family: "Archivo Black", sans-serif;
    font-size: 18px;
    text-transform: uppercase;
    margin: 0 0 12px;
}

.banner-actions {
    display: flex;
    gap: 10px;
}

.banner-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px;
    border: none;
    border-radius: 10px;
    font-family: "Inter", sans-serif;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
}

.banner-btn.good {
    background: var(--green);
    color: #0f2e1e;
}

.banner-btn.bad {
    background: var(--buzz-red);
    color: white;
}

.controls-row {
    display: flex;
    gap: 10px;
    margin: 0 20px 20px;
}

.control-btn {
    flex: 1;
    background: var(--surface);
    border: 1px solid #2a2e34;
    color: var(--text-primary);
    padding: 12px;
    border-radius: 12px;
    font-family: "Inter", sans-serif;
    font-weight: 500;
    font-size: 13px;
    cursor: pointer;
}

.control-btn.primary {
    background: var(--gold);
    color: #3d2a05;
    border-color: transparent;
}

.players-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0 20px;
}

.player-row {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface);
    border-radius: 12px;
    padding: 12px 14px;
    cursor: pointer;
}

.player-name {
    flex: 1;
    font-weight: 500;
    font-size: 14px;
}

.status-pill {
    font-size: 12px;
    font-weight: 500;
    padding: 4px 10px;
    border-radius: 20px;
    background: rgba(79, 174, 122, 0.15);
    color: var(--green);
}

.status-pill.bloque {
    background: rgba(232, 67, 47, 0.15);
    color: var(--buzz-red);
}

.status-pill.bloque-double {
    background: rgba(232, 67, 47, 0.25);
    color: #ff7a63;
}

.changeState-btn {
    display: flex;
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: none;
    background: var(--locked-gray);
    color: var(--text-primary);
    cursor: pointer;
}

/* ==========================================================================
   Écran d'accueil (welcome.html)
   ========================================================================== */

.welcome-app {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100dvh;
    padding: env(safe-area-inset-top) 24px env(safe-area-inset-bottom);
    gap: 48px;
    text-align: center;
}

.brand-mark {
    font-family: "Archivo Black", sans-serif;
    font-size: 56px;
    letter-spacing: 0.04em;
    color: var(--buzz-red);
    margin: 0;
    text-shadow: 0 4px 0 var(--buzz-red-dark);
}

.brand-tagline {
    font-size: 13px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin: 8px 0 0;
}

.welcome-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    max-width: 320px;
}

.welcome-btn {
    border: none;
    border-radius: 16px;
    padding: 18px;
    font-family: "Archivo Black", sans-serif;
    font-size: 15px;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: transform 0.08s ease;
}

.welcome-btn:active {
    transform: scale(0.97);
}

.welcome-btn.create {
    background: var(--gold);
    color: #3d2a05;
}

.welcome-btn.join {
    background: var(--surface);
    color: var(--text-primary);
    border: 1px solid #2a2e34;
}

.join-form {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

.join-form.open {
    grid-template-rows: 1fr;
}

.join-form > * {
    overflow: hidden;
}

.join-form-inner {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-top: 4px;
}

.join-input {
    background: var(--surface);
    border: 1px solid #2a2e34;
    border-radius: 12px;
    padding: 14px 16px;
    color: var(--text-primary);
    font-family: "Inter", sans-serif;
    font-size: 15px;
}

.join-input.code {
    font-family: "JetBrains Mono", monospace;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.join-input::placeholder {
    color: var(--text-secondary);
}

.join-input:focus {
    outline: none;
    border-color: var(--gold);
}

.join-submit {
    background: var(--buzz-red);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 14px;
    font-family: "Archivo Black", sans-serif;
    font-size: 14px;
    cursor: pointer;
    margin-top: 4px;
}

/* ==========================================================================
   Debug / dev uniquement — plus référencé dans le HTML depuis le branchement
   au serveur. À supprimer si tu ne comptes pas la remettre.
   ========================================================================== */

.demo-panel {
    position: fixed;
    bottom: env(safe-area-inset-bottom, 0);
    left: 0;
    right: 0;
    display: flex;
    gap: 8px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(6px);
}

.demo-panel button {
    flex: 1;
    font-family: "Inter", sans-serif;
    font-size: 11px;
    color: var(--text-secondary);
    background: var(--surface);
    border: 1px solid #2a2e34;
    border-radius: 8px;
    padding: 8px 4px;
}

.demo-panel span {
    display: block;
    color: #55595f;
    font-size: 9px;
    text-align: center;
    padding-bottom: 4px;
}