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

:root {
    --bg: #0f0f1a;
    --card: #1a1a2e;
    --surface: #16213e;
    --text: #e0e0e0;
    --text-dim: #888;
    --accent: #e94560;
    --green: #4ecca3;
    --red: #e94560;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100dvh;
    overflow-x: hidden;
    -webkit-user-select: none;
    user-select: none;
}

.hidden { display: none !important; }

/* ── User Select ─────────────────────────────── */

.user-select-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100dvh;
    padding: 2rem;
}

.user-select-content h1 {
    font-size: 2.5rem;
    margin-bottom: 0.25rem;
}

.subtitle {
    color: var(--text-dim);
    margin-bottom: 3rem;
    font-size: 1.1rem;
}

.user-buttons {
    display: flex;
    gap: 1.5rem;
}

.user-btn {
    padding: 1.5rem 3rem;
    font-size: 1.4rem;
    font-weight: 600;
    border: 2px solid var(--accent);
    background: transparent;
    color: var(--text);
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.2s;
}

.user-btn:hover, .user-btn:active {
    background: var(--accent);
    transform: scale(1.05);
}

/* ── Header ──────────────────────────────────── */

header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--surface);
    position: sticky;
    top: 0;
    z-index: 10;
}

header h2 { font-size: 1.1rem; }

.nav-btn {
    background: none;
    border: none;
    color: var(--accent);
    font-size: 0.9rem;
    cursor: pointer;
    padding: 0.4rem 0.6rem;
    border-radius: 8px;
}

.nav-btn:hover { background: rgba(233, 69, 96, 0.15); }

/* ── Stats Bar ───────────────────────────────── */

#stats-bar {
    text-align: center;
    padding: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-dim);
    background: var(--bg);
}

/* ── Card ────────────────────────────────────── */

#card-container {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 1rem;
    flex: 1;
}

.card {
    width: 100%;
    max-width: 360px;
    background: var(--card);
    border-radius: 16px;
    overflow: hidden;
    position: relative;
    touch-action: pan-y;
    transition: transform 0.1s ease;
}

.card.swiping { transition: none; }

.card.animate-out {
    transition: transform 0.4s ease, opacity 0.4s ease;
    opacity: 0;
}

#card-poster {
    width: 100%;
    aspect-ratio: 2/3;
    background: var(--surface) center/cover no-repeat;
    position: relative;
}

.card-info {
    padding: 1rem;
}

.card-info h3 {
    font-size: 1.2rem;
    margin-bottom: 0.25rem;
}

#card-meta {
    color: var(--text-dim);
    font-size: 0.85rem;
    display: block;
    margin-bottom: 0.5rem;
}

#card-overview {
    font-size: 0.85rem;
    color: var(--text-dim);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Swipe hints */
.swipe-hint {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 2rem;
    font-weight: 900;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    border: 3px solid;
    opacity: 0;
    pointer-events: none;
    z-index: 5;
}

#swipe-hint-left {
    left: 1rem;
    color: var(--red);
    border-color: var(--red);
}

#swipe-hint-right {
    right: 1rem;
    color: var(--green);
    border-color: var(--green);
}

/* ── Action Buttons ──────────────────────────── */

.action-buttons {
    display: flex;
    justify-content: center;
    gap: 3rem;
    padding: 1rem 0 2rem;
}

.action-btn {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: 2px solid;
    background: transparent;
    font-size: 1.8rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.action-btn.nope {
    color: var(--red);
    border-color: var(--red);
}

.action-btn.like {
    color: var(--green);
    border-color: var(--green);
}

.action-btn:hover {
    transform: scale(1.15);
}

.action-btn.nope:hover { background: rgba(233, 69, 96, 0.15); }
.action-btn.like:hover { background: rgba(78, 204, 163, 0.15); }

/* ── History Columns ─────────────────────────── */

.history-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    padding: 0.75rem;
    min-height: calc(100dvh - 50px);
}

.history-col-title {
    text-align: center;
    padding: 0.5rem;
    border-radius: 8px;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.liked-title { background: rgba(78, 204, 163, 0.15); color: var(--green); }
.rejected-title { background: rgba(233, 69, 96, 0.15); color: var(--red); }

.history-section-label {
    font-size: 0.7rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.5rem 0.25rem 0.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    margin-bottom: 0.4rem;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--card);
    border-radius: 8px;
    padding: 0.35rem;
    margin-bottom: 0.35rem;
    position: relative;
}

.history-thumb {
    width: 36px;
    height: 54px;
    border-radius: 4px;
    object-fit: cover;
    flex-shrink: 0;
}

.history-thumb-placeholder {
    width: 36px;
    height: 54px;
    border-radius: 4px;
    background: var(--surface);
    flex-shrink: 0;
}

.history-item-info {
    flex: 1;
    min-width: 0;
}

.history-item-info h4 {
    font-size: 0.75rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-item-info span {
    font-size: 0.65rem;
    color: var(--text-dim);
}

.history-undo {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 0.9rem;
    cursor: pointer;
    padding: 0.25rem 0.4rem;
    border-radius: 4px;
    flex-shrink: 0;
}

.history-undo:hover {
    background: rgba(233, 69, 96, 0.2);
    color: var(--red);
}

/* ── No movies ───────────────────────────────── */

#no-movies {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-dim);
}

#no-movies button {
    margin-top: 1rem;
    padding: 0.75rem 2rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    cursor: pointer;
}

/* ── Match Popup ─────────────────────────────── */

#match-popup {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    animation: fadeIn 0.3s;
}

.match-popup-content {
    text-align: center;
    padding: 2rem;
}

.match-emoji {
    font-size: 4rem;
    margin-bottom: 1rem;
    animation: bounce 0.6s ease;
}

.match-popup-content h2 {
    font-size: 2rem;
    color: var(--green);
    margin-bottom: 0.5rem;
}

#match-movie-name {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.match-sub {
    color: var(--text-dim);
    margin-bottom: 1.5rem;
}

.match-popup-content button {
    padding: 0.75rem 2rem;
    background: var(--green);
    color: var(--bg);
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
}

/* ── Animations ──────────────────────────────── */

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes bounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.3); }
}

/* ── Layout: make swipe view flex column ─────── */

#swipe-view {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
}

#swipe-view.hidden { display: none !important; }

/* ── Responsive ──────────────────────────────── */

@media (max-width: 400px) {
    .card { max-width: 100%; }
    .user-btn { padding: 1.2rem 2rem; }
    .action-buttons { gap: 2rem; }
}
