/* PAIRWISE COMPARISON VERSION - Mobile First Design */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #1e3a8a;
    background: linear-gradient(135deg, #0ea5e9 0%, #1e40af 50%, #1e3a8a 100%);
    min-height: 100vh;
    font-size: 16px;
}

.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 15px;
    min-height: 100vh;
}

/* Page system */
.page {
    display: none;
    animation: fadeIn 0.5s ease-in;
    min-height: calc(100vh - 30px);
}

.page.active {
    display: flex;
    flex-direction: column;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

header {
    text-align: center;
    margin-bottom: 25px;
    color: white;
    padding-top: 20px;
}

header h1 {
    font-size: 1.8rem;
    margin-bottom: 8px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: nowrap;
}

.header-emoji {
    font-size: 1.6rem;
    display: inline-block;
    flex-shrink: 0;
}

.header-text {
    white-space: nowrap;
}

/* Hide second emoji on mobile */
.desktop-only {
    display: none;
}

/* On very small screens, stack emoji above text */
@media (max-width: 380px) {
    header h1 {
        flex-direction: column;
        gap: 5px;
    }
    
    .header-emoji {
        font-size: 2rem;
    }
    
    .header-text {
        font-size: 1.5rem;
    }
}

header p {
    font-size: 1rem;
    opacity: 0.95;
    font-weight: 500;
}

main {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    gap: 0;
}

/* Sections */
.welcome-section, .results-section {
    background: white;
    border-radius: 20px;
    padding: 25px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 100%;
}

.voting-section {
    width: 100%;
    max-width: 100%;
    padding: 0;
}

/* Welcome page */
.welcome-content {
    text-align: center;
}

.hero-icon {
    font-size: 4rem;
    margin-bottom: 15px;
    display: block;
}

.welcome-content h2 {
    color: #1e3a8a;
    margin-bottom: 20px;
    font-size: 1.5rem;
    font-weight: 700;
}

.info-box {
    background: linear-gradient(135deg, #e0f2fe 0%, #b3e5fc 100%);
    border-radius: 15px;
    padding: 20px;
    margin: 20px 0;
    border: 2px solid #0ea5e9;
}

.info-box p {
    font-size: 1rem;
    margin-bottom: 15px;
    color: #1e3a8a;
    font-weight: 500;
}

.features {
    display: grid;
    gap: 12px;
    margin-top: 20px;
}

.feature {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.95rem;
    color: #1e3a8a;
    font-weight: 500;
}

.feature .icon {
    font-size: 1.3rem;
    min-width: 28px;
}

/* Progress bar */
.progress-container {
    margin-top: 15px;
    width: 100%;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
    padding: 15px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.progress-bar-wrapper {
    background: #e0f2fe;
    border-radius: 20px;
    height: 32px;
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
    position: relative;
}

.progress-bar-wrapper::after {
    content: attr(data-percentage);
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    font-weight: 700;
    font-size: 16px;
    z-index: 3;
    /* Dynamic text color based on progress */
    color: #0369a1;
    text-shadow: 0 0 3px rgba(255, 255, 255, 0.8),
                0 0 6px rgba(255, 255, 255, 0.6),
                0 0 9px rgba(255, 255, 255, 0.4);
    mix-blend-mode: normal;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #10b981 0%, #059669 100%);
    border-radius: 20px;
    transition: width 0.5s ease, background 0.5s ease, box-shadow 0.5s ease;
    width: 0%;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.4);
    position: relative;
    overflow: hidden;
}

.progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* Color stages for progress bar */
.progress-bar.progress-low {
    background: linear-gradient(90deg, #10b981 0%, #059669 100%);
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.4);
}

.progress-bar.progress-medium {
    background: linear-gradient(90deg, #06b6d4 0%, #0891b2 100%);
    box-shadow: 0 2px 12px rgba(6, 182, 212, 0.5);
}

.progress-bar.progress-high {
    background: linear-gradient(90deg, #a855f7 0%, #9333ea 100%);
    box-shadow: 0 2px 15px rgba(168, 85, 247, 0.6);
}

.progress-bar.progress-complete {
    background: linear-gradient(90deg, #ffd700 0%, #ffed4e 100%);
    box-shadow: 0 2px 20px rgba(255, 215, 0, 0.7);
    animation: goldPulse 1.5s ease infinite;
}

@keyframes goldPulse {
    0%, 100% { 
        box-shadow: 0 2px 20px rgba(255, 215, 0, 0.7);
    }
    50% { 
        box-shadow: 0 4px 30px rgba(255, 215, 0, 0.9);
    }
}

/* When progress is over 45%, switch to white text */
.progress-bar-wrapper.progress-high::after {
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.progress-text {
    display: none;
}

.progress-text strong {
    font-size: 1.3rem;
    color: #0369a1;
    font-weight: 700;
    margin-right: 5px;
}

/* Comparison container */
.comparison-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-width: 800px;
    width: 100%;
    padding: 20px;
    position: relative;
    margin: 0 auto;
}

@media (min-width: 768px) {
    .comparison-container {
        display: grid;
        grid-template-columns: 1fr auto 1fr;
        gap: 30px;
        align-items: center;
    }
}

.comparison-option {
    flex: 1;
}

.compare-btn {
    width: 100%;
    background: white;
    border: none;
    border-radius: 20px;
    padding: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    position: relative;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    min-height: 200px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.compare-btn:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.2);
}

.compare-btn:active {
    transform: translateY(-1px);
}

.compare-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.vs-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 900;
    color: white;
    margin: -10px 0;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
    animation: pulse 1.5s ease infinite;
}

@keyframes pulse {
    0%, 100% { 
        transform: scale(1); 
        opacity: 0.9;
    }
    50% { 
        transform: scale(1.2); 
        opacity: 1;
        text-shadow: 0 0 30px rgba(255, 255, 255, 0.8);
    }
}


/* Loading state */
.loading-state {
    text-align: center;
    padding: 40px;
    color: #64748b;
}

/* Completion message */
.completion-message {
    text-align: center;
    padding: 40px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.2);
    max-width: 500px;
    margin: 0 auto;
}

.completion-message h2 {
    color: #1e3a8a;
    margin-bottom: 15px;
    font-size: 1.8rem;
}

.completion-message p {
    color: #64748b;
    font-size: 1.1rem;
    margin-bottom: 10px;
}

.completion-message p:last-child {
    margin-bottom: 0;
}

/* Winner/loser animations */
.compare-btn.selected {
    animation: winnerGlow 1s ease forwards;
    border: 3px solid #ffd700 !important;
    background: linear-gradient(135deg, #fffdf7 0%, #fff9e6 100%) !important;
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.5),
                inset 0 0 20px rgba(255, 215, 0, 0.1) !important;
}

.compare-btn.not-selected {
    animation: loserFade 1s ease forwards;
}

@keyframes winnerGlow {
    0% { 
        transform: scale(1);
        background: white;
    }
    30% {
        transform: scale(1.03);
    }
    50% { 
        transform: scale(1.05);
        box-shadow: 0 0 60px rgba(255, 215, 0, 0.9),
                   0 0 100px rgba(255, 215, 0, 0.5),
                   inset 0 0 30px rgba(255, 215, 0, 0.2);
    }
    100% { 
        transform: scale(1.02);
        background: linear-gradient(135deg, #fffdf7 0%, #fff9e6 100%);
        box-shadow: 0 0 30px rgba(255, 215, 0, 0.5),
                   inset 0 0 20px rgba(255, 215, 0, 0.1);
    }
}

@keyframes loserFade {
    0% { 
        opacity: 1; 
        transform: scale(1); 
    }
    100% { 
        opacity: 0.4; 
        transform: scale(0.95); 
        filter: blur(1px);
    }
}

/* Avatar styles (reused from original) */
.avatar-container {
    margin-bottom: 15px;
}

.avatar-svg {
    width: 80px;
    height: 80px;
    margin: 0 auto;
    display: block;
    transition: transform 0.3s ease;
}

.compare-btn:hover .avatar-svg {
    transform: scale(1.1);
}

/* Text styles in options */
.compare-btn .name {
    font-size: 1.2rem;
    font-weight: 700;
    color: #1e3a8a;
    margin-bottom: 5px;
    display: block;
}

.compare-btn .meaning {
    font-size: 0.85rem;
    color: #0ea5e9;
    font-style: italic;
    font-weight: 500;
    display: block;
}

/* Buttons */
.primary-btn {
    width: 100%;
    padding: 18px 20px;
    font-size: 1.1rem;
    font-weight: 700;
    color: white;
    background: linear-gradient(135deg, #0ea5e9 0%, #1e40af 50%, #1e3a8a 100%);
    border: none;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    display: inline-block;
    text-decoration: none;
    box-shadow: 0 8px 25px rgba(14, 165, 233, 0.4);
    margin-top: 20px;
}

.primary-btn:hover, .primary-btn:focus {
    transform: translateY(-3px);
    box-shadow: 0 12px 35px rgba(14, 165, 233, 0.5);
}

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

.primary-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    background: linear-gradient(135deg, #94a3b8 0%, #64748b 50%, #475569 100%);
    box-shadow: 0 4px 15px rgba(100, 116, 139, 0.3);
}

/* Info banner */
.info-banner {
    text-align: center;
    padding: 15px;
    background: linear-gradient(135deg, #e0f2fe 0%, #b3e5fc 100%);
    border-radius: 15px;
    border: 2px solid #0ea5e9;
    margin-bottom: 20px;
}

.info-banner p {
    color: #1e3a8a;
    font-weight: 600;
    margin: 5px 0;
}

.info-banner p:first-child {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 10px;
}

.info-banner p em {
    font-weight: 700;
    font-style: normal;
    color: #0ea5e9;
}

/* Results page */
.ranking-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 30px;
}

.ranking-item {
    display: flex;
    align-items: center;
    gap: 15px;
    background: white;
    border: 2px solid #0ea5e9;
    border-radius: 15px;
    padding: 18px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(14, 165, 233, 0.1);
}

.ranking-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(14, 165, 233, 0.2);
}

.ranking-item.leader {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border-color: #f59e0b;
    box-shadow: 0 8px 25px rgba(245, 158, 11, 0.3);
}

.ranking-position {
    font-size: 1.8rem;
    font-weight: 700;
    min-width: 50px;
    text-align: center;
    color: #1e3a8a;
}

.ranking-info {
    flex: 1;
}

.ranking-name {
    font-size: 1.3rem;
    font-weight: 700;
    color: #1e3a8a;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: nowrap;
    width: 100%;
}

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

.star-rating {
    display: inline-flex;
    gap: 2px;
    flex-shrink: 0;
    margin-left: auto;
}

.star {
    font-size: 1.2rem;
    line-height: 1;
    transition: all 0.2s ease;
}

.star.filled {
    color: #fbbf24;
    text-shadow: 0 0 2px rgba(251, 191, 36, 0.5);
}

.star.empty {
    color: #d1d5db;
}

/* Enhance leader's stars with better contrast */
.ranking-item.leader .star.filled {
    color: #f59e0b;
    text-shadow: 
        0 0 2px rgba(255, 255, 255, 0.8),
        0 0 4px rgba(245, 158, 11, 0.5),
        0 1px 1px rgba(0, 0, 0, 0.2);
    animation: twinkle 2s ease-in-out infinite;
}

@keyframes twinkle {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Make stars smaller on mobile */
@media (max-width: 480px) {
    .ranking-name {
        font-size: 1.1rem;
        gap: 8px;
    }
    
    .star {
        font-size: 1rem;
    }
}


.ranking-bar {
    width: 120px;
    height: 12px;
    background: rgba(14, 165, 233, 0.2);
    border-radius: 6px;
    overflow: hidden;
}

.ranking-progress {
    height: 100%;
    background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
    border-radius: 6px;
    transition: width 0.8s ease;
}

.ranking-item.leader .ranking-progress {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

/* Hide progress bar on mobile to save space */
@media (max-width: 540px) {
    .ranking-bar {
        display: none;
    }
}


/* Thank you section */
.thank-you-section {
    background: white;
    border-radius: 20px;
    padding: 25px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 100%;
    border: 2px solid #0ea5e9;
    margin-top: 20px;
}

.thank-you {
    text-align: center;
    margin: 0;
    padding: 20px;
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.1) 0%, rgba(30, 58, 138, 0.1) 100%);
    border-radius: 15px;
    border: 2px solid rgba(14, 165, 233, 0.3);
}

.thank-you h3 {
    color: #1e3a8a;
    margin-bottom: 10px;
    font-size: 1.2rem;
    font-weight: 700;
}

.thank-you p {
    color: #0ea5e9;
    font-size: 1rem;
    font-weight: 500;
}

.final-note {
    margin-top: 15px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 12px;
    border: 2px solid rgba(14, 165, 233, 0.3);
}

.final-note p {
    color: #1e3a8a;
    font-size: 0.9rem;
    margin-bottom: 6px;
    font-weight: 500;
}

.final-note p:last-child {
    margin-bottom: 0;
}

/* Messages */
.message {
    margin-top: 20px;
    padding: 15px;
    border-radius: 12px;
    font-weight: 600;
    text-align: center;
}

.message.success {
    background-color: #dcfce7;
    color: #166534;
    border: 2px solid #22c55e;
}

.message.error {
    background-color: #fef2f2;
    color: #dc2626;
    border: 2px solid #ef4444;
}

.message.hidden {
    display: none;
}

/* Loading animation */
.loading {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #0ea5e9;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 8px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Tablet responsiveness */
@media (min-width: 768px) {
    .container {
        max-width: 800px;
        padding: 20px;
    }
    
    header h1 {
        font-size: 2.2rem;
    }
    
    /* Show second emoji on tablets and desktop */
    .desktop-only {
        display: inline-block;
    }
    
    header p {
        font-size: 1.1rem;
    }
    
    .welcome-section, .results-section {
        padding: 35px;
    }
    
    .comparison-container {
        gap: 30px;
    }
    
    .avatar-svg {
        width: 100px;
        height: 100px;
    }
    
    .vs-divider {
        margin: 0;
        font-size: 2.5rem;
    }
    
    .compare-btn {
        padding: 30px;
        min-height: auto;
    }
}