/* =========================
   VARIABLES / THEME
========================= */
:root {
    --bg: #2b1142;
    /* fondo general */
    --panel: #3a1a55;
    /* paneles/tarjetas */
    --ink: #f2e7d9;
    /* texto */
    --ink-dim: #cbbfb2;
    /* texto tenue */
    --accent: #e8d6c2;
    /* bordes/contornos */
    --radius: 16px;
    /* radio general */
    --gutter: 24px;
    /* margen lateral */
    --shadow: 0 6px 24px rgba(0, 0, 0, .35);

    /* Layout escritorio (puedes ajustar estos 3) */
    --wrap: min(1120px, calc(100vw - 2*var(--gutter)));
    --card-left: 480px;
    /* ancho tarjeta póster */
    --card-right: 620px;
    /* ancho tarjeta listado */
    --card-h: 68vh;
    /* alto de tarjetas (ambas) */

    /* Layout móvil */
    --fab-h: 88px;
    /* alto de barra de emojis */
    --m-head: 170px;
    /* alto aprox. de título+aires */
}

/* =========================
   BASE
========================= */
* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Inter, Arial;
    overflow: auto;
    /* permite scroll de página si hace falta */
}

/* =========================
   CONTROLES / TOPBAR
========================= */
.topbar {
    max-width: var(--wrap);
    margin-inline: auto;
    padding: 26px var(--gutter) 12px;
    display: grid;
    grid-template-columns: 1fr minmax(480px, 48%);
    /* título izq | controles der */
    align-items: end;
    gap: 18px;
}

.topbar h1 {
    margin: 0;
    line-height: 1;
}

.controls {
    display: grid;
    grid-template-areas:
        "search"
        "actions";
    /* buscador arriba, botones abajo */
    row-gap: 10px;
    justify-items: end;
}

.searchRow {
    grid-area: search;
    width: 100%;
}

.searchRow .search {
    width: 100%;
    max-width: 560px;
    background: transparent;
    color: var(--ink);
    border: 2px solid var(--accent);
    padding: 10px 16px;
    border-radius: 999px;
    outline: none;
}

/* Botones */
.actions {
    grid-area: actions;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.btn {
    background: transparent;
    color: var(--ink);
    border: 2px solid var(--accent);
    padding: 8px 14px;
    border-radius: 999px;
    cursor: pointer;
}

.btn.ghost {
    opacity: 0.9
}

/* =========================
   GRID PRINCIPAL (ESCRITORIO)
========================= */
main.grid {
    max-width: var(--wrap);
    margin-inline: auto;
    display: grid;
    grid-template-columns: var(--card-left) var(--card-right);
    justify-content: center;
    column-gap: 18px;
    /* separación entre tarjetas */
    padding: 12px var(--gutter) 24px;
}

#leftCard,
#rightCard {
    width: auto;
    max-width: 100%;
    height: var(--card-h);
}

/* Contenidos que hacen scroll interno si se exceden */
.winnerSlot,
.listWrap,
.slotViewport {
    height: 100%;
    min-height: 0;
    overflow: auto;
}

/* =========================
   TARJETA PÓSTER (GANADOR)
========================= */
.winnerSlot {
    position: relative;
    background: var(--panel);
    border: 2px solid var(--accent);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

#winnerOverlay {
    position: absolute;
    inset: 0;
    border-radius: var(--radius);
    overflow: hidden;
}

.winnerPoster {
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
}

/* Texto sobre póster */
#winnerOverlay h2,
#winnerOverlay .platform,
#winnerOverlay .meta {
    color: #fff !important;
    text-shadow: 0 2px 6px rgba(0, 0, 0, .55);
}

#winnerOverlay .platform {
    background: rgba(0, 0, 0, .72);
    color: #fff !important;
    border-radius: 999px;
    padding: 6px 10px;
    display: inline-block;
}

/* Gradiente para lectura */
#winnerOverlay::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 42%;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, .05) 20%, rgba(0, 0, 0, .65) 100%);
    pointer-events: none;
}

/* =========================
   TARJETA LISTA (HISTORIAL)
========================= */
.card {
    background: var(--panel);
    border: 2px solid var(--accent);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.listHead {
    padding: 16px 18px;
    border-bottom: 2px solid var(--accent);
    position: relative;
}

.listHead h2 {
    margin: 0;
}

.listHead .edit-btn {
    position: absolute;
    right: 16px;
    top: 12px;
}

.slotViewport {
    padding: 10px 10px 14px;
}

/* Ítems del listado – grid estable: poster | centro | estado */
.item {
    display: grid;
    grid-template-columns: 56px 1fr auto;
    align-items: center;
    column-gap: 12px;
    padding: 14px 16px;
    background: color-mix(in hsl, var(--panel), black 0%);
    border: 2px solid var(--accent);
    border-radius: 14px;
}

.item+.item {
    margin-top: 12px;
}

.item .thumb {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    overflow: hidden;
}

.item .mid {
    min-width: 0;
}

.item .title {
    font-weight: 800;
    line-height: 1.15;
    overflow-wrap: anywhere;
}

.item .muted {
    color: var(--ink-dim);
    font-size: .92rem;
    line-height: 1.2;
    overflow-wrap: anywhere;
}

/* Estado (PENDIENTE/SORTEADO) con aire a la derecha */
.item .right {
    justify-self: end;
    min-width: 8ch;
    padding-right: 6px;
    white-space: nowrap;
    letter-spacing: .05em;
}

/* Pills (plataformas, etc.) */
.pill {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    border: 2px solid var(--accent);
    color: var(--ink);
    margin-right: 6px;
    margin-top: 6px;
}

/* =========================
   MÓVIL
========================= */
@media (max-width: 900px) {

    /* Sin buscador arriba en móvil (lo tenías así) */
    .searchRow {
        display: none !important;
    }

    /* Grid a una columna centrada y con colchón para la barra de emojis */
    main.grid {
        grid-template-columns: 1fr !important;
        max-width: 680px;
        margin-inline: auto;
        padding: 8px var(--gutter) calc(var(--fab-h) + 8px);
    }

    /* Oculta la tarjeta de póster separada; el listado muestra el overlay cuando hay ganador */
    #leftCard {
        display: none;
    }

    /* La tarjeta derecha toma todo el ancho legible y controla la altura */
    #rightCard {
        width: 100% !important;
        max-width: 680px;
        margin: 0 auto;
        position: relative;
        display: flex;
        flex-direction: column;
        min-height: 0;
        /* alto máximo calculado para acercarse al título y a los botones */
        max-height: calc(100dvh - var(--m-head) - var(--fab-h) - 16px);
        overflow: hidden;
    }

    /* Encabezado fijo; el cuerpo scrollea por dentro */
    .listHead {
        position: sticky;
        top: 0;
        z-index: 1;
        background: var(--panel);
    }

    .listWrap {
        flex: 1 1 auto;
        min-height: 0;
        display: flex;
    }

    .slotViewport {
        flex: 1 1 auto;
        min-height: 0;
        overflow: auto;
        scrollbar-gutter: stable both-edges;
    }

    /* Overlay del ganador ocupa SOLO el card (no la página) */
    #rightCard.show-winner #winnerOverlay {
        position: absolute !important;
        inset: 0 !important;
        height: 100% !important;
    }

    /* Ítems un pelín más compactos en móvil */
    .item {
        padding: 14px 18px;
        column-gap: 10px;
    }

    .item .thumb {
        width: 44px;
        height: 44px;
    }

    .item .right {
        min-width: 7.6ch;
        padding-right: 8px;
    }

    /* Barra de acciones inferior (la gestionas en tu HTML/JS) */
    .actions {
        display: none;
    }

    /* arriba ocultas los botones; dejas solo la barra de emojis */
}

/* =========================
   UTILIDADES
========================= */
.center {
    display: grid;
    place-items: center;
}

.hidden {
    display: none !important;
}

.muted {
    color: var(--ink-dim);
}