:root {
    --bg: #0a051c;
    --surface: #160f30;
    --surface-2: #120b28;
    --text: #f2f3f5;
    --muted: #9d94c2;
    --primary: #7c3ce0;
    --primary-hover: #6b2fc7;
    --danger: #e74c3c;
    --border: #2a2050;
    --radius: 12px;

    --tier-s: #fd3e5a;
    --tier-a: #fe7a25;
    --tier-b: #fdc92e;
    --tier-c: #5acb56;
    --tier-d: #2c7bf4;
    --tier-e: #7e3cdd;
}

* {
    box-sizing: border-box;
}

/* L'attribut hidden l'emporte sur les display: flex des classes (.stack, label...). */
[hidden] {
    display: none !important;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    line-height: 1.4;
}

.container {
    max-width: 480px;
    margin: 0 auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.brand-logo {
    display: block;
    max-width: 260px;
    width: 100%;
    margin: 1rem auto 0;
}

.room-logo {
    display: block;
    width: 40px;
    height: 40px;
    margin-bottom: 0.5rem;
}

.room-header-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
}

.back-home {
    color: var(--muted);
    font-size: 0.9rem;
    text-decoration: none;
    padding: 0.35rem 0;
}

.back-home::before {
    content: "← ";
}

.back-home:hover {
    color: var(--text);
}

/* Lien presente comme un bouton (meme rendu que button). */
a.button {
    display: block;
    text-align: center;
    font-size: 1rem;
    padding: 0.65rem 0.75rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #241a48;
    color: var(--text);
    text-decoration: none;
    margin-top: 0.75rem;
}

a.button.primary {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    font-weight: 600;
}

.muted {
    color: var(--muted);
}

.small {
    font-size: 0.85rem;
}

.resume-card .resume-theme {
    font-size: 1.15rem;
    font-weight: 600;
    margin: 0 0 0.25rem;
}

.tagline {
    text-align: center;
    color: var(--muted);
    margin-top: 0;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
}

.card h1 {
    margin-top: 0;
}

.stack {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.9rem;
    color: var(--muted);
}

.checkbox-label {
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
}

.checkbox-label input[type="checkbox"] {
    width: auto;
    flex: 0 0 auto;
}

.tier-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: -0.25rem;
}

.chip {
    font-size: 0.9rem;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
}

.chip.selected {
    border-color: var(--primary);
    background: rgba(124, 60, 224, 0.25);
}

/* Reglage rattache a la case a cocher qui le precede. */
.sub-option {
    margin-left: 1.75rem;
}

.sub-option[hidden] {
    display: none;
}

.sub-option input {
    max-width: 6rem;
}

input, button {
    font-size: 1rem;
    padding: 0.65rem 0.75rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
}

button {
    cursor: pointer;
    border: 1px solid var(--border);
    background: #241a48;
}

button.primary {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    font-weight: 600;
}

button.primary:hover {
    background: var(--primary-hover);
}

button:hover {
    filter: brightness(1.1);
}

details summary {
    cursor: pointer;
    color: var(--muted);
    margin-bottom: 0.5rem;
}

.room-share {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    align-items: center;
}

.cast-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    color: var(--muted);
    font-size: 0.9rem;
}

.cast-separator {
    color: var(--muted);
    font-style: italic;
}

.cast-controls google-cast-launcher {
    width: 28px;
    height: 28px;
    --disconnected-color: var(--text);
    --connected-color: var(--primary);
}

.cast-tv-hint {
    font-size: 1.3rem;
    color: var(--muted);
    text-align: center;
    padding: 1.5rem 0;
}

.room-code {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 0.15em;
}

.qr-code {
    width: 160px;
    height: 160px;
    border-radius: 8px;
    background: white;
    padding: 8px;
}

.player-list {
    list-style: none;
    margin: 0 0 1rem;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.player-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
}

.badge {
    font-size: 0.75rem;
    background: var(--primary);
    color: white;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
}

.kick-btn {
    color: var(--danger);
    border-color: var(--danger);
    background: transparent;
    padding: 0.35rem 0.6rem;
    font-size: 0.85rem;
}

.breakdown-list {
    list-style: none;
    margin: 0 0 1rem;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.breakdown-list li {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.25rem 0.75rem;
    font-size: 0.85rem;
}

.breakdown-list .count {
    font-weight: 700;
    color: var(--primary);
}

.proposal-list {
    list-style: none;
    margin: 0 0 1rem;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.proposal-list li {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
}

.proposal-list img {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 6px;
}

.proposal-list span {
    flex: 1;
}

.delete-proposal-btn {
    color: var(--danger);
    border-color: var(--danger);
    background: transparent;
    padding: 0.35rem 0.6rem;
    font-size: 0.85rem;
}

.proposal-preview {
    width: 100%;
    max-height: 220px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.hint {
    color: #6ce7a0;
    font-size: 0.9rem;
}

#close-proposals-btn {
    margin-top: 0.75rem;
    color: var(--danger);
    border-color: var(--danger);
    background: transparent;
}

.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    z-index: 100;
}

.modal[hidden] {
    display: none;
}

.modal-content {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    max-width: 360px;
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
}

.tier-grid {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.5rem;
}

.tier-grid[hidden] {
    display: none;
}

.tier-row {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.5rem;
}

.tier-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.tier-label {
    flex: 0 0 2.5rem;
    font-weight: 700;
    font-size: 1.1rem;
    text-align: center;
    padding: 0.4rem 0;
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
}

.tier-row[data-tier-index="0"] .tier-label { background: var(--tier-s); color: #2b0410; }
.tier-row[data-tier-index="1"] .tier-label { background: var(--tier-a); color: #3a1a00; }
.tier-row[data-tier-index="2"] .tier-label { background: var(--tier-b); color: #3a2c00; }
.tier-row[data-tier-index="3"] .tier-label { background: var(--tier-c); color: #0a2b0a; }
.tier-row[data-tier-index="4"] .tier-label { background: var(--tier-d); color: #ffffff; }
.tier-row[data-tier-index="5"] .tier-label { background: var(--tier-e); color: #ffffff; }

.tier-items {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    min-height: 3rem;
}

.tier-item {
    margin: 0;
    width: 64px;
}

.tier-item img {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: 6px;
    display: block;
}

.tier-item figcaption {
    font-size: 0.65rem;
    text-align: center;
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tier-item.just-revealed img {
    box-shadow: 0 0 0 3px var(--primary), 0 0 18px 5px rgba(124, 60, 224, 0.7);
    animation: pulse-highlight 1.4s ease-in-out 2;
}

@keyframes pulse-highlight {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.12);
    }
}

#toggle-tier-grid-btn {
    margin-bottom: 0.75rem;
}

#force-resolve-btn {
    margin-top: 1rem;
    color: var(--danger);
    border-color: var(--danger);
    background: transparent;
}

#advance-btn {
    margin-top: 0.5rem;
}

#joker-used-msg {
    background: var(--surface-2);
    border: 1px solid var(--primary);
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
}

.vote-panel {
    text-align: center;
}

.vote-panel .proposal-preview {
    max-height: 260px;
    width: auto;
    max-width: 100%;
}

.proposal-title {
    font-size: 1.2rem;
    font-weight: 700;
}

.tier-buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin-top: 1rem;
}

.tier-vote-btn {
    font-weight: 700;
    font-size: 1.1rem;
    padding: 0.9rem 0.5rem;
    border: none;
}

.tier-vote-btn[data-tier-index="0"] { background: var(--tier-s); color: #2b0410; }
.tier-vote-btn[data-tier-index="1"] { background: var(--tier-a); color: #3a1a00; }
.tier-vote-btn[data-tier-index="2"] { background: var(--tier-b); color: #3a2c00; }
.tier-vote-btn[data-tier-index="3"] { background: var(--tier-c); color: #0a2b0a; }
.tier-vote-btn[data-tier-index="4"] { background: var(--tier-d); color: #ffffff; }
.tier-vote-btn[data-tier-index="5"] { background: var(--tier-e); color: #ffffff; }

@media (min-width: 640px) {
    .container {
        padding: 2rem 1rem;
    }

    .room-share {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }

    .room-share > div {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        flex: 1;
    }
}

.cast-main {
    max-width: 100%;
    padding: 1.5rem 3rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.cast-main h1 {
    font-size: 3rem;
    margin: 0 0 0.25rem;
    flex-shrink: 0;
}

.cast-main #cast-subtitle {
    color: var(--muted);
    font-size: 1.5rem;
    margin: 0 0 0.5rem;
    flex-shrink: 0;
}

.cast-main .vote-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: safe center;
    min-height: 0;
}

.cast-main .vote-panel[hidden] {
    display: none;
}

.cast-main .vote-panel .proposal-preview {
    max-height: 52vh;
    max-width: 70vw;
    object-fit: contain;
}

.cast-main .proposal-title {
    font-size: 2.2rem;
}

.cast-main .tier-grid {
    flex: 1;
    min-height: 0;
    gap: 0.25rem;
    padding: 0.5rem;
    margin-bottom: 0;
}

.cast-main .tier-row {
    flex: 1;
    min-height: 0;
    align-items: stretch;
    padding-bottom: 0.25rem;
    overflow: hidden;
}

.cast-main .tier-label {
    flex: 0 0 5rem;
    font-size: 1.6rem;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cast-main .tier-items {
    min-height: 0;
    align-items: stretch;
    flex-wrap: nowrap;
    overflow: hidden;
}

.cast-main .tier-item {
    width: auto;
    height: 100%;
    flex-shrink: 0;
    overflow: hidden;
}

.cast-main .tier-item img {
    width: auto;
    height: 100%;
    max-height: 100%;
    aspect-ratio: 1;
    object-fit: cover;
}

.cast-main .tier-item figcaption {
    display: none;
}

.cast-main .proposal-counter {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
    margin: 0.25rem 0 0.5rem;
}

.cast-main .proposal-counter[hidden] {
    display: none;
}

.cast-main .proposal-counter--large {
    flex: 1;
    justify-content: center;
}

.cast-main #proposal-counter-value {
    font-size: 4rem;
    font-weight: 800;
    line-height: 1;
}

.cast-main .proposal-counter--large #proposal-counter-value {
    font-size: 10rem;
}

.cast-main #proposal-counter-label {
    font-size: 1.5rem;
    color: var(--muted);
}

.cast-main .proposals-panel {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-wrap: wrap;
    align-content: center;
    justify-content: center;
    gap: 1rem;
    padding: 1rem;
    overflow: hidden;
}

.cast-main .proposals-panel[hidden] {
    display: none;
}

.cast-main .proposal-card {
    text-align: center;
}

.cast-main .proposal-card img {
    width: 16vh;
    height: 16vh;
    object-fit: cover;
    border-radius: 10px;
    border: 2px solid var(--border);
}

.cast-main .proposal-card p {
    margin: 0.4rem 0 0;
    font-size: 1rem;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---- Ecran TV : progression du vote ---- */

.cast-main .cast-vote-progress {
    width: min(60vw, 900px);
    margin-top: 1rem;
}

.cast-main .cast-progress-bar {
    height: 1.1rem;
    border-radius: 999px;
    background: var(--surface);
    border: 1px solid var(--border);
    overflow: hidden;
}

.cast-main .cast-progress-fill {
    height: 100%;
    width: 0;
    background: var(--primary);
    transition: width 0.4s ease-out;
}

.cast-main .cast-progress-label {
    margin: 0.5rem 0 0;
    font-size: 1.6rem;
    color: var(--muted);
}

/* ---- Recherche d'images en ligne ---- */

.picked-image {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.picked-image img {
    width: 72px;
    height: 72px;
    object-fit: cover;
    border-radius: 8px;
    flex-shrink: 0;
}

.picked-image p {
    margin: 0 0 0.35rem;
}

.modal-content.image-search {
    width: 100%;
    max-width: 640px;
    max-height: 90vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.modal-content.image-search h3 {
    margin: 0;
}

.image-search-bar {
    display: flex;
    gap: 0.5rem;
}

.image-search-bar input {
    flex: 1;
    min-width: 0;
}

.image-search-results {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 0.5rem;
    flex-shrink: 0;
}

.image-search-hit {
    display: block;
    width: 100%;
    padding: 0;
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    background: var(--surface-2);
}

.image-search-hit img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.image-search-hit:hover,
.image-search-hit:focus-visible {
    outline: 2px solid var(--primary);
}

.modal-content.image-search .muted {
    margin: 0;
}

/* ---- Mode TV (panneau de l'hote) ---- */

.tv-panel {
    margin-top: 1rem;
    padding: 0.9rem 1rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-2);
}

.tv-panel.is-on {
    border-color: var(--primary);
    background: rgba(124, 60, 224, 0.12);
}

.tv-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.tv-panel-head p {
    margin: 0.2rem 0 0;
}

.tv-panel-head button {
    flex-shrink: 0;
}

.tv-panel-state {
    margin-left: 0.4rem;
    font-size: 0.8rem;
    color: var(--muted);
}

.tv-panel.is-on .tv-panel-state {
    color: #6ce7a0;
}

.tv-panel .cast-controls {
    margin-top: 0.75rem;
}

/* ---- Ecran TV : fond anime ---- */

.cast-body {
    background: #070313;
}

.cast-backdrop {
    position: fixed;
    inset: 0;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.cast-backdrop span {
    position: absolute;
    width: 55vmax;
    height: 55vmax;
    border-radius: 50%;
    filter: blur(90px);
    opacity: 0.22;
    animation: cast-drift 26s ease-in-out infinite alternate;
}

.cast-backdrop span:nth-child(1) { background: #fd3e5a; top: -20vmax; left: -15vmax; }
.cast-backdrop span:nth-child(2) { background: #7e3cdd; top: -10vmax; right: -20vmax; animation-delay: -7s; }
.cast-backdrop span:nth-child(3) { background: #2c7bf4; bottom: -25vmax; left: 10vmax; animation-delay: -13s; }
.cast-backdrop span:nth-child(4) { background: #fdc92e; bottom: -30vmax; right: -10vmax; opacity: 0.12; animation-delay: -19s; }

@keyframes cast-drift {
    from { transform: translate(0, 0) scale(1); }
    to { transform: translate(6vmax, 4vmax) scale(1.15); }
}

@media (prefers-reduced-motion: reduce) {
    .cast-backdrop span,
    .cast-main .cast-player,
    .cast-main .cast-dots::after {
        animation: none;
    }
}

/* ---- Ecran TV : lobby ---- */

.cast-main .cast-lobby {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: min(5rem, 5vw);
    padding: 0 min(3rem, 3vw);
    text-align: left;
}

.cast-main .cast-lobby-join {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: min(2rem, 2.5vh) min(2.5rem, 2.5vw);
    border-radius: 28px;
    background: rgba(22, 15, 48, 0.75);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(8px);
}

.cast-main .cast-lobby-step {
    margin: 0 0 1rem;
    font-size: min(1.7rem, 2.6vh);
    font-weight: 700;
}

.cast-main .cast-lobby-qr-frame {
    padding: 1rem;
    border-radius: 22px;
    background: white;
    box-shadow: 0 0 0 6px rgba(124, 60, 224, 0.55), 0 0 50px rgba(124, 60, 224, 0.45);
}

.cast-main .cast-lobby-qr {
    display: block;
    width: min(34vh, 30vw);
    height: min(34vh, 30vw);
    /* Le QR code est agrandi : pixels nets plutot que flous. */
    image-rendering: pixelated;
}

.cast-main .cast-lobby-url {
    margin: 1rem 0 0;
    font-size: min(1.4rem, 2.2vh);
    color: var(--muted);
}

.cast-main .cast-lobby-or {
    margin: 1.2rem 0 0.6rem;
    font-size: min(1.2rem, 2vh);
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.15em;
}

.cast-main .cast-lobby-code {
    display: flex;
    gap: min(0.6rem, 0.6vw);
}

.cast-main .cast-code-tile {
    display: grid;
    place-items: center;
    width: min(5.2rem, 9vh, 5.5vw);
    height: min(6.2rem, 11vh, 6.5vw);
    border-radius: 16px;
    background: #1c1338;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-bottom: 6px solid var(--tile-color);
    font-size: min(3.6rem, 7vh, 4vw);
    font-weight: 800;
}

.cast-main .cast-lobby-room {
    display: flex;
    flex-direction: column;
    align-self: stretch;
    justify-content: center;
    min-width: 0;
}

.cast-main .cast-lobby-count {
    margin: 0 0 1.2rem;
    font-size: min(2.6rem, 4.2vh);
    font-weight: 800;
}

.cast-main .cast-players {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    gap: min(1rem, 1.4vh);
    max-height: 52vh;
    overflow: hidden;
}

.cast-main .cast-player {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.45rem 1.3rem 0.45rem 0.45rem;
    border-radius: 999px;
    background: rgba(22, 15, 48, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.08);
    animation: cast-player-in 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.cast-main .cast-player-avatar {
    display: grid;
    place-items: center;
    width: min(4.2rem, 7vh);
    height: min(4.2rem, 7vh);
    border-radius: 50%;
    background: var(--avatar-color);
    color: #12091f;
    font-size: min(2rem, 3.4vh);
    font-weight: 800;
}

.cast-main .cast-player-name {
    font-size: min(2.2rem, 3.6vh);
    font-weight: 700;
    max-width: 18vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@keyframes cast-player-in {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.6);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.cast-main .cast-lobby-wait {
    margin: 2rem 0 0;
    font-size: min(1.8rem, 2.8vh);
    color: var(--muted);
}

.cast-main .cast-dots::after {
    content: "";
    display: inline-block;
    width: 1.5em;
    text-align: left;
    animation: cast-dots 1.6s steps(4, end) infinite;
}

@keyframes cast-dots {
    0% { content: ""; }
    25% { content: "."; }
    50% { content: ".."; }
    75% { content: "..."; }
}

@media (max-aspect-ratio: 4/3) {
    .cast-main .cast-lobby {
        grid-template-columns: 1fr;
        justify-items: center;
        text-align: center;
    }

    .cast-main .cast-lobby-room {
        align-items: center;
    }

    .cast-main .cast-players {
        justify-content: center;
    }
}

/* ---- Accueil ---- */

.home-page {
    background:
        radial-gradient(60rem 30rem at 50% -10rem, rgba(124, 60, 224, 0.35), transparent 70%),
        var(--bg);
    min-height: 100vh;
}

.container.home {
    max-width: 520px;
    gap: 1.25rem;
}

.home-top {
    display: flex;
    justify-content: flex-end;
    min-height: 2.5rem;
}

.avatar {
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--tier-s), var(--tier-a));
    color: #2b0410;
    font-weight: 800;
    font-size: 0.95rem;
}

.pseudo-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    max-width: 100%;
    padding: 0.3rem 0.85rem 0.3rem 0.3rem;
    border-radius: 999px;
    background: rgba(22, 15, 48, 0.8);
}

.pseudo-chip-name {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pseudo-chip-edit {
    color: var(--muted);
    font-size: 0.85rem;
}

.hero {
    text-align: center;
}

.hero .brand-logo {
    margin-top: 0;
}

.hero-title {
    margin: 0.75rem 0 0.25rem;
    font-size: clamp(1.7rem, 7vw, 2.3rem);
    line-height: 1.15;
    letter-spacing: -0.02em;
}

.hero .tagline {
    margin-bottom: 1.25rem;
}

.tier-s { background: var(--tier-s); color: #2b0410; }
.tier-b { background: var(--tier-b); color: #3a2c00; }
.tier-d { background: var(--tier-d); color: #ffffff; }

.home-actions {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

button.big {
    padding: 0.95rem 1rem;
    font-size: 1.15rem;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(124, 60, 224, 0.35);
}

.divider {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--muted);
    font-size: 0.85rem;
}

.divider::before,
.divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border);
}

.join-inline {
    display: flex;
    gap: 0.5rem;
}

.join-inline input {
    flex: 1;
    min-width: 0;
    text-align: center;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.3em;
    text-transform: uppercase;
}

.join-inline input::placeholder {
    letter-spacing: 0.2em;
    font-weight: 500;
}

.how-it-works h2 {
    font-size: 1.1rem;
    text-align: center;
    margin: 0.5rem 0 1rem;
}

.steps {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.steps li {
    display: flex;
    gap: 0.85rem;
    align-items: flex-start;
}

.steps p {
    margin: 0.2rem 0 0;
    font-size: 0.92rem;
}

.step-num {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    width: 2rem;
    height: 2rem;
    border-radius: 8px;
    font-weight: 800;
}

.home-layout,
.home-side {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* Telephone : l'accueil tient sur un ecran, les etapes s'ouvrent dans une fenetre. */
.how-inline {
    display: none;
}

.how-link {
    align-self: center;
    font-size: 0.95rem;
}

.home-actions-head {
    display: none;
}

.home-actions-head h2 {
    margin: 0 0 0.25rem;
}

.home-actions-head p {
    margin: 0;
}

.hero .brand-logo {
    max-width: min(220px, 26vh);
}

/* Ordinateur : presentation a gauche, actions a droite, le tout centre dans la fenetre. */
@media (min-width: 900px) {
    .container.home {
        max-width: 1120px;
        min-height: 100vh;
        padding: 1.5rem 2.5rem 2.5rem;
    }

    .home-layout {
        flex: 1;
        display: grid;
        grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
        align-items: center;
        gap: 4rem;
    }

    .hero {
        text-align: left;
    }

    .hero .brand-logo {
        max-width: 230px;
        margin: 0;
    }

    .hero-title {
        font-size: clamp(2.6rem, 4.2vw, 3.6rem);
        margin-top: 1rem;
    }

    .hero .tagline {
        text-align: left;
        font-size: 1.2rem;
        margin-bottom: 2.5rem;
    }

    .how-inline {
        display: block;
    }

    .how-inline h2 {
        text-align: left;
        margin-top: 0;
    }

    .how-link {
        display: none;
    }

    .home-actions {
        padding: 2rem;
        gap: 1.25rem;
        box-shadow: 0 24px 60px rgba(124, 60, 224, 0.18);
    }

    .home-actions-head {
        display: block;
        margin-bottom: 0.25rem;
    }
}

/* Ordinateur portable a l'ecran peu haut : tout reste visible sans defiler. */
@media (min-width: 900px) and (max-height: 860px) {
    .container.home {
        padding-top: 1rem;
        padding-bottom: 1rem;
    }

    .hero .brand-logo {
        max-width: 150px;
    }

    .hero-title {
        margin-top: 0.5rem;
        font-size: clamp(2.2rem, 3.6vw, 3rem);
    }

    .hero .tagline {
        margin-bottom: 1.5rem;
    }

    .how-inline .steps {
        gap: 0.6rem;
    }
}

/* ---- Fenetres (dialog) ---- */

dialog.sheet {
    width: min(480px, calc(100vw - 2rem));
    max-height: calc(100dvh - 2rem);
    overflow-y: auto;
    padding: 1.5rem;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
    color: var(--text);
}

dialog.sheet::backdrop {
    background: rgba(5, 2, 15, 0.7);
    backdrop-filter: blur(3px);
}

dialog.sheet[open] {
    animation: sheet-in 0.2s ease-out;
}

dialog.sheet h2 {
    margin: 0;
}

dialog.sheet .modal-actions {
    justify-content: flex-end;
}

.sheet-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.icon-button {
    width: 2.4rem;
    height: 2.4rem;
    padding: 0;
    border-radius: 50%;
    font-size: 1.4rem;
    line-height: 1;
}

@keyframes sheet-in {
    from { opacity: 0; transform: translateY(1rem); }
    to { opacity: 1; transform: none; }
}

/* Sur telephone, le formulaire de creation monte du bas de l'ecran. */
@media (max-width: 639px) {
    dialog.sheet.tall {
        width: 100%;
        max-width: 100%;
        margin: auto 0 0;
        max-height: 92dvh;
        border-radius: 16px 16px 0 0;
        border-bottom: none;
    }
}

/* ---- Rejoindre une salle ---- */

.join-card {
    text-align: center;
}

.join-card .room-logo {
    margin: 0 auto 0.5rem;
}

.join-card h1 {
    margin: 0.25rem 0 0.5rem;
}

.join-card form {
    margin-top: 1rem;
    text-align: left;
}

.eyebrow {
    margin: 0;
    color: var(--muted);
    font-size: 0.85rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.identity {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: 10px;
    background: var(--surface-2);
    border: 1px solid var(--border);
}

.identity .avatar {
    width: 2.6rem;
    height: 2.6rem;
    font-size: 1.2rem;
}

.identity-text {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.identity-text strong {
    font-size: 1.1rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.link-button {
    padding: 0.35rem 0.5rem;
    border: none;
    background: none;
    color: #b99cff;
    text-decoration: underline;
}

.form-error {
    margin: 0;
    padding: 0.65rem 0.75rem;
    border-radius: 8px;
    border: 1px solid rgba(231, 76, 60, 0.5);
    background: rgba(231, 76, 60, 0.12);
    color: #ffb4aa;
    font-size: 0.92rem;
}

@media (prefers-reduced-motion: reduce) {
    dialog.sheet[open] {
        animation: none;
    }
}

/* ---- Politique de confidentialite et liens du bas de l'accueil ---- */

.home-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 0.25rem 1rem;
}

.home-links .how-link {
    align-self: auto;
}

.legal-link {
    color: var(--muted);
    font-size: 0.85rem;
}

.container.legal {
    max-width: 760px;
    padding-bottom: 3rem;
}

.legal-back {
    display: inline-block;
    margin: 0.5rem 0 1rem;
    color: var(--muted);
}

.legal h1 {
    margin: 0 0 0.25rem;
}

.legal h2 {
    margin: 1.75rem 0 0.5rem;
    font-size: 1.15rem;
}

.legal p,
.legal li {
    line-height: 1.6;
}

.legal ul {
    padding-left: 1.25rem;
}

.legal li + li {
    margin-top: 0.4rem;
}

.legal a {
    color: #b99cff;
}
