:root {
    --theme-background: linear-gradient(135deg, #9333ea 0%, #7c3aed 100%);
    --theme-primary: #9333ea;
    --theme-secondary: #7c3aed;
    --theme-accent: #a855f7;
    --theme-question: linear-gradient(135deg, #e9d5ff 0%, #f3e8ff 100%);
    --theme-success: #c084fc;
    --theme-danger: #6b21a8;
    --theme-info: #d8b4fe;
    --theme-title: #581c87;
    --theme-progress: #c084fc;
    --theme-score: #a855f7;
}

body {
    background: var(--theme-background);
    min-height: 100vh;
    font-family: 'Karla', sans-serif;
    color: var(--theme-title);
}

.box.game-container {
    background: var(--theme-question);
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    border: 4px solid var(--theme-accent);
    padding: 2rem;
    position: relative;
    overflow: hidden;
}

.game-container::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, var(--theme-accent) 0%, transparent 70%);
    opacity: 0.05;
    transform: rotate(45deg);
    pointer-events: none;
}

.title {
    color: var(--theme-title);
    font-family: 'Concert One', cursive;
    font-weight: 400 !important;
    letter-spacing: 0.02em;
}

/* Override Bulma title styling */
h1.title {
    font-weight: 400 !important;
    text-shadow: none !important;
}

.subtitle {
    color: var(--theme-primary);
    opacity: 0.9;
}

body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        radial-gradient(circle at 20% 80%, var(--theme-accent) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, var(--theme-primary) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, var(--theme-secondary) 0%, transparent 50%);
    opacity: 0.1;
    pointer-events: none;
    z-index: -1;
}

/* Section styling for proper spacing with header/footer */
.section {
    padding: 3rem 1.5rem;
}

.progress-info {
    margin-bottom: 2rem;
}

.progress-info .tag {
    white-space: nowrap;
}

.progress-info #current-question {
    margin-left: 0.25rem;
}

.tag {
    font-size: 1.1rem;
    padding: 0.75rem 1.5rem;
    border-radius: 25px;
}

.tag.is-info {
    background: var(--theme-accent);
    color: white;
    border: 2px solid var(--theme-secondary);
}

.tag.is-success {
    background: var(--theme-score);
    color: white;
    border: 2px solid var(--theme-primary);
}

.question-container {
    margin-bottom: 3rem;
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 15px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

#question-text {
    font-size: 2rem;
    color: var(--theme-primary);
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

.position-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 1.5rem;
    max-width: 600px;
    margin: 0 auto 2rem;
    aspect-ratio: 1;
}

.position-cell {
    background: white;
    border: 4px solid var(--theme-info);
    border-radius: 20px;
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

@media (hover: hover) {
    .position-cell:hover {
        transform: translateY(-5px);
        box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
        border-color: var(--theme-accent);
    }
}

.position-cell.selected {
    background: var(--theme-info);
    border-color: var(--theme-primary);
    transform: scale(1.05);
    box-shadow: 0 0 0 3px var(--theme-primary);
}

/* Ensure no focus outline on touch devices */
.position-cell:focus {
    outline: none;
}

/* Remove any active state styling that might cause confusion */
.position-cell:active {
    transform: scale(0.98);
}

.position-cell.correct {
    background: #86efac;
    border-color: #22c55e;
    animation: correctPulse 0.6s ease-out;
}

.position-cell.incorrect {
    background: #fca5a5;
    border-color: #ef4444;
    animation: incorrectShake 0.5s ease-out;
}

@keyframes correctPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

@keyframes incorrectShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

.cell-content {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-image {
    max-width: 80%;
    max-height: 80%;
    width: auto;
    height: auto;
    object-fit: contain;
}

.submit-section {
    margin-top: 2rem;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

#submit-btn {
    font-size: 1.2rem;
    font-weight: 700;
    padding: 1rem 2rem;
    border-radius: 30px;
    transition: all 0.3s ease;
    background: var(--theme-primary);
    border: none;
    color: white;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

#submit-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
    background: var(--theme-secondary);
}

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

.feedback-message {
    margin-top: 2rem;
    border-radius: 15px;
    font-size: 1.1rem;
    font-weight: 600;
    padding: 1.5rem;
    animation: slideIn 0.3s ease-out;
}

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

.notification.is-success {
    background-color: #86efac;
    color: #15803d;
    border: 2px solid #22c55e;
}

.notification.is-danger {
    background-color: #fca5a5;
    color: #991b1b;
    border: 2px solid #ef4444;
}

#next-btn-container {
    margin-top: 2rem;
}

#next-btn {
    font-size: 1.1rem;
    font-weight: 700;
    padding: 0.75rem 2rem;
    border-radius: 25px;
    background: var(--theme-accent);
    border: none;
    color: white;
    transition: all 0.3s ease;
}

#next-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
    background: var(--theme-secondary);
}

.result-card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 3rem;
    margin-top: 2rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    border: 4px solid var(--theme-accent);
}

#final-score {
    color: var(--theme-primary);
    font-size: 4rem;
    font-weight: 800;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

#time-taken {
    color: var(--theme-secondary);
    font-weight: 700;
}

.result-message {
    margin: 2rem 0;
    padding: 1rem 2rem;
    border-radius: 15px;
    font-size: 1.2rem;
    font-weight: 600;
}

.result-message.is-success {
    background-color: #86efac;
    color: #15803d;
    border: 2px solid #22c55e;
}

.result-message.is-warning {
    background-color: #fde047;
    color: #854d0e;
    border: 2px solid #facc15;
}

.result-message.is-info {
    background-color: var(--theme-info);
    color: var(--theme-title);
    border: 2px solid var(--theme-accent);
}

#play-again-btn {
    font-size: 1.3rem;
    font-weight: 700;
    padding: 1rem 3rem;
    border-radius: 30px;
    background: var(--theme-primary);
    border: none;
    color: white;
    transition: all 0.3s ease;
    margin-top: 1rem;
}

#play-again-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
    background: var(--theme-secondary);
}

@media (max-width: 768px) {
    .box.game-container {
        padding: 1.5rem;
    }
    
    .game-container .title {
        font-size: 1.1rem;
        margin-bottom: 1rem;
    }
    
    .position-grid {
        gap: 1rem;
    }
    
    .position-cell {
        padding: 1rem;
    }
    
    #question-text {
        font-size: 1.5rem;
    }
    
    .result-card {
        padding: 2rem 1.5rem;
        margin-top: 1.5rem;
    }
    
    #final-score {
        font-size: 3rem;
    }
    
    .result-message {
        font-size: 1.1rem;
        padding: 1rem 1.5rem;
        margin: 1.5rem 0;
    }
}

@media (max-width: 480px) {
    .box.game-container {
        padding: 1rem;
    }
    
    .section {
        padding: 1.5rem 0.75rem;
    }
    
    .game-container .title {
        font-size: 1rem;
    }
    
    .position-grid {
        gap: 0.75rem;
    }
    
    .position-cell {
        padding: 0.75rem;
        border-width: 3px;
    }
    
    .position-cell.selected {
        box-shadow: 0 0 0 2px var(--theme-primary);
    }
    
    #question-text {
        font-size: 1.25rem;
    }
    
    .tag {
        font-size: 0.9rem;
        padding: 0.5rem 1rem;
    }
    
    .question-label {
        font-size: 0;
    }
    
    .question-label::after {
        content: 'Q:';
        font-size: 0.9rem;
    }
    
    /* Result screen mobile styles */
    #result-screen .title.is-3 {
        font-size: 1.5rem;
        margin-bottom: 1rem;
    }
    
    .result-card {
        padding: 1.5rem 1rem;
        margin-top: 1rem;
        border-width: 3px;
    }
    
    .result-card .subtitle.is-4 {
        font-size: 1rem;
        margin-bottom: 0.5rem;
    }
    
    #final-score {
        font-size: 2.5rem;
        margin: 0.5rem 0;
    }
    
    .result-card .subtitle.is-5 {
        font-size: 0.9rem;
        margin-bottom: 1rem;
    }
    
    .result-message {
        font-size: 1rem;
        padding: 0.75rem 1rem;
        margin: 1rem 0;
    }
    
    #play-again-btn {
        font-size: 1.1rem;
        padding: 0.75rem 2rem;
    }
}

/* Very small screens (iPhone 4 and similar) */
@media (max-width: 360px) {
    .section {
        padding: 1.5rem 0.75rem;
    }
    
    .box.game-container {
        padding: 0.75rem;
    }
    
    .game-container .title {
        font-size: 1rem;
        line-height: 1.3;
    }
    
    .progress-info {
        margin-bottom: 1rem;
    }
    
    .tag {
        font-size: 0.75rem;
        padding: 0.4rem 0.8rem;
    }
    
    .question-container {
        padding: 0.5rem;
        margin-bottom: 1rem;
    }
    
    #question-text {
        font-size: 1rem;
    }
    
    .position-grid {
        gap: 0.5rem;
    }
    
    .position-cell {
        padding: 0.5rem;
        border-width: 3px;
    }
    
    .icon-image {
        max-width: 80%;
        max-height: 80%;
    }
    
    #submit-btn, #next-btn, #play-again-btn {
        font-size: 1rem;
        padding: 1rem 2rem;
    }
    
    .feedback-message {
        font-size: 0.9rem;
        padding: 0.75rem;
    }
    
    .question-label {
        font-size: 0;
    }
    
    .question-label::after {
        content: 'Q:';
        font-size: 0.75rem;
    }
}