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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #f8f9fa;
    color: #212529;
    line-height: 1.6;
}

.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Top Navigation */
.top-nav {
    background: white;
    border-bottom: 2px solid #e0e0e0;
    margin: -20px -20px 2rem -20px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-tabs {
    display: flex;
    max-width: 600px;
    margin: 0 auto;
    gap: 0;
}

.nav-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 1rem 2rem;
    text-decoration: none;
    color: #666;
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
    font-weight: 500;
    font-size: 1.1rem;
    background: #f8f9fa;
    flex: 1;
    justify-content: center;
}

.nav-tab:hover {
    color: #333;
    background: #e9ecef;
}

.nav-tab.active {
    color: #5d4e75;
    background: white;
    border-bottom-color: #5d4e75;
}

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

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 10px;
}

.subtitle {
    font-size: 1.1rem;
    color: #6c757d;
    margin-bottom: 20px;
}

.game-board {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.puzzle-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.puzzle-navigation {
    display: flex;
    align-items: center;
    gap: 15px;
}

.nav-arrow {
    background: white;
    border: 2px solid #dee2e6;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.5rem;
    font-weight: bold;
    color: #2c3e50;
    transition: all 0.3s ease;
    user-select: none;
}

.nav-arrow:hover {
    border-color: #3498db;
    background-color: #f8f9fa;
    transform: scale(1.05);
}

.nav-arrow:active {
    transform: scale(0.95);
}

.nav-arrow:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    transform: none;
}

.puzzle-number {
    font-weight: 600;
    font-size: 1.1rem;
    color: #2c3e50;
    min-width: 200px;
    text-align: center;
}

.mistakes {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
}

.mistake-dots {
    display: flex;
    gap: 5px;
}

.dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: #dee2e6;
    transition: all 0.3s ease;
}

.dot.active {
    background-color: #dc3545;
}

.word-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.word-card {
    background: white;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    padding: 20px 15px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    user-select: none;
    position: relative;
    overflow: hidden;
    height: 80px;
    min-height: 80px;
    max-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1.2;
    word-break: keep-all;
    hyphens: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.word-card:hover {
    border-color: #6c757d;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.word-card.selected {
    background-color: #3498db;
    border-color: #2980b9;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

.word-card.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.solved-groups {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.solved-group {
    background: white;
    border-radius: 8px;
    padding: 8px 20px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    animation: slideIn 0.5s ease-out;
    margin-bottom: 8px;
}

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

/* Colors based on solve order (1st, 2nd, 3rd, 4th) - Higher specificity */
.solved-group.solve-order-0 {
    background-color: #f1c40f !important; /* Yellow */
    color: #2c3e50 !important;
}

.solved-group.solve-order-1 {
    background-color: #27ae60 !important; /* Green */
    color: white !important;
}

.solved-group.solve-order-2 {
    background-color: #e74c3c !important; /* Red */
    color: white !important;
}

.solved-group.solve-order-3 {
    background-color: #9b59b6 !important; /* Purple */
    color: white !important;
}

/* Fallback difficulty classes (only used when solve-order is not available) */
.solved-group.difficulty-easy {
    background-color: #f39c12; /* Orange - different from solve-order colors */
    color: white;
}

.solved-group.difficulty-medium {
    background-color: #3498db; /* Blue - different from solve-order colors */
    color: white;
}

.solved-group.difficulty-hard {
    background-color: #8e44ad; /* Dark Purple - different from solve-order colors */
    color: white;
}

.group-category {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 2px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.group-words {
    font-size: 0.9rem;
    opacity: 0.9;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.difficulty-selector {
    text-align: center;
    margin-bottom: 15px;
    padding: 8px 15px;
    background: white;
    border-radius: 6px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.difficulty-selector label {
    font-weight: 500;
    color: #2c3e50;
    font-size: 0.9rem;
    margin: 0;
}

.difficulty-dropdown {
    padding: 5px 10px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 500;
    background: white;
    color: #2c3e50;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 120px;
}

.difficulty-dropdown:hover {
    border-color: #6c757d;
}

.difficulty-dropdown:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.game-controls {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-bottom: 15px;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

.btn-primary {
    background-color: #2c3e50;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background-color: #34495e;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(44, 62, 80, 0.3);
}

.btn-secondary {
    background-color: white;
    color: #2c3e50;
    border: 2px solid #dee2e6;
}

.btn-secondary:hover {
    border-color: #6c757d;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.game-message {
    text-align: center;
    font-weight: 500;
    padding: 10px;
    border-radius: 6px;
    opacity: 0;
    transition: all 0.3s ease;
}

.game-message.show {
    opacity: 1;
}

.game-message.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.game-message.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.game-message.info {
    background-color: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

.game-over-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.game-over-modal.show {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 12px;
    padding: 30px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-content h2 {
    margin-bottom: 20px;
    color: #2c3e50;
    font-size: 1.8rem;
}

.final-groups {
    margin-bottom: 25px;
}

.modal-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.instructions {
    background: white;
    border-radius: 8px;
    padding: 25px;
    margin-top: 30px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.instructions h3 {
    color: #2c3e50;
    margin-bottom: 15px;
    font-size: 1.2rem;
}

.instructions ol {
    text-align: left;
    padding-left: 20px;
}

.instructions li {
    margin-bottom: 8px;
    color: #6c757d;
}

/* Feedback Section */
.feedback-section {
    margin-top: 20px;
    text-align: center;
}

.btn-feedback {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-feedback:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

/* Feedback Modal */
.feedback-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.feedback-modal.show {
    opacity: 1;
}

.feedback-modal .modal-content {
    background: white;
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -60%);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
    opacity: 0;
}

.feedback-modal.show .modal-content {
    transform: translate(-50%, -50%);
    opacity: 1;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px 0;
    border-bottom: 1px solid #e9ecef;
    margin-bottom: 20px;
}

.modal-header h2 {
    margin: 0;
    color: #2c3e50;
    font-size: 1.4rem;
}

.close-btn {
    background: none;
    border: none;
    font-size: 28px;
    color: #6c757d;
    cursor: pointer;
    padding: 5px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
    font-weight: 300;
    line-height: 1;
}

.close-btn:hover {
    background: #f8f9fa;
    color: #dc3545;
    transform: scale(1.1);
}

.close-btn:active {
    transform: scale(0.95);
}

.modal-body {
    padding: 0 24px 20px;
    text-align: center;
}

.modal-body p {
    margin-bottom: 20px;
    color: #6c757d;
    line-height: 1.5;
}

.x-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: #1da1f2;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
    border-bottom: 1px solid transparent;
}

.x-link:hover {
    color: #0d8bd9;
    border-bottom: 1px solid #0d8bd9;
}

.x-link .x-icon {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

#feedbackForm {
    text-align: left;
    max-width: 400px;
    margin: 0 auto;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: #2c3e50;
}

.form-input {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    font-family: inherit;
    font-size: 1rem;
    transition: border-color 0.3s ease;
    resize: vertical;
}

.form-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}



@media (max-width: 600px) {
    .container {
        padding: 15px;
    }
    
    .feedback-modal .modal-content {
        width: 95%;
        margin: 20px;
        max-height: 85vh;
    }
    
    .modal-header {
        padding: 15px 20px 0;
    }
    
    .modal-body {
        padding: 0 20px 15px;
    }
    
    #feedbackForm {
        max-width: none;
    }
    
    .btn-feedback {
        padding: 10px 20px;
        font-size: 0.9rem;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .word-grid {
        gap: 6px;
    }
    
    .word-card {
        padding: 12px 8px;
        font-size: 0.75rem;
        height: 60px;
        min-height: 60px;
        max-height: 60px;
        word-break: keep-all;
        hyphens: none;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .game-controls {
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .btn {
        padding: 10px 20px;
        font-size: 0.9rem;
    }
    
    .puzzle-info {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
    
    .puzzle-navigation {
        gap: 10px;
    }
    
    .nav-arrow {
        width: 35px;
        height: 35px;
        font-size: 1.3rem;
    }
    
    .puzzle-number {
        min-width: 160px;
        font-size: 1rem;
    }
    
    .difficulty-selector {
        padding: 6px 12px;
        flex-direction: column;
        gap: 5px;
    }
    
    .difficulty-dropdown {
        min-width: 100px;
        font-size: 0.8rem;
    }
    
    .nav-tab {
        padding: 0.75rem 1rem;
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .word-grid {
        gap: 4px;
    }
    
    .word-card {
        padding: 10px 6px;
        font-size: 0.7rem;
        height: 50px;
        min-height: 50px;
        max-height: 50px;
    }
    
    .game-controls {
        flex-direction: column;
    }
    
    .modal-actions {
        flex-direction: column;
    }
    
    .nav-tabs {
        flex-direction: row;
    }
    
    .nav-tab {
        padding: 0.5rem 0.75rem;
        font-size: 0.9rem;
    }
}
