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

:root {
    --primary-gradient: linear-gradient(135deg, #6a00ff, #ff00ff);
    --secondary-gradient: linear-gradient(135deg, #00ddeb, #00ff88);
    --draw-gradient: linear-gradient(135deg, #ffaa00, #ff4d4d);
    --background-dark: #121212;
    --card-bg: #1d1d1d;
    --card-hover: #252525;
    --text-primary: #f0f0f0;
    --text-secondary: #a0a0a0;
    --accent-color: #ff00ff;
    --border-radius: 12px;
    --shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.15);
    --transition-default: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

body {
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    background-color: var(--background-dark);
    color: var(--text-primary);
    min-height: 100dvh;
    overflow-x: hidden;
}

a {
    text-decoration: none;
    color: var(--text-primary);
}

/* Modern glassmorphism header */
.mojen-header {
    background: rgba(26, 26, 26, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.2);
}

.mojen-header .logo {
    img {
        width: 36px;
        height: 36px;
        margin-right: 8px;
    }

    display: flex;
    align-items: center;
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

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

.header-actions .action-btn {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 8px 18px;
    border-radius: 24px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition-default);
    position: relative;
    overflow: hidden;
    z-index: 1;
}

.header-actions .action-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--primary-gradient);
    z-index: -1;
    opacity: 0;
    transition: var(--transition-default);
}

.header-actions .action-btn:hover {
    border-color: transparent;
    transform: translateY(-2px);
}

.header-actions .action-btn:hover::before {
    opacity: 1;
}

.header-actions .action-btn:active {
    transform: translateY(1px);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    animation: fadeIn 0.5s ease-in-out;
}

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

header {
    text-align: center;
    margin-bottom: 30px;
    padding: 15px 0;
}

header h1 {
    color: var(--text-primary);
    margin-bottom: 12px;
    font-size: 36px;
    font-weight: 800;
    letter-spacing: -1px;
    position: relative;
    display: inline-block;
}

header h1::after {
    content: '';
    position: absolute;
    width: 50px;
    height: 4px;
    background: var(--primary-gradient);
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 2px;
}

header p {
    color: var(--text-secondary);
    font-size: 16px;
    max-width: 550px;
    margin: 0 auto;
    font-weight: 400;
}

#game-container {
    background-color: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-soft);
    padding: 30px;
    margin-bottom: 40px;
    text-align: center;
    position: relative;
    overflow: hidden;
    transition: var(--transition-default);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

#game-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: var(--primary-gradient);
}

#loading {
    font-size: 18px;
    color: var(--text-secondary);
    margin: 40px 0;
    position: relative;
    display: inline-block;
}

.loading-animation {
    display: inline-block;
    position: relative;
    width: 80px;
    height: 20px;
    margin-left: 10px;
}

.loading-animation div {
    position: absolute;
    top: 8px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--accent-color);
    animation-timing-function: cubic-bezier(0, 1, 1, 0);
}

.loading-animation div:nth-child(1) {
    left: 8px;
    animation: loading1 0.6s infinite;
}

.loading-animation div:nth-child(2) {
    left: 8px;
    animation: loading2 0.6s infinite;
}

.loading-animation div:nth-child(3) {
    left: 32px;
    animation: loading2 0.6s infinite;
}

.loading-animation div:nth-child(4) {
    left: 56px;
    animation: loading3 0.6s infinite;
}

@keyframes loading1 {
    0% { transform: scale(0); }
    100% { transform: scale(1); }
}

@keyframes loading2 {
    0% { transform: translate(0, 0); }
    100% { transform: translate(24px, 0); }
}

@keyframes loading3 {
    0% { transform: scale(1); }
    100% { transform: scale(0); }
}

#image-comparison {
    display: flex;
    justify-content: space-around;
    align-items: center;
    flex-wrap: wrap;
    gap: 30px;
    margin-bottom: 30px;
}

.image-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    min-width: 300px;
    position: relative;
    transition: var(--transition-default);
    cursor: pointer;
}

.image-card {
    position: relative;
    width: 100%;
    max-width: 400px;
    margin-bottom: 20px;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow-soft);
    transition: var(--transition-default);
    border: 3px solid transparent;
}

.image-card:hover {
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.3);
    border-color: rgba(255, 255, 255, 0.3);
}

.image-container.selected .image-card {
    border-color: #00ff88;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(0, 255, 136, 0.4); }
    70% { box-shadow: 0 0 0 15px rgba(0, 255, 136, 0); }
    100% { box-shadow: 0 0 0 0 rgba(0, 255, 136, 0); }
}

.image-container img {
    width: 100%;
    height: auto;
    max-height: 400px;
    object-fit: contain;
    display: block;
    transition: var(--transition-default);
}

.vs {
    font-size: 28px;
    font-weight: 800;
    color: #ff4d4d;
    margin: 0 15px;
    align-self: center;
    text-shadow: 0 0 15px rgba(255, 77, 77, 0.5);
    position: relative;
}

.vs::before, .vs::after {
    content: '';
    position: absolute;
    width: 30px;
    height: 2px;
    background: rgba(255, 77, 77, 0.3);
    top: 50%;
}

.vs::before {
    right: 100%;
    margin-right: 10px;
}

.vs::after {
    left: 100%;
    margin-left: 10px;
}

.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    max-width: 300px;
}

.btn {
    border: none;
    border-radius: 24px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    padding: 12px 20px;
    transition: var(--transition-default);
    position: relative;
    overflow: hidden;
    z-index: 1;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: 0 7px 14px rgba(0, 0, 0, 0.2);
}

.btn:not(:disabled):active {
    transform: translateY(1px);
}

.select-btn {
    background: var(--secondary-gradient);
    color: #000;
}

.select-btn i {
    font-size: 18px;
}

.draw-btn {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.draw-btn:not(:disabled):hover {
    background: var(--draw-gradient);
    border-color: transparent;
    color: white;
}

#result-message {
    margin: 20px 0;
    padding: 15px;
    font-size: 18px;
    font-weight: bold;
    color: #00ff88;
    background-color: rgba(0, 255, 136, 0.1);
    border-radius: var(--border-radius);
    border-left: 4px solid #00ff88;
    display: none;
    animation: fadeIn 0.5s ease;
}

#result-message.error {
    color: #ff4d4d;
    background-color: rgba(255, 77, 77, 0.1);
    border-left-color: #ff4d4d;
}

#result-message.draw {
    color: #ffaa00;
    background-color: rgba(255, 170, 0, 0.1);
    border-left-color: #ffaa00;
}

#next-round {
    background: var(--primary-gradient);
    color: white;
    border: none;
    padding: 12px 28px;
    border-radius: 24px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    margin-top: 20px;
    transition: var(--transition-default);
    transform-origin: center;
    display: none;
}

#next-round:hover {
    transform: scale(1.05);
    box-shadow: 0 7px 14px rgba(0, 0, 0, 0.2);
}

#next-round:active {
    transform: scale(0.98);
}

#timer-container {
    width: 100%;
    max-width: 400px;
    margin: 15px auto 0;
    text-align: center;
}

.timer-bar-wrapper {
    width: 100%;
    height: 8px;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 5px;
}

.timer-bar {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #4cd964, #5ac8fa);
    transform-origin: left;
    transform: scaleX(1);
    transition: transform 5s linear;
}

.timer-text {
    font-size: 14px;
    color: #a0a0a0;
}

#stats-container {
    background-color: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-soft);
    padding: 30px;
    position: relative;
    overflow: hidden;
    transition: var(--transition-default);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

#stats-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: var(--draw-gradient);
}

#stats-container h2 {
    text-align: center;
    margin-bottom: 20px;
    color: var(--text-primary);
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

#show-stats {
    background: var(--primary-gradient);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 24px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    display: block;
    margin: 0 auto 20px;
    transition: var(--transition-default);
}

#show-stats:hover {
    transform: translateY(-2px);
    box-shadow: 0 7px 14px rgba(0, 0, 0, 0.2);
}

#show-stats:active {
    transform: translateY(1px);
}

.stats-section {
    margin-bottom: 40px;
}

.stats-section h3 {
    margin-bottom: 20px;
    color: var(--text-primary);
    font-size: 22px;
    font-weight: 600;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 10px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
}

.stat-card {
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 15px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: var(--transition-default);
    position: relative;
    overflow: hidden;
}

.stat-card:hover {
    transform: translateY(-5px);
    background-color: rgba(255, 255, 255, 0.08);
}

.stat-card img {
    width: 100%;
    height: auto;
    max-height: 120px;
    object-fit: contain;
    border-radius: 8px;
    margin-bottom: 10px;
    transition: var(--transition-default);
}

.stat-info {
    font-size: 14px;
    line-height: 1.4;
    color: var(--text-secondary);
}

.stat-info p {
    margin-bottom: 5px;
}

.score {
    font-weight: bold;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Toast notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background-color: rgba(26, 26, 26, 0.95);
    backdrop-filter: blur(10px);
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 300px;
    transform: translateX(120%);
    animation: slideIn 0.3s forwards, fadeOut 0.3s 2.7s forwards;
}

.toast.success {
    border-left: 4px solid #00ff88;
}

.toast.error {
    border-left: 4px solid #ff4d4d;
}

.toast.info {
    border-left: 4px solid #00ddeb;
}

@keyframes slideIn {
    to { transform: translateX(0); }
}

@keyframes fadeOut {
    to { opacity: 0; transform: translateX(120%); }
}

/* Adding clickable styles for the images */
.image-card.clickable {
    cursor: pointer;
    position: relative;
    transition: all 0.3s ease;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent; /* Remove green highlight on iOS devices */
    -webkit-touch-callout: none; /* Prevent callout to copy image */
    user-select: none; /* Prevent text selection during taps */
}

.image-card.clickable::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: transparent;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

.image-card.clickable:hover::after {
    opacity: 1;
}

/* Responsive adjustments */
@media (max-width: 835px) {
    .image-container {
        min-width: 100%;
    }
    
    .vs {
        margin: 5px 0;
        padding: 0;
        font-size: 20px;
        width: 100%;
        text-align: center;
    }
    
    #image-comparison {
        flex-direction: column;
        gap: 0;
        align-items: center;
        justify-content: center;
    }
    
    .image-card {
        max-width: 100%;
        margin-bottom: 0;
    }

    .image-card.clickable::after {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: transparent;
        opacity: 0;
        pointer-events: none;
    }
    
    .image-card img {
        max-height: 200px;
    }
    
    header {
        display: none;
    }
    
    header h1 {
        font-size: 20px;
        margin-bottom: 8px;
    }
    
    header h1::after {
        width: 30px;
        height: 2px;
        bottom: -4px;
    }
    
    header p {
        font-size: 12px;
        padding: 0 10px;
        max-width: 85%;
    }
    
    .container {
        padding: 10px;
    }
    
    #game-container {
        padding: 12px;
        margin-bottom: 20px;
    }
    
    .mojen-header {
        padding: 6px 10px;
    }
    
    .mojen-header .logo {
        font-size: 14px;
    }
    
    .mojen-header .logo img {
        width: 18px;
        height: 18px;
        margin-right: 3px;
    }
    
    .header-actions .action-btn {
        padding: 5px 10px;
        font-size: 11px;
    }
    
    .action-buttons {
        margin: 10px auto !important;
        max-width: 90%;
    }
    
    .btn {
        padding: 10px 15px;
        font-size: 14px;
    }
    
    .draw-btn {
        padding: 10px 15px;
        font-size: 14px;
    }
    
    .keyboard-shortcuts {
        display: none; /* Hide keyboard shortcuts on mobile */
    }
    
    /* Set 2 columns for the stats grid on mobile */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    /* Adjust the stat cards for mobile view */
    .stat-card {
        padding: 10px;
    }
    
    .stat-card img {
        max-height: 90px;
    }
    
    .stat-info {
        font-size: 11px;
    }
    
    #stats-container {
        padding: 15px;
    }
    
    #stats-container h2 {
        font-size: 22px;
        margin-bottom: 15px;
    }
    
    .stats-section h3 {
        font-size: 18px;
        margin-bottom: 12px;
    }

    .image-card:hover {
        box-shadow: var(--shadow-soft);
        border-color: transparent;
    }
    
    .image-card.clickable:hover::after {
        opacity: 0; /* Disable hover effect on mobile */
    }
}

/* Dark mode enhancements */
@media (prefers-color-scheme: dark) {
    :root {
        --background-dark: #0a0a0a;
        --card-bg: #141414;
        --card-hover: #1c1c1c;
    }
}

/* Smooth preference transition */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}