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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #b91c1c;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.container {
    max-width: 700px;
    width: 100%;
}

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

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.subtitle {
    font-size: 1.3rem;
    opacity: 0.9;
}

.game-container {
    background: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    margin-bottom: 20px;
}

.difficulty-selector {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.difficulty-btn {
    flex: 1;
    min-width: 120px;
    padding: 10px 15px;
    border: 2px solid #e5e7eb;
    background: white;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #6b7280;
}

.difficulty-btn:hover {
    border-color: #3b82f6;
    color: #3b82f6;
}

.difficulty-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: transparent;
}

.game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e5e7eb;
}

.info-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.label {
    font-weight: 600;
    color: #374151;
    font-size: 1.1rem;
}

.value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #3b82f6;
}

.control-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.control-button:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.control-button:active {
    transform: scale(0.98);
}

.pattern-container {
    position: relative;
    width: 100%;
    max-width: 350px;
    margin: 0 auto 25px;
    aspect-ratio: 1;
    background: #e5e7eb;
    border-radius: 15px;
    padding: 20px;
}

#pattern-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.dot-grid {
    position: relative;
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 0;
    z-index: 2;
}

.dot {
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
}

.dot::before {
    content: '';
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #9ca3af;
    transition: all 0.2s ease;
}

.dot:hover::before {
    background: #6b7280;
    transform: scale(1.2);
}

.dot.selected::before {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    transform: scale(1.4);
    box-shadow: 0 0 15px rgba(102, 126, 234, 0.6);
}

.dot.active::before {
    animation: pulse 0.5s ease;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1.4);
    }
    50% {
        transform: scale(1.6);
    }
}

.current-pattern {
    margin-bottom: 25px;
}

.current-pattern h3 {
    color: #1f2937;
    margin-bottom: 10px;
    font-size: 1.1rem;
}

.pattern-display {
    background: #f9fafb;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    padding: 15px;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 15px;
    color: #6b7280;
    font-size: 1.5rem;
}

.pattern-display.has-pattern {
    color: #1f2937;
}

.submit-button {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-right: 10px;
}

.submit-button:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(16, 185, 129, 0.4);
}

.submit-button:disabled {
    background: #d1d5db;
    cursor: not-allowed;
}

.clear-button {
    background: #ef4444;
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.clear-button:hover {
    background: #dc2626;
    transform: scale(1.05);
}

.feedback-section {
    margin-bottom: 25px;
}

.feedback-section h3 {
    color: #1f2937;
    margin-bottom: 15px;
    font-size: 1.1rem;
}

.attempts-history {
    max-height: 300px;
    overflow-y: auto;
    background: #f9fafb;
    border-radius: 10px;
    padding: 15px;
}

.empty-state {
    color: #9ca3af;
    text-align: center;
    font-style: italic;
}

.attempt-item {
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
}

.attempt-pattern {
    display: flex;
    gap: 8px;
    font-size: 1.3rem;
}

.attempt-feedback {
    display: flex;
    gap: 5px;
    font-size: 1.5rem;
}

.feedback-correct {
    color: #10b981;
}

.feedback-wrong-position {
    color: #f59e0b;
}

.win-message {
    text-align: center;
    padding: 30px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    border-radius: 15px;
    color: white;
    margin-top: 20px;
    box-shadow: 0 10px 25px rgba(16, 185, 129, 0.3);
}

.win-message.hidden {
    display: none;
}

.win-message h2 {
    font-size: 2rem;
    margin-bottom: 10px;
}

.win-message p {
    font-size: 1.1rem;
    margin-bottom: 10px;
}

.attempts-count {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 20px;
}

.help-button-container {
    position: absolute;
    top: 20px;
    right: 20px;
}

.help-button {
    display: inline-block;
    color: white;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    border: none;
    padding: 12px 24px;
    border-radius: 20px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.help-button:hover {
    background: rgba(255, 255, 255, 0.3);
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal.hidden {
    display: none;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
}

.modal-content {
    position: relative;
    background: white;
    border-radius: 20px;
    padding: 40px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    z-index: 1001;
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: #6b7280;
    cursor: pointer;
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: #f3f4f6;
    color: #1f2937;
}

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

.modal-content p {
    color: #4b5563;
    line-height: 1.6;
    margin-bottom: 15px;
}

.modal-content ul {
    margin-left: 20px;
    margin-top: 10px;
    margin-bottom: 15px;
    color: #4b5563;
    line-height: 1.8;
}

.modal-content strong {
    color: #1f2937;
}

.back-button-container {
    position: absolute;
    top: 20px;
    left: 20px;
}

.back-button {
    display: inline-block;
    color: white;
    text-decoration: none;
    padding: 12px 24px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    font-weight: 600;
    transition: all 0.2s ease;
}

.back-button:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateX(-5px);
}

@media (max-width: 768px) {
    header {
        margin-bottom: 60px;
    }

    header h1 {
        display: none;
    }

    .subtitle {
        display: none;
    }

    .game-container {
        padding: 20px;
    }

    .lock-grid {
        width: 280px;
        height: 280px;
    }

    .pattern-container {
        padding: 5px 20px 35px 20px;
    }

    .dot::before {
        width: 16px;
        height: 16px;
    }

    .dot.selected::before {
        transform: scale(1.3);
    }

    .attempt-item {
        padding: 10px;
        gap: 10px;
    }

    .attempt-pattern {
        font-size: 1rem;
        gap: 5px;
    }

    .attempt-feedback {
        font-size: 1.1rem;
        gap: 3px;
    }

    .win-message h2 {
        font-size: 1.5rem;
    }

    .back-button {
        font-size: 0;
        padding: 8px;
        min-width: 36px;
        min-height: 36px;
    }

    .back-button::before {
        content: '←';
        font-size: 1.2rem;
    }

    .help-button {
        font-size: 0;
        padding: 8px;
        min-width: 36px;
        min-height: 36px;
    }

    .help-button::before {
        content: '📖';
        font-size: 1.2rem;
    }

    .pattern-container {
        max-width: 100%;
    }

    .submit-button,
    .clear-button {
        width: 100%;
        margin-right: 0;
        margin-bottom: 10px;
    }

    .difficulty-btn {
        min-width: 0;
        padding: 8px 10px;
        font-size: 0.85rem;
        flex: 1;
    }

    .dots-text {
        display: none;
    }

    .full-text {
        display: none;
    }
}
