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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #ff6b9d 0%, #ffa8c5 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 32px;
    box-shadow: 0 25px 70px rgba(255, 107, 157, 0.3);
    padding: 50px;
}

header {
    margin-bottom: 50px;
    position: relative;
    min-height: 120px;
}

.header-left {
    text-align: center;
    width: 100%;
}

.header-right {
    position: absolute;
    top: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: flex-end;
    min-width: 280px;
    pointer-events: none;
}

.header-right > * {
    pointer-events: auto;
}

header h1 {
    font-size: 3.2em;
    background: linear-gradient(135deg, #ff6b9d 0%, #e91e63 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 15px;
    font-weight: 800;
    letter-spacing: -1px;
    text-align: center;
}

.subtitle {
    font-size: 1.3em;
    color: #555;
    font-weight: 500;
    text-align: center;
}

.vote-status {
    padding: 14px 24px;
    border-radius: 12px;
    font-size: 0.95em;
    font-weight: 600;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: flex-end;
    text-align: right;
}

.vote-status.not-voted {
    background: linear-gradient(135deg, #ffe6f0 0%, #ffc1e3 100%);
    color: #c2185b;
    border: 2px solid #ff6b9d;
}

.vote-status.voted {
    background: linear-gradient(135deg, #fff0f5 0%, #ffe6f0 100%);
    color: #d81b60;
    border: 2px solid #ff6b9d;
}

/* Modern unified header button style */
.header-btn {
    background: white;
    color: #333;
    border: 2px solid #e8e8e8;
    padding: 10px 18px;
    min-height: 44px; /* iOS touch target minimum */
    font-size: 0.9em;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 600;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.header-btn:hover {
    background: #fafafa;
    border-color: #ff6b9d;
    color: #ff6b9d;
    transform: translateY(-1px);
}

.header-btn:active {
    transform: translateY(0);
    background: #f5f5f5;
}

@media (max-width: 1024px) {
    header {
        min-height: auto;
    }
    
    .header-right {
        position: static;
        margin-top: 30px;
        align-items: center;
        pointer-events: auto;
    }
    
    .vote-status {
        align-items: center;
        text-align: center;
    }
}

/* Top 3 Section */
.top-three-section {
    margin: 40px 0 50px;
    padding: 30px;
    background: linear-gradient(135deg, #f8f9ff 0%, #fff5f9 100%);
    border-radius: 24px;
    border: 2px solid #e8eaf6;
}

.top-three-title {
    text-align: center;
    font-size: 1.8em;
    color: #333;
    margin-bottom: 25px;
    font-weight: 800;
}

.top-three-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    max-width: 900px;
    margin: 0 auto;
}

.top-three-item {
    background: white;
    border-radius: 20px;
    padding: 20px;
    text-align: center;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    border: 3px solid transparent;
    position: relative;
}

.top-three-item:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.15);
}

.top-three-item.rank-1 {
    border-color: #FFD700;
    background: linear-gradient(135deg, #fff9e6 0%, #ffffff 100%);
}

.top-three-item.rank-2 {
    border-color: #C0C0C0;
    background: linear-gradient(135deg, #f5f5f5 0%, #ffffff 100%);
}

.top-three-item.rank-3 {
    border-color: #CD7F32;
    background: linear-gradient(135deg, #fff4e6 0%, #ffffff 100%);
}

.top-three-medal {
    font-size: 3em;
    margin-bottom: 10px;
    display: block;
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.top-three-item.rank-1 .top-three-medal {
    animation: bounce 2s infinite, glow-gold 2s infinite;
}

@keyframes glow-gold {
    0%, 100% { filter: drop-shadow(0 0 8px rgba(255, 215, 0, 0.5)); }
    50% { filter: drop-shadow(0 0 15px rgba(255, 215, 0, 0.8)); }
}

.top-three-image {
    width: 140px;
    height: 140px;
    object-fit: cover;
    border-radius: 15px;
    margin: 0 auto 15px;
    display: block;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

.top-three-votes {
    font-size: 1.3em;
    font-weight: 800;
    color: #ff6b9d;
    margin-top: 10px;
}

.top-three-percentage {
    font-size: 0.95em;
    color: #666;
    margin-top: 5px;
}

.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 25px;
    margin-bottom: 60px;
}

.image-card {
    position: relative;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.08);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    background: #fff;
    border: 3px solid #ffc1e3;
    /* Better touch targets */
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.image-card::before {
    content: '💝 Klikk for å stemme';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 107, 157, 0.95);
    color: white;
    padding: 15px 30px;
    border-radius: 30px;
    font-weight: 700;
    font-size: 1.1em;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 10;
    white-space: nowrap;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.image-card:hover::before {
    opacity: 1;
}

.image-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(255, 107, 157, 0.25);
    border-color: #ff6b9d;
}

.image-card img {
    width: 100%;
    height: 280px;
    object-fit: cover;
    display: block;
}

.image-card:active {
    transform: translateY(-5px) scale(0.98);
}

.image-card.voted-disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.image-card.voted-disabled:hover {
    transform: none;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.image-card.voted-for {
    opacity: 1;
    border: 4px solid #ff6b9d;
    box-shadow: 0 10px 30px rgba(255, 107, 157, 0.5);
}

.image-card.voted-for::before {
    content: '✓ Din stemme • Klikk for å endre';
    background: rgba(76, 175, 80, 0.95);
}

.image-card.voted-for:hover {
    transform: translateY(-5px);
}

.your-vote-badge {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #ff6b9d 0%, #e91e63 100%);
    color: white;
    padding: 10px 24px;
    border-radius: 25px;
    font-weight: 700;
    font-size: 0.9em;
    box-shadow: 0 4px 20px rgba(255, 107, 157, 0.5);
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        transform: translateX(-50%) scale(1);
    }

    50% {
        transform: translateX(-50%) scale(1.05);
    }
}

.vote-count {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(255, 255, 255, 0.98);
    padding: 10px 18px;
    border-radius: 25px;
    font-weight: 700;
    color: #ff6b9d;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 6px;
    backdrop-filter: blur(10px);
}

.statistics {
    background: linear-gradient(135deg, #fff5f9 0%, #ffe6f0 100%);
    padding: 45px;
    border-radius: 24px;
    margin-bottom: 30px;
    border: 2px solid #ffc1e3;
}

.statistics h2 {
    background: linear-gradient(135deg, #ff6b9d 0%, #e91e63 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 25px;
    text-align: center;
    font-size: 2.3em;
    font-weight: 800;
}

/* Fun Stats Grid */
.fun-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 50px;
}

.stat-card {
    background: white;
    padding: 30px 20px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    border: 3px solid transparent;
}

.stat-card:hover {
    transform: translateY(-8px) scale(1.05);
    box-shadow: 0 15px 40px rgba(255, 107, 157, 0.3);
    border-color: #ff6b9d;
}

.stat-icon {
    font-size: 3em;
    margin-bottom: 10px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.stat-card:nth-child(1) .stat-icon { animation-delay: 0s; }
.stat-card:nth-child(2) .stat-icon { animation-delay: 0.5s; }
.stat-card:nth-child(3) .stat-icon { animation-delay: 1s; }
.stat-card:nth-child(4) .stat-icon { animation-delay: 1.5s; }

.stat-value {
    font-size: 2.5em;
    font-weight: 900;
    background: linear-gradient(135deg, #ff6b9d 0%, #e91e63 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 0.95em;
    color: #666;
    font-weight: 600;
}

/* Trend Card Special Styling */
.trend-card {
    position: relative;
    overflow: hidden;
}

.trend-image-container {
    width: 80px;
    height: 80px;
    margin: 10px auto;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    position: relative;
}

.trend-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    animation: trendPulse 2s ease-in-out infinite;
}

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

.trend-up {
    border: 3px solid #4CAF50;
    animation: glowGreen 2s ease-in-out infinite;
}

@keyframes glowGreen {
    0%, 100% { box-shadow: 0 4px 15px rgba(76, 175, 80, 0.3); }
    50% { box-shadow: 0 4px 25px rgba(76, 175, 80, 0.6); }
}

.trend-down {
    border: 3px solid #f44336;
    animation: glowRed 2s ease-in-out infinite;
}

@keyframes glowRed {
    0%, 100% { box-shadow: 0 4px 15px rgba(244, 67, 54, 0.3); }
    50% { box-shadow: 0 4px 25px rgba(244, 67, 54, 0.6); }
}

/* Visual Leaderboard */
.visual-leaderboard {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;
    max-width: 100%;
    margin: 0 auto;
}

.visual-item {
    background: white;
    border-radius: 16px;
    padding: 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.visual-item:hover {
    transform: translateY(-10px) scale(1.05);
    box-shadow: 0 12px 30px rgba(255, 107, 157, 0.3);
    z-index: 10;
}

.visual-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #ff6b9d, #ffa8c5);
}

.visual-rank {
    position: absolute;
    top: 10px;
    left: 10px;
    width: 35px;
    height: 35px;
    background: linear-gradient(135deg, #ff6b9d 0%, #e91e63 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    color: white;
    font-size: 0.9em;
    box-shadow: 0 3px 10px rgba(255, 107, 157, 0.4);
    z-index: 5;
}

.visual-item.top-1 .visual-rank {
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
    font-size: 1.3em;
    width: 40px;
    height: 40px;
}

.visual-item.top-2 .visual-rank {
    background: linear-gradient(135deg, #C0C0C0 0%, #808080 100%);
}

.visual-item.top-3 .visual-rank {
    background: linear-gradient(135deg, #CD7F32 0%, #8B4513 100%);
}

.visual-image {
    width: 100%;
    height: 140px;
    object-fit: cover;
    border-radius: 12px;
    margin: 35px 0 12px 0;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.15);
}

.visual-votes {
    font-size: 1.4em;
    font-weight: 800;
    color: #ff6b9d;
    margin-bottom: 5px;
}

.visual-bar-container {
    width: 100%;
    height: 8px;
    background: #f0f0f0;
    border-radius: 10px;
    overflow: hidden;
    margin-top: 10px;
}

.visual-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #ff6b9d 0%, #ffa8c5 100%);
    border-radius: 10px;
    transition: width 1s ease;
    animation: slideIn 1s ease;
}

@keyframes slideIn {
    from { width: 0; }
}

.visual-item.top-1 .visual-bar-fill {
    background: linear-gradient(90deg, #FFD700 0%, #FFA500 100%);
}

.visual-item.top-2 .visual-bar-fill {
    background: linear-gradient(90deg, #C0C0C0 0%, #808080 100%);
}

.visual-item.top-3 .visual-bar-fill {
    background: linear-gradient(90deg, #CD7F32 0%, #8B4513 100%);
}

.rank {
    font-size: 2em;
    font-weight: bold;
    min-width: 60px;
    text-align: center;
}

.rank-1 {
    color: #FFD700;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.rank-2 {
    color: #C0C0C0;
    text-shadow: 0 0 10px rgba(192, 192, 192, 0.5);
}

.rank-3 {
    color: #CD7F32;
    text-shadow: 0 0 10px rgba(205, 127, 50, 0.5);
}

.rank-other {
    color: #999;
}

.leaderboard-thumb {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 8px;
    margin: 0 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.leaderboard-info {
    flex: 1;
}

.leaderboard-name {
    font-weight: bold;
    color: #333;
    margin-bottom: 5px;
}

.leaderboard-votes {
    color: #ff6b9d;
    font-size: 1.3em;
    font-weight: 700;
    display: flex;
    align-items: center;
}

.leaderboard-bar {
    flex: 1;
    height: 30px;
    background: #e0e0e0;
    border-radius: 15px;
    overflow: hidden;
    margin-left: 20px;
}

.leaderboard-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #ff6b9d 0%, #ffa8c5 100%);
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 12px;
    color: white;
    font-weight: 700;
}

footer {
    text-align: center;
}

.reset-button {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%);
    color: white;
    border: none;
    padding: 15px 40px;
    font-size: 1em;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(238, 90, 111, 0.3);
    font-weight: bold;
}

.reset-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(238, 90, 111, 0.4);
}

.reset-button:active {
    transform: translateY(-1px);
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: white;
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
    max-width: 400px;
}

.modal-icon {
    font-size: 4em;
    margin-bottom: 20px;
    animation: heartbeat 0.6s ease;
}

.modal-content h3 {
    background: linear-gradient(135deg, #ff6b9d 0%, #e91e63 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 12px;
    font-size: 2em;
    font-weight: 800;
}

.modal-content p {
    color: #666;
    font-size: 1.1em;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }

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

@keyframes heartbeat {

    0%,
    100% {
        transform: scale(1);
    }

    25% {
        transform: scale(1.2);
    }

    50% {
        transform: scale(1);
    }

    75% {
        transform: scale(1.1);
    }
}

/* Name modal specific styles */
.name-modal-content {
    max-width: 450px;
}

.name-input {
    width: 100%;
    padding: 15px 20px;
    font-size: 1.1em;
    border: 2px solid #ffc1e3;
    border-radius: 12px;
    margin-bottom: 20px;
    font-family: inherit;
    transition: all 0.3s ease;
    box-sizing: border-box;
}

.name-input:focus {
    outline: none;
    border-color: #ff6b9d;
    box-shadow: 0 0 0 3px rgba(255, 107, 157, 0.1);
}

.modal-buttons {
    display: flex;
    gap: 12px;
    margin-top: 10px;
}

.modal-btn {
    flex: 1;
    padding: 14px 24px;
    font-size: 1em;
    font-weight: 700;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: inherit;
}

.primary-btn {
    background: linear-gradient(135deg, #ff6b9d 0%, #e91e63 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(255, 107, 157, 0.3);
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 107, 157, 0.4);
}

.primary-btn:active {
    transform: translateY(0);
}

.secondary-btn {
    background: #f0f0f0;
    color: #666;
}

.secondary-btn:hover {
    background: #e0e0e0;
}

.existing-users {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 15px;
}

.existing-user-btn {
    padding: 10px 18px;
    background: linear-gradient(135deg, #ffc1e3 0%, #ffa8c5 100%);
    color: #e91e63;
    border: none;
    border-radius: 20px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.95em;
}

.existing-user-btn:hover {
    background: linear-gradient(135deg, #ff6b9d 0%, #e91e63 100%);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 107, 157, 0.3);
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .container {
        padding: 20px;
        border-radius: 20px;
    }

    header h1 {
        font-size: 2em;
    }

    .subtitle {
        font-size: 1em;
    }
    
    .header-btn {
        font-size: 0.85em;
        padding: 10px 16px;
    }

    .gallery {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 15px;
    }
    
    .image-card::before {
        font-size: 0.9em;
        padding: 12px 20px;
    }
    
    .top-three-section {
        padding: 20px;
    }
    
    .top-three-title {
        font-size: 1.5em;
    }
    
    .top-three-container {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
        gap: 15px;
    }
    
    .top-three-image {
        width: 100px;
        height: 100px;
    }
    
    .fun-stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
    
    .stat-card {
        padding: 20px 15px;
    }
    
    .stat-icon {
        font-size: 2.5em;
    }
    
    .stat-value {
        font-size: 2em;
    }

    .statistics {
        padding: 25px 15px;
    }

    .statistics h2 {
        font-size: 1.6em;
    }
    
    .visual-leaderboard {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 15px;
    }
    
    .visual-image {
        height: 120px;
    }

    .leaderboard-item {
        flex-wrap: wrap;
    }

    .leaderboard-bar {
        width: 100%;
        margin-left: 0;
        margin-top: 12px;
    }
    
    .name-modal-content {
        width: 90%;
        max-width: 350px;
    }
    
    .modal-buttons {
        flex-direction: column;
    }
}

/* Extra small devices (phones in portrait) */
@media (max-width: 480px) {
    body {
        padding: 5px;
    }
    
    .container {
        padding: 15px;
        border-radius: 16px;
    }
    
    header h1 {
        font-size: 1.6em;
    }
    
    .subtitle {
        font-size: 0.9em;
    }
    
    .gallery {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 12px;
    }
    
    .top-three-container {
        grid-template-columns: 1fr;
    }
    
    .fun-stats-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .visual-leaderboard {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 12px;
    }
}