:root {
    --bg-color: #0d0d0d;
    --card-bg: #1a1a1a;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --accent: #646cff;
    /* Vibrant indigo */
    --accent-glow: rgba(100, 108, 255, 0.4);
    --error: #ff4d4d;
    --success: #4caf50;

    --font-family: 'Outfit', sans-serif;

    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;

    --radius: 16px;
    --transition: 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

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

body {
    margin: 0;
    padding: 0;
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-family);
    height: 100dvh;
    overflow: hidden;
    /* App-like feel */
    display: flex;
    justify-content: center;
}

#app {
    width: 100%;
    max-width: 600px;
    height: 100%;
    position: relative;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

/* Views */
.view {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: var(--spacing-md);
    animation: fadeIn 0.4s ease;
}

.view.hidden {
    display: none;
}

.hidden {
    display: none !important;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Headers */
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-md) 0;
    margin-bottom: var(--spacing-md);
}

h1,
h2 {
    margin: 0;
    font-weight: 600;
    letter-spacing: -0.5px;
}

h1 {
    font-size: 2rem;
    background: linear-gradient(to right, #fff, #aaa);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

h2 {
    font-size: 1.5rem;
}

/* Login */
.login-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: var(--spacing-lg);
    text-align: center;
}

input {
    background: var(--card-bg);
    border: 1px solid #333;
    padding: 12px 16px;
    border-radius: var(--radius);
    color: #fff;
    font-family: inherit;
    font-size: 1rem;
    width: 100%;
    outline: none;
    transition: var(--transition);
}

input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

button {
    background: var(--accent);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    width: 100%;
}

button:active {
    transform: scale(0.96);
}

.icon-btn {
    background: transparent;
    width: auto;
    padding: 8px;
    font-size: 1.5rem;
    line-height: 1;
}

.secondary-btn {
    background: #333;
}

/* Category List */
.card-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--spacing-md);
}

.category-card {
    background: var(--card-bg);
    padding: var(--spacing-lg);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.category-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}

.card-actions {
    display: flex;
    gap: 8px;
}

.small-btn {
    padding: 6px 12px;
    font-size: 0.8rem;
    background: #333;
    width: auto;
}

.header-actions {
    display: flex;
    gap: 8px;
}

/* Vote Screen */
.vote-header {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: var(--spacing-md);
    align-items: center;
}

.progress-bar {
    height: 6px;
    background: #333;
    border-radius: 10px;
    overflow: hidden;
    flex: 1;
}

#progress-fill {
    background: var(--accent);
    height: 100%;
    width: 0%;
    transition: width 0.3s ease;
}

.vote-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    justify-content: center;
    margin-bottom: var(--spacing-lg);
}

.photo-card {
    flex: 1;
    background: var(--card-bg);
    border-radius: var(--radius);
    overflow: hidden;
    position: relative;
    border: 2px solid transparent;
    transition: var(--transition);
    cursor: pointer;
    max-height: 45vh;
    /* Keep both visible */
    display: flex;
    align-items: center;
    justify-content: center;
}

.photo-card:active {
    transform: scale(0.98);
    border-color: var(--accent);
}

.photo-card img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    /* Don't crop photos, fit them */
    display: block;
}

/* Skeleton */
.skeleton-loader {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #222;
    animation: pulse 1.5s infinite;
    z-index: 0;
}

img.loaded+.skeleton-loader {
    display: none;
}

img.loaded {
    z-index: 1;
    animation: fadeImg 0.5s ease;
}

@keyframes pulse {
    0% {
        opacity: 0.6;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.6;
    }
}

@keyframes fadeImg {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.instructions {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: var(--spacing-md);
}

/* Results */
.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: var(--spacing-sm);
    padding-bottom: 40px;
}

.result-item {
    background: var(--card-bg);
    border-radius: 8px;
    overflow: hidden;
    position: relative;
}

.result-item img {
    width: 100%;
    height: 100px;
    /* Thumbnail height */
    object-fit: cover;
    display: block;
}

.result-info {
    padding: 8px;
    font-size: 0.8rem;
}

.rank-badge {
    position: absolute;
    top: 4px;
    left: 4px;
    background: var(--accent);
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: bold;
}

/* Utilities */
.center-msg {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    gap: var(--spacing-md);
}

.error-msg {
    color: var(--error);
    font-size: 0.9rem;
    height: 20px;
}

/* Loader */
.loader {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #333;
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Desktop override */
@media (min-width: 768px) {
    .vote-container {
        flex-direction: row;
    }

    .photo-card {
        max-height: 60vh;
    }
}

/* Lightbox */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100dvh;
    background: rgba(0, 0, 0, 0.95);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.lightbox.hidden {
    display: none;
    opacity: 0;
    pointer-events: none;
}

.lightbox img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

#lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 2rem;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1001;
}

#lightbox-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 3rem;
    width: 50px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1001;
    border-radius: 8px;
    border: none;
}

.lightbox-nav:hover {
    background: rgba(255, 255, 255, 0.2);
}

#lightbox-prev {
    left: 20px;
}

#lightbox-next {
    right: 20px;
}