/* ===== Thème sombre façon Discord ===== */

:root {
    --bg-primary: #313338;
    --bg-secondary: #2b2d31;
    --bg-tertiary: #1e1f22;
    --bg-hover: #393c41;
    --accent: #5865f2;
    --accent-hover: #4752c4;
    --green: #23a55a;
    --red: #da373c;
    --gold: #f0b232;
    --text: #dbdee1;
    --text-header: #f2f3f5;
    --text-muted: #949ba4;
    --radius: 8px;
}

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

body {
    background: var(--bg-tertiary);
    color: var(--text);
    font-family: "gg sans", "Noto Sans", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    min-height: 100vh;
}

button {
    font-family: inherit;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    color: inherit;
    background: none;
}

input[type="text"],
input[type="number"] {
    font-family: inherit;
    background: var(--bg-tertiary);
    border: 1px solid #232428;
    border-radius: var(--radius);
    color: var(--text);
    padding: 10px 12px;
    font-size: 15px;
    outline: none;
}

input[type="text"]:focus,
input[type="number"]:focus {
    border-color: var(--accent);
}

select.select {
    font-family: inherit;
    background: var(--bg-tertiary);
    border: 1px solid #232428;
    border-radius: var(--radius);
    color: var(--text);
    padding: 9px 10px;
    font-size: 14px;
    cursor: pointer;
    outline: none;
}

select.select:focus {
    border-color: var(--accent);
}

h1, h2, h3 {
    color: var(--text-header);
}

/* ===== Layout général ===== */

#app {
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px 16px;
}

.layout {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.layout main {
    flex: 1;
    min-width: 0;
}

.layout aside {
    width: 240px;
    flex-shrink: 0;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 16px;
    position: sticky;
    top: 24px;
}

@media (max-width: 720px) {
    .layout {
        flex-direction: column-reverse;
    }

    .layout aside {
        width: 100%;
        position: static;
    }
}

.card {
    background: var(--bg-primary);
    border-radius: var(--radius);
    padding: 24px;
}

.btn {
    background: var(--accent);
    color: #fff;
    padding: 10px 20px;
    font-size: 15px;
    font-weight: 600;
    transition: background .15s;
}

.btn:hover {
    background: var(--accent-hover);
}

.btn:disabled {
    opacity: .5;
    cursor: not-allowed;
}

.btn.green {
    background: var(--green);
}

.btn.green:hover {
    background: #1e8e4e;
}

.muted {
    color: var(--text-muted);
    font-size: 14px;
}

/* ===== Écran pseudo / info ===== */

.center-screen {
    min-height: 80vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.join-card {
    width: 380px;
    max-width: 92vw;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 14px;
    animation: slide-fade .3s ease;
}

.join-card h1 {
    font-size: 24px;
}

.join-card input {
    width: 100%;
}

/* ===== Sidebar joueurs ===== */

aside h3 {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.player-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 6px;
}

.player-row:hover {
    background: var(--bg-hover);
}

.player-row.offline {
    opacity: .4;
}

.player-row .p-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.player-row .p-score {
    color: var(--text-muted);
    font-size: 13px;
}

.player-row .p-voted {
    color: var(--green);
    font-weight: 700;
}

.player-row.manageable {
    cursor: pointer;
}

/* Menu de modération de l'host (expulser / bannir) */
.context-menu {
    position: absolute;
    z-index: 200;
    min-width: 180px;
    background: var(--bg-tertiary);
    border: 1px solid #3f4147;
    border-radius: var(--radius);
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, .4);
    animation: slide-fade .12s ease;
}

.menu-title {
    font-size: 12px;
    color: var(--text-muted);
    padding: 4px 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.menu-item {
    text-align: left;
    padding: 8px 10px;
    font-size: 14px;
    border-radius: 4px;
}

.menu-item:hover {
    background: var(--bg-hover);
}

.menu-item.danger {
    color: #f98a8d;
}

.menu-item.danger:hover {
    background: var(--red);
    color: #fff;
}

.avatar-bubble {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
}

/* ===== Lobby ===== */

.lobby-settings {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: var(--bg-secondary);
    padding: 12px 16px;
    border-radius: var(--radius);
}

.setting-row label {
    font-weight: 600;
}

.setting-row input[type="number"] {
    width: 80px;
}

details.setting-list {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 12px 16px;
}

details.setting-list summary {
    cursor: pointer;
    font-weight: 600;
}

details.setting-list .list-body {
    margin-top: 10px;
    max-height: 220px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.check-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 8px;
    border-radius: 6px;
    cursor: pointer;
}

.check-row:hover {
    background: var(--bg-hover);
}

.list-search {
    width: 100%;
    margin-bottom: 8px;
}

/* Toggle (checkbox stylisée) */
.toggle {
    appearance: none;
    width: 40px;
    height: 24px;
    background: #80848e;
    border-radius: 12px;
    position: relative;
    cursor: pointer;
    transition: background .15s;
    flex-shrink: 0;
}

.toggle:checked {
    background: var(--green);
}

.toggle::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    transition: left .15s;
}

.toggle:checked::after {
    left: 19px;
}

/* ===== Manche : message façon Discord ===== */

.round-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.progress {
    height: 6px;
    border-radius: 3px;
    background: var(--bg-secondary);
    overflow: hidden;
    margin-bottom: 16px;
}

.progress .bar {
    height: 100%;
    width: 100%;
    background: var(--accent);
    transition-property: width;
    transition-timing-function: linear;
}

.discord-message {
    display: flex;
    gap: 16px;
    background: var(--bg-primary);
    border-radius: var(--radius);
    padding: 18px;
    animation: slide-fade .3s ease;
}

.msg-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #4e5058;
    color: #b5bac1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
    overflow: hidden;
    user-select: none;
}

.msg-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.msg-avatar.revealed img {
    animation: pop-in .5s ease;
}

.msg-body {
    min-width: 0;
    flex: 1;
}

.msg-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.msg-username.masked {
    display: inline-block;
    height: 16px;
    border-radius: 5px;
    background: #80848e;
    filter: blur(4px);
}

.msg-username.reveal-name {
    font-weight: 600;
    color: var(--text-header);
    animation: pop-in .5s ease;
}

.msg-date {
    color: var(--text-muted);
    font-size: 12px;
}

.msg-body > * + * {
    margin-top: 8px;
}

.msg-content {
    white-space: pre-wrap;
    overflow-wrap: break-word;
    line-height: 1.4;
}

.mention {
    background: rgba(88, 101, 242, .25);
    color: #c9cdfb;
    border-radius: 4px;
    padding: 0 2px;
    font-weight: 500;
}

.msg-link {
    color: #00a8fc;
    text-decoration: none;
    overflow-wrap: anywhere;
}

.msg-link:hover {
    text-decoration: underline;
}

.msg-file {
    display: inline-block;
    color: #00a8fc;
    font-size: 14px;
    text-decoration: none;
}

.msg-file:hover {
    text-decoration: underline;
}

/* ===== Médias : galerie façon Discord ===== */

.media-gallery {
    display: grid;
    gap: 6px;
    align-items: start;
    max-width: 560px;
}

/* Un média seul garde sa taille naturelle, plusieurs se rangent deux par ligne */
.media-gallery.single {
    grid-template-columns: minmax(0, max-content);
}

.media-gallery.grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (max-width: 480px) {
    .media-gallery.grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

.media-item {
    min-width: 0;
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg-secondary);
}

.media-link {
    display: block;
    line-height: 0;
}

.media-item img,
.media-item video {
    display: block;
    border-radius: var(--radius);
}

.media-gallery.single img,
.media-gallery.single video {
    width: auto;
    height: auto;
    max-width: min(400px, 100%);
    max-height: 350px;
}

.media-gallery.grid img,
.media-gallery.grid video {
    width: 100%;
    height: auto;
}

.tenor-embed {
    width: min(340px, 100%);
    height: 280px;
    border: 0;
    border-radius: var(--radius);
    background: var(--bg-secondary);
}

/* ===== Aperçus de liens (embeds) ===== */

.link-embed {
    display: flex;
    gap: 12px;
    max-width: 520px;
    background: var(--bg-secondary);
    border-left: 4px solid var(--accent);
    border-radius: 4px;
    padding: 12px 16px 12px 12px;
}

.embed-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.embed-site {
    font-size: 12px;
    color: var(--text-muted);
}

.embed-author {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-header);
}

.embed-title {
    color: #00a8fc;
    font-weight: 600;
    text-decoration: none;
}

.embed-title:hover {
    text-decoration: underline;
}

.embed-description {
    font-size: 14px;
    line-height: 1.4;
    white-space: pre-wrap;
    overflow-wrap: break-word;
}

.embed-media img,
.embed-media video,
.embed-iframe {
    display: block;
    width: 100%;
    max-width: 100%;
    border-radius: 4px;
}

.embed-iframe {
    aspect-ratio: 16 / 9;
    border: 0;
}

.embed-thumb img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 4px;
}

.embed-player {
    position: relative;
    display: block;
    width: 100%;
    padding: 0;
    line-height: 0;
}

.embed-player .play-button {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: rgba(0, 0, 0, .65);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    line-height: 1;
    transition: background .15s;
}

.embed-player:hover .play-button {
    background: var(--red);
}

/* ===== Vote ===== */

.vote-panel {
    margin-top: 16px;
}

.vote-panel h3 {
    margin-bottom: 10px;
}

.member-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 8px;
    max-height: 320px;
    overflow-y: auto;
    padding: 2px;
}

.member-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-secondary);
    padding: 8px 10px;
    border-radius: var(--radius);
    text-align: left;
    font-size: 14px;
    color: var(--text);
    border: 2px solid transparent;
    transition: background .1s, border-color .1s;
}

.member-btn:hover {
    background: var(--bg-hover);
}

.member-btn.selected {
    border-color: var(--green);
    background: rgba(35, 165, 90, .12);
}

.member-btn img {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    flex-shrink: 0;
}

.member-btn span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ===== Reveal ===== */

.reveal-panel {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.reveal-panel > * {
    animation: slide-fade .45s ease backwards;
}

.reveal-panel > *:nth-child(2) {
    animation-delay: .35s;
}

.reveal-panel > *:nth-child(3) {
    animation-delay: .7s;
}

.reveal-panel > *:nth-child(4) {
    animation-delay: 1.05s;
}

.vote-line {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    border-radius: 6px;
    background: var(--bg-secondary);
    border-left: 3px solid transparent;
}

.vote-line + .vote-line {
    margin-top: 6px;
}

.vote-line.correct {
    border-left-color: var(--green);
}

.vote-line.wrong {
    border-left-color: var(--red);
}

.vote-line .vote-mark {
    width: 20px;
    text-align: center;
}

.vote-line .p-name {
    font-weight: 600;
}

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

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

.reveal-author {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-secondary);
    border-left: 4px solid var(--gold);
    padding: 14px 16px;
    border-radius: var(--radius);
    font-size: 17px;
}

.reveal-author img {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    animation: pop-in .5s ease;
}

.score-line {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    border-radius: 6px;
    background: var(--bg-secondary);
}

.score-line .rank {
    width: 26px;
    text-align: center;
}

.score-line .p-name {
    flex: 1;
}

/* ===== Fin de partie ===== */

.podium {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 12px;
    margin: 24px 0 28px;
}

.podium-step {
    width: 130px;
    text-align: center;
    border-radius: var(--radius) var(--radius) 0 0;
    background: var(--bg-secondary);
    padding: 14px 8px;
    animation: rise .6s ease backwards;
}

.podium-step .medal {
    font-size: 28px;
}

.podium-step .p-name {
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.podium-step.first {
    height: 150px;
    background: linear-gradient(180deg, rgba(240, 178, 50, .25), var(--bg-secondary));
    animation-delay: .5s;
}

.podium-step.second {
    height: 115px;
    animation-delay: .25s;
}

.podium-step.third {
    height: 95px;
    animation-delay: 0s;
}

.final-actions {
    margin-top: 20px;
    text-align: center;
    animation: slide-fade .45s ease backwards;
    animation-delay: .8s;
}

/* ===== Toasts / bannières ===== */

#toasts {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 100;
}

.toast {
    background: var(--bg-tertiary);
    border: 1px solid #3f4147;
    border-radius: var(--radius);
    padding: 10px 18px;
    animation: slide-fade .25s ease;
    max-width: 90vw;
}

.toast.error {
    border-color: var(--red);
}

/* ===== Animations ===== */

@keyframes slide-fade {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

@keyframes pop-in {
    0% {
        transform: scale(0);
        opacity: 0;
    }

    70% {
        transform: scale(1.15);
        opacity: 1;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes rise {
    from {
        opacity: 0;
        transform: translateY(40px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}
